From a890e88d588f06d880a0f86211e22329504236a1 Mon Sep 17 00:00:00 2001 From: caoyiwen Date: Fri, 24 Nov 2023 00:20:47 +0800 Subject: [PATCH] fix --- .../mathvision/diet/service/EnumService.java | 11 + .../diet/service/MenuReportService.java | 76 ++- .../diet/domian/MeasurementType.java | 24 +- .../mathvision/diet/domian/RuleItemDTO.java | 19 +- .../com/mathvision/diet/entity/Nutrition.java | 10 +- .../diet/aspect/GlobalExceptionHandler.java | 2 +- .../diet/controller/MenuReportController.java | 2 +- .../diet/controller/NutritionController.java | 25 +- diet-web/src/main/resources/static/basic.html | 634 ++++++++++-------- .../main/resources/static/menu/report.html | 500 +++++--------- .../src/main/resources/static/nutrition.html | 95 +-- doc/basic.md | 634 ++++++++++-------- doc/menu/report.md | 500 +++++--------- doc/nutrition.md | 107 +-- 14 files changed, 1200 insertions(+), 1439 deletions(-) diff --git a/diet-core/src/main/java/com/mathvision/diet/service/EnumService.java b/diet-core/src/main/java/com/mathvision/diet/service/EnumService.java index b9de06d..a4bfc34 100644 --- a/diet-core/src/main/java/com/mathvision/diet/service/EnumService.java +++ b/diet-core/src/main/java/com/mathvision/diet/service/EnumService.java @@ -104,6 +104,17 @@ public class EnumService { return x.getType(); } }).collect(Collectors.toList())); + result.put("measurementType", Arrays.stream(MeasurementType.values()).map(x -> new KeyValue() { + @Override + public String getKey() { + return x.name(); + } + + @Override + public String getValue() { + return x.getType(); + } + }).collect(Collectors.toList())); return result; } diff --git a/diet-core/src/main/java/com/mathvision/diet/service/MenuReportService.java b/diet-core/src/main/java/com/mathvision/diet/service/MenuReportService.java index ff6846c..334ae7c 100644 --- a/diet-core/src/main/java/com/mathvision/diet/service/MenuReportService.java +++ b/diet-core/src/main/java/com/mathvision/diet/service/MenuReportService.java @@ -5,11 +5,14 @@ import com.alibaba.fastjson2.JSONObject; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Range; +import com.mathvision.diet.domian.MeasurementType; import com.mathvision.diet.domian.MenuDishItemDTO; +import com.mathvision.diet.domian.RuleItemDTO; import com.mathvision.diet.entity.*; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.tuple.Pair; +import org.apache.commons.lang3.tuple.Triple; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -32,12 +35,13 @@ public class MenuReportService { @Resource IngredientService ingredientService; - public JSONObject assess(Menu menu, long day, String crow, List dishes) { + public JSONObject nutrition(Menu menu, long day, String crow, List dishes) { Nutrition nutrition = nutritionService.get(menu.getNutrient()); BigDecimal overflow = nutrition.getOverflow(); Map> itemStandard = nutrition.getIngredient().getOrDefault(crow, new HashMap<>()); Map ingredientMap = ingredientService.getFullByKeys(dishes.stream().filter(x -> CollectionUtils.isNotEmpty(x.getIngredient())).flatMap(x -> x.getIngredient().stream().map(MenuDishItemDTO::getKey)).collect(Collectors.toSet())).stream().collect(Collectors.toMap(Ingredient::getKey, v -> v)); - Map items = dishes.stream().flatMap(dish -> dish.getIngredient().stream().filter(item -> item.getValue().containsKey(crow) && item.getValue().get(crow).doubleValue() > 0 && ingredientMap.containsKey(item.getKey()))) + Map items = dishes.stream() + .flatMap(dish -> dish.getIngredient().stream().filter(item -> item.getValue().containsKey(crow) && item.getValue().get(crow).doubleValue() > 0 && ingredientMap.containsKey(item.getKey()))) .flatMap(x -> ingredientMap.get(x.getKey()).getNutrient().entrySet().stream().map(n -> Pair.of(n.getKey(), n.getValue().multiply(x.getValue().get(crow)).divide(new BigDecimal(100), RoundingMode.HALF_UP)))) .collect(Collectors.toMap(Pair::getKey, Pair::getValue, BigDecimal::add)); Map types = dishes.stream().flatMap(dish -> dish.getIngredient().stream().filter(item -> ingredientMap.containsKey(item.getKey())).map(item -> ingredientMap.get(item.getKey()).getType())).collect(Collectors.toMap(x -> x, x -> 1, Integer::sum)); @@ -144,39 +148,50 @@ public class MenuReportService { public JSONObject types(Menu menu, String crow, List dishes) { dishes = dishes.stream().filter(menuDish -> menuDish.getIngredient().stream().anyMatch(item -> item.getValue().containsKey(crow))).collect(Collectors.toList()); Nutrition nutrition = nutritionService.get(menu.getNutrient()); - Map dayStandard = nutrition.getFoodCategoryDay(); - Map weekStandard = nutrition.getFoodCategoryWeek(); + + List dayStandard = nutrition.getFoodCategoryDay(); + List weekStandard = nutrition.getFoodCategoryWeek(); Map ingredientMap = ingredientService.getFullByKeys(dishes.stream().filter(x -> CollectionUtils.isNotEmpty(x.getIngredient())).flatMap(x -> x.getIngredient().stream().map(MenuDishItemDTO::getKey)).collect(Collectors.toSet())).stream().collect(Collectors.toMap(Ingredient::getKey, v -> v)); Map, Integer> typesDay = dishes.stream().flatMap(dish -> dish.getIngredient().stream().filter(item -> ingredientMap.containsKey(item.getKey())).map(item -> Pair.of(dish.getDay(), ingredientMap.get(item.getKey()).getType()))).collect(Collectors.toMap(x -> x, x -> 1, Integer::sum)); - JSONArray dayRule = new JSONArray(); - Map dayMaps = Maps.newHashMap(); - typesDay.forEach((key, num) -> { - Long day = key.getKey(); - JSONArray dayCollection = dayMaps.getOrDefault(day, new JSONArray()); - String type = key.getValue(); - int standard = dayStandard.getOrDefault(type, BigDecimal.ZERO).intValue(); + Map, BigDecimal> weightDay = dishes.stream().flatMap(dish -> dish.getIngredient().stream().filter(item -> ingredientMap.containsKey(item.getKey())).map(item -> Triple.of(dish.getDay(), ingredientMap.get(item.getKey()).getType(), item.getValue().getOrDefault(crow, BigDecimal.ZERO)))).collect(Collectors.toMap(x -> Pair.of(x.getLeft(), x.getMiddle()), Triple::getRight, BigDecimal::add)); + + Map dayRule = Maps.newHashMap(); + dishes.stream().map(MenuDish::getDay).forEach(day -> dayRule.put(day, dayStandard.stream().map(standard -> { JSONObject content = new JSONObject(); content.put("day", day); - content.put("name", type); - content.put("standard", standard); - content.put("supplied", num); - content.put("lack", num >= standard ? 0 : standard - num); - dayCollection.add(content); - dayMaps.put(day, dayCollection); - }); - dayRule.addAll(dayMaps.values()); + content.put("name", standard.getName()); + content.put("standard", standard.getRange()); + if (MeasurementType.quantity.equals(standard.getType())) { + long supplied = typesDay.entrySet().stream().filter(x -> x.getKey().getKey().equals(day) && standard.getCategory().contains(x.getKey().getValue())).map(Map.Entry::getValue).reduce(Integer::sum).orElse(0); + content.put("measurement", standard.getType()); + content.put("supplied", supplied); + content.put("lack", standard.getLack(new BigDecimal(supplied))); + } else { + BigDecimal supplied = weightDay.entrySet().stream().filter(x -> x.getKey().getKey().equals(day) && standard.getCategory().contains(x.getKey().getValue())).map(Map.Entry::getValue).reduce(BigDecimal::add).orElse(BigDecimal.ZERO); + content.put("measurement", standard.getType()); + content.put("supplied", supplied); + content.put("lack", standard.getLack(supplied)); + } + return content; + }).collect(Collectors.toList()))); - Map typesAll = dishes.stream().flatMap(dish -> dish.getIngredient().stream().filter(item -> ingredientMap.containsKey(item.getKey())).map(item -> ingredientMap.get(item.getKey()).getType())).collect(Collectors.toMap(x -> x, x -> 1, Integer::sum)); - JSONArray weekRule = new JSONArray(); - typesAll.forEach((type, num) -> { - BigDecimal standard = weekStandard.getOrDefault(type, BigDecimal.ZERO); + List weekRule = weekStandard.stream().map(standard -> { JSONObject content = new JSONObject(); - content.put("name", type); - content.put("standard", standard); - content.put("supplied", num); - content.put("lack", num.compareTo(standard.intValue()) > 0 ? 0 : standard.intValue() - num); - weekRule.add(content); - }); + content.put("name", standard.getName()); + content.put("standard", standard.getRange()); + if (MeasurementType.quantity.equals(standard.getType())) { + long supplied = typesDay.entrySet().stream().filter(x -> standard.getCategory().contains(x.getKey().getValue())).map(Map.Entry::getValue).reduce(Integer::sum).orElse(0); + content.put("measurement", standard.getType()); + content.put("supplied", supplied); + content.put("lack", standard.getLack(new BigDecimal(supplied))); + } else { + BigDecimal supplied = weightDay.entrySet().stream().filter(x -> standard.getCategory().contains(x.getKey().getValue())).map(Map.Entry::getValue).reduce(BigDecimal::add).orElse(BigDecimal.ZERO); + content.put("measurement", standard.getType()); + content.put("supplied", supplied); + content.put("lack", standard.getLack(supplied)); + } + return content; + }).collect(Collectors.toList()); JSONObject result = new JSONObject(); result.put("crow", crow); @@ -196,7 +211,7 @@ public class MenuReportService { } public JSONObject energy(long day, String crow, List dishes) { - List allConcerned= Lists.newArrayList("energy", "protein", "fat", "carbs"); + List allConcerned= Lists.newArrayList("protein", "fat", "carbs"); Map ingredientMap = ingredientService.getFullByKeys(dishes.stream().filter(x -> CollectionUtils.isNotEmpty(x.getIngredient())).flatMap(x -> x.getIngredient().stream().map(MenuDishItemDTO::getKey)).collect(Collectors.toSet())).stream().collect(Collectors.toMap(Ingredient::getKey, v -> v)); Map items = dishes.stream() .flatMap(dish -> dish.getIngredient().stream().filter(item -> item.getValue().containsKey(crow) && item.getValue().get(crow).doubleValue() > 0 && ingredientMap.containsKey(item.getKey()))) @@ -215,7 +230,6 @@ public class MenuReportService { result.put("crow", crow); result.put("meals", dishes.stream().map(MenuDish::getMeal).collect(Collectors.toSet())); - //BigDecimal energy = items.get("energy").multiply(new BigDecimal("4.18")); BigDecimal protein = items.get("protein").multiply(new BigDecimal("4")); BigDecimal fat = items.get("fat").multiply(new BigDecimal("9")); BigDecimal carbs = items.get("carbs").multiply(new BigDecimal("4")); diff --git a/diet-dao/src/main/java/com/mathvision/diet/domian/MeasurementType.java b/diet-dao/src/main/java/com/mathvision/diet/domian/MeasurementType.java index f9e7ab5..6cdc08e 100644 --- a/diet-dao/src/main/java/com/mathvision/diet/domian/MeasurementType.java +++ b/diet-dao/src/main/java/com/mathvision/diet/domian/MeasurementType.java @@ -1,5 +1,25 @@ package com.mathvision.diet.domian; +import lombok.Getter; + +import java.util.Arrays; + public enum MeasurementType { - weight, quantity -} + weight("克"), quantity("种"); + + @Getter + private final String type; + + MeasurementType(String type) { + this.type = type; + } + + @Override + public String toString() { + return type; + } + + public static MeasurementType toType(String s) { + return Arrays.stream(MeasurementType.values()).filter(x -> x.getType().equals(s)).findFirst().orElse(null); + } +} \ No newline at end of file diff --git a/diet-dao/src/main/java/com/mathvision/diet/domian/RuleItemDTO.java b/diet-dao/src/main/java/com/mathvision/diet/domian/RuleItemDTO.java index e121436..e21c5a4 100644 --- a/diet-dao/src/main/java/com/mathvision/diet/domian/RuleItemDTO.java +++ b/diet-dao/src/main/java/com/mathvision/diet/domian/RuleItemDTO.java @@ -35,7 +35,24 @@ public class RuleItemDTO { */ BigDecimal min; + public String getRange() { + if (max == null) return "≥" + min; + if (min == null) return "≤" + max; + return min + "~" + max; + } + + public BigDecimal getLack(BigDecimal num) { + if (max == null) return min.compareTo(num) > 0 ? min.subtract(num) : BigDecimal.ZERO; + if (min == null) return max.compareTo(num) > 0 ? BigDecimal.ZERO : max.subtract(num); + return min.compareTo(num) > 0 ? min.subtract(num) : max.compareTo(num) > 0 ? BigDecimal.ZERO : max.subtract(num); + } + public boolean check() { - return StringUtils.isNotBlank(name) && type != null && CollectionUtils.isNotEmpty(category) && (max != null || min != null); + if(max != null && min != null && max.compareTo(min) < 0) { + BigDecimal temp = max; + max = min; + min = temp; + } + return StringUtils.isNotBlank(name) && type != null && CollectionUtils.isNotEmpty(category) && (max != null && min == null || max == null && min != null || max != null); } } \ No newline at end of file diff --git a/diet-dao/src/main/java/com/mathvision/diet/entity/Nutrition.java b/diet-dao/src/main/java/com/mathvision/diet/entity/Nutrition.java index 51c8cf7..64bc7ef 100644 --- a/diet-dao/src/main/java/com/mathvision/diet/entity/Nutrition.java +++ b/diet-dao/src/main/java/com/mathvision/diet/entity/Nutrition.java @@ -2,6 +2,8 @@ package com.mathvision.diet.entity; import com.alibaba.fastjson2.annotation.JSONField; import com.mathvision.diet.convert.IngredientConvert; +import com.mathvision.diet.convert.RuleItemConvert; +import com.mathvision.diet.domian.RuleItemDTO; import com.vladmihalcea.hibernate.type.json.JsonStringType; import lombok.*; import org.hibernate.annotations.Type; @@ -34,13 +36,13 @@ public class Nutrition { @Column(name = "vendors", columnDefinition = "json", nullable = false) private List vendors; - @Type( type = "json" ) + @Convert(converter = RuleItemConvert.class) @Column(name = "food_category_day", columnDefinition = "json") - private Map foodCategoryDay; + private List foodCategoryDay; - @Type( type = "json" ) + @Convert(converter = RuleItemConvert.class) @Column(name = "food_category_week", columnDefinition = "json") - private Map foodCategoryWeek; + private List foodCategoryWeek; @Convert(converter = IngredientConvert.class) @Column(name = "ingredient", columnDefinition = "json") diff --git a/diet-web/src/main/java/com/mathvision/diet/aspect/GlobalExceptionHandler.java b/diet-web/src/main/java/com/mathvision/diet/aspect/GlobalExceptionHandler.java index 6ed6523..3247c6d 100644 --- a/diet-web/src/main/java/com/mathvision/diet/aspect/GlobalExceptionHandler.java +++ b/diet-web/src/main/java/com/mathvision/diet/aspect/GlobalExceptionHandler.java @@ -33,7 +33,7 @@ public class GlobalExceptionHandler { } @ResponseBody - @ExceptionHandler({IllegalArgumentException.class}) + @ExceptionHandler({IllegalArgumentException.class, IllegalStateException.class}) public Result errorHandler(IllegalArgumentException e) { return _innerHandler(Result.ILLEGAL_ARGUMENT, e, false); } diff --git a/diet-web/src/main/java/com/mathvision/diet/controller/MenuReportController.java b/diet-web/src/main/java/com/mathvision/diet/controller/MenuReportController.java index 44ed11c..ac355bf 100644 --- a/diet-web/src/main/java/com/mathvision/diet/controller/MenuReportController.java +++ b/diet-web/src/main/java/com/mathvision/diet/controller/MenuReportController.java @@ -38,7 +38,7 @@ public class MenuReportController extends BaseController { day = checkAndGetDay(day, menu.getDay()); crow = checkAndGetCrow(crow, menu.getCrows()); List dishes = menuDishService.query(id, menu.getVender(), day); - return menuReportService.assess(menu, day, crow, dishes); + return menuReportService.nutrition(menu, day, crow, dishes); } @ResponseBody diff --git a/diet-web/src/main/java/com/mathvision/diet/controller/NutritionController.java b/diet-web/src/main/java/com/mathvision/diet/controller/NutritionController.java index 71a4c8f..5208ed5 100644 --- a/diet-web/src/main/java/com/mathvision/diet/controller/NutritionController.java +++ b/diet-web/src/main/java/com/mathvision/diet/controller/NutritionController.java @@ -1,8 +1,11 @@ package com.mathvision.diet.controller; import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.TypeReference; +import com.mathvision.diet.domian.RuleItemDTO; import com.mathvision.diet.entity.Nutrition; +import com.mathvision.diet.service.EnumService; import com.mathvision.diet.service.NutritionService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -24,6 +27,9 @@ import java.util.Map; @RequestMapping("/api/nutrition") @Controller public class NutritionController extends BaseController { + @Resource + EnumService enumService; + @Resource NutritionService nutritionService; @@ -52,8 +58,6 @@ public class NutritionController extends BaseController { @RequestMapping(method = RequestMethod.POST) public Nutrition update(@RequestParam Long id, @RequestParam(required = false) String name, @RequestParam(required = false) BigDecimal overflow, @RequestParam(required = false) List vendors, @RequestParam(required = false) String foodCategoryDay, @RequestParam(required = false) String foodCategoryWeek, @RequestParam(required = false) String ingredient) { Assert.isTrue(isAdmin(), "[参数错误]无操作权限!"); - Assert.isTrue(foodCategoryDay == null || JSON.isValid(foodCategoryDay), "[参数错误]日标准JSON解析错误!"); - Assert.isTrue(foodCategoryWeek == null || JSON.isValid(foodCategoryWeek), "[参数错误]周标准JSON解析错误!"); Assert.isTrue(ingredient == null || JSON.isValid(ingredient), "[参数错误]食材JSON解析错误!"); Nutrition nutrition = nutritionService.get(id); @@ -72,12 +76,12 @@ public class NutritionController extends BaseController { nutrition.setVendors(vendors); flag = true; } - if (JSON.isValid(foodCategoryDay)) { - nutrition.setFoodCategoryDay(JSON.parseObject(foodCategoryDay, new TypeReference>(){})); + if (StringUtils.isNotBlank(foodCategoryDay)) { + nutrition.setFoodCategoryDay(checkAndConvert(foodCategoryDay, "日规则")); flag = true; } - if (JSON.isValid(foodCategoryWeek)) { - nutrition.setFoodCategoryWeek(JSON.parseObject(foodCategoryWeek, new TypeReference>(){})); + if (StringUtils.isNotBlank(foodCategoryWeek)) { + nutrition.setFoodCategoryWeek(checkAndConvert(foodCategoryWeek, "周规则")); flag = true; } if (JSON.isValid(ingredient)) { @@ -99,10 +103,17 @@ public class NutritionController extends BaseController { @ResponseBody @RequestMapping(value="select", method = RequestMethod.GET) - public Object query(@RequestParam(required = false) Long id, @RequestParam(required = false, value = "name") String keyword, @RequestParam(required = false) Long vender) { + public Object query(@RequestParam(required = false) Long id, @RequestParam(required = false) String keyword, @RequestParam(required = false) Long vender) { if (id != null) { return nutritionService.get(id); } return nutritionService.query(isAdmin() ? vender : getVender(), keyword); } + + private List checkAndConvert(String standard, String desc) { + Assert.isTrue(JSON.isValid(standard), "[参数错误]" + desc + "JSON解析错误!"); + List result = JSONArray.parseArray(standard, RuleItemDTO.class); + Assert.isTrue(result.stream().allMatch(x -> x.check() && x.getCategory().stream().allMatch(c -> enumService.checkCategory(c))), "[参数错误]" + desc + ":规则名称/计量单位/食材种类必填, 最大值/最小值至少填一个!"); + return result; + } } diff --git a/diet-web/src/main/resources/static/basic.html b/diet-web/src/main/resources/static/basic.html index c65ec08..0a12a33 100644 --- a/diet-web/src/main/resources/static/basic.html +++ b/diet-web/src/main/resources/static/basic.html @@ -66,295 +66,351 @@ password=BE56E057F20F883E //

GET /api/enum

:

{
-  "body": {
-    "nutrient": [
-      {
-        "key": "fiber",
-        "measurement": "g",
-        "nrv": 25.00,
-        "value": "ʳά"
-      },
-      {
-        "key": "calcium",
-        "measurement": "mg",
-        "nrv": 800.00,
-        "value": ""
-      },
-      {
-        "key": "vb1",
-        "measurement": "mg",
-        "nrv": 1.40,
-        "value": "άB1"
-      },
-      {
-        "key": "carbs",
-        "measurement": "g",
-        "nrv": 300.00,
-        "value": "̼ˮ"
-      },
-      {
-        "key": "vb2",
-        "measurement": "mg",
-        "nrv": 1.40,
-        "value": "άB2"
-      },
-      {
-        "key": "va",
-        "measurement": "gRAE",
-        "nrv": 800.00,
-        "value": "άA"
-      },
-      {
-        "key": "vc",
-        "measurement": "mg",
-        "nrv": 100.00,
-        "value": "άC"
-      },
-      {
-        "key": "protein",
-        "measurement": "g",
-        "nrv": 60.00,
-        "value": ""
-      },
-      {
-        "key": "fat",
-        "measurement": "g",
-        "nrv": 60.00,
-        "value": "֬"
-      },
-      {
-        "key": "iron",
-        "measurement": "mg",
-        "nrv": 15.00,
-        "value": ""
-      },
-      {
-        "key": "zinc",
-        "measurement": "mg",
-        "nrv": 15.00,
-        "value": "п"
-      },
-      {
-        "key": "energy",
-        "measurement": "kcal",
-        "nrv": 2000.00,
-        "value": "kcal"
-      }
-    ],
-    "menuStatus": [
-      {
-        "key": 0,
-        "value": "ݸ"
-      },
-      {
-        "key": 1,
-        "value": "ύ"
-      },
-      {
-        "key": 2,
-        "value": "ͨ"
-      },
-      {
-        "key": 3,
-        "value": "ʧ"
-      },
-      {
-        "key": 4,
-        "value": ""
-      },
-      {
-        "key": 5,
-        "value": ""
-      }
-    ],
-    "markType": [
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "",
-        "value": ""
-      }
-    ],
-    "mealType": [
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "",
-        "value": ""
-      }
-    ],
-    "category": [
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "༰Ʒ",
-        "value": "༰Ʒ"
-      },
-      {
-        "key": "Ӥ׶ʳƷ",
-        "value": "Ӥ׶ʳƷ"
-      },
-      {
-        "key": "Ϻ",
-        "value": "Ϻ"
-      },
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "ƾ",
-        "value": "ƾ"
-      },
-      {
-        "key": "ζƷ",
-        "value": "ζƷ"
-      },
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "߲",
-        "value": "߲"
-      },
-      {
-        "key": "ˮ",
-        "value": "ˮ"
-      },
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "Сԡ",
-        "value": "Сԡ"
-      },
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "̼Ʒ",
-        "value": "̼Ʒ"
-      },
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "ʳʳƷ",
-        "value": "ʳʳƷ"
-      },
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "",
-        "value": ""
-      }
-    ],
-    "mark": [
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "ˮ",
-        "value": "ˮ"
-      },
-      {
-        "key": "ʳ",
-        "value": "ʳ"
-      },
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "λ",
-        "value": "λ"
-      },
-      {
-        "key": "ʳ",
-        "value": "ʳ"
-      },
-      {
-        "key": "ʳ",
-        "value": "ʳ"
-      },
-      {
-        "key": "ز",
-        "value": "ز"
-      },
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "",
-        "value": ""
-      },
-      {
-        "key": "",
-        "value": ""
-      }
-    ],
-    "venderType": [
-      {
-        "key": "ѧУ",
-        "value": "ѧУ"
-      },
-      {
-        "key": "ҽԺ",
-        "value": "ҽԺ"
-      },
-      {
-        "key": "ҵλ",
-        "value": "ҵλ"
-      },
-      {
-        "key": "",
-        "value": ""
-      }
-    ],
-    "poly":[
-      {
-        "key": "",
-        "value": ""
-      }
-    ]
-  },
-  "code": 200,
-  "desc": "ɹ",
-  "success": true
+    "body": {
+        "nutrient": [
+            {
+                "key": "fiber",
+                "measurement": "g",
+                "nrv": 25.00,
+                "value": "ʳά"
+            },
+            {
+                "key": "calcium",
+                "measurement": "mg",
+                "nrv": 800.00,
+                "value": ""
+            },
+            {
+                "key": "vb1",
+                "measurement": "mg",
+                "nrv": 1.40,
+                "value": "άB1"
+            },
+            {
+                "key": "carbs",
+                "measurement": "g",
+                "nrv": 300.00,
+                "value": "̼ˮ"
+            },
+            {
+                "key": "vb2",
+                "measurement": "mg",
+                "nrv": 1.40,
+                "value": "άB2"
+            },
+            {
+                "key": "va",
+                "measurement": "gRAE",
+                "nrv": 800.00,
+                "value": "άA"
+            },
+            {
+                "key": "vc",
+                "measurement": "mg",
+                "nrv": 100.00,
+                "value": "άC"
+            },
+            {
+                "key": "sodium",
+                "measurement": "mg",
+                "nrv": 2000.00,
+                "value": ""
+            },
+            {
+                "key": "protein",
+                "measurement": "g",
+                "nrv": 60.00,
+                "value": ""
+            },
+            {
+                "key": "fat",
+                "measurement": "g",
+                "nrv": 60.00,
+                "value": "֬"
+            },
+            {
+                "key": "iron",
+                "measurement": "mg",
+                "nrv": 15.00,
+                "value": ""
+            },
+            {
+                "key": "zinc",
+                "measurement": "mg",
+                "nrv": 15.00,
+                "value": "п"
+            },
+            {
+                "key": "energy",
+                "measurement": "kcal",
+                "nrv": 2000.00,
+                "value": ""
+            }
+        ],
+        "menuStatus": [
+            {
+                "key": 0,
+                "value": "ݸ"
+            },
+            {
+                "key": 5,
+                "value": ""
+            }
+        ],
+        "markType": [
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "",
+                "value": ""
+            }
+        ],
+        "poly": [
+            {
+                "key": "",
+                "name": ""
+            },
+            {
+                "key": "±",
+                "name": "±"
+            },
+            {
+                "key": "",
+                "name": ""
+            },
+            {
+                "key": "",
+                "name": ""
+            },
+            {
+                "key": "",
+                "name": ""
+            },
+            {
+                "key": "",
+                "name": ""
+            },
+            {
+                "key": "",
+                "name": ""
+            },
+            {
+                "key": "",
+                "name": ""
+            },
+            {
+                "key": "Ѭ",
+                "name": "Ѭ"
+            },
+            {
+                "key": "",
+                "name": ""
+            },
+            {
+                "key": "",
+                "name": ""
+            },
+            {
+                "key": "",
+                "name": ""
+            },
+            {
+                "key": "",
+                "name": ""
+            },
+            {
+                "key": "ը",
+                "name": "ը"
+            }
+        ],
+        "mealType": [
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "",
+                "value": ""
+            }
+        ],
+        "measurementType": [
+            {
+                "key": "weight",
+                "value": ""
+            },
+            {
+                "key": "quantity",
+                "value": ""
+            }
+        ],
+        "category": [
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "༰Ʒ",
+                "value": "༰Ʒ"
+            },
+            {
+                "key": "Ӷ",
+                "value": "Ӷ"
+            },
+            {
+                "key": "Ӥ׶ʳƷ",
+                "value": "Ӥ׶ʳƷ"
+            },
+            {
+                "key": "Ϻ",
+                "value": "Ϻ"
+            },
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "ƾ",
+                "value": "ƾ"
+            },
+            {
+                "key": "ζƷ",
+                "value": "ζƷ"
+            },
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "߲",
+                "value": "߲"
+            },
+            {
+                "key": "ˮ",
+                "value": "ˮ"
+            },
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "Сԡ",
+                "value": "Сԡ"
+            },
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "̼Ʒ",
+                "value": "̼Ʒ"
+            },
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "ʳʳƷ",
+                "value": "ʳʳƷ"
+            },
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "",
+                "value": ""
+            }
+        ],
+        "mark": [
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "ˮ",
+                "value": "ˮ"
+            },
+            {
+                "key": "ʳ",
+                "value": "ʳ"
+            },
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "λ",
+                "value": "λ"
+            },
+            {
+                "key": "ʳ",
+                "value": "ʳ"
+            },
+            {
+                "key": "ʳ",
+                "value": "ʳ"
+            },
+            {
+                "key": "ز",
+                "value": "ز"
+            },
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "",
+                "value": ""
+            },
+            {
+                "key": "",
+                "value": ""
+            }
+        ],
+        "venderType": [
+            {
+                "key": "ѧУ",
+                "value": "ѧУ"
+            },
+            {
+                "key": "ҽԺ",
+                "value": "ҽԺ"
+            },
+            {
+                "key": "ҵλ",
+                "value": "ҵλ"
+            },
+            {
+                "key": "",
+                "value": ""
+            }
+        ]
+    },
+    "code": 200,
+    "desc": "ɹ",
+    "success": true
 }
 
