diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java index d99e1c0..d889527 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java @@ -750,69 +750,42 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient if(StringUtils.isNotEmpty(bmi)) { bmiD = Double.parseDouble(bmi); } - double low = 0D; - double low2 = 0D; - double high = 0D; - double high2 = 0D; + List highData = new ArrayList<>(); + List normalData = new ArrayList<>(); + List lowData = new ArrayList<>(); String color = ""; if(bmiD <= 18.5) { - low = 1.2; - low2 = 11.9; - high = 3.8; - high2 = 18.1; + highData = getDoubleList(Arrays.asList("0.0,0.3,0.6,0.9,1.2,1.5,1.8,2.0,2.3,2.6,2.9,3.2,3.5,3.8,4.3,4.9,5.4,5.9,6.4,7.0,7.5,8.0,8.6,9.1,9.6,10.2,10.7,11.2,11.7,12.3,12.8,13.3,13.9,14.4,14.9,15.5,16.0,16.5,17.0,17.6,18.1".split(","))); + normalData = getDoubleList(Arrays.asList("0.0,0.2,0.4,0.6,0.8,1.0,1.2,1.3,1.5,1.7,1.9,2.1,2.3,2.5,3.0,3.4,3.9,4.4,4.8,5.3,5.7,6.2,6.7,7.1,7.6,8.1,8.5,9.0,9.4,9.9,10.4,10.8,11.3,11.8,12.2,12.7,13.1,13.6,14.1,14.5,15.0".split(","))); + lowData = getDoubleList(Arrays.asList("0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.6,2.0,2.4,2.8,3.2,3.6,4.0,4.4,4.8,5.2,5.6,6.0,6.4,6.7,7.1,7.5,7.9,8.3,8.7,9.1,9.5,9.9,10.3,10.7,11.1,11.5,11.9".split(","))); color = "#00CD00"; } else if(bmiD > 18.5 && bmiD <= 24.9){ - low = 1.4; - low2 = 11.9; - high = 3.2; - high2 = 15.9; + highData = getDoubleList(Arrays.asList("0.0,0.2,0.5,0.7,1.0,1.2,1.5,1.7,2.0,2.2,2.5,2.7,3.0,3.2,3.7,4.1,4.6,5.1,5.6,6.0,6.5,7.0,7.4,7.9,8.4,8.8,9.3,9.8,10.3,10.7,11.2,11.7,12.1,12.6,13.1,13.5,14.0,14.5,15.0,15.4,15.9".split(","))); + normalData = getDoubleList(Arrays.asList("0.0,0.2,0.4,0.5,0.7,0.9,1.1,1.2,1.4,1.6,1.8,1.9,2.1,2.3,2.7,3.2,3.6,4.0,4.4,4.9,5.3,5.7,6.2,6.6,7.0,7.5,7.9,8.3,8.7,9.2,9.6,10.0,10.5,10.9,11.3,11.8,12.2,12.6,13.0,13.5,13.9".split(","))); + lowData = getDoubleList(Arrays.asList("0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.8,2.2,2.6,3.0,3.3,3.7,4.1,4.5,4.9,5.3,5.7,6.1,6.5,6.8,7.2,7.6,8.0,8.4,8.8,9.2,9.6,10.0,10.3,10.7,11.1,11.5,11.9".split(","))); color = "#7EC0EE"; } else if(bmiD > 24.9 && bmiD < 30){ - low = 1.1 ; - low2 = 7.1; - high = 3.1; - high2 = 11.6; + highData = getDoubleList(Arrays.asList("0.0,0.2,0.5,0.7,1.0,1.2,1.4,1.7,1.9,2.1,2.4,2.6,2.9,3.1,3.4,3.7,4.0,4.4,4.7,5.0,5.3,5.6,5.9,6.2,6.6,6.9,7.2,7.5,7.8,8.1,8.5,8.8,9.1,9.4,9.7,10.0,10.3,10.7,11.0,11.3,11.6".split(","))); + normalData = getDoubleList(Arrays.asList("0.0,0.2,0.3,0.5,0.6,0.8,1.0,1.1,1.3,1.5,1.6,1.8,1.9,2.1,2.4,2.6,2.9,3.2,3.4,3.7,4.0,4.2,4.5,4.8,5.1,5.3,5.6,5.9,6.1,6.4,6.7,6.9,7.2,7.5,7.7,8.0,8.3,8.5,8.8,9.1,9.3".split(","))); + lowData = getDoubleList(Arrays.asList("0.0,0.1,0.2,0.3,0.3,0.4,0.5,0.6,0.7,0.8,0.8,0.9,1.0,1.1,1.3,1.5,1.8,2.0,2.2,2.4,2.7,2.9,3.1,3.3,3.5,3.8,4.0,4.2,4.4,4.7,4.9,5.1,5.3,5.5,5.8,6.0,6.2,6.4,6.7,6.9,7.1".split(","))); color = "#CD3333"; } else if(bmiD >= 30){ - low = 0.8 ; - low2 = 4.9; - high = 2.1; - high2 = 8.9; + highData = getDoubleList(Arrays.asList("0.0,0.2,0.3,0.5,0.6,0.8,1.0,1.1,1.3,1.5,1.6,1.8,1.9,2.1,2.4,2.6,2.9,3.1,3.4,3.6,3.9,4.1,4.4,4.6,4.9,5.1,5.4,5.6,5.9,6.1,6.4,6.6,6.9,7.1,7.4,7.6,7.9,8.1,8.4,8.6,8.9".split(","))); + normalData = getDoubleList(Arrays.asList("0.0,0.1,0.2,0.3,0.4,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.5,1.7,1.9,2.1,2.3,2.5,2.7,2.9,3.1,3.3,3.5,3.7,3.9,4.1,4.3,4.5,4.7,4.9,5.1,5.3,5.5,5.7,5.9,6.1,6.3,6.5,6.7,6.9".split(","))); + lowData = getDoubleList(Arrays.asList("0.0,0.1,0.1,0.2,0.2,0.3,0.4,0.4,0.5,0.6,0.6,0.7,0.7,0.8,1.0,1.1,1.3,1.4,1.6,1.7,1.9,2.0,2.2,2.3,2.5,2.6,2.8,2.9,3.1,3.2,3.4,3.5,3.7,3.8,4.0,4.1,4.3,4.4,4.6,4.7,4.9".split(","))); color = "#CD00CD"; } - Map highMap = new HashMap<>(); - Map normalMap = new HashMap<>(); - Map lowMap = new HashMap<>(); List xAxis = new ArrayList<>(); - double avg = low / 13; - for (int i = 0; i <= 13; i++) { - lowMap.put(i, i * avg); - } - double avg2 = (low2 - low) / 27; - for (int i = 1; i <= 27; i++) { - lowMap.put(13 + i, low + i * avg2); - } - double highAvg = high / 13; - for (int i = 0; i <= 13; i++) { - highMap.put(i, i * highAvg); - } - double highAvg2 = (high2 - high) / 27; - for (int i = 1; i <= 27; i++) { - highMap.put(13 + i, high + i * highAvg2); - } - for (int i = 0; i <= 40; i++) { - normalMap.put(i, (highMap.get(i) + lowMap.get(i)) / 2); - } Map reportModel = new HashMap<>(); Map series = new HashMap<>(); // series.put("lowData", MathUtil.doubleFormat2(CollectionUtils.getValList(lowMap))); // series.put("highData", MathUtil.doubleFormat2(CollectionUtils.getValList(highMap))); // series.put("normalData", MathUtil.doubleFormat2(CollectionUtils.getValList(normalMap))); - series.put("lowData", delOtherPort(CollectionUtils.getValList(lowMap))); - series.put("highData", delOtherPort(CollectionUtils.getValList(highMap))); - series.put("normalData", delOtherPort(CollectionUtils.getValList(normalMap))); + series.put("lowData", lowData); + series.put("highData", highData); + series.put("normalData", normalData); series.put("dayWeights", restList); @@ -867,7 +840,95 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient return restList; } + public List getDoubleList(List list) { + List rest = new ArrayList<>(); + for (String s : list) { + rest.add(Double.parseDouble(s)); + } + return rest; + } + public void setReport(Map restMap, Map weights, String beforeWeight, String bmi, Map dayWeights) { + List> restList = new ArrayList<>(); + if(MapUtils.isNotEmpty(dayWeights)) { + for (String key : dayWeights.keySet()) { + Map temp = new HashMap<>(); + temp.put("nowWeight", dayWeights.get(key)); + temp.put("recordTime", key); + restList.add(temp); + } + } + + List highData = new ArrayList<>(); + List normalData = new ArrayList<>(); + List lowData = new ArrayList<>(); + // 小程序和app可能没有bmi 默认返回标准 + Double bmiD = 20D; + if(StringUtils.isNotEmpty(bmi)) { + bmiD = Double.parseDouble(bmi); + } + String title = ""; + String color = ""; + if(bmiD <= 18.5) { + title = "低体重推荐增重均值"; + highData = getDoubleList(Arrays.asList("0.0,0.3,0.6,0.9,1.2,1.5,1.8,2.0,2.3,2.6,2.9,3.2,3.5,3.8,4.3,4.9,5.4,5.9,6.4,7.0,7.5,8.0,8.6,9.1,9.6,10.2,10.7,11.2,11.7,12.3,12.8,13.3,13.9,14.4,14.9,15.5,16.0,16.5,17.0,17.6,18.1".split(","))); + normalData = getDoubleList(Arrays.asList("0.0,0.2,0.4,0.6,0.8,1.0,1.2,1.3,1.5,1.7,1.9,2.1,2.3,2.5,3.0,3.4,3.9,4.4,4.8,5.3,5.7,6.2,6.7,7.1,7.6,8.1,8.5,9.0,9.4,9.9,10.4,10.8,11.3,11.8,12.2,12.7,13.1,13.6,14.1,14.5,15.0".split(","))); + lowData = getDoubleList(Arrays.asList("0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.6,2.0,2.4,2.8,3.2,3.6,4.0,4.4,4.8,5.2,5.6,6.0,6.4,6.7,7.1,7.5,7.9,8.3,8.7,9.1,9.5,9.9,10.3,10.7,11.1,11.5,11.9".split(","))); + color = "#00CD00"; + } else if(bmiD > 18.5 && bmiD <= 24.9){ + title = "标准体重推荐增重均值"; + highData = getDoubleList(Arrays.asList("0.0,0.2,0.5,0.7,1.0,1.2,1.5,1.7,2.0,2.2,2.5,2.7,3.0,3.2,3.7,4.1,4.6,5.1,5.6,6.0,6.5,7.0,7.4,7.9,8.4,8.8,9.3,9.8,10.3,10.7,11.2,11.7,12.1,12.6,13.1,13.5,14.0,14.5,15.0,15.4,15.9".split(","))); + normalData = getDoubleList(Arrays.asList("0.0,0.2,0.4,0.5,0.7,0.9,1.1,1.2,1.4,1.6,1.8,1.9,2.1,2.3,2.7,3.2,3.6,4.0,4.4,4.9,5.3,5.7,6.2,6.6,7.0,7.5,7.9,8.3,8.7,9.2,9.6,10.0,10.5,10.9,11.3,11.8,12.2,12.6,13.0,13.5,13.9".split(","))); + lowData = getDoubleList(Arrays.asList("0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.8,2.2,2.6,3.0,3.3,3.7,4.1,4.5,4.9,5.3,5.7,6.1,6.5,6.8,7.2,7.6,8.0,8.4,8.8,9.2,9.6,10.0,10.3,10.7,11.1,11.5,11.9".split(","))); + color = "#7EC0EE"; + } else if(bmiD > 24.9 && bmiD < 30){ + title = "超重体重推荐增重均值"; + highData = getDoubleList(Arrays.asList("0.0,0.2,0.5,0.7,1.0,1.2,1.4,1.7,1.9,2.1,2.4,2.6,2.9,3.1,3.4,3.7,4.0,4.4,4.7,5.0,5.3,5.6,5.9,6.2,6.6,6.9,7.2,7.5,7.8,8.1,8.5,8.8,9.1,9.4,9.7,10.0,10.3,10.7,11.0,11.3,11.6".split(","))); + normalData = getDoubleList(Arrays.asList("0.0,0.2,0.3,0.5,0.6,0.8,1.0,1.1,1.3,1.5,1.6,1.8,1.9,2.1,2.4,2.6,2.9,3.2,3.4,3.7,4.0,4.2,4.5,4.8,5.1,5.3,5.6,5.9,6.1,6.4,6.7,6.9,7.2,7.5,7.7,8.0,8.3,8.5,8.8,9.1,9.3".split(","))); + lowData = getDoubleList(Arrays.asList("0.0,0.1,0.2,0.3,0.3,0.4,0.5,0.6,0.7,0.8,0.8,0.9,1.0,1.1,1.3,1.5,1.8,2.0,2.2,2.4,2.7,2.9,3.1,3.3,3.5,3.8,4.0,4.2,4.4,4.7,4.9,5.1,5.3,5.5,5.8,6.0,6.2,6.4,6.7,6.9,7.1".split(","))); + color = "#CD3333"; + } else if(bmiD >= 30){ + title = "肥胖体重推荐增重均值"; + highData = getDoubleList(Arrays.asList("0.0,0.2,0.3,0.5,0.6,0.8,1.0,1.1,1.3,1.5,1.6,1.8,1.9,2.1,2.4,2.6,2.9,3.1,3.4,3.6,3.9,4.1,4.4,4.6,4.9,5.1,5.4,5.6,5.9,6.1,6.4,6.6,6.9,7.1,7.4,7.6,7.9,8.1,8.4,8.6,8.9".split(","))); + normalData = getDoubleList(Arrays.asList("0.0,0.1,0.2,0.3,0.4,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.5,1.7,1.9,2.1,2.3,2.5,2.7,2.9,3.1,3.3,3.5,3.7,3.9,4.1,4.3,4.5,4.7,4.9,5.1,5.3,5.5,5.7,5.9,6.1,6.3,6.5,6.7,6.9".split(","))); + lowData = getDoubleList(Arrays.asList("0.0,0.1,0.1,0.2,0.2,0.3,0.4,0.4,0.5,0.6,0.6,0.7,0.7,0.8,1.0,1.1,1.3,1.4,1.6,1.7,1.9,2.0,2.2,2.3,2.5,2.6,2.8,2.9,3.1,3.2,3.4,3.5,3.7,3.8,4.0,4.1,4.3,4.4,4.6,4.7,4.9".split(","))); + color = "#CD00CD"; + } + + List xAxis = new ArrayList<>(); + + Map reportModel = new HashMap<>(); + Map series = new HashMap<>(); + series.put("lowData", lowData); + series.put("highData", highData); + series.put("normalData", normalData); + + series.put("dayWeights", restList); + + reportModel.put("series", series); + + reportModel.put("title", title); + reportModel.put("color", color); + + for (int i = 0; i <= 40; i++) { + xAxis.add(i); + } + reportModel.put("xAxis", xAxis); + + List list = new ArrayList<>(); + if(MapUtils.isNotEmpty(weights)) { + Iterator> iterator = weights.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry next = iterator.next(); + list.add(Arrays.asList(next.getKey(), getDiff(beforeWeight, next.getValue()))); + } + } + series.put("portData", list); + series.put("portData", list); + restMap.put("reportModel", reportModel); + } + + /*public void setReport(Map restMap, Map weights, String beforeWeight, String bmi, Map dayWeights) { logger.info("restMap>> " + restMap); logger.info("weights>> " + weights); logger.info("beforeWeight>> " + beforeWeight); @@ -977,7 +1038,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient series.put("portData", list); series.put("portData", list); restMap.put("reportModel", reportModel); - } + }*/ /** * 获取两个体重之间相差的数值