Commit f4875c7220f20316a53cbd7d009f72ea385c1770
1 parent
7d8298254e
Exists in
master
and in
6 other branches
血压报告bug修改
Showing 2 changed files with 90 additions and 93 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BloodPressureController.java
View file @
f4875c7
... | ... | @@ -146,7 +146,9 @@ |
146 | 146 | @ResponseBody |
147 | 147 | @RequestMapping(value = "/getXyPresentation/{bloodId}", method = RequestMethod.GET) |
148 | 148 | public BaseResponse getXyPresentation(@PathVariable String bloodId) { |
149 | - System.out.println("bloodID:" + bloodId); | |
149 | + if (StringUtils.isEmpty(bloodId) || "null".equals(bloodId)) { | |
150 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.PARAMETER_ERROR).setErrormsg("bloodId参数不能为空"); | |
151 | + } | |
150 | 152 | return bloodPressureService.getXyPresentation(bloodId); |
151 | 153 | } |
152 | 154 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodPressureServiceImpl.java
View file @
f4875c7
... | ... | @@ -674,8 +674,7 @@ |
674 | 674 | @Override |
675 | 675 | public BaseResponse getXyPresentation(String bloodId) { |
676 | 676 | //1.通过血压ID 查询到pnationId |
677 | - List<Map> datas = new ArrayList<>(); | |
678 | - Map<String, Object> maps = new HashMap<>(); | |
677 | + Map<String, Object> datas = new HashMap<>(); | |
679 | 678 | Map<String, Map<Integer, Double>> series = new HashMap<>(); |
680 | 679 | BloodPressure bloodPressure = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(bloodId)), BloodPressure.class); |
681 | 680 | //1.1回去bim值 String getBmi(String weight, String height); |
... | ... | @@ -683,7 +682,7 @@ |
683 | 682 | String height = bloodPressure.getHeight(); |
684 | 683 | String bregmatic = bloodPressure.getTireNumber(); |
685 | 684 | //2.通过pnationId ID获取到相应的信息例如:末次月经 |
686 | - if (StringUtils.isNotEmpty(bloodPressure.getParentId())) { | |
685 | + if (StringUtils.isNotEmpty(bloodPressure.getParentId()) && StringUtils.isNotEmpty(weight) && StringUtils.isNotEmpty(height) && StringUtils.isNotEmpty(bregmatic)) { | |
687 | 686 | Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(bloodPressure.getParentId())), Patients.class); |
688 | 687 | Integer weeks = DateUtil.daysBetween(patients.getLastMenses(), new Date()) / 7; |
689 | 688 | Map paMap = new HashMap(); |
690 | 689 | |
691 | 690 | |
692 | 691 | |
693 | 692 | |
694 | 693 | |
695 | 694 | |
696 | 695 | |
697 | 696 | |
698 | 697 | |
699 | 698 | |
700 | 699 | |
... | ... | @@ -691,109 +690,107 @@ |
691 | 690 | paMap.put("username", patients.getUsername()); |
692 | 691 | paMap.put("phone", patients.getPhone()); |
693 | 692 | paMap.put("age", patients.getAge()); |
694 | - paMap.put("dueDate", patients.getDueDate()); | |
693 | + paMap.put("dueDate", DateUtil.getyyyy_MM_dd(patients.getDueDate())); | |
695 | 694 | paMap.put("height", bloodPressure.getHeight()); |
696 | 695 | paMap.put("beforWeight", bloodPressure.getBeforWeight()); |
697 | 696 | paMap.put("weeks", weeks); |
698 | - datas.add(paMap); | |
697 | + datas.put("userInfo", paMap); | |
699 | 698 | Double bmiD = Double.valueOf(patientWeightService.getBmi(weight, height)).doubleValue(); |
700 | 699 | String bmiStr = ""; |
701 | 700 | //空和1表示单胎 |
702 | - if (StringUtils.isEmpty(weight) || StringUtils.isEmpty(height) || StringUtils.isEmpty(bregmatic)) { | |
703 | - return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.NO_DATA).setErrormsg("没有填写孕前体重或身高"); | |
701 | + if (!org.apache.commons.lang.StringUtils.isNotEmpty(bregmatic) || "1".equals(bregmatic)) { | |
702 | + if (bmiD < 18.5) { | |
703 | + bmiStr = "BMI<18.5"; | |
704 | + } else if (bmiD >= 18.5 && bmiD <= 24.99) { | |
705 | + bmiStr = "BMI=18.5-24.9"; | |
706 | + } else if (bmiD > 24.9 && bmiD < 30) { | |
707 | + bmiStr = "BMI=25-29.9"; | |
708 | + } else if (bmiD >= 30) { | |
709 | + bmiStr = "BMI≥30"; | |
710 | + } | |
704 | 711 | } else { |
705 | - if (!org.apache.commons.lang.StringUtils.isNotEmpty(bregmatic) || "1".equals(bregmatic)) { | |
706 | - if (bmiD < 18.5) { | |
707 | - bmiStr = "BMI<18.5"; | |
708 | - } else if (bmiD >= 18.5 && bmiD <= 24.99) { | |
709 | - bmiStr = "BMI=18.5-24.9"; | |
710 | - } else if (bmiD > 24.9 && bmiD < 30) { | |
711 | - bmiStr = "BMI=25-29.9"; | |
712 | - } else if (bmiD >= 30) { | |
713 | - bmiStr = "BMI≥30"; | |
714 | - } | |
715 | - } else { | |
716 | - if (bmiD <= 24.9) { | |
717 | - bmiStr = "BMI≤24.9"; | |
718 | - } else if (bmiD >= 25 && bmiD <= 29.99) { | |
719 | - bmiStr = "BMI=25-29.9"; | |
720 | - } else if (bmiD >= 30) { | |
721 | - bmiStr = "BMI≥30"; | |
722 | - } | |
712 | + if (bmiD <= 24.9) { | |
713 | + bmiStr = "BMI≤24.9"; | |
714 | + } else if (bmiD >= 25 && bmiD <= 29.99) { | |
715 | + bmiStr = "BMI=25-29.9"; | |
716 | + } else if (bmiD >= 30) { | |
717 | + bmiStr = "BMI≥30"; | |
723 | 718 | } |
724 | - //计算出区间范围 | |
725 | - double low = 0.0; | |
726 | - double high = 0.0; | |
727 | - this.getSeries(series, bmiStr, bregmatic); | |
728 | - Map<Integer, Double> lowMap = series.get("lowData"); | |
729 | - for (Map.Entry<Integer, Double> entry : lowMap.entrySet()) { | |
730 | - if (entry.getKey() == weeks) { | |
731 | - low = entry.getValue(); | |
732 | - } | |
719 | + } | |
720 | + //计算出区间范围 | |
721 | + double low = 0.0; | |
722 | + double high = 0.0; | |
723 | + this.getSeries(series, bmiStr, bregmatic); | |
724 | + Map<Integer, Double> lowMap = series.get("lowData"); | |
725 | + for (Map.Entry<Integer, Double> entry : lowMap.entrySet()) { | |
726 | + if (entry.getKey() == weeks) { | |
727 | + low = entry.getValue(); | |
733 | 728 | } |
734 | - Map<Integer, Double> highMap = series.get("highData"); | |
735 | - for (Map.Entry<Integer, Double> entry : highMap.entrySet()) { | |
736 | - if (entry.getKey() == weeks) { | |
737 | - high = entry.getValue(); | |
738 | - } | |
729 | + } | |
730 | + Map<Integer, Double> highMap = series.get("highData"); | |
731 | + for (Map.Entry<Integer, Double> entry : highMap.entrySet()) { | |
732 | + if (entry.getKey() == weeks) { | |
733 | + high = entry.getValue(); | |
739 | 734 | } |
740 | - //计算出属于那种类型 偏重 还事负重 还是正常 当前体重-孕前体重 | |
741 | - Double residualWeight = Double.valueOf(bloodPressure.getWeight()).doubleValue() - Double.valueOf(bloodPressure.getBeforWeight()).doubleValue(); | |
742 | - //把厘米转换成米 | |
743 | - Double heights = (Double.valueOf(bloodPressure.getHeight()).doubleValue()) / 100d; | |
744 | - int cals = this.getRounding((int) this.getCal(bregmatic, residualWeight, low, high, weeks, bmiD, patients, bloodPressure, heights)); | |
745 | - String calStr = cals + "kcal"; | |
746 | - List<XyPresentationModel> xyPresentationModels = mongoTemplate.find(Query.query(Criteria.where("originWeek").lte(weeks).and("endWeek").gte(weeks)), XyPresentationModel.class); | |
747 | - XyPresentationModel xy = mongoTemplate.findOne(Query.query(Criteria.where("quantityHeat").is(calStr)), XyPresentationModel.class); | |
748 | - if (xy != null) { | |
749 | - Map mapxy = new HashMap(); | |
750 | - if (weeks >= 0 && weeks <= 12) { | |
751 | - mapxy.put("proposal", "建议(孕早期)"); | |
752 | - mapxy.put("proposalInfo", xy.getEarlySuggests()); | |
753 | - } else if (weeks >= 13 && weeks <= 28) { | |
754 | - mapxy.put("proposal", "建议(孕中期)"); | |
755 | - mapxy.put("proposalInfo", xy.getMiddleSuggests()); | |
756 | - mapxy.put("proposal", "建议(孕晚期)"); | |
757 | - } else if (weeks >= 30) { | |
758 | - mapxy.put("proposalInfo", xy.getLaterSuggests()); | |
759 | - } | |
760 | - mapxy.put("quantityHeat", xy.getQuantityHeat()); | |
761 | - mapxy.put("breakfast", xy.getBreakfast()); | |
762 | - mapxy.put("breakfastAdd", xy.getBreakfastAdd()); | |
763 | - mapxy.put("lunch", xy.getLunch()); | |
764 | - mapxy.put("lunchAdd", xy.getLunchAdd()); | |
765 | - mapxy.put("dinner", xy.getDinner()); | |
766 | - mapxy.put("dinnerAdd", xy.getDinnerAdd()); | |
767 | - mapxy.put("northSouth", xy.getNorthSouth()); | |
768 | - maps.put("recipes", mapxy); | |
769 | - } else { | |
770 | - return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.NO_DATA).setErrormsg("未获取到热量值"); | |
735 | + } | |
736 | + //计算出属于那种类型 偏重 还事负重 还是正常 当前体重-孕前体重 | |
737 | + Double residualWeight = Double.valueOf(bloodPressure.getWeight()).doubleValue() - Double.valueOf(bloodPressure.getBeforWeight()).doubleValue(); | |
738 | + //把厘米转换成米 | |
739 | + Double heights = (Double.valueOf(bloodPressure.getHeight()).doubleValue()) / 100d; | |
740 | + int cals = this.getRounding((int) this.getCal(bregmatic, residualWeight, low, high, weeks, bmiD, patients, bloodPressure, heights)); | |
741 | + String calStr = cals + "kcal"; | |
742 | + List<XyPresentationModel> xyPresentationModels = mongoTemplate.find(Query.query(Criteria.where("originWeek").lte(weeks).and("endWeek").gte(weeks)), XyPresentationModel.class); | |
743 | + XyPresentationModel xy = mongoTemplate.findOne(Query.query(Criteria.where("quantityHeat").is(calStr)), XyPresentationModel.class); | |
744 | + if (xy != null) { | |
745 | + Map mapxy = new HashMap(); | |
746 | + if (weeks >= 0 && weeks <= 12) { | |
747 | + mapxy.put("proposal", "建议(孕早期)"); | |
748 | + mapxy.put("proposalInfo", xy.getEarlySuggests()); | |
749 | + } else if (weeks >= 13 && weeks <= 28) { | |
750 | + mapxy.put("proposal", "建议(孕中期)"); | |
751 | + mapxy.put("proposalInfo", xy.getMiddleSuggests()); | |
752 | + } else if (weeks >= 30) { | |
753 | + mapxy.put("proposal", "建议(孕晚期)"); | |
754 | + mapxy.put("proposalInfo", xy.getLaterSuggests()); | |
771 | 755 | } |
772 | - if (xyPresentationModels.isEmpty()) { | |
773 | - return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.NO_DATA).setErrormsg("没有对应的数据"); | |
774 | - } else { | |
775 | - List<Map> motionList = new LinkedList<>(); | |
776 | - for (XyPresentationModel p : xyPresentationModels) { | |
777 | - Map map = new HashMap(); | |
778 | - map.put("title", p.getTitle()); | |
779 | - map.put("content", p.getContent()); | |
780 | - map.put("modular", p.getModular()); | |
781 | - map.put("type", p.getType()); | |
782 | - if (p.getType() == 3) { | |
783 | - motionList.add(map); | |
784 | - } else if (p.getType() == 2) { | |
785 | - maps.put("guide", map); | |
786 | - } else { | |
787 | - maps.put("pregnancy", map); | |
788 | - } | |
756 | + mapxy.put("quantityHeat", xy.getQuantityHeat()); | |
757 | + mapxy.put("breakfast", xy.getBreakfast()); | |
758 | + mapxy.put("breakfastAdd", xy.getBreakfastAdd()); | |
759 | + mapxy.put("lunch", xy.getLunch()); | |
760 | + mapxy.put("lunchAdd", xy.getLunchAdd()); | |
761 | + mapxy.put("dinner", xy.getDinner()); | |
762 | + mapxy.put("dinnerAdd", xy.getDinnerAdd()); | |
763 | + mapxy.put("northSouth", xy.getNorthSouth()); | |
764 | + datas.put("recipes", mapxy); | |
765 | + } else { | |
766 | + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.NO_DATA).setErrormsg("未获取到热量值"); | |
767 | + } | |
768 | + if (xyPresentationModels.isEmpty()) { | |
769 | + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.NO_DATA).setErrormsg("没有对应的数据"); | |
770 | + } else { | |
771 | + List<Map> motionList = new ArrayList<>(); | |
772 | + for (XyPresentationModel p : xyPresentationModels) { | |
773 | + Map map = new HashMap(); | |
774 | + map.put("title", p.getTitle()); | |
775 | + map.put("content", p.getContent()); | |
776 | + map.put("modular", p.getModular()); | |
777 | + map.put("type", p.getType()); | |
778 | + if (3 == p.getType()) { | |
779 | + motionList.add(map); | |
780 | + } else if (2 == p.getType()) { | |
781 | + datas.put("guide", map); | |
782 | + } else if (0 == p.getType()) { | |
783 | + datas.put("pregnancy", map); | |
789 | 784 | } |
790 | - maps.put("motion", motionList); | |
791 | - datas.add(maps); | |
792 | 785 | } |
786 | + datas.put("motion", motionList); | |
793 | 787 | } |
788 | + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(datas); | |
789 | + } else { | |
790 | + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.NO_DATA).setErrormsg("失败").setData("请检查数据是否填写完整!"); | |
794 | 791 | } |
795 | 792 | //3.算出孕周通过孕周查询到对应的信息进行返回 |
796 | - return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(datas); | |
793 | + | |
797 | 794 | } |
798 | 795 | |
799 | 796 | public void getSeries(Map<String, Map<Integer, Double>> series, String bmiStr, String bregmatic) { |
... | ... | @@ -1073,7 +1070,6 @@ |
1073 | 1070 | int b = number / 100 % 10 + 1; |
1074 | 1071 | int q = number / 1000 % 10; |
1075 | 1072 | int num = q * 1000 + b * 100 + sw * 0 + g * 0; |
1076 | - System.out.println("向上取cal值为:" + num); | |
1077 | 1073 | return num; |
1078 | 1074 | } else { |
1079 | 1075 | int g = 0; //s % 10; |
... | ... | @@ -1081,7 +1077,6 @@ |
1081 | 1077 | int b = number / 100 % 10; |
1082 | 1078 | int q = number / 1000 % 10; |
1083 | 1079 | int num = q * 1000 + b * 100 + sw * 0 + g * 0; |
1084 | - System.out.println("向下取得cal值为:" + num); | |
1085 | 1080 | return num; |
1086 | 1081 | } |
1087 | 1082 | } |