Commit 98329a1cc5f3be8be135be4b523d893bd5297545

Authored by litao@lymsh.com
1 parent f56d87617b
Exists in master and in 1 other branch dev

改为有序map

Showing 1 changed file with 88 additions and 158 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java View file @ 98329a1
... ... @@ -18,8 +18,6 @@
18 18 import com.lyms.platform.pojo.Patients;
19 19 import org.apache.commons.collections.MapUtils;
20 20 import org.apache.commons.lang.StringUtils;
21   -import org.slf4j.Logger;
22   -import org.slf4j.LoggerFactory;
23 21 import org.springframework.beans.factory.annotation.Autowired;
24 22 import org.springframework.data.domain.Sort;
25 23 import org.springframework.data.mongodb.core.MongoTemplate;
... ... @@ -49,8 +47,6 @@
49 47 @Autowired
50 48 private PatientsService patientsService;
51 49  
52   - private Logger logger = LoggerFactory.getLogger(PatientWeightServiceImpl.class);
53   -
54 50 /**
55 51 * 最低:0~13 : 0~1.9 13~40 1.9~11.9
56 52 * 最高: 0~2.2 2.2~15.9
... ... @@ -92,7 +88,7 @@
92 88 patientsService.addPatient(patients);
93 89 patientWeight.setPatientId(patients.getId());
94 90 }
95   - Map<String, String> dayWeights = new HashMap<>();
  91 + Map<String, String> dayWeights = new LinkedHashMap<>();
96 92 if(pw != null) {
97 93 if(MapUtils.isNotEmpty(pw.getDayWeights())) {
98 94 dayWeights = pw.getDayWeights();
... ... @@ -168,7 +164,7 @@
168 164 for (PatientWeight patientWeight : patientWeights) {
169 165 Patients p = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class);
170 166 if(patients != null) {
171   - Map<String, Object> temp = new HashMap<>();
  167 + Map<String, Object> temp = new LinkedHashMap<>();
172 168 temp.put("id", patientWeight.getId());
173 169 temp.put("username", p.getUsername());
174 170 temp.put("age", DateUtil.getAge(p.getBirth()));
... ... @@ -216,7 +212,7 @@
216 212 map.put("bim", patientWeight.getBmi()); // 体质指数(BMI)=体重(kg)÷身高^2(m)
217 213  
218 214 Map<String, String> dayWeights = patientWeight.getDayWeights();
219   - Map<Integer, String> weights = new HashMap<>();
  215 + Map<Integer, String> weights = new LinkedHashMap<>();
220 216 if (MapUtils.isNotEmpty(dayWeights)) {
221 217 Set<Map.Entry<String, String>> entries = dayWeights.entrySet();
222 218 for (Map.Entry<String, String> entry : entries) {
... ... @@ -248,7 +244,7 @@
248 244 public BaseResponse report(String id) {
249 245 PatientWeight patientWeight = mongoTemplate.findById(id, PatientWeight.class);
250 246 if(patientWeight != null) {
251   - Map<String, Object> map = new HashMap<>();
  247 + Map<String, Object> map = new LinkedHashMap<>();
252 248 Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class);
253 249 Integer week = null;
254 250 if(patients != null) {
... ... @@ -285,7 +281,7 @@
285 281 }
286 282  
287 283 Map<String, String> dayWeights = patientWeight.getDayWeights();
288   - Map<Integer, String> weights = new HashMap<>();
  284 + Map<Integer, String> weights = new LinkedHashMap<>();
289 285 if (MapUtils.isNotEmpty(dayWeights)) {
290 286 Set<Map.Entry<String, String>> entries = dayWeights.entrySet();
291 287 for (Map.Entry<String, String> entry : entries) {
292 288  
... ... @@ -303,11 +299,11 @@
303 299 public BaseResponse wxReport(String pid) {
304 300 PatientWeight patientWeight = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(pid).and("yn").ne("0")), PatientWeight.class);
305 301 if(patientWeight != null) {
306   - Map<String, Object> map = new HashMap<>();
  302 + Map<String, Object> map = new LinkedHashMap<>();
307 303 map.put("beforeWeight", patientWeight.getBeforeWeight());
308 304 Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class);
309 305 Map<String, String> dayWeights = patientWeight.getDayWeights();
310   - Map<Integer, String> weights = new HashMap<>();
  306 + Map<Integer, String> weights = new LinkedHashMap<>();
311 307 if (MapUtils.isNotEmpty(dayWeights)) {
312 308 Set<Map.Entry<String, String>> entries = dayWeights.entrySet();
313 309 for (Map.Entry<String, String> entry : entries) {
... ... @@ -325,7 +321,7 @@
325 321 String nowWeight = patientWeight.getNowWeight();
326 322 Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class);
327 323 PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(patientWeight.getPid())), PatientWeight.class);
328   - Map<String, String> dayWeights = new HashMap<>();
  324 + Map<String, String> dayWeights = new LinkedHashMap<>();
329 325 if(pw == null && StringUtils.isEmpty(patientWeight.getBeforeWeight())) {
330 326 return RespBuilder.buildErro(ResponseCode.NEED_ADD_PATIENT_WEIGHT);
331 327 }
... ... @@ -369,7 +365,7 @@
369 365 String nowWeight = patientWeight.getNowWeight();
370 366 Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class);
371 367 PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(patientWeight.getPid())), PatientWeight.class);
372   - Map<String, String> dayWeights = new HashMap<>();
  368 + Map<String, String> dayWeights = new LinkedHashMap<>();
373 369 if(pw == null && StringUtils.isEmpty(patientWeight.getBeforeWeight())) {
374 370 return RespBuilder.buildErro(ResponseCode.NEED_ADD_PATIENT_WEIGHT);
375 371 }
... ... @@ -442,12 +438,12 @@
442 438 private void setRecipe(Integer week, Map<String, Object> map) {
443 439 String recipeTitle1 = "";
444 440 String recipeTitle2 = "";
445   - Map<String, Object> breakfast = new HashMap<>(); // 早餐
446   - Map<String, Object> breakfast2 = new HashMap<>(); // 上午加餐
447   - Map<String, Object> lunch = new HashMap<>(); // 午餐
448   - Map<String, Object> lunch2 = new HashMap<>(); // 下午加餐
449   - Map<String, Object> dinner = new HashMap<>(); // 晚餐
450   - Map<String, Object> dinner2 = new HashMap<>(); // 晚加餐
  441 + Map<String, Object> breakfast = new LinkedHashMap<>(); // 早餐
  442 + Map<String, Object> breakfast2 = new LinkedHashMap<>(); // 上午加餐
  443 + Map<String, Object> lunch = new LinkedHashMap<>(); // 午餐
  444 + Map<String, Object> lunch2 = new LinkedHashMap<>(); // 下午加餐
  445 + Map<String, Object> dinner = new LinkedHashMap<>(); // 晚餐
  446 + Map<String, Object> dinner2 = new LinkedHashMap<>(); // 晚加餐
451 447 if(week <= 12) {
452 448 setData(breakfast, "早餐", "(谷类80克,蔬菜70克,蛋类50克,坚果18克,油脂5克)\n" +
453 449 "面包(30克);小米绿豆粥(小米25克,绿豆25克);\n" +
... ... @@ -536,7 +532,7 @@
536 532 }
537 533  
538 534 private Map<String, Object> setData2(String ... values) {
539   - Map<String, Object> map = new HashMap<>();
  535 + Map<String, Object> map = new LinkedHashMap<>();
540 536 map.put("id", values[0]);
541 537 List<String> value = new ArrayList<>();
542 538 for (int i = 1; i < values.length; i++) {
543 539  
544 540  
... ... @@ -718,27 +714,27 @@
718 714 }
719 715 }
720 716  
721   - /**
722   - BMI指数:
723   - 低体重(<18.5) 0-13周 13-40周
724   - 最低 0-1.2 1.2-11.9
725   - 最高 0-3.8 3.8-18.1
726   - 标准 (18.5-24.9) 0-13周 13-40周
727   - 最低 0-1.4 1.4-11.9
728   - 最高 0-3.2 3.2-15.9
  717 + /**
  718 + BMI指数:
  719 + 低体重(<18.5) 0-13周 13-40周
  720 + 最低 0-1.2 1.2-11.9
  721 + 最高 0-3.8 3.8-18.1
  722 + 标准 (18.5-24.9) 0-13周 13-40周
  723 + 最低 0-1.4 1.4-11.9
  724 + 最高 0-3.2 3.2-15.9
729 725  
730   - 超重(25.0-29.9) 0-13周 13-40周
731   - 最低 0-1.1 1.1-7.1
732   - 最高 0-3.1 3.2-11.6
733   - 肥胖 (>=30.0) 0-13周 13-40周
734   - 最低 0-0.8 0.9-4.9
735   - 最高 0-2.1 2.1-8.9
  726 + 超重(25.0-29.9) 0-13周 13-40周
  727 + 最低 0-1.1 1.1-7.1
  728 + 最高 0-3.1 3.2-11.6
  729 + 肥胖 (>=30.0) 0-13周 13-40周
  730 + 最低 0-0.8 0.9-4.9
  731 + 最高 0-2.1 2.1-8.9
736 732 */
737 733 public void setAppReport(Map<String, Object> restMap, Map<Integer, String> weights, String beforeWeight, String bmi, Map<String, String> dayWeights) {
738 734 List<Map<String, Object>> restList = new ArrayList<>();
739 735 if(MapUtils.isNotEmpty(dayWeights)) {
740 736 for (String key : dayWeights.keySet()) {
741   - Map<String, Object> temp = new HashMap<>();
  737 + Map<String, Object> temp = new LinkedHashMap<>();
742 738 temp.put("nowWeight", dayWeights.get(key));
743 739 temp.put("recordTime", key);
744 740 restList.add(temp);
745 741  
746 742  
747 743  
748 744  
749 745  
750 746  
751 747  
752 748  
... ... @@ -750,42 +746,69 @@
750 746 if(StringUtils.isNotEmpty(bmi)) {
751 747 bmiD = Double.parseDouble(bmi);
752 748 }
753   - List<Double> highData = new ArrayList<>();
754   - List<Double> normalData = new ArrayList<>();
755   - List<Double> lowData = new ArrayList<>();
  749 + double low = 0D;
  750 + double low2 = 0D;
  751 + double high = 0D;
  752 + double high2 = 0D;
756 753 String color = "";
757 754 if(bmiD <= 18.5) {
758   - 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(",")));
759   - 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(",")));
760   - 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(",")));
  755 + low = 1.2;
  756 + low2 = 11.9;
  757 + high = 3.8;
  758 + high2 = 18.1;