diff --git a/diet-web/src/main/resources/static/menu/report.html b/diet-web/src/main/resources/static/menu/report.html index 07f9805..508fbff 100644 --- a/diet-web/src/main/resources/static/menu/report.html +++ b/diet-web/src/main/resources/static/menu/report.html @@ -9,103 +9,135 @@ crow=xxx //

:

{
-  "body": {
-    "day": 5,
-    "crow": "10",
-    "meals": [
-      ""
-    ],
-    "types": {
-      "": 5,
-      "Ϻ": 2,
-      "ζƷ": 1
+    "body": {
+        "day": 1,
+        "crow": "6~8 Ů",
+        "meals": [
+            "",
+            "",
+            ""
+        ],
+        "types": {
+            "": 1,
+            "༰Ʒ": 1,
+            "Ϻ": 1,
+            "": 5,
+            "": 1,
+            "": 3,
+            "̼Ʒ": 1,
+            "ζƷ": 1,
+            "߲": 6
+        },
+        "ingredient": [
+            {
+                "nutrition": "ʳά/g",
+                "virtual": 4.8,
+                "ul": "-",
+                "standard": "20~20",
+                "overload": "-76.00%",
+                "conclusion": ""
+            },
+            {
+                "nutrition": "/mg",
+                "virtual": 490,
+                "ul": "-",
+                "standard": "750~750",
+                "overload": "-34.67%",
+                "conclusion": ""
+            },
+            {
+                "nutrition": "άB1/mg",
+                "virtual": 1.05,
+                "ul": "-",
+                "standard": "0.9~0.9",
+                "overload": "16.67%",
+                "conclusion": ""
+            },
+            {
+                "nutrition": "̼ˮ/g",
+                "virtual": 267.4,
+                "ul": "-",
+                "standard": "193.75~251.88",
+                "overload": "6.16%",
+                "conclusion": ""
+            },
+            {
+                "nutrition": "άB2/mg",
+                "virtual": 0.62,
+                "ul": "-",
+                "standard": "0.9~0.9",
+                "overload": "-31.11%",
+                "conclusion": ""
+            },
+            {
+                "nutrition": "άA/gRAE",
+                "virtual": 516,
+                "ul": "-",
+                "standard": "450~450",
+                "overload": "14.67%",
+                "conclusion": ""
+            },
+            {
+                "nutrition": "άC/mg",
+                "virtual": 117.5,
+                "ul": "-",
+                "standard": "60~60",
+                "overload": "95.83%",
+                "conclusion": ""
+            },
+            {
+                "nutrition": "/mg",
+                "virtual": 953.9,
+                "ul": "-",
+                "standard": "5000",
+                "overload": "-",
+                "conclusion": ""
+            },
+            {
+                "nutrition": "/g",
+                "virtual": 70.2,
+                "ul": "-",
+                "standard": "32~48",
+                "overload": "46.25%",
+                "conclusion": ""
+            },
+            {
+                "nutrition": "֬/g",
+                "virtual": 47.4,
+                "ul": "-",
+                "standard": "34.44~51.67",
+                "overload": "37.63%",
+                "conclusion": ""
+            },
+            {
+                "nutrition": "/mg",
+                "virtual": 10.8,
+                "ul": "-",
+                "standard": "12~12",
+                "overload": "-10.00%",
+                "conclusion": ""
+            },
+            {
+                "nutrition": "п/mg",
+                "virtual": 7.15,
+                "ul": "-",
+                "standard": "6.5~6.5",
+                "overload": "10.00%",
+                "conclusion": ""
+            },
+            {
+                "nutrition": "/kcal",
+                "virtual": 1755,
+                "ul": "-",
+                "standard": "1395~1705",
+                "overload": "2.93%",
+                "conclusion": ""
+            }
+        ]
     },
-    "ingredient": [
-      {
-        "nutrition": "ʳά/g",
-        "virtual": 0,
-        "standard": "1~2",
-        "ul": "-",
-        "overload": -1,
-        "conclusion": ""
-      },
-      {
-        "nutrition": "/mg",
-        "virtual": 2,
-        "standard": "-",
-        "ul": "-",
-        "overload": "-",
-        "conclusion": "-"
-      },
-      {
-        "nutrition": "άB1/mg",
-        "virtual": 1,
-        "standard": "-",
-        "ul": "-",
-        "overload": "-",
-        "conclusion": "-"
-      },
-      {
-        "nutrition": "̼ˮ/g",
-        "virtual": 0.1,
-        "standard": "-",
-        "ul": "-",
-        "overload": "-",
-        "conclusion": "-"
-      },
-      {
-        "nutrition": "/g",
-        "virtual": 0.1,
-        "standard": "-",
-        "ul": "-",
-        "overload": "-",
-        "conclusion": "-"
-      },
-      {
-        "nutrition": "άB2/mg",
-        "virtual": 2,
-        "standard": "-",
-        "ul": "-",
-        "overload": "-",
-        "conclusion": "-"
-      },
-      {
-        "nutrition": "֬/g",
-        "virtual": 0.0,
-        "standard": "-",
-        "ul": "-",
-        "overload": "-",
-        "conclusion": "-"
-      },
-      {
-        "nutrition": "/mg",
-        "virtual": 0.1,
-        "standard": "-",
-        "ul": "-",
-        "overload": "-",
-        "conclusion": "-"
-      },
-      {
-        "nutrition": "άA/gRAE",
-        "virtual": 4,
-        "standard": "-",
-        "ul": "-",
-        "overload": "-",
-        "conclusion": "-"
-      },
-      {
-        "nutrition": "kcal/kcal",
-        "virtual": 0.79,
-        "standard": "-",
-        "ul": "-",
-        "overload": "-",
-        "conclusion": "-"
-      }
-    ]
-  },
-  "code": 200,
-  "desc": "ɹ",
-  "success": true
+    "code": 200,
+    "desc": "ɹ",
+    "success": true
 }
 

2.

@@ -119,36 +151,38 @@ crow=xxx //

:

{
-  "body": {
-    "day": 5,
-    "crow": "10",
-    "meals": [
-      ""
-    ],
-    "energy": [
-      {
-        "name": "/",
-        "standard": "10~20",
-        "value": 10.0,
-        "conclusion": ""
-      },
-      {
-        "name": "֬/",
-        "standard": "20~30",
-        "value": 0.0,
-        "conclusion": "Ե"
-      },
-      {
-        "name": "̼ˮ/",
-        "standard": "50~60",
-        "value": 10.0,
-        "conclusion": "Ե"
-      }
-    ]
-  },
-  "code": 200,
-  "desc": "ɹ",
-  "success": true
+    "body": {
+        "day": 1,
+        "crow": "6~8 Ů",
+        "meals": [
+            "",
+            "",
+            ""
+        ],
+        "energy": [
+            {
+                "name": "/",
+                "standard": "10~20",
+                "value": 15.80,
+                "conclusion": ""
+            },
+            {
+                "name": "֬/",
+                "standard": "20~30",
+                "value": 24.01,
+                "conclusion": ""
+            },
+            {
+                "name": "̼ˮ/",
+                "standard": "50~60",
+                "value": 60.19,
+                "conclusion": ""
+            }
+        ]
+    },
+    "code": 200,
+    "desc": "ɹ",
+    "success": true
 }
 

3. ͷ

@@ -161,195 +195,33 @@ crow=xxx //

:

{
-  "body": {
-    "crow": "6~8 Ů",
-    "dayRule": [
-      [
-        {
-          "day": 1,
-          "name": "",
-          "standard": 0,
-          "supplied": 5,
-          "lack": 0
-        },
-        {
-          "day": 1,
-          "name": "Ϻ",
-          "standard": 0,
-          "supplied": 2,
-          "lack": 0
-        },
-        {
-          "day": 1,
-          "name": "ζƷ",
-          "standard": 0,
-          "supplied": 1,
-          "lack": 0
-        }
-      ],
-      [
-        {
-          "day": 2,
-          "name": "",
-          "standard": 0,
-          "supplied": 5,
-          "lack": 0
+    "body": {
+        "crow": "6~8 Ů",
+        "dayRule": {
+            "1": [
+                {
+                    "day": 1,
+                    "name": "",
+                    "standard": "10~100",
+                    "measurement": "weight",
+                    "supplied": 320,
+                    "lack": -220
+                }
+            ]
         },
-        {
-          "day": 2,
-          "name": "Ϻ",
-          "standard": 0,
-          "supplied": 2,
-          "lack": 0
-        },
-        {
-          "day": 2,
-          "name": "ζƷ",
-          "standard": 0,
-          "supplied": 1,
-          "lack": 0
-        }
-      ],
-      [
-        {
-          "day": 3,
-          "name": "",
-          "standard": 0,
-          "supplied": 5,
-          "lack": 0
-        },
-        {
-          "day": 3,
-          "name": "Ϻ",
-          "standard": 0,
-          "supplied": 2,
-          "lack": 0
-        },
-        {
-          "day": 3,
-          "name": "ζƷ",
-          "standard": 0,
-          "supplied": 1,
-          "lack": 0
-        }
-      ],
-      [
-        {
-          "day": 4,
-          "name": "Ϻ",
-          "standard": 0,
-          "supplied": 2,
-          "lack": 0
-        },
-        {
-          "day": 4,
-          "name": "",
-          "standard": 0,
-          "supplied": 5,
-          "lack": 0
-        },
-        {
-          "day": 4,
-          "name": "ζƷ",
-          "standard": 0,
-          "supplied": 1,
-          "lack": 0
-        }
-      ],
-      [
-        {
-          "day": 5,
-          "name": "Ϻ",
-          "standard": 0,
-          "supplied": 2,
-          "lack": 0
-        },
-        {
-          "day": 5,
-          "name": "",
-          "standard": 0,
-          "supplied": 5,
-          "lack": 0
-        },
-        {
-          "day": 5,
-          "name": "ζƷ",
-          "standard": 0,
-          "supplied": 1,
-          "lack": 0
-        }
-      ],
-      [
-        {
-          "day": 6,
-          "name": "Ϻ",
-          "standard": 0,
-          "supplied": 2,
-          "lack": 0
-        },
-        {
-          "day": 6,
-          "name": "",
-          "standard": 0,
-          "supplied": 5,
-          "lack": 0
-        },
-        {
-          "day": 6,
-          "name": "ζƷ",
-          "standard": 0,
-          "supplied": 1,
-          "lack": 0
-        }
-      ],
-      [
-        {
-          "day": 7,
-          "name": "Ϻ",
-          "standard": 0,
-          "supplied": 2,
-          "lack": 0
-        },
-        {
-          "day": 7,
-          "name": "",
-          "standard": 0,
-          "supplied": 5,
-          "lack": 0
-        },
-        {
-          "day": 7,
-          "name": "ζƷ",
-          "standard": 0,
-          "supplied": 1,
-          "lack": 0
-        }
-      ]
-    ],
-    "weekRule": [
-      {
-        "name": "",
-        "standard": 0,
-        "supplied": 35,
-        "lack": 0
-      },
-      {
-        "name": "Ϻ",
-        "standard": 0,
-        "supplied": 14,
-        "lack": 0
-      },
-      {
-        "name": "ζƷ",
-        "standard": 0,
-        "supplied": 7,
-        "lack": 0
-      }
-    ]
-  },
-  "code": 200,
-  "desc": "ɹ",
-  "success": true
+        "weekRule": [
+            {
+                "name": "",
+                "standard": "10~100",
+                "measurement": "weight",
+                "supplied": 320,
+                "lack": -220
+            }
+        ]
+    },
+    "code": 200,
+    "desc": "ɹ",
+    "success": true
 }
 

4. ⿷ʽ

diff --git a/diet-web/src/main/resources/static/nutrition.html b/diet-web/src/main/resources/static/nutrition.html index f0016de..84420d0 100644 --- a/diet-web/src/main/resources/static/nutrition.html +++ b/diet-web/src/main/resources/static/nutrition.html @@ -13,18 +13,8 @@ keyword= "body": { "content": [ { - "foodCategoryDay": { - "ˮ": 20, - "߲": 50, - "": 10, - "": 30 - }, - "foodCategoryWeek": { - "ˮ": 100, - "߲": 200, - "": 500, - "": 300 - }, + "foodCategoryDay": [{"max":100,"min":10,"name":"","type":"quantity","category":["",""]}], + "foodCategoryWeek": [{"max":100,"min":10,"name":"","type":"quantity","category":["",""]}], "id": 1, "ingredient": { "": { @@ -69,18 +59,8 @@ keyword=

:

{
   "body": {
-    "foodCategoryDay": {
-      "ˮ": 20,
-      "߲": 50,
-      "": 10,
-      "": 30
-    },
-    "foodCategoryWeek": {
-      "ˮ": 100,
-      "߲": 200,
-      "": 500,
-      "": 300
-    },
+    "foodCategoryDay": [{"max":100,"min":10,"name":"","type":"weight","category":["",""]}],
+    "foodCategoryWeek": [{"max":100,"min":10,"name":"","type":"weight","category":["",""]}],
     "id": 1,
     "ingredient": {
       "": {
@@ -121,18 +101,8 @@ keyword=
 
{
   "body": [
       {
-        "foodCategoryDay": {
-          "ˮ": 20,
-          "߲": 50,
-          "": 10,
-          "": 30
-        },
-        "foodCategoryWeek": {
-          "ˮ": 100,
-          "߲": 200,
-          "": 500,
-          "": 300
-        },
+        "foodCategoryDay": [{"max":100,"min":10,"name":"","type":"weight","category":["",""]}],
+        "foodCategoryWeek": [{"max":100,"min":10,"name":"","type":"weight","category":["",""]}],
         "id": 1,
         "ingredient": {
           "": {
@@ -189,8 +159,8 @@ id=1   // 
 name=Ͳָ   //  
 vendors=1,2,3      //  λб
 overflow=0.5       //  
-foodCategoryDay={"ˮ": 20, "߲": 50, "": 10, "": 30}
-foodCategoryWeek={"ˮ": 200, "߲": 500, "": 100, "": 300}
+foodCategoryDay=[{"max":100,"min":10,"name":"","type":"weight","category":["",""]}]
+foodCategoryWeek=[{"max":100,"min":10,"name":"","type":"quantity","category":["",""]}]
 ingredient={"": {"vitamin-a": {"ul": 5, "max": 10, "min": 2}}, "": {"vitamin-a": {"ul": 5, "max": 10, "min": 2}}}
 

:

@@ -216,53 +186,4 @@ id=1 // "success": true }
-

5. ʳĴ(ҵ˽ӿ)

-
-

PUT /api/ingredient/mark

-
-

:

-
Content-Type:application/x-www-form-urlencoded
-nutrient=010101
-mark=        // , ȡֵ:  /
-
-
-

:

-
{
-  "code": 200,
-  "desc": "ɹ",
-  "success": true
-}
-
-

6. ȡ(ҵ˽ӿ)

-
-

DELETE /api/ingredient/mark

-
-

:

-
Content-Type:application/x-www-form-urlencoded
-nutrient=010101
-
-
-

:

-
{
-  "code": 200,
-  "desc": "ɹ",
-  "success": true
-}
-
-

7. (˽ӿ)

-
-

PUT /api/ingredient/mark

-
-

:

-
Content-Type: multipart/form-data
-files   // ش
-
-
-

:

-
{
-  "code": 200,
-  "desc": "ɹ",
-  "success": true
-}
-
diff --git a/doc/basic.md b/doc/basic.md index 046bfea..c18d938 100644 --- a/doc/basic.md +++ b/doc/basic.md @@ -84,294 +84,350 @@ password=BE56E057F20F883E // 新密码 ### 输出: ```json { - "body": { - "nutrient": [ - { - "key": "fiber", - "measurement": "g", - "nrv": 25.00, - "value": "膳食纤维" - }, - { - "key": "calcium", - "measurement": "mg", - "nrv": 800.00, - "value": "钙" - }, - { - "key": "vb1", - "measurement": "mg", - "nrv": 1.40, - "value": "维生素B1" - }, - { - "key": "carbs", - "measurement": "g", - "nrv": 300.00, - "value": "碳水化合物" - }, - { - "key": "vb2", - "measurement": "mg", - "nrv": 1.40, - "value": "维生素B2" - }, - { - "key": "va", - "measurement": "μgRAE", - "nrv": 800.00, - "value": "维生素A" - }, - { - "key": "vc", - "measurement": "mg", - "nrv": 100.00, - "value": "维生素C" - }, - { - "key": "protein", - "measurement": "g", - "nrv": 60.00, - "value": "蛋白质" - }, - { - "key": "fat", - "measurement": "g", - "nrv": 60.00, - "value": "脂肪" - }, - { - "key": "iron", - "measurement": "mg", - "nrv": 15.00, - "value": "铁" - }, - { - "key": "zinc", - "measurement": "mg", - "nrv": 15.00, - "value": "锌" - }, - { - "key": "energy", - "measurement": "kcal", - "nrv": 2000.00, - "value": "能量kcal" - } - ], - "menuStatus": [ - { - "key": 0, - "value": "草稿" - }, - { - "key": 1, - "value": "提交审核" - }, - { - "key": 2, - "value": "审核通过" - }, - { - "key": 3, - "value": "审核失败" - }, - { - "key": 4, - "value": "禁用" - }, - { - "key": 5, - "value": "发布" - } - ], - "markType": [ - { - "key": "常用", - "value": "常用" - }, - { - "key": "忌用", - "value": "忌用" - } - ], - "mealType": [ - { - "key": "早餐", - "value": "早餐" - }, - { - "key": "午餐", - "value": "午餐" - }, - { - "key": "晚餐", - "value": "晚餐" - } - ], - "category": [ - { - "key": "蛋类", - "value": "蛋类" - }, - { - "key": "大豆类及其制品", - "value": "大豆类及其制品" - }, - { - "key": "婴幼儿食品", - "value": "婴幼儿食品" - }, - { - "key": "鱼虾类", - "value": "鱼虾类" - }, - { - "key": "畜肉类", - "value": "畜肉类" - }, - { - "key": "坚果", - "value": "坚果" - }, - { - "key": "含酒精饮料", - "value": "含酒精饮料" - }, - { - "key": "调味品", - "value": "调味品" - }, - { - "key": "糖类", - "value": "糖类" - }, - { - "key": "其他", - "value": "其他" - }, - { - "key": "蔬菜类", - "value": "蔬菜类" - }, - { - "key": "水果类", - "value": "水果类" - }, - { - "key": "菌藻类", - "value": "菌藻类" - }, - { - "key": "小吃、甜饼", - "value": "小吃、甜饼" - }, - { - "key": "谷类", - "value": "谷类" - }, - { - "key": "禽肉类", - "value": "禽肉类" - }, - { - "key": "奶及奶制品", - "value": "奶及奶制品" - }, - { - "key": "烹调油", - "value": "烹调油" - }, - { - "key": "速食食品", - "value": "速食食品" - }, - { - "key": "薯类", - "value": "薯类" - }, - { - "key": "饮料类", - "value": "饮料类" - } - ], - "mark": [ - { - "key": "主荤", - "value": "主荤" - }, - { - "key": "水果", - "value": "水果" - }, - { - "key": "辅食", - "value": "辅食" - }, - { - "key": "糕点", - "value": "糕点" - }, - { - "key": "次荤", - "value": "次荤" - }, - { - "key": "主食", - "value": "主食" - }, - { - "key": "面食", - "value": "面食" - }, - { - "key": "素菜", - "value": "素菜" - }, - { - "key": "奶", - "value": "奶" - }, - { - "key": "粥类", - "value": "粥类" - }, - { - "key": "汤类", - "value": "汤类" - }, - { - "key": "饮料类", - "value": "饮料类" - } - ], - "venderType": [ - { - "key": "学校", - "value": "学校" - }, - { - "key": "医院", - "value": "医院" - }, - { - "key": "事业单位", - "value": "事业单位" - }, - { - "key": "其他", - "value": "其他" - } - ], - "poly":[ - { - "key": "蒸", - "value": "蒸" - } - ] - }, - "code": 200, - "desc": "成功", - "success": true + "body": { + "nutrient": [ + { + "key": "fiber", + "measurement": "g", + "nrv": 25.00, + "value": "膳食纤维" + }, + { + "key": "calcium", + "measurement": "mg", + "nrv": 800.00, + "value": "钙" + }, + { + "key": "vb1", + "measurement": "mg", + "nrv": 1.40, + "value": "维生素B1" + }, + { + "key": "carbs", + "measurement": "g", + "nrv": 300.00, + "value": "碳水化合物" + }, + { + "key": "vb2", + "measurement": "mg", + "nrv": 1.40, + "value": "维生素B2" + }, + { + "key": "va", + "measurement": "μgRAE", + "nrv": 800.00, + "value": "维生素A" + }, + { + "key": "vc", + "measurement": "mg", + "nrv": 100.00, + "value": "维生素C" + }, + { + "key": "sodium", + "measurement": "mg", + "nrv": 2000.00, + "value": "钠" + }, + { + "key": "protein", + "measurement": "g", + "nrv": 60.00, + "value": "蛋白质" + }, + { + "key": "fat", + "measurement": "g", + "nrv": 60.00, + "value": "脂肪" + }, + { + "key": "iron", + "measurement": "mg", + "nrv": 15.00, + "value": "铁" + }, + { + "key": "zinc", + "measurement": "mg", + "nrv": 15.00, + "value": "锌" + }, + { + "key": "energy", + "measurement": "kcal", + "nrv": 2000.00, + "value": "能量" + } + ], + "menuStatus": [ + { + "key": 0, + "value": "草稿" + }, + { + "key": 5, + "value": "发布" + } + ], + "markType": [ + { + "key": "常用", + "value": "常用" + }, + { + "key": "忌用", + "value": "忌用" + } + ], + "poly": [ + { + "key": "烤", + "name": "烤" + }, + { + "key": "卤", + "name": "卤" + }, + { + "key": "无需烹饪", + "name": "无需烹饪" + }, + { + "key": "烧", + "name": "烧" + }, + { + "key": "烩", + "name": "烩" + }, + { + "key": "腌", + "name": "腌" + }, + { + "key": "煎", + "name": "煎" + }, + { + "key": "煮", + "name": "煮" + }, + { + "key": "熏", + "name": "熏" + }, + { + "key": "炒", + "name": "炒" + }, + { + "key": "炖", + "name": "炖" + }, + { + "key": "焖", + "name": "焖" + }, + { + "key": "蒸", + "name": "蒸" + }, + { + "key": "炸", + "name": "炸" + } + ], + "mealType": [ + { + "key": "早餐", + "value": "早餐" + }, + { + "key": "午餐", + "value": "午餐" + }, + { + "key": "晚餐", + "value": "晚餐" + } + ], + "measurementType": [ + { + "key": "weight", + "value": "克" + }, + { + "key": "quantity", + "value": "种" + } + ], + "category": [ + { + "key": "蛋类", + "value": "蛋类" + }, + { + "key": "大豆类及其制品", + "value": "大豆类及其制品" + }, + { + "key": "杂豆类", + "value": "杂豆类" + }, + { + "key": "婴幼儿食品", + "value": "婴幼儿食品" + }, + { + "key": "鱼虾类", + "value": "鱼虾类" + }, + { + "key": "畜肉类", + "value": "畜肉类" + }, + { + "key": "坚果", + "value": "坚果" + }, + { + "key": "含酒精饮料", + "value": "含酒精饮料" + }, + { + "key": "调味品", + "value": "调味品" + }, + { + "key": "糖类", + "value": "糖类" + }, + { + "key": "其他", + "value": "其他" + }, + { + "key": "蔬菜类", + "value": "蔬菜类" + }, + { + "key": "水果类", + "value": "水果类" + }, + { + "key": "菌藻类", + "value": "菌藻类" + }, + { + "key": "小吃、甜饼", + "value": "小吃、甜饼" + }, + { + "key": "谷类", + "value": "谷类" + }, + { + "key": "禽肉类", + "value": "禽肉类" + }, + { + "key": "奶及奶制品", + "value": "奶及奶制品" + }, + { + "key": "烹调油", + "value": "烹调油" + }, + { + "key": "速食食品", + "value": "速食食品" + }, + { + "key": "薯类", + "value": "薯类" + }, + { + "key": "饮料类", + "value": "饮料类" + } + ], + "mark": [ + { + "key": "主荤", + "value": "主荤" + }, + { + "key": "水果", + "value": "水果" + }, + { + "key": "辅食", + "value": "辅食" + }, + { + "key": "糕点", + "value": "糕点" + }, + { + "key": "次荤", + "value": "次荤" + }, + { + "key": "主食", + "value": "主食" + }, + { + "key": "面食", + "value": "面食" + }, + { + "key": "素菜", + "value": "素菜" + }, + { + "key": "奶", + "value": "奶" + }, + { + "key": "粥类", + "value": "粥类" + }, + { + "key": "汤类", + "value": "汤类" + }, + { + "key": "饮料类", + "value": "饮料类" + } + ], + "venderType": [ + { + "key": "学校", + "value": "学校" + }, + { + "key": "医院", + "value": "医院" + }, + { + "key": "事业单位", + "value": "事业单位" + }, + { + "key": "其他", + "value": "其他" + } + ] + }, + "code": 200, + "desc": "成功", + "success": true } ``` \ No newline at end of file diff --git a/doc/menu/report.md b/doc/menu/report.md index deb3e7a..b138dc3 100644 --- a/doc/menu/report.md +++ b/doc/menu/report.md @@ -13,103 +13,135 @@ crow=xxx // ### : ~~~json { - "body": { - "day": 5, - "crow": "10", - "meals": [ - "" - ], - "types": { - "": 5, - "Ϻ": 2, - "ζƷ": 1 + "body": { + "day": 1, + "crow": "6~8 Ů", + "meals": [ + "", + "", + "" + ], + "types": { + "": 1, + "༰Ʒ": 1, + "Ϻ": 1, + "": 5, + "": 1, + "": 3, + "̼Ʒ": 1, + "ζƷ": 1, + "߲": 6 + }, + "ingredient": [ + { + "nutrition": "ʳά/g", + "virtual": 4.8, + "ul": "-", + "standard": "20~20", + "overload": "-76.00%", + "conclusion": "" + }, + { + "nutrition": "/mg", + "virtual": 490, + "ul": "-", + "standard": "750~750", + "overload": "-34.67%", + "conclusion": "" + }, + { + "nutrition": "άB1/mg", + "virtual": 1.05, + "ul": "-", + "standard": "0.9~0.9", + "overload": "16.67%", + "conclusion": "" + }, + { + "nutrition": "̼ˮ/g", + "virtual": 267.4, + "ul": "-", + "standard": "193.75~251.88", + "overload": "6.16%", + "conclusion": "" + }, + { + "nutrition": "άB2/mg", + "virtual": 0.62, + "ul": "-", + "standard": "0.9~0.9", + "overload": "-31.11%", + "conclusion": "" + }, + { + "nutrition": "άA/gRAE", + "virtual": 516, + "ul": "-", + "standard": "450~450", + "overload": "14.67%", + "conclusion": "" + }, + { + "nutrition": "άC/mg", + "virtual": 117.5, + "ul": "-", + "standard": "60~60", + "overload": "95.83%", + "conclusion": "" + }, + { + "nutrition": "/mg", + "virtual": 953.9, + "ul": "-", + "standard": "5000", + "overload": "-", + "conclusion": "" + }, + { + "nutrition": "/g", + "virtual": 70.2, + "ul": "-", + "standard": "32~48", + "overload": "46.25%", + "conclusion": "" + }, + { + "nutrition": "֬/g", + "virtual": 47.4, + "ul": "-", + "standard": "34.44~51.67", + "overload": "37.63%", + "conclusion": "" + }, + { + "nutrition": "/mg", + "virtual": 10.8, + "ul": "-", + "standard": "12~12", + "overload": "-10.00%", + "conclusion": "" + }, + { + "nutrition": "п/mg", + "virtual": 7.15, + "ul": "-", + "standard": "6.5~6.5", + "overload": "10.00%", + "conclusion": "" + }, + { + "nutrition": "/kcal", + "virtual": 1755, + "ul": "-", + "standard": "1395~1705", + "overload": "2.93%", + "conclusion": "" + } + ] }, - "ingredient": [ - { - "nutrition": "ʳά/g", - "virtual": 0, - "standard": "1~2", - "ul": "-", - "overload": -1, - "conclusion": "" - }, - { - "nutrition": "/mg", - "virtual": 2, - "standard": "-", - "ul": "-", - "overload": "-", - "conclusion": "-" - }, - { - "nutrition": "άB1/mg", - "virtual": 1, - "standard": "-", - "ul": "-", - "overload": "-", - "conclusion": "-" - }, - { - "nutrition": "̼ˮ/g", - "virtual": 0.1, - "standard": "-", - "ul": "-", - "overload": "-", - "conclusion": "-" - }, - { - "nutrition": "/g", - "virtual": 0.1, - "standard": "-", - "ul": "-", - "overload": "-", - "conclusion": "-" - }, - { - "nutrition": "άB2/mg", - "virtual": 2, - "standard": "-", - "ul": "-", - "overload": "-", - "conclusion": "-" - }, - { - "nutrition": "֬/g", - "virtual": 0.0, - "standard": "-", - "ul": "-", - "overload": "-", - "conclusion": "-" - }, - { - "nutrition": "/mg", - "virtual": 0.1, - "standard": "-", - "ul": "-", - "overload": "-", - "conclusion": "-" - }, - { - "nutrition": "άA/gRAE", - "virtual": 4, - "standard": "-", - "ul": "-", - "overload": "-", - "conclusion": "-" - }, - { - "nutrition": "kcal/kcal", - "virtual": 0.79, - "standard": "-", - "ul": "-", - "overload": "-", - "conclusion": "-" - } - ] - }, - "code": 200, - "desc": "ɹ", - "success": true + "code": 200, + "desc": "ɹ", + "success": true } ~~~ @@ -128,36 +160,38 @@ crow=xxx // ### : ~~~json { - "body": { - "day": 5, - "crow": "10", - "meals": [ - "" - ], - "energy": [ - { - "name": "/", - "standard": "10~20", - "value": 10.0, - "conclusion": "" - }, - { - "name": "֬/", - "standard": "20~30", - "value": 0.0, - "conclusion": "Ե" - }, - { - "name": "̼ˮ/", - "standard": "50~60", - "value": 10.0, - "conclusion": "Ե" - } - ] - }, - "code": 200, - "desc": "ɹ", - "success": true + "body": { + "day": 1, + "crow": "6~8 Ů", + "meals": [ + "", + "", + "" + ], + "energy": [ + { + "name": "/", + "standard": "10~20", + "value": 15.80, + "conclusion": "" + }, + { + "name": "֬/", + "standard": "20~30", + "value": 24.01, + "conclusion": "" + }, + { + "name": "̼ˮ/", + "standard": "50~60", + "value": 60.19, + "conclusion": "" + } + ] + }, + "code": 200, + "desc": "ɹ", + "success": true } ~~~ @@ -174,195 +208,33 @@ crow=xxx // ### : ~~~json { - "body": { - "crow": "6~8 Ů", - "dayRule": [ - [ - { - "day": 1, - "name": "", - "standard": 0, - "supplied": 5, - "lack": 0 - }, - { - "day": 1, - "name": "Ϻ", - "standard": 0, - "supplied": 2, - "lack": 0 - }, - { - "day": 1, - "name": "ζƷ", - "standard": 0, - "supplied": 1, - "lack": 0 - } - ], - [ - { - "day": 2, - "name": "", - "standard": 0, - "supplied": 5, - "lack": 0 + "body": { + "crow": "6~8 Ů", + "dayRule": { + "1": [ + { + "day": 1, + "name": "", + "standard": "10~100", + "measurement": "weight", + "supplied": 320, + "lack": -220 + } + ] }, - { - "day": 2, - "name": "Ϻ", - "standard": 0, - "supplied": 2, - "lack": 0 - }, - { - "day": 2, - "name": "ζƷ", - "standard": 0, - "supplied": 1, - "lack": 0 - } - ], - [ - { - "day": 3, - "name": "", - "standard": 0, - "supplied": 5, - "lack": 0 - }, - { - "day": 3, - "name": "Ϻ", - "standard": 0, - "supplied": 2, - "lack": 0 - }, - { - "day": 3, - "name": "ζƷ", - "standard": 0, - "supplied": 1, - "lack": 0 - } - ], - [ - { - "day": 4, - "name": "Ϻ", - "standard": 0, - "supplied": 2, - "lack": 0 - }, - { - "day": 4, - "name": "", - "standard": 0, - "supplied": 5, - "lack": 0 - }, - { - "day": 4, - "name": "ζƷ", - "standard": 0, - "supplied": 1, - "lack": 0 - } - ], - [ - { - "day": 5, - "name": "Ϻ", - "standard": 0, - "supplied": 2, - "lack": 0 - }, - { - "day": 5, - "name": "", - "standard": 0, - "supplied": 5, - "lack": 0 - }, - { - "day": 5, - "name": "ζƷ", - "standard": 0, - "supplied": 1, - "lack": 0 - } - ], - [ - { - "day": 6, - "name": "Ϻ", - "standard": 0, - "supplied": 2, - "lack": 0 - }, - { - "day": 6, - "name": "", - "standard": 0, - "supplied": 5, - "lack": 0 - }, - { - "day": 6, - "name": "ζƷ", - "standard": 0, - "supplied": 1, - "lack": 0 - } - ], - [ - { - "day": 7, - "name": "Ϻ", - "standard": 0, - "supplied": 2, - "lack": 0 - }, - { - "day": 7, - "name": "", - "standard": 0, - "supplied": 5, - "lack": 0 - }, - { - "day": 7, - "name": "ζƷ", - "standard": 0, - "supplied": 1, - "lack": 0 - } - ] - ], - "weekRule": [ - { - "name": "", - "standard": 0, - "supplied": 35, - "lack": 0 - }, - { - "name": "Ϻ", - "standard": 0, - "supplied": 14, - "lack": 0 - }, - { - "name": "ζƷ", - "standard": 0, - "supplied": 7, - "lack": 0 - } - ] - }, - "code": 200, - "desc": "ɹ", - "success": true + "weekRule": [ + { + "name": "", + "standard": "10~100", + "measurement": "weight", + "supplied": 320, + "lack": -220 + } + ] + }, + "code": 200, + "desc": "ɹ", + "success": true } ~~~ diff --git a/doc/nutrition.md b/doc/nutrition.md index 9d128b6..a060205 100644 --- a/doc/nutrition.md +++ b/doc/nutrition.md @@ -18,18 +18,8 @@ keyword=青少年 // 查询关键字 "body": { "content": [ { - "foodCategoryDay": { - "水果类": 20, - "蔬菜类": 50, - "谷薯类": 10, - "畜肉禽类": 30 - }, - "foodCategoryWeek": { - "水果类": 100, - "蔬菜类": 200, - "谷薯类": 500, - "畜肉禽类": 300 - }, + "foodCategoryDay": [{"max":100,"min":10,"name":"规则名称","type":"quantity","category":["谷类","薯类"]}], + "foodCategoryWeek": [{"max":100,"min":10,"name":"规则名称","type":"quantity","category":["谷类","薯类"]}], "id": 1, "ingredient": { "轻体力": { @@ -77,18 +67,8 @@ id=1 ``` { "body": { - "foodCategoryDay": { - "水果类": 20, - "蔬菜类": 50, - "谷薯类": 10, - "畜肉禽类": 30 - }, - "foodCategoryWeek": { - "水果类": 100, - "蔬菜类": 200, - "谷薯类": 500, - "畜肉禽类": 300 - }, + "foodCategoryDay": [{"max":100,"min":10,"name":"规则名称","type":"weight","category":["谷类","薯类"]}], + "foodCategoryWeek": [{"max":100,"min":10,"name":"规则名称","type":"weight","category":["谷类","薯类"]}], "id": 1, "ingredient": { "轻体力": { @@ -132,18 +112,8 @@ keyword=青 { "body": [ { - "foodCategoryDay": { - "水果类": 20, - "蔬菜类": 50, - "谷薯类": 10, - "畜肉禽类": 30 - }, - "foodCategoryWeek": { - "水果类": 100, - "蔬菜类": 200, - "谷薯类": 500, - "畜肉禽类": 300 - }, + "foodCategoryDay": [{"max":100,"min":10,"name":"规则名称","type":"weight","category":["谷类","薯类"]}], + "foodCategoryWeek": [{"max":100,"min":10,"name":"规则名称","type":"weight","category":["谷类","薯类"]}], "id": 1, "ingredient": { "轻体力": { @@ -206,8 +176,8 @@ id=1 // 必填 name=青少年就餐指导 // 名称 vendors=1,2,3 // 单位列表 overflow=0.5 // 溢出 -foodCategoryDay={"水果类": 20, "蔬菜类": 50, "谷薯类": 10, "畜肉禽类": 30} -foodCategoryWeek={"水果类": 200, "蔬菜类": 500, "谷薯类": 100, "畜肉禽类": 300} +foodCategoryDay=[{"max":100,"min":10,"name":"规则名称","type":"weight","category":["谷类","薯类"]}] +foodCategoryWeek=[{"max":100,"min":10,"name":"规则名称","type":"quantity","category":["谷类","薯类"]}] ingredient={"中体力": {"vitamin-a": {"ul": 5, "max": 10, "min": 2}}, "轻体力": {"vitamin-a": {"ul": 5, "max": 10, "min": 2}}} ``` @@ -230,67 +200,6 @@ id=1 // 必填 ``` -### 输出: -``` -{ - "code": 200, - "desc": "成功", - "success": true -} -``` - -# 5. 食材打标(业务端接口) - -> PUT /api/ingredient/mark - -### 输入: -``` -Content-Type:application/x-www-form-urlencoded -nutrient=010101 -mark=常用 // 必填, 取值: 常用/忌用 - -``` - -### 输出: -``` -{ - "code": 200, - "desc": "成功", - "success": true -} -``` - -# 6. 取消打标(业务端接口) - -> DELETE /api/ingredient/mark - -### 输入: -``` -Content-Type:application/x-www-form-urlencoded -nutrient=010101 - -``` - -### 输出: -``` -{ - "code": 200, - "desc": "成功", - "success": true -} -``` - -# 7. 批量导入(管理端接口) - -> PUT /api/ingredient/mark - -### 输入: -``` -Content-Type: multipart/form-data -files // 必传 - -``` - ### 输出: ``` {