|
@ -165,10 +165,14 @@ public class DishService { |
|
|
List<ComponentAnalysisDO> component = items.entrySet().stream().filter(x -> MUST_DISPLAY_ITEM.contains(x.getKey()) || WANT_DISPLAY_ITEM.contains(x.getKey()) && x.getValue() != null && x.getValue().compareTo(BigDecimal.ZERO) > 0).map(x -> { |
|
|
List<ComponentAnalysisDO> component = items.entrySet().stream().filter(x -> MUST_DISPLAY_ITEM.contains(x.getKey()) || WANT_DISPLAY_ITEM.contains(x.getKey()) && x.getValue() != null && x.getValue().compareTo(BigDecimal.ZERO) > 0).map(x -> { |
|
|
FoodNutrient foodNutrient = enumService.getNutrient(x.getKey()); |
|
|
FoodNutrient foodNutrient = enumService.getNutrient(x.getKey()); |
|
|
if (foodNutrient == null) { |
|
|
if (foodNutrient == null) { |
|
|
foodNutrient = FoodNutrient.builder().key(x.getKey()).measurement("-").build(); |
|
|
if (x.getKey().equals("sugar")) { |
|
|
|
|
|
foodNutrient = FoodNutrient.builder().key(x.getKey()).value("糖").measurement("g").build(); |
|
|
|
|
|
} else { |
|
|
|
|
|
foodNutrient = FoodNutrient.builder().key(x.getKey()).value(x.getKey()).measurement("-").build(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
String name = x.getKey().equals("sugar") ? "糖" : StringUtils.isBlank(foodNutrient.getValue()) ? x.getKey() : foodNutrient.getValue(); |
|
|
String name = foodNutrient.getValue(); |
|
|
String value = String.format("%s(%s)", format.format(x.getValue().floatValue()), foodNutrient.getMeasurement() == null ? "-" : foodNutrient.getMeasurement()); |
|
|
String value = String.format("%s(%s)", format.format(x.getValue().floatValue()), foodNutrient.getMeasurement() == null ? "-" : foodNutrient.getMeasurement()); |
|
|
String nvr = foodNutrient.getNrv() == null || foodNutrient.getNrv().floatValue() == 0 ? "-" : String.format("%.2f%%", x.getValue().divide(foodNutrient.getNrv(), RoundingMode.HALF_UP).multiply(new BigDecimal(100))); |
|
|
String nvr = foodNutrient.getNrv() == null || foodNutrient.getNrv().floatValue() == 0 ? "-" : String.format("%.2f%%", x.getValue().divide(foodNutrient.getNrv(), RoundingMode.HALF_UP).multiply(new BigDecimal(100))); |
|
|
if (StringUtils.equalsIgnoreCase(x.getKey(), "sodium")) { |
|
|
if (StringUtils.equalsIgnoreCase(x.getKey(), "sodium")) { |
|
|