761 759 color = "#00CD00";
762 760 } else if(bmiD > 18.5 && bmiD <= 24.9){
763   - 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(",")));
764   - 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(",")));
765   - 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(",")));
  761 + low = 1.4;
  762 + low2 = 11.9;
  763 + high = 3.2;
  764 + high2 = 15.9;
766 765 color = "#7EC0EE";
767 766 } else if(bmiD > 24.9 && bmiD < 30){
768   - 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(",")));
769   - 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(",")));
770   - 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(",")));
  767 + low = 1.1 ;
  768 + low2 = 7.1;
  769 + high = 3.1;
  770 + high2 = 11.6;
771 771 color = "#CD3333";
772 772 } else if(bmiD >= 30){
773   - 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(",")));
774   - 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(",")));
775   - 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(",")));
  773 + low = 0.8 ;
  774 + low2 = 4.9;
  775 + high = 2.1;
  776 + high2 = 8.9;
776 777 color = "#CD00CD";
777 778 }
778 779  
  780 + Map<Integer, Double> highMap = new LinkedHashMap<>();
  781 + Map<Integer, Double> normalMap = new LinkedHashMap<>();
  782 + Map<Integer, Double> lowMap = new LinkedHashMap<>();
779 783 List<Integer> xAxis = new ArrayList<>();
  784 + double avg = low / 13;
  785 + for (int i = 0; i <= 13; i++) {
  786 + lowMap.put(i, i * avg);
  787 + }
  788 + double avg2 = (low2 - low) / 27;
  789 + for (int i = 1; i <= 27; i++) {
  790 + lowMap.put(13 + i, low + i * avg2);
  791 + }
  792 + double highAvg = high / 13;
  793 + for (int i = 0; i <= 13; i++) {
  794 + highMap.put(i, i * highAvg);
  795 + }
  796 + double highAvg2 = (high2 - high) / 27;
  797 + for (int i = 1; i <= 27; i++) {
  798 + highMap.put(13 + i, high + i * highAvg2);
  799 + }
  800 + for (int i = 0; i <= 40; i++) {
  801 + normalMap.put(i, (highMap.get(i) + lowMap.get(i)) / 2);
  802 + }
