From 48994baf486994c317e690b65164afbf856404c6 Mon Sep 17 00:00:00 2001 From: "litao@lymsh.com" Date: Wed, 18 Oct 2017 16:08:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=93=E9=87=8D=E7=AE=A1=E7=90=86=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/PatientWeightController.java | 4 +-- .../operate/web/service/PatientWeightService.java | 2 +- .../web/service/impl/PatientWeightServiceImpl.java | 38 ++++++++++++++++++---- 3 files changed, 34 insertions(+), 10 deletions(-) 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); } -- 1.8.3.1