Commit 48994baf486994c317e690b65164afbf856404c6
1 parent
92bf3a77d8
Exists in
master
and in
6 other branches
体重管理修改接口
Showing 3 changed files with 34 additions and 10 deletions
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java
View file @
48994ba
| ... | ... | @@ -122,8 +122,8 @@ |
| 122 | 122 | @ResponseBody |
| 123 | 123 | @RequestMapping(value = "/update", method = RequestMethod.POST) |
| 124 | 124 | @TokenRequired |
| 125 | - public BaseResponse update(String id, String beforeWeight, String beforeHeight) { | |
| 126 | - return patientWeightService.update(id, beforeWeight, beforeHeight); | |
| 125 | + public BaseResponse update(String id, String beforeWeight, String beforeHeight, String date, String nowWeight, HttpServletRequest request) { | |
| 126 | + return patientWeightService.update(getUserId(request), id, beforeWeight, beforeHeight, date, nowWeight); | |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java
View file @
48994ba
| ... | ... | @@ -27,6 +27,6 @@ |
| 27 | 27 | |
| 28 | 28 | BaseResponse wxAddOrUpdateSync(PatientWeight patientWeight); |
| 29 | 29 | |
| 30 | - BaseResponse update(String id, String beforeWeight, String beforeHeight); | |
| 30 | + BaseResponse update(Integer userId, String id, String beforeWeight, String beforeHeight, String date, String nowWeight); | |
| 31 | 31 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
View file @
48994ba
| ... | ... | @@ -439,13 +439,37 @@ |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | @Override |
| 442 | - public BaseResponse update(String id, String beforeWeight, String beforeHeight) { | |
| 443 | - PatientWeight pw = new PatientWeight(); | |
| 444 | - pw.setId(id); | |
| 445 | - pw.setBeforeHeight(beforeHeight); | |
| 446 | - pw.setBeforeWeight(beforeWeight); | |
| 447 | - pw.setBmi(getBmi(beforeWeight, beforeHeight)); | |
| 448 | - patientWeightService2.update(Query.query(Criteria.where("id").is(id)), pw); | |
| 442 | + public BaseResponse update(Integer userId, String id, String beforeWeight, String beforeHeight, String date, String nowWeight) { | |
| 443 | + PatientWeight patientWeight = mongoTemplate.findById(id, PatientWeight.class); | |
| 444 | + if(patientWeight == null) { | |
| 445 | + return RespBuilder.buildSuccess("该体重未找到"); | |
| 446 | + } | |
| 447 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
| 448 | + if(StringUtils.isNotEmpty(beforeWeight)) { | |
| 449 | + patientWeight.setBeforeWeight(beforeWeight); | |
| 450 | + } | |
| 451 | + if(StringUtils.isNotEmpty(beforeHeight)) { | |
| 452 | + patientWeight.setBeforeHeight(beforeHeight); | |
| 453 | + } | |
| 454 | + if(StringUtils.isNotEmpty(nowWeight)) { | |
| 455 | + patientWeight.setNowWeight(nowWeight); | |
| 456 | + } | |
| 457 | + if(StringUtils.isNotEmpty(date)) { | |
| 458 | + List<Map<String, Object>> dayWeights2 = patientWeight.getDayWeights2(); | |
| 459 | + for (Map<String, Object> map : dayWeights2) { | |
| 460 | + if(date.equals(map.get("date") + "")) { | |
| 461 | + map.put("hospitalId", hospitalId); | |
| 462 | + map.put("hospitalName", couponMapper.getHospitalName(hospitalId)); | |
| 463 | + map.put("nowWeight", nowWeight); | |
| 464 | + } | |
| 465 | + } | |
| 466 | + Map<String, String> dayWeights = patientWeight.getDayWeights(); | |
| 467 | + dayWeights.put(date, nowWeight); | |
| 468 | + | |
| 469 | + patientWeight.setDayWeights2(dayWeights2); | |
| 470 | + patientWeight.setDayWeights(dayWeights); | |
| 471 | + } | |
| 472 | + patientWeightService2.update(Query.query(Criteria.where("id").is(id)), patientWeight); | |
| 449 | 473 | return RespBuilder.buildSuccess(id); |
| 450 | 474 | } |
| 451 | 475 |