Commit 5891062cc971fde0ea69f7999ec0167b2d77ad31
1 parent
7b4038399f
Exists in
master
and in
6 other branches
优惠券
Showing 3 changed files with 35 additions and 37 deletions
platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
View file @
5891062
platform-dal/src/main/java/com/lyms/platform/pojo/PatientWeight.java
View file @
5891062
... | ... | @@ -33,8 +33,6 @@ |
33 | 33 | // 当前体重 |
34 | 34 | private String nowWeight; |
35 | 35 | |
36 | - private Map<Integer, String> weights; | |
37 | - | |
38 | 36 | // 存储 年月日 = xxKG |
39 | 37 | private Map<String, String> dayWeights; |
40 | 38 | |
... | ... | @@ -52,14 +50,6 @@ |
52 | 50 | |
53 | 51 | public void setDayWeights(Map<String, String> dayWeights) { |
54 | 52 | this.dayWeights = dayWeights; |
55 | - } | |
56 | - | |
57 | - public Map<Integer, String> getWeights() { | |
58 | - return weights; | |
59 | - } | |
60 | - | |
61 | - public void setWeights(Map<Integer, String> weights) { | |
62 | - this.weights = weights; | |
63 | 53 | } |
64 | 54 | |
65 | 55 | public String getBmi() { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
View file @
5891062
... | ... | @@ -64,20 +64,12 @@ |
64 | 64 | if(pw != null && StringUtils.isNotEmpty(patientWeight.getBeforeWeight())) { |
65 | 65 | return RespBuilder.buildErro(ResponseCode.PATIENT_WEIGHT_IS_EXIST); |
66 | 66 | } |
67 | - Map<Integer, String> weights = new HashMap<>(); | |
68 | 67 | Map<String, String> dayWeights = new HashMap<>(); |
69 | 68 | if(pw != null) { |
70 | - if(MapUtils.isNotEmpty(pw.getWeights())) { | |
71 | - weights = pw.getWeights(); | |
72 | - } | |
73 | 69 | if(MapUtils.isNotEmpty(pw.getDayWeights())) { |
74 | 70 | dayWeights = pw.getDayWeights(); |
75 | 71 | } |
76 | 72 | dayWeights.put(DateUtil.getyyyy_MM_dd(new Date()), nowWeight); |
77 | - if(patients != null) { | |
78 | - weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); | |
79 | - } | |
80 | - pw.setWeights(weights); | |
81 | 73 | pw.setDayWeights(dayWeights); |
82 | 74 | pw.setNowWeight(patientWeight.getNowWeight()); |
83 | 75 | pw.setBmi(getBmi(patientWeight.getNowWeight(), pw.getBeforeHeight())); |
... | ... | @@ -92,10 +84,6 @@ |
92 | 84 | patientWeight.setHospitalId(hospitalId); |
93 | 85 | patientWeight.setOperaterId(userId.toString()); |
94 | 86 | patientWeight.setCreated(new Date()); |
95 | - if(StringUtils.isNotBlank(patientWeight.getPatientId())) { | |
96 | - weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); | |
97 | - patientWeight.setWeights(weights); | |
98 | - } | |
99 | 87 | if(StringUtils.isNotBlank(patientWeight.getNowWeight()) && patientWeight.getBeforeHeight() != null) { |
100 | 88 | patientWeight.setBmi(getBmi(patientWeight.getNowWeight(), patientWeight.getBeforeHeight())); |
101 | 89 | } |
102 | 90 | |
103 | 91 | |
... | ... | @@ -185,12 +173,25 @@ |
185 | 173 | public BaseResponse info(String id) { |
186 | 174 | PatientWeight patientWeight = mongoTemplate.findById(id, PatientWeight.class); |
187 | 175 | if(patientWeight != null) { |
176 | + Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); | |
177 | + if(patients == null) { | |
178 | + return RespBuilder.buildSuccess("建档数据未找到"); | |
179 | + } | |
188 | 180 | Map<String, Object> map = ReflectionUtils.beanToMap(patientWeight); |
189 | 181 | map.put("bregmatic", BregmaticEnums2.getName(patientWeight.getBregmatic())); |
190 | 182 | map.put("bim", patientWeight.getBmi()); // 体质指数(BMI)=体重(kg)÷身高^2(m) |
191 | 183 | |
192 | - setReport(map, patientWeight.getWeights(), patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights()); | |
184 | + Map<String, String> dayWeights = patientWeight.getDayWeights(); | |
185 | + Map<Integer, String> weights = new HashMap<>(); | |
186 | + if (MapUtils.isNotEmpty(dayWeights)) { | |
187 | + Set<Map.Entry<String, String>> entries = dayWeights.entrySet(); | |
188 | + for (Map.Entry<String, String> entry : entries) { | |
189 | + weights.put(DateUtil.getWeek2(patients.getLastMenses(), DateUtil.parseYMD(entry.getKey())), entry.getValue()); | |
190 | + } | |
191 | + } | |
193 | 192 | |
193 | + setReport(map, weights, patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights()); | |
194 | + | |
194 | 195 | CollectionUtils.removeNullValue(map); |
195 | 196 | return RespBuilder.buildSuccess(map); |
196 | 197 | } |
... | ... | @@ -243,7 +244,16 @@ |
243 | 244 | setRecipe(week, map); // 设置食谱 |
244 | 245 | setGuide(week, map); // 设置指南 |
245 | 246 | } |
246 | - setReport(map, patientWeight.getWeights(), patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights()); | |
247 | + | |
248 | + Map<String, String> dayWeights = patientWeight.getDayWeights(); | |
249 | + Map<Integer, String> weights = new HashMap<>(); | |
250 | + if (MapUtils.isNotEmpty(dayWeights)) { | |
251 | + Set<Map.Entry<String, String>> entries = dayWeights.entrySet(); | |
252 | + for (Map.Entry<String, String> entry : entries) { | |
253 | + weights.put(DateUtil.getWeek2(patients.getLastMenses(), DateUtil.parseYMD(entry.getKey())), entry.getValue()); | |
254 | + } | |
255 | + } | |
256 | + setReport(map, weights, patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights()); | |
247 | 257 | CollectionUtils.removeNullValue(map); |
248 | 258 | return RespBuilder.buildSuccess(map); |
249 | 259 | } |
... | ... | @@ -256,7 +266,16 @@ |
256 | 266 | if(patientWeight != null) { |
257 | 267 | Map<String, Object> map = new HashMap<>(); |
258 | 268 | map.put("beforeWeight", patientWeight.getBeforeWeight()); |
259 | - setAppReport(map, patientWeight.getWeights(), patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights()); | |
269 | + Patients patients = mongoTemplate.findById(patientId, Patients.class); | |
270 | + Map<String, String> dayWeights = patientWeight.getDayWeights(); | |
271 | + Map<Integer, String> weights = new HashMap<>(); | |
272 | + if (MapUtils.isNotEmpty(dayWeights)) { | |
273 | + Set<Map.Entry<String, String>> entries = dayWeights.entrySet(); | |
274 | + for (Map.Entry<String, String> entry : entries) { | |
275 | + weights.put(DateUtil.getWeek2(patients.getLastMenses(), DateUtil.parseYMD(entry.getKey())), entry.getValue()); | |
276 | + } | |
277 | + } | |
278 | + setAppReport(map, weights, patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights()); | |
260 | 279 | return RespBuilder.buildSuccess(map); |
261 | 280 | } |
262 | 281 | return RespBuilder.buildSuccess(); |
... | ... | @@ -267,7 +286,6 @@ |
267 | 286 | String nowWeight = patientWeight.getNowWeight(); |
268 | 287 | Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); |
269 | 288 | PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientWeight.getPatientId())), PatientWeight.class); |
270 | - Map<Integer, String> weights = new HashMap<>(); | |
271 | 289 | Map<String, String> dayWeights = new HashMap<>(); |
272 | 290 | if(pw == null && StringUtils.isEmpty(patientWeight.getBeforeWeight())) { |
273 | 291 | return RespBuilder.buildErro(ResponseCode.NEED_ADD_PATIENT_WEIGHT); |
... | ... | @@ -276,9 +294,6 @@ |
276 | 294 | return RespBuilder.buildErro(ResponseCode.PATIENT_WEIGHT_IS_EXIST); |
277 | 295 | } |
278 | 296 | if(pw != null) { |
279 | - if(MapUtils.isNotEmpty(pw.getWeights())) { | |
280 | - weights = pw.getWeights(); | |
281 | - } | |
282 | 297 | if(MapUtils.isNotEmpty(pw.getDayWeights())) { |
283 | 298 | dayWeights = pw.getDayWeights(); |
284 | 299 | } |
... | ... | @@ -286,10 +301,6 @@ |
286 | 301 | pw.setNowWeight(nowWeight); |
287 | 302 | pw.setBmi(getBmi(patientWeight.getNowWeight(), pw.getBeforeHeight())); |
288 | 303 | pw.setDayWeights(dayWeights); |
289 | - if(patients != null && StringUtils.isNotEmpty(nowWeight)) { | |
290 | - weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); | |
291 | - } | |
292 | - pw.setWeights(weights); | |
293 | 304 | pw.setBmi(getBmi(patientWeight.getNowWeight(), pw.getBeforeHeight())); |
294 | 305 | Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(pw)); |
295 | 306 | mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(pw.getId())), update, PatientWeight.class); |
... | ... | @@ -299,10 +310,6 @@ |
299 | 310 | if(StringUtils.isEmpty(patientWeight.getId()) && patients != null) { |
300 | 311 | patientWeight.setCreated(new Date()); |
301 | 312 | patientWeight.setHospitalId(patients.getHospitalId()); |
302 | - if(StringUtils.isNotBlank(patientWeight.getPatientId()) && StringUtils.isNotEmpty(patientWeight.getNowWeight())) { | |
303 | - weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); | |
304 | - } | |
305 | - patientWeight.setWeights(weights); | |
306 | 313 | if(StringUtils.isNotBlank(patientWeight.getNowWeight()) && patientWeight.getBeforeHeight() != null) { |
307 | 314 | patientWeight.setBmi(getBmi(patientWeight.getNowWeight(), patientWeight.getBeforeHeight())); |
308 | 315 | } |