Commit 875718bde9336177e34ee312ad47ad2463fe0a49

Authored by litao@lymsh.com
1 parent b2418b7ce8

体重管理相关代码

Showing 1 changed file with 92 additions and 2 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java View file @ 875718b
... ... @@ -254,7 +254,7 @@
254 254 if(patientWeight != null) {
255 255 Map<String, Object> map = new HashMap<>();
256 256 map.put("beforeWeight", patientWeight.getBeforeWeight());
257   - setReport(map, patientWeight.getWeights(), patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights());
  257 + setAppReport(map, patientWeight.getWeights(), patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights());
258 258 return RespBuilder.buildSuccess(map);
259 259 }
260 260 return RespBuilder.buildSuccess();
... ... @@ -621,7 +621,7 @@
621 621 最低 0-0.8 0.9-4.9
622 622 最高 0-2.1 2.1-8.9
623 623 */
624   - public void setReport(Map<String, Object> restMap, Map<Integer, String> weights, String beforeWeight, String bmi, Map<String, String> dayWeights) {
  624 + public void setAppReport(Map<String, Object> restMap, Map<Integer, String> weights, String beforeWeight, String bmi, Map<String, String> dayWeights) {
625 625 List<Map<String, Object>> restList = new ArrayList<>();
626 626 if(MapUtils.isNotEmpty(dayWeights)) {
627 627 for (String key : dayWeights.keySet()) {
... ... @@ -718,6 +718,96 @@
718 718 list.add(temp);
719 719 }
720 720 }
  721 + series.put("portData", list);
  722 + restMap.put("reportModel", reportModel);
  723 + }
  724 +
  725 + public void setReport(Map<String, Object> restMap, Map<Integer, String> weights, String beforeWeight, String bmi, Map<String, String> dayWeights) {
  726 + List<Map<String, Object>> restList = new ArrayList<>();
  727 + if(MapUtils.isNotEmpty(dayWeights)) {
  728 + for (String key : dayWeights.keySet()) {
  729 + Map<String, Object> temp = new HashMap<>();
  730 + temp.put("nowWeight", dayWeights.get(key));
  731 + temp.put("recordTime", key);
  732 + restList.add(temp);
  733 + }
  734 + }
  735 +
  736 + Double bmiD = Double.parseDouble(bmi);
  737 + double low = 0D;
  738 + double low2 = 0D;
  739 + double high = 0D;
  740 + double high2 = 0D;
  741 + if(bmiD <= 18.5) {
  742 + low = 1.2;
  743 + low2 = 11.9;
  744 + high = 3.8;
  745 + high2 = 18.1;
  746 + } else if(bmiD > 18.5 && bmiD <= 24.9){
  747 + low = 1.4;
  748 + low2 = 11.9;
  749 + high = 3.2;
  750 + high2 = 15.9;
  751 + } else if(bmiD > 24.9 && bmiD < 30){
  752 + low = 1.1 ;
  753 + low2 = 7.1;
  754 + high = 3.1;
  755 + high2 = 11.6;
  756 + } else if(bmiD >= 30){
  757 + low = 0.8 ;
  758 + low2 = 4.9;
  759 + high = 2.1;
  760 + high2 = 8.9;
  761 + }
  762 +
  763 + Map<Integer, Double> highMap = new HashMap<>();
  764 + Map<Integer, Double> normalMap = new HashMap<>();
  765 + Map<Integer, Double> lowMap = new HashMap<>();
  766 + List<Integer> xAxis = new ArrayList<>();
  767 + double avg = low / 13;
  768 + for (int i = 0; i <= 13; i++) {
  769 + lowMap.put(i, i * avg);
  770 + }
  771 + double avg2 = (low2 - low) / 27;
  772 + for (int i = 1; i <= 27; i++) {
  773 + lowMap.put(13 + i, low + i * avg2);
  774 + }
  775 + double highAvg = high / 13;
  776 + for (int i = 0; i <= 13; i++) {
  777 + highMap.put(i, i * highAvg);
  778 + }
  779 + double highAvg2 = (high2 - high) / 27;
  780 + for (int i = 1; i <= 27; i++) {
  781 + highMap.put(13 + i, high + i * highAvg2);
  782 + }
  783 + for (int i = 0; i <= 40; i++) {
  784 + normalMap.put(i, (highMap.get(i) + lowMap.get(i)) / 2);
  785 + }
  786 +
  787 + Map<String, Object> reportModel = new HashMap<>();
  788 + Map<String, Object> series = new HashMap<>();
  789 + series.put("lowData", MathUtil.doubleFormat2(CollectionUtils.getValList(lowMap)));
  790 + series.put("highData", MathUtil.doubleFormat2(CollectionUtils.getValList(highMap)));
  791 + series.put("normalData", MathUtil.doubleFormat2(CollectionUtils.getValList(normalMap)));
  792 +
  793 + series.put("dayWeights", restList);
  794 +
  795 + reportModel.put("series", series);
  796 +
  797 + for (int i = 0; i <= 40; i++) {
  798 + xAxis.add(i);
  799 + }
  800 + reportModel.put("xAxis", xAxis);
  801 +
  802 + List<Object> list = new ArrayList<>();
  803 + if(MapUtils.isNotEmpty(weights)) {
  804 + Iterator<Map.Entry<Integer, String>> iterator = weights.entrySet().iterator();
  805 + while (iterator.hasNext()) {
  806 + Map.Entry<Integer, String> next = iterator.next();
  807 + list.add(Arrays.asList(next.getKey(), getDiff(beforeWeight, next.getValue())));
  808 + }
  809 + }
  810 + series.put("portData", list);
721 811 series.put("portData", list);
722 812 restMap.put("reportModel", reportModel);
723 813 }