780 803  
781   - Map<String, Object> reportModel = new HashMap<>();
782   - Map<String, Object> series = new HashMap<>();
  804 + Map<String, Object> reportModel = new LinkedHashMap<>();
  805 + Map<String, Object> series = new LinkedHashMap<>();
783 806 // series.put("lowData", MathUtil.doubleFormat2(CollectionUtils.getValList(lowMap)));
784 807 // series.put("highData", MathUtil.doubleFormat2(CollectionUtils.getValList(highMap)));
785 808 // series.put("normalData", MathUtil.doubleFormat2(CollectionUtils.getValList(normalMap)));
786   - series.put("lowData", lowData);
787   - series.put("highData", highData);
788   - series.put("normalData", normalData);
  809 + series.put("lowData", delOtherPort(CollectionUtils.getValList(lowMap)));
  810 + series.put("highData", delOtherPort(CollectionUtils.getValList(highMap)));
  811 + series.put("normalData", delOtherPort(CollectionUtils.getValList(normalMap)));
789 812  
790 813 series.put("dayWeights", restList);
791 814  
... ... @@ -811,7 +834,7 @@
811 834 Iterator<Map.Entry<Integer, String>> iterator = weights.entrySet().iterator();
812 835 while (iterator.hasNext()) {
813 836 Map.Entry<Integer, String> next = iterator.next();
814   - Map<String, Object> temp = new HashMap<>();
  837 + Map<String, Object> temp = new LinkedHashMap<>();
815 838 temp.put("week", next.getKey());
816 839 temp.put("weight", getDiff(beforeWeight, next.getValue()));
817 840 list.add(temp);
818 841  
819 842  
... ... @@ -840,28 +863,17 @@
840 863 return restList;
841 864 }
842 865  
843   - public List<Double> getDoubleList(List<String> list) {
844   - List<Double> rest = new ArrayList<>();
845   - for (String s : list) {
846   - rest.add(Double.parseDouble(s));
847   - }
848   - return rest;
849   - }
850   -
851 866 public void setReport(Map<String, Object> restMap, Map<Integer, String> weights, String beforeWeight, String bmi, Map<String, String> dayWeights) {
852 867 List<Map<String, Object>> restList = new ArrayList<>();
853 868 if(MapUtils.isNotEmpty(dayWeights)) {
854 869 for (String key : dayWeights.keySet()) {
855   - Map<String, Object> temp = new HashMap<>();
  870 + Map<String, Object> temp = new LinkedHashMap<>();
856 871 temp.put("nowWeight", dayWeights.get(key));
857 872 temp.put("recordTime", key);
858 873 restList.add(temp);
859 874 }
860 875 }
861 876  
862   - List<Double> highData = new ArrayList<>();
863   - List<Double> normalData = new ArrayList<>();
864   - List<Double> lowData = new ArrayList<>();
865 877 // 小程序和app可能没有bmi 默认返回标准
866 878 Double bmiD = 20D;
867 879 if(StringUtils.isNotEmpty(bmi)) {
... ... @@ -869,88 +881,6 @@
869 881 }
870 882 String title = "";
871 883 String color = "";
872   - if(bmiD <= 18.5) {
873   - title = "低体重推荐增重均值";
874   - 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(",")));
875   - 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(",")));
876   - 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(",")));
877   - color = "#00CD00";
878   - } else if(bmiD > 18.5 && bmiD <= 24.9){
879   - title = "标准体重推荐增重均值";
880   - 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(",")));
881   - 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(",")));
882   - 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(",")));
883   - color = "#7EC0EE";
884   - } else if(bmiD > 24.9 && bmiD < 30){
885   - title = "超重体重推荐增重均值";
886   - 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(",")));
887   - 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(",")));
888   - 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(",")));
889   - color = "#CD3333";
890   - } else if(bmiD >= 30){
891   - title = "肥胖体重推荐增重均值";
892   - 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(",")));
893   - 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(",")));
894   - 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(",")));
895   - color = "#CD00CD";
896   - }
897   -
898   - List<Integer> xAxis = new ArrayList<>();
899   -
900   - Map<String, Object> reportModel = new HashMap<>();
901   - Map<String, Object> series = new HashMap<>();
902   - series.put("lowData", lowData);
903   - series.put("highData", highData);
904   - series.put("normalData", normalData);
905   -
906   - series.put("dayWeights", restList);
907   -
908   - reportModel.put("series", series);
909   -
910   - reportModel.put("title", title);
911   - reportModel.put("color", color);
912   -
913   - for (int i = 0; i <= 40; i++) {
914   - xAxis.add(i);
915   - }
916   - reportModel.put("xAxis", xAxis);
917   -
918   - List<Object> list = new ArrayList<>();
919   - if(MapUtils.isNotEmpty(weights)) {
920   - Iterator<Map.Entry<Integer, String>> iterator = weights.entrySet().iterator();
921   - while (iterator.hasNext()) {
922   - Map.Entry<Integer, String> next = iterator.next();
923   - list.add(Arrays.asList(next.getKey(), getDiff(beforeWeight, next.getValue())));
924   - }
925   - }
926   - series.put("portData", list);
927   - series.put("portData", list);
928   - restMap.put("reportModel", reportModel);
929   - }
930   -
931   - /*public void setReport(Map<String, Object> restMap, Map<Integer, String> weights, String beforeWeight, String bmi, Map<String, String> dayWeights) {
932   - logger.info("restMap>> " + restMap);
933   - logger.info("weights>> " + weights);
934   - logger.info("beforeWeight>> " + beforeWeight);
935   - logger.info("bmi>> " + bmi);
936   - logger.info("dayWeights>> " + dayWeights);
937   - List<Map<String, Object>> restList = new ArrayList<>();
938   - if(MapUtils.isNotEmpty(dayWeights)) {
939   - for (String key : dayWeights.keySet()) {
940   - Map<String, Object> temp = new HashMap<>();
941   - temp.put("nowWeight", dayWeights.get(key));
942   - temp.put("recordTime", key);
943   - restList.add(temp);
944   - }
945   - }
946   -
947   - // 小程序和app可能没有bmi 默认返回标准
948   - Double bmiD = 20D;
949   - if(StringUtils.isNotEmpty(bmi)) {
950   - bmiD = Double.parseDouble(bmi);
951   - }
952   - String title = "";
953   - String color = "";
954 884 double low = 0D;
955 885 double low2 = 0D;
956 886 double high = 0D;
... ... @@ -985,9 +915,9 @@
985 915 color = "#CD00CD";
986 916 }
987 917  
988   - Map<Integer, Double> highMap = new HashMap<>();
989   - Map<Integer, Double> normalMap = new HashMap<>();
990   - Map<Integer, Double> lowMap = new HashMap<>();
  918 + Map<Integer, Double> highMap = new LinkedHashMap<>();
  919 + Map<Integer, Double> normalMap = new LinkedHashMap<>();
  920 + Map<Integer, Double> lowMap = new LinkedHashMap<>();
991 921 List<Integer> xAxis = new ArrayList<>();
992 922 double avg = low / 13;
993 923 for (int i = 0; i <= 13; i++) {
... ... @@ -1009,8 +939,8 @@
1009 939 normalMap.put(i, (highMap.get(i) + lowMap.get(i)) / 2);
1010 940 }
1011 941  
1012   - Map<String, Object> reportModel = new HashMap<>();
1013   - Map<String, Object> series = new HashMap<>();
  942 + Map<String, Object> reportModel = new LinkedHashMap<>();
  943 + Map<String, Object> series = new LinkedHashMap<>();
1014 944 series.put("lowData", MathUtil.doubleFormat2(CollectionUtils.getValList(lowMap)));
1015 945 series.put("highData", MathUtil.doubleFormat2(CollectionUtils.getValList(highMap)));
1016 946 series.put("normalData", MathUtil.doubleFormat2(CollectionUtils.getValList(normalMap)));
... ... @@ -1027,7 +957,7 @@
1027 957 }
1028 958 reportModel.put("xAxis", xAxis);
1029 959  
1030   - List<Object> list = new ArrayList<>();
  960 + List<Object> list = new ArrayList<>();
1031 961 if(MapUtils.isNotEmpty(weights)) {
1032 962 Iterator<Map.Entry<Integer, String>> iterator = weights.entrySet().iterator();
1033 963 while (iterator.hasNext()) {
... ... @@ -1038,7 +968,7 @@
1038 968 series.put("portData", list);
1039 969 series.put("portData", list);
1040 970 restMap.put("reportModel", reportModel);
1041   - }*/
  971 + }
1042 972  
1043 973 /**
1044 974 * 获取两个体重之间相差的数值