Commit 7c11d2541a0e9a39a20b09f3813692f0ab914140
1 parent
182f50e227
Exists in
master
and in
6 other branches
体重管理相关代码
Showing 3 changed files with 72 additions and 5 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 @
7c11d25
| ... | ... | @@ -3,17 +3,13 @@ |
| 3 | 3 | import com.lyms.platform.common.annotation.TokenRequired; |
| 4 | 4 | import com.lyms.platform.common.base.BaseController; |
| 5 | 5 | import com.lyms.platform.common.result.BaseResponse; |
| 6 | -import com.lyms.platform.operate.web.service.BabyEyeCheckService; | |
| 7 | 6 | import com.lyms.platform.operate.web.service.PatientWeightService; |
| 8 | -import com.lyms.platform.pojo.BabyEyeCheck; | |
| 9 | 7 | import com.lyms.platform.pojo.PatientWeight; |
| 10 | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | 9 | import org.springframework.stereotype.Controller; |
| 12 | 10 | import org.springframework.web.bind.annotation.*; |
| 13 | 11 | |
| 14 | 12 | import javax.servlet.http.HttpServletRequest; |
| 15 | -import javax.servlet.http.HttpServletResponse; | |
| 16 | -import java.util.Date; | |
| 17 | 13 | |
| 18 | 14 | /** |
| 19 | 15 | * 孕产妇体重管理 |
| ... | ... | @@ -92,6 +88,25 @@ |
| 92 | 88 | @RequestMapping(value = "report/{id}", method = RequestMethod.GET) |
| 93 | 89 | public BaseResponse report(@PathVariable String id) { |
| 94 | 90 | return patientWeightService.report(id); |
| 91 | + } | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * 体重报告(小程序使用) | |
| 95 | + */ | |
| 96 | + @ResponseBody | |
| 97 | + @RequestMapping(value = "/report/wx/{patientId}/{hospitalId}", method = RequestMethod.GET) | |
| 98 | + public BaseResponse wxReport(@PathVariable String patientId, @PathVariable String hospitalId) { | |
| 99 | + return patientWeightService.wxReport(patientId, hospitalId); | |
| 100 | + } | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * 保存修改体重报告(小程序使用) | |
| 104 | + * @return | |
| 105 | + */ | |
| 106 | + @ResponseBody | |
| 107 | + @RequestMapping(value = "/wx", method = RequestMethod.POST) | |
| 108 | + public BaseResponse wxAddOrUpdate(PatientWeight patientWeight) { | |
| 109 | + return patientWeightService.wxAddOrUpdate(patientWeight); | |
| 95 | 110 | } |
| 96 | 111 | |
| 97 | 112 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java
View file @
7c11d25
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
View file @
7c11d25
| ... | ... | @@ -8,7 +8,6 @@ |
| 8 | 8 | import com.lyms.platform.operate.web.facade.AutoMatchFacade; |
| 9 | 9 | import com.lyms.platform.operate.web.service.PatientWeightService; |
| 10 | 10 | import com.lyms.platform.operate.web.utils.CollectionUtils; |
| 11 | -import com.lyms.platform.operate.web.utils.MathUtil; | |
| 12 | 11 | import com.lyms.platform.operate.web.utils.MongoUtil; |
| 13 | 12 | import com.lyms.platform.pojo.PatientWeight; |
| 14 | 13 | import com.lyms.platform.pojo.Patients; |
| ... | ... | @@ -262,6 +261,55 @@ |
| 262 | 261 | return RespBuilder.buildSuccess(map); |
| 263 | 262 | } |
| 264 | 263 | return RespBuilder.buildSuccess(); |
| 264 | + } | |
| 265 | + | |
| 266 | + @Override | |
| 267 | + public BaseResponse wxReport(String patientId, String hospitalId) { | |
| 268 | + PatientWeight patientWeight = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientId).and("hospitalId").is(hospitalId)), PatientWeight.class); | |
| 269 | + if(patientWeight != null) { | |
| 270 | + Map<String, Object> map = new HashMap<>(); | |
| 271 | + setReport(map, patientWeight.getWeights(), patientWeight.getBeforeWeight(), patientWeight.getBmi()); | |
| 272 | + return RespBuilder.buildSuccess(map); | |
| 273 | + } | |
| 274 | + return RespBuilder.buildSuccess(); | |
| 275 | + } | |
| 276 | + | |
| 277 | + @Override | |
| 278 | + public BaseResponse wxAddOrUpdate(PatientWeight patientWeight) { | |
| 279 | + String nowWeight = patientWeight.getNowWeight(); | |
| 280 | + Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); | |
| 281 | + PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientWeight.getPatientId())), PatientWeight.class); | |
| 282 | + Map<Integer, String> weights = new HashMap<>(); | |
| 283 | + if(pw != null) { | |
| 284 | + if(MapUtils.isNotEmpty(pw.getWeights())) { | |
| 285 | + weights = pw.getWeights(); | |
| 286 | + } | |
| 287 | + if(patients != null) { | |
| 288 | + weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); | |
| 289 | + } | |
| 290 | + pw.setWeights(weights); | |
| 291 | + Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(pw)); | |
| 292 | + mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(pw.getId())), update, PatientWeight.class); | |
| 293 | + return RespBuilder.buildSuccess(pw.getId()); | |
| 294 | + } | |
| 295 | + | |
| 296 | + if(StringUtils.isEmpty(patientWeight.getId()) && patients != null) { | |
| 297 | + patientWeight.setCreated(new Date()); | |
| 298 | + if(StringUtils.isNotBlank(patientWeight.getPatientId())) { | |
| 299 | + weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); | |
| 300 | + patientWeight.setWeights(weights); | |
| 301 | + } | |
| 302 | + if(StringUtils.isNotBlank(patientWeight.getNowWeight()) && patientWeight.getBeforeHeight() != null) { | |
| 303 | + patientWeight.setBmi(getBmi(patientWeight.getNowWeight(), patientWeight.getBeforeHeight())); | |
| 304 | + } | |
| 305 | + patientWeight.setYn("1"); | |
| 306 | + mongoTemplate.save(patientWeight); | |
| 307 | + return RespBuilder.buildSuccess(patientWeight.getId()); | |
| 308 | + } else { | |
| 309 | + Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(patientWeight)); | |
| 310 | + mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(patientWeight.getId())), update, PatientWeight.class); | |
| 311 | + return RespBuilder.buildSuccess(patientWeight.getId()); | |
| 312 | + } | |
| 265 | 313 | } |
| 266 | 314 | |
| 267 | 315 | private void setGuide(Integer week, Map<String, Object> map) { |