Commit 4c395f30cdaffbed41548dbc1661440c66e00b24
Exists in
master
and in
6 other branches
Merge remote-tracking branch 'origin/master'
Showing 1 changed file
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
View file @
4c395f3
| ... | ... | @@ -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); |
| ... | ... | @@ -781,9 +777,9 @@ |
| 781 | 777 | color = "#CD00CD"; |
| 782 | 778 | } |
| 783 | 779 | |
| 784 | - Map<Integer, Double> highMap = new HashMap<>(); | |
| 785 | - Map<Integer, Double> normalMap = new HashMap<>(); | |
| 786 | - Map<Integer, Double> lowMap = new HashMap<>(); | |
| 780 | + Map<Integer, Double> highMap = new LinkedHashMap<>(); | |
| 781 | + Map<Integer, Double> normalMap = new LinkedHashMap<>(); | |
| 782 | + Map<Integer, Double> lowMap = new LinkedHashMap<>(); | |
| 787 | 783 | List<Integer> xAxis = new ArrayList<>(); |
| 788 | 784 | double avg = low / 13; |
| 789 | 785 | for (int i = 0; i <= 13; i++) { |
| ... | ... | @@ -805,8 +801,8 @@ |
| 805 | 801 | normalMap.put(i, (highMap.get(i) + lowMap.get(i)) / 2); |
| 806 | 802 | } |
| 807 | 803 | |
| 808 | - Map<String, Object> reportModel = new HashMap<>(); | |
| 809 | - Map<String, Object> series = new HashMap<>(); | |
| 804 | + Map<String, Object> reportModel = new LinkedHashMap<>(); | |
| 805 | + Map<String, Object> series = new LinkedHashMap<>(); | |
| 810 | 806 | // series.put("lowData", MathUtil.doubleFormat2(CollectionUtils.getValList(lowMap))); |
| 811 | 807 | // series.put("highData", MathUtil.doubleFormat2(CollectionUtils.getValList(highMap))); |
| 812 | 808 | // series.put("normalData", MathUtil.doubleFormat2(CollectionUtils.getValList(normalMap))); |
| ... | ... | @@ -838,7 +834,7 @@ |
| 838 | 834 | Iterator<Map.Entry<Integer, String>> iterator = weights.entrySet().iterator(); |
| 839 | 835 | while (iterator.hasNext()) { |
| 840 | 836 | Map.Entry<Integer, String> next = iterator.next(); |
| 841 | - Map<String, Object> temp = new HashMap<>(); | |
| 837 | + Map<String, Object> temp = new LinkedHashMap<>(); | |
| 842 | 838 | temp.put("week", next.getKey()); |
| 843 | 839 | temp.put("weight", getDiff(beforeWeight, next.getValue())); |
| 844 | 840 | list.add(temp); |
| 845 | 841 | |
| ... | ... | @@ -868,15 +864,10 @@ |
| 868 | 864 | } |
| 869 | 865 | |
| 870 | 866 | public void setReport(Map<String, Object> restMap, Map<Integer, String> weights, String beforeWeight, String bmi, Map<String, String> dayWeights) { |
| 871 | - logger.info("restMap>> " + restMap); | |
| 872 | - logger.info("weights>> " + weights); | |
| 873 | - logger.info("beforeWeight>> " + beforeWeight); | |
| 874 | - logger.info("bmi>> " + bmi); | |
| 875 | - logger.info("dayWeights>> " + dayWeights); | |
| 876 | 867 | List<Map<String, Object>> restList = new ArrayList<>(); |
| 877 | 868 | if(MapUtils.isNotEmpty(dayWeights)) { |
| 878 | 869 | for (String key : dayWeights.keySet()) { |
| 879 | - Map<String, Object> temp = new HashMap<>(); | |
| 870 | + Map<String, Object> temp = new LinkedHashMap<>(); | |
| 880 | 871 | temp.put("nowWeight", dayWeights.get(key)); |
| 881 | 872 | temp.put("recordTime", key); |
| 882 | 873 | restList.add(temp); |
| ... | ... | @@ -924,9 +915,9 @@ |
| 924 | 915 | color = "#CD00CD"; |
| 925 | 916 | } |
| 926 | 917 | |
| 927 | - Map<Integer, Double> highMap = new HashMap<>(); | |
| 928 | - Map<Integer, Double> normalMap = new HashMap<>(); | |
| 929 | - 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<>(); | |
| 930 | 921 | List<Integer> xAxis = new ArrayList<>(); |
| 931 | 922 | double avg = low / 13; |
| 932 | 923 | for (int i = 0; i <= 13; i++) { |
| ... | ... | @@ -948,8 +939,8 @@ |
| 948 | 939 | normalMap.put(i, (highMap.get(i) + lowMap.get(i)) / 2); |
| 949 | 940 | } |
| 950 | 941 | |
| 951 | - Map<String, Object> reportModel = new HashMap<>(); | |
| 952 | - Map<String, Object> series = new HashMap<>(); | |
| 942 | + Map<String, Object> reportModel = new LinkedHashMap<>(); | |
| 943 | + Map<String, Object> series = new LinkedHashMap<>(); | |
| 953 | 944 | series.put("lowData", MathUtil.doubleFormat2(CollectionUtils.getValList(lowMap))); |
| 954 | 945 | series.put("highData", MathUtil.doubleFormat2(CollectionUtils.getValList(highMap))); |
| 955 | 946 | series.put("normalData", MathUtil.doubleFormat2(CollectionUtils.getValList(normalMap))); |
| ... | ... | @@ -966,7 +957,7 @@ |
| 966 | 957 | } |
| 967 | 958 | reportModel.put("xAxis", xAxis); |
| 968 | 959 | |
| 969 | - List<Object> list = new ArrayList<>(); | |
| 960 | + List<Object> list = new ArrayList<>(); | |
| 970 | 961 | if(MapUtils.isNotEmpty(weights)) { |
| 971 | 962 | Iterator<Map.Entry<Integer, String>> iterator = weights.entrySet().iterator(); |
| 972 | 963 | while (iterator.hasNext()) { |