Commit 0845fe94eb32d9624c1e0dd59a0926b471f6500b
1 parent
64bd0dd70a
Exists in
master
and in
6 other branches
体重管理相关代码
Showing 2 changed files with 34 additions and 59 deletions
platform-dal/src/main/java/com/lyms/platform/pojo/PatientWeight.java
View file @
0845fe9
... | ... | @@ -24,26 +24,6 @@ |
24 | 24 | |
25 | 25 | private String patientId; |
26 | 26 | |
27 | - /* // 证件号 | |
28 | - private String cardNo; | |
29 | - | |
30 | - // 就诊卡号 | |
31 | - private String vcCardNo; | |
32 | - | |
33 | - // 姓名 | |
34 | - private String username; | |
35 | - | |
36 | - // 电话 | |
37 | - private String phone; | |
38 | - | |
39 | - // 生日 | |
40 | - private Date birth; | |
41 | - | |
42 | - private Date lastMenses; | |
43 | - | |
44 | - // 证件类型 | |
45 | - private String pcerteTypeId;*/ | |
46 | - | |
47 | 27 | // 孕前体重 |
48 | 28 | private String beforeWeight; |
49 | 29 | |
... | ... | @@ -55,6 +35,9 @@ |
55 | 35 | |
56 | 36 | private Map<Integer, String> weights; |
57 | 37 | |
38 | + // 存储 年月日 = xxKG | |
39 | + private Map<String, String> dayWeights; | |
40 | + | |
58 | 41 | // 前囟 单胎/双胎/多胎 |
59 | 42 | private String bregmatic; |
60 | 43 | |
... | ... | @@ -63,6 +46,13 @@ |
63 | 46 | |
64 | 47 | private String bmi; |
65 | 48 | |
49 | + public Map<String, String> getDayWeights() { | |
50 | + return dayWeights; | |
51 | + } | |
52 | + | |
53 | + public void setDayWeights(Map<String, String> dayWeights) { | |
54 | + this.dayWeights = dayWeights; | |
55 | + } | |
66 | 56 | |
67 | 57 | public Map<Integer, String> getWeights() { |
68 | 58 | return weights; |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
View file @
0845fe9
... | ... | @@ -36,44 +36,11 @@ |
36 | 36 | @Autowired |
37 | 37 | private MongoUtil mongoUtil; |
38 | 38 | |
39 | - | |
40 | - | |
41 | - /* *//** | |
39 | + /** | |
42 | 40 | * 最低:0~13 : 0~1.9 13~40 1.9~11.9 |
43 | 41 | * 最高: 0~2.2 2.2~15.9 |
44 | - *//* | |
45 | - static { | |
46 | - for (int i = 0; i <= 40; i++) { | |
47 | - xAxis.add(i); | |
48 | - } | |
42 | + */ | |
49 | 43 | |
50 | - double avg = 1.9 / 13; | |
51 | - for (int i = 0; i <= 13; i++) { | |
52 | - lowMap.put(i, i * avg); | |
53 | - } | |
54 | - | |
55 | - double avg2 = 10.0 / 27; | |
56 | - for (int i = 1; i <= 27; i++) { | |
57 | - lowMap.put(13 + i, 1.9 + i * avg2); | |
58 | - } | |
59 | - | |
60 | - double highAvg = 2.2 / 13; | |
61 | - for (int i = 0; i <= 13; i++) { | |
62 | - highMap.put(i, i * highAvg); | |
63 | - } | |
64 | - | |
65 | - double highAvg2 = 13.7 / 27; | |
66 | - for (int i = 1; i <= 27; i++) { | |
67 | - highMap.put(13 + i, 2.2 + i * highAvg2); | |
68 | - } | |
69 | - | |
70 | - for (int i = 0; i <= 40; i++) { | |
71 | - normalMap.put(i, (highMap.get(i) + lowMap.get(i)) / 2); | |
72 | - } | |
73 | - }*/ | |
74 | - | |
75 | - | |
76 | - | |
77 | 44 | @Override |
78 | 45 | public BaseResponse init() { |
79 | 46 | List<Map<String, Object>> bregmaticEnums2 = EnumUtil.toJson(BregmaticEnums2.class); |
80 | 47 | |
81 | 48 | |
82 | 49 | |
... | ... | @@ -88,20 +55,28 @@ |
88 | 55 | Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); |
89 | 56 | PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientWeight.getPatientId()).and("hospitalId").is(hospitalId)), PatientWeight.class); |
90 | 57 | Map<Integer, String> weights = new HashMap<>(); |
58 | + Map<String, String> dayWeights = new HashMap<>(); | |
91 | 59 | if(pw != null) { |
92 | 60 | if(MapUtils.isNotEmpty(pw.getWeights())) { |
93 | 61 | weights = pw.getWeights(); |
94 | 62 | } |
63 | + if(MapUtils.isNotEmpty(pw.getDayWeights())) { | |
64 | + dayWeights = pw.getDayWeights(); | |
65 | + } | |
66 | + dayWeights.put(DateUtil.getyyyy_MM_dd(new Date()), nowWeight); | |
95 | 67 | if(patients != null) { |
96 | 68 | weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); |
97 | 69 | } |
98 | 70 | pw.setWeights(weights); |
71 | + pw.setDayWeights(dayWeights); | |
99 | 72 | Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(pw)); |
100 | 73 | mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(pw.getId())), update, PatientWeight.class); |
101 | 74 | return RespBuilder.buildSuccess(pw.getId()); |
102 | 75 | } |
103 | 76 | |
104 | 77 | if(StringUtils.isEmpty(patientWeight.getId()) && patients != null) { |
78 | + dayWeights.put(DateUtil.getyyyy_MM_dd(new Date()), nowWeight); | |
79 | + patientWeight.setDayWeights(dayWeights); | |
105 | 80 | patientWeight.setHospitalId(hospitalId); |
106 | 81 | patientWeight.setOperaterId(userId.toString()); |
107 | 82 | patientWeight.setCreated(new Date()); |
... | ... | @@ -202,7 +177,7 @@ |
202 | 177 | map.put("bregmatic", BregmaticEnums2.getName(patientWeight.getBregmatic())); |
203 | 178 | map.put("bim", patientWeight.getBmi()); // 体质指数(BMI)=体重(kg)÷身高^2(m) |
204 | 179 | |
205 | - setReport(map, patientWeight.getWeights(), patientWeight.getBeforeWeight(), patientWeight.getBmi()); | |
180 | + setReport(map, patientWeight.getWeights(), patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights()); | |
206 | 181 | |
207 | 182 | CollectionUtils.removeNullValue(map); |
208 | 183 | return RespBuilder.buildSuccess(map); |
... | ... | @@ -256,7 +231,7 @@ |
256 | 231 | setRecipe(week, map); // 设置食谱 |
257 | 232 | setGuide(week, map); // 设置指南 |
258 | 233 | } |
259 | - setReport(map, patientWeight.getWeights(), patientWeight.getBeforeWeight(), patientWeight.getBmi()); | |
234 | + setReport(map, patientWeight.getWeights(), patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights()); | |
260 | 235 | CollectionUtils.removeNullValue(map); |
261 | 236 | return RespBuilder.buildSuccess(map); |
262 | 237 | } |
... | ... | @@ -268,7 +243,7 @@ |
268 | 243 | PatientWeight patientWeight = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientId).and("hospitalId").is(hospitalId)), PatientWeight.class); |
269 | 244 | if(patientWeight != null) { |
270 | 245 | Map<String, Object> map = new HashMap<>(); |
271 | - setReport(map, patientWeight.getWeights(), patientWeight.getBeforeWeight(), patientWeight.getBmi()); | |
246 | + setReport(map, patientWeight.getWeights(), patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights()); | |
272 | 247 | return RespBuilder.buildSuccess(map); |
273 | 248 | } |
274 | 249 | return RespBuilder.buildSuccess(); |
... | ... | @@ -629,7 +604,17 @@ |
629 | 604 | 最低 0-0.8 0.9-4.9 |
630 | 605 | 最高 0-2.1 2.1-8.9 |
631 | 606 | */ |
632 | - public void setReport(Map<String, Object> restMap, Map<Integer, String> weights, String beforeWeight, String bmi) { | |
607 | + public void setReport(Map<String, Object> restMap, Map<Integer, String> weights, String beforeWeight, String bmi, Map<String, String> dayWeights) { | |
608 | + if(MapUtils.isNotEmpty(dayWeights)) { | |
609 | + List<Map<String, Object>> restList = new ArrayList<>(); | |
610 | + for (String key : dayWeights.keySet()) { | |
611 | + Map<String, Object> temp = new HashMap<>(); | |
612 | + temp.put("nowWeight", dayWeights.get(key)); | |
613 | + temp.put("recordTime", key); | |
614 | + restList.add(temp); | |
615 | + } | |
616 | + } | |
617 | + | |
633 | 618 | Double bmiD = Double.parseDouble(bmi); |
634 | 619 | double low = 0D; |
635 | 620 | double low2 = 0D; |