diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyNutritionFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyNutritionFacade.java index a9abdd6..16441ff 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyNutritionFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyNutritionFacade.java @@ -91,7 +91,7 @@ public class BabyNutritionFacade { Map map = new HashMap<>(); map.put("id",model.getId()); map.put("babyId",model.getBabyId()); - map.put("created",DateUtil.getyyyy_MM_dd(model.getCreated())); + map.put("recordTime",DateUtil.getyyyy_MM_dd(model.getNutritiTime())); map.put("hospitalId",model.getHospitalId()); list.add(map); } @@ -327,9 +327,9 @@ public class BabyNutritionFacade { return new BaseObjectResponse().setData(data).setErrorcode(ErrorCodeConstants.NO_DATA).setErrormsg("月龄范围没有报告"); } String bmi = patientWeightService.getBmi(String.valueOf(model.getWeight()),String.valueOf(model.getHeight())); - String kaupEvaluate = getBabyStatus(month,baby.getSex(),model.getHeight(),model.getWeight(),bmi); + String kaupEvaluate = getBabyStatus(month, baby.getSex(), model.getHeight(), model.getWeight(), bmi); - double kaul = getKal(month,model.getHeight(),model.getWeight(), baby.getSex(), kaupEvaluate); + double kaul = getKal(month, model.getHeight(), model.getWeight(), baby.getSex(), kaupEvaluate); map.put("kaupEvaluate", kaupEvaluate); map.put("month", month); @@ -399,7 +399,7 @@ public class BabyNutritionFacade { } - List yys = getYys(month); + List yys = getYys(month,kaul,model.getWeight()); //每日所需营养素 data.put("yys",yys); @@ -410,45 +410,6 @@ public class BabyNutritionFacade { List wlysMapList = new ArrayList<>(); - //能量计算 - double nl = getBasicKaul( month, model.getWeight(),model.getHeight(),baby.getSex()); - double nlCurrent = 0; - yysMapList.add(getNl(nl,nlCurrent)); - - double tsCurrent = 0;//碳素化合物 TODO - double dbzCurrent = 0;//蛋白质 TODO - double zfCurrent = 0;//脂肪 TODO - if (month < 5) - { - yysMapList.add(getYysItems( nl, tsCurrent, "碳水化合物",0.55,0.65)); - yysMapList.add(getYysItems( nl, dbzCurrent, "蛋白质",0.07,0.09)); - yysMapList.add(getYysItems( nl, zfCurrent, "脂肪",0.4,0.5)); - - } - else if (month < 12) - { - - yysMapList.add(getYysItems( nl, tsCurrent, "碳水化合物",0.55,0.65)); - - yysMapList.add(getYysItems( nl, dbzCurrent, "蛋白质",0.05,0.07)); - - yysMapList.add(getYysItems( nl, zfCurrent, "脂肪",0.4,0.5)); - } - else if (month < 36) - { - yysMapList.add(getYysItems( nl, tsCurrent, "碳水化合物",0.5,0.7)); - - yysMapList.add(getYysItems( nl, dbzCurrent, "蛋白质",0.07,0.2)); - - yysMapList.add(getYysItems( nl, zfCurrent, "脂肪",0.2,0.35)); - } - else - { - yysMapList.add(getYysItems( nl, tsCurrent, "碳水化合物",0.55,0.7)); - yysMapList.add(getYysItems( nl, dbzCurrent, "蛋白质",0.07,0.2)); - yysMapList.add(getYysItems( nl, zfCurrent, "脂肪",0.15,0.3)); - } - Map elements = new HashMap(); List mainFoods = model.getMainFood(); @@ -511,6 +472,48 @@ public class BabyNutritionFacade { List vegXd = model.getVegXd(); getFoodElements(elements,vegXd); + + + //能量计算 + double nl = getBasicKaul( month, model.getWeight(),model.getHeight(),baby.getSex()); + Double nlCurrent = elements.get("能量") == null ? 0 : elements.get("能量"); + getNl(yysMapList, nl, nlCurrent); + + Double tsCurrent = elements.get("碳素化合物") == null ? 0 : elements.get("碳素化合物");//碳素化合物 + Double dbzCurrent = elements.get("蛋白质") == null ? 0 : elements.get("蛋白质");//蛋白质 + Double zfCurrent = elements.get("脂肪") == null ? 0 : elements.get("脂肪");//脂肪 + if (month < 5) + { + getYysItems(yysMapList, nl, tsCurrent, "碳水化合物", 0.55, 0.65); + getYysItems(yysMapList, nl, dbzCurrent, "蛋白质", 0.07, 0.09); + getYysItems(yysMapList, nl, zfCurrent, "脂肪", 0.4, 0.5); + + } + else if (month < 12) + { + + getYysItems(yysMapList, nl, tsCurrent, "碳水化合物", 0.55, 0.65); + + getYysItems(yysMapList, nl, dbzCurrent, "蛋白质", 0.05, 0.07); + + getYysItems(yysMapList, nl, zfCurrent, "脂肪", 0.4, 0.5); + } + else if (month < 36) + { + getYysItems(yysMapList, nl, tsCurrent, "碳水化合物", 0.5, 0.7); + + getYysItems(yysMapList, nl, dbzCurrent, "蛋白质", 0.07, 0.2); + + getYysItems(yysMapList, nl, zfCurrent, "脂肪", 0.2, 0.35); + } + else + { + getYysItems(yysMapList, nl, tsCurrent, "碳水化合物", 0.55, 0.7); + getYysItems(yysMapList, nl, dbzCurrent, "蛋白质", 0.07, 0.2); + getYysItems(yysMapList, nl, zfCurrent, "脂肪", 0.15, 0.3); + } + + if (elements.size() > 0) { for (String key : elements.keySet()) @@ -526,11 +529,25 @@ public class BabyNutritionFacade { String normalValue = babyNutritionConfig1.getNormalValue(); String downValue = babyNutritionConfig1.getDownValue(); + int status = 0; + if (StringUtils.isNotEmpty(upValue) && StringUtils.isNotEmpty(normalValue)) + { + status = Double.parseDouble(upValue) < value ? 1 : (Double.parseDouble(normalValue) > value ? -1 : 0); + }else if (StringUtils.isNotEmpty(downValue) && StringUtils.isNotEmpty(normalValue)) + { + status = Double.parseDouble(normalValue) < value ? 1 : (Double.parseDouble(downValue) > value ? -1 : 0); + } + else if (StringUtils.isNotEmpty(normalValue)) + { + status = Double.parseDouble(normalValue) > value ? -1 : 0; + } + + Map wly = new HashMap(); wly.put("name",key); wly.put("normalValue", normalValue); - wly.put("currentValue", value); - wly.put("status", -1); + wly.put("currentValue", String.format("%.2f",value)); + wly.put("status", status); wlysMapList.add(wly); } } @@ -544,14 +561,23 @@ public class BabyNutritionFacade { { for (Map map1 : yysMapList) { + if (map1 == null) + { + continue; + } + Integer status = Integer.valueOf(String.valueOf(map1.get("status"))); if (status != 0) { String str = status == -1 ? "摄入不足" : "摄入过量"; BabyNutritionConfigModel babyNutritionConfig1 = mongoTemplate.findOne( Query.query(Criteria.where("type").is(7).and("status").is(str).and("title").is(String.valueOf(map1.get("name")))), BabyNutritionConfigModel.class); + if (babyNutritionConfig1 == null) + { + continue; + } Map item = new HashMap(); - item.put("title",babyNutritionConfig1.getTitle()); + item.put("title",babyNutritionConfig1.getTitle()+str); item.put("content",babyNutritionConfig1.getContentOne()); items.add(item); } @@ -570,8 +596,12 @@ public class BabyNutritionFacade { String str = status == -1 ? "摄入不足" : "摄入过量"; BabyNutritionConfigModel babyNutritionConfig1 = mongoTemplate.findOne( Query.query(Criteria.where("type").is(7).and("status").is(str).and("title").is(String.valueOf(map1.get("name")))), BabyNutritionConfigModel.class); + if (babyNutritionConfig1 == null) + { + continue; + } Map item = new HashMap(); - item.put("title",babyNutritionConfig1.getTitle()); + item.put("title",babyNutritionConfig1.getTitle()+str); item.put("content",babyNutritionConfig1.getContentOne()); wlysitems.add(item); } @@ -614,8 +644,12 @@ public class BabyNutritionFacade { { for (FoodResult food : foodResults) { - Double protein = (elements.get(food.getNutritionName()) == null ? 0 : elements.get(food.getNutritionName())) * Double.valueOf(val); - elements.put(food.getNutritionName(),protein == null ? 0+food.getProtein() : protein+food.getProtein()); + Double protein = (elements.get(food.getNutritionName()) == null ? 0 : elements.get(food.getNutritionName())); + if (food.getProtein() != null) + { + elements.put(food.getNutritionName(),protein == null ? food.getProtein() : protein+food.getProtein()); + } + } } } @@ -623,57 +657,85 @@ public class BabyNutritionFacade { } } - private Map getYysItems(double nl,double current,String title,double down,double up) + private void getYysItems(List yysMapList,double nl,Double current,String title,double down,double up) { + if (current == null || current == 0) + { + return; + } Map map = new HashMap(); map.put("name",title); - map.put("normalValue", (nl * down) + "-" + (nl * up)); - map.put("currentValue", current); + map.put("normalValue", String.format("%.2f",(nl * down)) + "-" + String.format("%.2f",(nl * up))); + map.put("currentValue", String.format("%.2f", current)); map.put("status", (nl * up) < current ? 1 : (nl * down > current ? -1 : 0)); - return map; + yysMapList.add(map); } - private Map getNl(double nl,double current) + private void getNl(List yysMapList,double nl,Double current) { - + if (current == null || current == 0) + { + return; + } Map nlMap = new HashMap(); nlMap.put("name","能量"); - nlMap.put("normalValue",(nl-50)+"-" +(nl+50)); - nlMap.put("currentValue",current); + nlMap.put("normalValue",String.format("%.2f",(nl-50))+"-" +String.format("%.2f",(nl+50))); + nlMap.put("currentValue",String.format("%.2f",current)); nlMap.put("status", nl + 50 < current ? 1 : (nl - 50 > current ? -1 : 0)); - return nlMap; + yysMapList.add(nlMap); } - private List getYys(int month){ + private List getYys(int month,Double nl,Double weight){ List list = new ArrayList<>(); if (month < 36) { - list.add("碳水化合物:总能量的50-70%"); - list.add("蛋白质:总能量的7-20%,平均每日约0.96g/kg"); - list.add("脂肪:总能量的20-35%"); - list.add("n-6:总能量的4-8%"); - list.add("N-3:总能量的1%"); + //总能量的50-70% + list.add("碳水化合物:"+handleData( nl,0.5,0.7)); + //总能量的7-20% + list.add("蛋白质:"+handleData( nl,0.07,0.2)+",平均每日约0.96g/kg"); + //总能量的20-35% + list.add("脂肪:"+handleData( nl,0.2,0.35)); + //总能量的4-8% + list.add("n-6:"+handleData( nl,0.04,0.08)); + //总能量的1% + list.add("N-3:"+handleData( nl,0.01)); list.add("无机物:钙的推荐摄入量为500mg,磷的推荐摄入量为500mg,钠的充分摄入为0.7g,氯的充分摄入量为1.1g,钾的充分摄入量为1.7g,镁的推荐摄入量为75mg,铁的推荐摄入量为6mg,锌的推荐摄入量为3mg,铜的推荐摄入量为290 μg,氟的充分摄入量为0.6mg,猛的充分摄入量为1.4mg,碘的推荐摄入量为80 μg,硒的推荐摄入量为20 μg"); list.add("维生素:维生素A的推荐摄入量为300 μgRE,维生素D的充分摄入量为5 μg,维生素E的充分摄入量为5mg α-TE,维生素K的充分摄入量为25μg,维生素C的推荐摄入量为40mg,维生素B1的推荐摄入量为0.5mg,维生素B2(核黄素)的0.6mg,维生素B3烟酸的推荐摄入量为6mgNE,尼克酸的上限摄入量为10mg,尼克酰胺的上限摄入量为180mg,维生素B6的推荐摄入量0.6mg,叶酸的推荐摄入量为150μg DFE,维生素B12的推荐摄入量为0.9μg,泛酸的充分摄入量为2mg,维生素H的充分摄入量9μg"); - list.add("水分:1岁120-135ml/kg/day;2岁115-125ml/kg/day"); + //1岁120-135ml/kg/day;2岁115-125ml/kg/day + list.add("水分:1岁"+handleData(weight,120,135)+"ml/day;2岁"+handleData(weight,115,125)+"ml/kg/day"); } else { - list.add("碳水化合物:总能量的55-70%"); - list.add("蛋白质:总能量的7-20%,平均每日约0.88g/kg"); - list.add("脂肪:总能量的15-30%"); - list.add("n-6:总能量的4-8%"); - list.add("n-3:总能量的1%"); + //总能量的55-70% + list.add("碳水化合物:"+handleData( nl,0.55,0.7)); + //总能量的7-20% + list.add("蛋白质:"+handleData( nl,0.07,0.2)+",平均每日约0.88g/kg"); + //总能量的15-30% + list.add("脂肪:"+handleData( nl,0.15,0.3)); + //总能量的4-8% + list.add("n-6:"+handleData( nl,0.04,0.08)); + //总能量的1% + list.add("n-3:"+handleData( nl,0.01)); list.add("无机物:钙的推荐摄入量为600mg,磷的推荐摄入量为500mg,钠的充分摄入量为0.9g,氯的充分摄入量为1.4g,钾的充分摄入量为2.3g,镁的推荐摄入量为100mg,铁的推荐摄入量7mg,锌的推荐摄入量为4mg,铜的推荐摄入量为330 μg,氟的充分摄入量为0.8mg,猛的充分摄入量为2.0mg,碘的推荐摄入量为90 μg,硒的推荐摄入量为25 μg"); list.add("维生素:维生素A的推荐摄入量为300 μgRE,维生素D的充分摄入量为5 μg,维生素E的充分摄入量为6mg α-TE,维生素K的充分摄入量为30μg,维生素C的推荐摄入量为40mg,维生素B1的推荐摄入量为0.5mg,维生素B2(核黄素)的0.7mg,维生素B3烟酸的推荐摄入量为7mgNE,尼克酸的上限摄入量为10mg,尼克酰胺的上限摄入量为250mg,维生素B6的推荐摄入量0.7mg,叶酸的推荐摄入量为180μg DFE,维生素B12的推荐摄入量为1.1μg,泛酸的充分摄入量为3mg,维生素H的充分摄入量11μg"); - list.add("水分:90-100ml/kg/day"); + //90-100ml/kg/day + list.add("水分:"+handleData(weight,90,100)+"ml/day"); } return list; } + private String handleData(Double nl,double up,double down) + { + return String.format("%.2f",(nl * down))+"-"+String.format("%.2f",(nl * up)); + } + private String handleData(Double nl,double value) + { + return String.format("%.2f",(nl * value)); + } + /** * 1-5 体重 * 90kcal/kg * 6-11月龄热量计算:体重 * 80kcal/kg