Commit 04a8732726a3913ed3188e3018cafa349439c28f
1 parent
ca75c67cf3
Exists in
master
and in
6 other branches
改逻辑
Showing 7 changed files with 161 additions and 9 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IPatientWeightDao.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PatientWeightDaoImpl.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PatientWeightService2.java
- platform-common/src/main/java/com/lyms/platform/common/utils/ReflectionUtils.java
- 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-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IPatientWeightDao.java
View file @
04a8732
| 1 | +package com.lyms.platform.biz.dal; | |
| 2 | + | |
| 3 | +import com.lyms.platform.pojo.PatientWeight; | |
| 4 | +import org.springframework.data.mongodb.core.query.Query; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * 体重管理 | |
| 8 | + */ | |
| 9 | +public interface IPatientWeightDao { | |
| 10 | + | |
| 11 | + void add(PatientWeight patientWeight); | |
| 12 | + | |
| 13 | + void updatePatient(Query query, PatientWeight patientWeight); | |
| 14 | + | |
| 15 | +} |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PatientWeightDaoImpl.java
View file @
04a8732
| 1 | +package com.lyms.platform.biz.dal.impl; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.dal.IPatientWeightDao; | |
| 4 | +import com.lyms.platform.common.dao.BaseMongoDAOImpl; | |
| 5 | +import com.lyms.platform.pojo.PatientWeight; | |
| 6 | +import org.springframework.data.mongodb.core.query.Query; | |
| 7 | +import org.springframework.stereotype.Repository; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 产前检查 初诊记录 | |
| 11 | + */ | |
| 12 | +@Repository | |
| 13 | +public class PatientWeightDaoImpl extends BaseMongoDAOImpl<PatientWeight> implements IPatientWeightDao { | |
| 14 | + | |
| 15 | + @Override | |
| 16 | + public void add(PatientWeight patientWeight) { | |
| 17 | + save(patientWeight); | |
| 18 | + } | |
| 19 | + | |
| 20 | + @Override | |
| 21 | + public void updatePatient(Query query, PatientWeight patientWeight) { | |
| 22 | + update(query, patientWeight); | |
| 23 | + } | |
| 24 | + | |
| 25 | +} |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PatientWeightService2.java
View file @
04a8732
| 1 | +package com.lyms.platform.biz.service; | |
| 2 | + | |
| 3 | + | |
| 4 | +import com.lyms.platform.biz.dal.IPatientWeightDao; | |
| 5 | +import com.lyms.platform.pojo.PatientWeight; | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.data.mongodb.core.query.Query; | |
| 8 | +import org.springframework.stereotype.Service; | |
| 9 | + | |
| 10 | +@Service | |
| 11 | +public class PatientWeightService2 { | |
| 12 | + | |
| 13 | + @Autowired | |
| 14 | + private IPatientWeightDao patientWeightDao; | |
| 15 | + | |
| 16 | + public void add(PatientWeight patientWeight) { | |
| 17 | + patientWeightDao.add(patientWeight); | |
| 18 | + } | |
| 19 | + | |
| 20 | + public void update(Query query, PatientWeight patientWeight) { | |
| 21 | + patientWeightDao.updatePatient(query, patientWeight); | |
| 22 | + } | |
| 23 | +} |
platform-common/src/main/java/com/lyms/platform/common/utils/ReflectionUtils.java
View file @
04a8732
| ... | ... | @@ -9,9 +9,12 @@ |
| 9 | 9 | import java.lang.reflect.ParameterizedType; |
| 10 | 10 | import java.lang.reflect.Type; |
| 11 | 11 | import java.util.HashMap; |
| 12 | +import java.util.Iterator; | |
| 12 | 13 | import java.util.Map; |
| 14 | +import java.util.Set; | |
| 13 | 15 | import java.util.concurrent.ConcurrentHashMap; |
| 14 | 16 | |
| 17 | +import org.apache.commons.collections.MapUtils; | |
| 15 | 18 | import org.apache.commons.lang.StringUtils; |
| 16 | 19 | import org.slf4j.Logger; |
| 17 | 20 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -62,6 +65,21 @@ |
| 62 | 65 | e.printStackTrace(); |
| 63 | 66 | } |
| 64 | 67 | return map; |
| 68 | + | |
| 69 | + } | |
| 70 | + | |
| 71 | + public static Map<String, String> beanToStrMap(Object obj) { | |
| 72 | + Map<String, Object> map = beanToMap(obj); | |
| 73 | + Map<String, String> restMap = new HashMap<>(); | |
| 74 | + if(MapUtils.isNotEmpty(map)) { | |
| 75 | + Set<Map.Entry<String, Object>> entries = map.entrySet(); | |
| 76 | + Iterator<Map.Entry<String, Object>> iterator = entries.iterator(); | |
| 77 | + while (iterator.hasNext()) { | |
| 78 | + Map.Entry<String, Object> entry = iterator.next(); | |
| 79 | + restMap.put(entry.getKey(), entry.getValue() + ""); | |
| 80 | + } | |
| 81 | + } | |
| 82 | + return restMap; | |
| 65 | 83 | |
| 66 | 84 | } |
| 67 | 85 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientWeightController.java
View file @
04a8732
| ... | ... | @@ -109,5 +109,15 @@ |
| 109 | 109 | return patientWeightService.wxAddOrUpdate(patientWeight); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | + /** | |
| 113 | + * 保存修改体重报告(小程序使用) | |
| 114 | + * @return | |
| 115 | + */ | |
| 116 | + @ResponseBody | |
| 117 | + @RequestMapping(value = "/wx/sync", method = RequestMethod.POST) | |
| 118 | + public BaseResponse wxAddOrUpdateSync(PatientWeight patientWeight) { | |
| 119 | + return patientWeightService.wxAddOrUpdateSync(patientWeight); | |
| 120 | + } | |
| 121 | + | |
| 112 | 122 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PatientWeightService.java
View file @
04a8732
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
View file @
04a8732
| 1 | 1 | package com.lyms.platform.operate.web.service.impl; |
| 2 | 2 | |
| 3 | +import com.lyms.platform.biz.service.PatientWeightService2; | |
| 4 | +import com.lyms.platform.biz.service.PatientsService; | |
| 3 | 5 | import com.lyms.platform.common.enums.*; |
| 4 | 6 | import com.lyms.platform.common.result.BaseResponse; |
| 5 | 7 | import com.lyms.platform.common.result.PageResult; |
| 6 | 8 | |
| ... | ... | @@ -40,8 +42,11 @@ |
| 40 | 42 | private MongoUtil mongoUtil; |
| 41 | 43 | |
| 42 | 44 | @Autowired |
| 43 | - private AntenatalExaminationFacade antenatalExaminationFacade; | |
| 45 | + private PatientWeightService2 patientWeightService2; | |
| 44 | 46 | |
| 47 | + @Autowired | |
| 48 | + private PatientsService patientsService; | |
| 49 | + | |
| 45 | 50 | /** |
| 46 | 51 | * 最低:0~13 : 0~1.9 13~40 1.9~11.9 |
| 47 | 52 | * 最高: 0~2.2 2.2~15.9 |
| ... | ... | @@ -79,7 +84,8 @@ |
| 79 | 84 | patients.setEnable("2"); |
| 80 | 85 | patients.setSource(patientWeight.getPatientId()); |
| 81 | 86 | patients.setCreated(new Date()); |
| 82 | - mongoTemplate.save(patients); | |
| 87 | +// mongoTemplate.save(patients); | |
| 88 | + patientsService.addPatient(patients); | |
| 83 | 89 | patientWeight.setPatientId(patients.getId()); |
| 84 | 90 | } |
| 85 | 91 | Map<String, String> dayWeights = new HashMap<>(); |
| ... | ... | @@ -90,9 +96,9 @@ |
| 90 | 96 | dayWeights.put(DateUtil.getyyyy_MM_dd(new Date()), nowWeight); |
| 91 | 97 | pw.setDayWeights(dayWeights); |
| 92 | 98 | pw.setNowWeight(patientWeight.getNowWeight()); |
| 93 | -// pw.setBmi(getBmi(patientWeight.getNowWeight(), pw.getBeforeHeight())); | |
| 94 | - Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(pw)); | |
| 95 | - mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(pw.getId())), update, PatientWeight.class); | |
| 99 | +// Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(pw)); | |
| 100 | +// mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(pw.getId())), update, PatientWeight.class); | |
| 101 | + patientWeightService2.update(Query.query(Criteria.where("id").is(pw.getId())), pw); | |
| 96 | 102 | return RespBuilder.buildSuccess(pw.getId()); |
| 97 | 103 | } |
| 98 | 104 | |
| 99 | 105 | |
| ... | ... | @@ -109,12 +115,14 @@ |
| 109 | 115 | patientWeight.setBmi(getBmi(patientWeight.getBeforeWeight(), patientWeight.getBeforeHeight())); |
| 110 | 116 | } |
| 111 | 117 | patientWeight.setYn("1"); |
| 112 | - mongoTemplate.save(patientWeight); | |
| 118 | +// mongoTemplate.save(patientWeight); | |
| 119 | + patientWeightService2.add(patientWeight); | |
| 113 | 120 | return RespBuilder.buildSuccess(patientWeight.getId()); |
| 114 | 121 | } else { |
| 115 | 122 | patientWeight.setOperaterId(userId.toString()); |
| 116 | - Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(patientWeight)); | |
| 117 | - mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(patientWeight.getId())), update, PatientWeight.class); | |
| 123 | +// Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(patientWeight)); | |
| 124 | +// mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(patientWeight.getId())), update, PatientWeight.class); | |
| 125 | + patientWeightService2.update(Query.query(Criteria.where("id").is(patientWeight.getId())), patientWeight); | |
| 118 | 126 | return RespBuilder.buildSuccess(patientWeight.getId()); |
| 119 | 127 | } |
| 120 | 128 | } |
| ... | ... | @@ -260,7 +268,11 @@ |
| 260 | 268 | map.put("beforeWeight", patientWeight.getBeforeWeight() + " 公斤"); |
| 261 | 269 | map.put("bmi", patientWeight.getBmi()); |
| 262 | 270 | map.put("nowWeight", patientWeight.getNowWeight() + " 公斤"); |
| 263 | - map.put("pregnancy", DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); | |
| 271 | + String pregnancy = DateUtil.getWeekDesc(patients.getLastMenses(), new Date()); | |
| 272 | + if(StringUtils.isNotEmpty(pregnancy) && pregnancy.endsWith("0天")) { | |
| 273 | + pregnancy.replaceAll("\\+0天", ""); | |
| 274 | + } | |
| 275 | + map.put("pregnancy", pregnancy); | |
| 264 | 276 | if(week != null) { |
| 265 | 277 | setInfo(week, map); // 设置孕期相关营养信息 |
| 266 | 278 | setRecipe(week, map); // 设置食谱 |
| 267 | 279 | |
| ... | ... | @@ -322,8 +334,53 @@ |
| 322 | 334 | dayWeights.put(DateUtil.getyyyy_MM_dd(new Date()), nowWeight); |
| 323 | 335 | pw.setNowWeight(nowWeight); |
| 324 | 336 | pw.setDayWeights(dayWeights); |
| 337 | +// Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(pw)); | |
| 338 | +// mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(pw.getId())), update, PatientWeight.class); | |
| 339 | + patientWeightService2.update(Query.query(Criteria.where("id").is(pw.getId())), pw); | |
| 340 | + return RespBuilder.buildSuccess(pw.getId()); | |
| 341 | + } | |
| 342 | + | |
| 343 | + if(StringUtils.isEmpty(patientWeight.getId()) && patients != null) { | |
| 344 | + patientWeight.setCreated(new Date()); | |
| 345 | + patientWeight.setHospitalId(patients.getHospitalId()); | |
| 346 | + if(StringUtils.isNotBlank(patientWeight.getNowWeight()) && patientWeight.getBeforeHeight() != null) { | |
| 347 | + patientWeight.setBmi(getBmi(patientWeight.getNowWeight(), patientWeight.getBeforeHeight())); | |
| 348 | + } | |
| 349 | + patientWeight.setYn("1"); | |
| 350 | + patientWeight.setPid(patients.getPid()); | |
| 351 | +// mongoTemplate.save(patientWeight); | |
| 352 | + patientWeightService2.add(patientWeight); | |
| 353 | + return RespBuilder.buildSuccess(patientWeight.getId()); | |
| 354 | + } else { | |
| 355 | +// Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(patientWeight)); | |
| 356 | +// mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(patientWeight.getId())), update, PatientWeight.class); | |
| 357 | + patientWeightService2.update(Query.query(Criteria.where("id").is(patientWeight.getId())), patientWeight); | |
| 358 | + return RespBuilder.buildSuccess(patientWeight.getId()); | |
| 359 | + } | |
| 360 | + } | |
| 361 | + | |
| 362 | + @Override | |
| 363 | + public BaseResponse wxAddOrUpdateSync(PatientWeight patientWeight) { | |
| 364 | + String nowWeight = patientWeight.getNowWeight(); | |
| 365 | + Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); | |
| 366 | + PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(patientWeight.getPid())), PatientWeight.class); | |
| 367 | + Map<String, String> dayWeights = new HashMap<>(); | |
| 368 | + if(pw == null && StringUtils.isEmpty(patientWeight.getBeforeWeight())) { | |
| 369 | + return RespBuilder.buildErro(ResponseCode.NEED_ADD_PATIENT_WEIGHT); | |
| 370 | + } | |
| 371 | + if(pw != null && StringUtils.isNotEmpty(patientWeight.getBeforeWeight())) { | |
| 372 | + return RespBuilder.buildErro(ResponseCode.PATIENT_WEIGHT_IS_EXIST); | |
| 373 | + } | |
| 374 | + if(pw != null) { | |
| 375 | + if(MapUtils.isNotEmpty(pw.getDayWeights())) { | |
| 376 | + dayWeights = pw.getDayWeights(); | |
| 377 | + } | |
| 378 | + dayWeights.put(DateUtil.getyyyy_MM_dd(new Date()), nowWeight); | |
| 379 | + pw.setNowWeight(nowWeight); | |
| 380 | + pw.setDayWeights(dayWeights); | |
| 325 | 381 | Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(pw)); |
| 326 | 382 | mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(pw.getId())), update, PatientWeight.class); |
| 383 | +// patientWeightService2.update(Query.query(Criteria.where("id").is(pw.getId())), pw); | |
| 327 | 384 | return RespBuilder.buildSuccess(pw.getId()); |
| 328 | 385 | } |
| 329 | 386 | |
| 330 | 387 | |
| ... | ... | @@ -336,10 +393,12 @@ |
| 336 | 393 | patientWeight.setYn("1"); |
| 337 | 394 | patientWeight.setPid(patients.getPid()); |
| 338 | 395 | mongoTemplate.save(patientWeight); |
| 396 | +// patientWeightService2.add(patientWeight); | |
| 339 | 397 | return RespBuilder.buildSuccess(patientWeight.getId()); |
| 340 | 398 | } else { |
| 341 | 399 | Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(patientWeight)); |
| 342 | 400 | mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(patientWeight.getId())), update, PatientWeight.class); |
| 401 | +// patientWeightService2.update(Query.query(Criteria.where("id").is(patientWeight.getId())), patientWeight); | |
| 343 | 402 | return RespBuilder.buildSuccess(patientWeight.getId()); |
| 344 | 403 | } |
| 345 | 404 | } |