From 1d21235bdf730b8425838d8169d24ffd835f4efd Mon Sep 17 00:00:00 2001 From: liquanyu Date: Thu, 2 Jan 2020 13:56:16 +0800 Subject: [PATCH] update --- .../web/service/impl/BloodSugarServiceImpl.java | 99 +++++++++++++++++++++- 1 file changed, 97 insertions(+), 2 deletions(-) diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java index 5bb03ac..834ddd1 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java @@ -1115,7 +1115,7 @@ public class BloodSugarServiceImpl extends BaseServiceImpl implements IBloodSuga double bmi = Double.parseDouble(patientWeight.getBmi()); //根据高危获取不同的卡路里计算公式 - Map kmap = computeKulServiceManager.getComputeKulByRisk(rid).getComputeKul(Double.parseDouble(patientWeight.getBeforeWeight()), + Map kmap = getComputeKul(Double.parseDouble(patientWeight.getBeforeWeight()), Double.parseDouble(patientWeight.getNowWeight()), week, bmi, patientWeight.getBregmatic(), patientWeight.getBeforeHeight(), version); @@ -1139,7 +1139,7 @@ public class BloodSugarServiceImpl extends BaseServiceImpl implements IBloodSuga Map dinner2 = new LinkedHashMap<>(); // 晚加餐 String nsArea = ReportConfig.getNSArea(basicConfig.getName()); - WeightConfigModel configModel = patientWeightService.getWeightConfigBykcal(kmap, nsArea, rid); + WeightConfigModel configModel = getWeightConfigBykcal(kmap, nsArea, rid); if (configModel != null) { setData(breakfast, "早餐", configModel.getBreakfast()); @@ -1171,6 +1171,101 @@ public class BloodSugarServiceImpl extends BaseServiceImpl implements IBloodSuga } + public WeightConfigModel getWeightConfigBykcal(Map map, String northSouth, String risk) { + if (map.get("kulStart") == null) { + return null; + } + double kulStart = Double.valueOf(map.get("kulStart")); + int k1 = ((int) kulStart / 100) * 100; + double k2 = kulStart - k1; + if (k2 > 50) { + k1 += 100; + } + + if (k1 < 1500) { + k1 = 1500; + } else if (k1 > 2800) { + k1 = 2800; + } + Criteria criteria = null; + if ("3".equals((String) map.get("type"))) { + criteria = Criteria.where("kcal").is(k1).and("dietaryType").is(0); + } else { + criteria = Criteria.where("northSouth").is(northSouth).and("kcal").is(k1); + } + //如果传了高危因素id就按高危去查 + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(risk)) { + criteria = criteria.and("riskId").in(risk).and("type").is("1"); + } else { + criteria = criteria.and("type").is("0"); + } + Query query = Query.query(criteria); + WeightConfigModel weightConfigModel = mongoTemplate.findOne(query, + WeightConfigModel.class); + return weightConfigModel; + } + + + public Map getComputeKul(double beforeWeight, double currentWeight, int week, double bmi, String bregmatic, String beforeHeight,String version) { + Map map = new HashMap<>(); + double kulStart = 0; + double height = Double.valueOf(String.format("%.2f", Double.parseDouble(beforeHeight) / 100)); + //孕早期 + if (week <= 12) { + kulStart = (new BigDecimal(Double.toString(height)).multiply(new BigDecimal(Double.toString(height))).doubleValue() * 21 + 1.5) * 30; + } + //孕中期 //孕晚期 + else if (week > 12) { + //基础kcal值 + int basekul = (week > 12 && week <= 27) ? 340 : 450; + + String bmiStr = ""; + + if (org.apache.commons.lang.StringUtils.isEmpty(bregmatic) || "1".equals(bregmatic)) { + if (bmi < 18.5) { + bmiStr = "BMI<18.5孕" + week + "周"; + } else if (bmi <= 24.9 && bmi >= 18.5) { + bmiStr = "BMI=18.5-24.9孕" + week + "周"; + } else if (bmi <= 29.9 && bmi >= 25) { + bmiStr = "BMI=25-29.9孕" + week + "周"; + } else if (bmi >= 30) { + bmiStr = "BMI≥30孕" + week + "周"; + } + } else { + if (bmi <= 24.9) { + bmiStr = "BMI≤24.9孕" + week + "周"; + } else if (bmi <= 29.9 && bmi >= 25) { + bmiStr = "BMI=25-29.9孕" + week + "周"; + } else if (bmi >= 30) { + bmiStr = "BMI≥30孕" + week + "周"; + } + } + + if (org.apache.commons.lang.StringUtils.isEmpty(bmiStr)) { + return map; + } + + String[] rangeWeight = null; + if (org.apache.commons.lang.StringUtils.isEmpty(bregmatic) || "1".equals(bregmatic)) { + rangeWeight = ReportConfig.getWeightRange(bmiStr).split("-"); + } else { + rangeWeight = ReportConfig.getDWeightRange(bmiStr).split("-"); + } + + if (rangeWeight == null || rangeWeight.length != 2) { + return map; + } + + double addWeightEnd = Double.parseDouble(rangeWeight[1]); + + kulStart = (new BigDecimal(Double.toString(height)).multiply(new BigDecimal(Double.toString(height))).doubleValue() * 21 + addWeightEnd ) * 30+basekul; + } + + map.put("kulStart", String.valueOf(kulStart)); + return map; + } + + private void setData(Map map, String key, String value) { map.put("id", key); map.put("name", value); -- 1.8.3.1