diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java index 97220c5..50204fa 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java @@ -122,8 +122,8 @@ public class PatientWeightController extends BaseController { @ResponseBody @RequestMapping(value = "/update", method = RequestMethod.POST) @TokenRequired - public BaseResponse update(String id, String beforeWeight, String beforeHeight) { - return patientWeightService.update(id, beforeWeight, beforeHeight); + public BaseResponse update(String id, String beforeWeight, String beforeHeight, String date, String nowWeight, HttpServletRequest request) { + return patientWeightService.update(getUserId(request), id, beforeWeight, beforeHeight, date, nowWeight); } } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java index 5eb46b4..9c1126e 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java @@ -27,5 +27,5 @@ public interface PatientWeightService extends IBaseService { BaseResponse wxAddOrUpdateSync(PatientWeight patientWeight); - BaseResponse update(String id, String beforeWeight, String beforeHeight); + BaseResponse update(Integer userId, String id, String beforeWeight, String beforeHeight, String date, String nowWeight); } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java index 89a716b..baac7f4 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java @@ -439,13 +439,37 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient } @Override - public BaseResponse update(String id, String beforeWeight, String beforeHeight) { - PatientWeight pw = new PatientWeight(); - pw.setId(id); - pw.setBeforeHeight(beforeHeight); - pw.setBeforeWeight(beforeWeight); - pw.setBmi(getBmi(beforeWeight, beforeHeight)); - patientWeightService2.update(Query.query(Criteria.where("id").is(id)), pw); + public BaseResponse update(Integer userId, String id, String beforeWeight, String beforeHeight, String date, String nowWeight) { + PatientWeight patientWeight = mongoTemplate.findById(id, PatientWeight.class); + if(patientWeight == null) { + return RespBuilder.buildSuccess("该体重未找到"); + } + String hospitalId = autoMatchFacade.getHospitalId(userId); + if(StringUtils.isNotEmpty(beforeWeight)) { + patientWeight.setBeforeWeight(beforeWeight); + } + if(StringUtils.isNotEmpty(beforeHeight)) { + patientWeight.setBeforeHeight(beforeHeight); + } + if(StringUtils.isNotEmpty(nowWeight)) { + patientWeight.setNowWeight(nowWeight); + } + if(StringUtils.isNotEmpty(date)) { + List> dayWeights2 = patientWeight.getDayWeights2(); + for (Map map : dayWeights2) { + if(date.equals(map.get("date") + "")) { + map.put("hospitalId", hospitalId); + map.put("hospitalName", couponMapper.getHospitalName(hospitalId)); + map.put("nowWeight", nowWeight); + } + } + Map dayWeights = patientWeight.getDayWeights(); + dayWeights.put(date, nowWeight); + + patientWeight.setDayWeights2(dayWeights2); + patientWeight.setDayWeights(dayWeights); + } + patientWeightService2.update(Query.query(Criteria.where("id").is(id)), patientWeight); return RespBuilder.buildSuccess(id); }