diff --git a/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java b/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java index d3e5daa..e72b585 100644 --- a/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java +++ b/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java @@ -976,6 +976,7 @@ public class DateUtil { /** * 获取孕周 + * 上面写的有bug 有时候会多一周!!! * @param start * @param end * @return diff --git a/platform-dal/src/main/java/com/lyms/platform/pojo/PatientWeight.java b/platform-dal/src/main/java/com/lyms/platform/pojo/PatientWeight.java index dc64245..ca6c01e 100644 --- a/platform-dal/src/main/java/com/lyms/platform/pojo/PatientWeight.java +++ b/platform-dal/src/main/java/com/lyms/platform/pojo/PatientWeight.java @@ -33,8 +33,6 @@ public class PatientWeight { // 当前体重 private String nowWeight; - private Map weights; - // 存储 年月日 = xxKG private Map dayWeights; @@ -54,14 +52,6 @@ public class PatientWeight { this.dayWeights = dayWeights; } - public Map getWeights() { - return weights; - } - - public void setWeights(Map weights) { - this.weights = weights; - } - public String getBmi() { return bmi; } 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 2706ae0..d4b3ac3 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 @@ -64,20 +64,12 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient if(pw != null && StringUtils.isNotEmpty(patientWeight.getBeforeWeight())) { return RespBuilder.buildErro(ResponseCode.PATIENT_WEIGHT_IS_EXIST); } - Map weights = new HashMap<>(); Map dayWeights = new HashMap<>(); if(pw != null) { - if(MapUtils.isNotEmpty(pw.getWeights())) { - weights = pw.getWeights(); - } if(MapUtils.isNotEmpty(pw.getDayWeights())) { dayWeights = pw.getDayWeights(); } dayWeights.put(DateUtil.getyyyy_MM_dd(new Date()), nowWeight); - if(patients != null) { - weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); - } - pw.setWeights(weights); pw.setDayWeights(dayWeights); pw.setNowWeight(patientWeight.getNowWeight()); pw.setBmi(getBmi(patientWeight.getNowWeight(), pw.getBeforeHeight())); @@ -92,10 +84,6 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient patientWeight.setHospitalId(hospitalId); patientWeight.setOperaterId(userId.toString()); patientWeight.setCreated(new Date()); - if(StringUtils.isNotBlank(patientWeight.getPatientId())) { - weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); - patientWeight.setWeights(weights); - } if(StringUtils.isNotBlank(patientWeight.getNowWeight()) && patientWeight.getBeforeHeight() != null) { patientWeight.setBmi(getBmi(patientWeight.getNowWeight(), patientWeight.getBeforeHeight())); } @@ -185,11 +173,24 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient public BaseResponse info(String id) { PatientWeight patientWeight = mongoTemplate.findById(id, PatientWeight.class); if(patientWeight != null) { + Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); + if(patients == null) { + return RespBuilder.buildSuccess("建档数据未找到"); + } Map map = ReflectionUtils.beanToMap(patientWeight); map.put("bregmatic", BregmaticEnums2.getName(patientWeight.getBregmatic())); map.put("bim", patientWeight.getBmi()); // 体质指数(BMI)=体重(kg)÷身高^2(m) - setReport(map, patientWeight.getWeights(), patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights()); + Map dayWeights = patientWeight.getDayWeights(); + Map weights = new HashMap<>(); + if (MapUtils.isNotEmpty(dayWeights)) { + Set> entries = dayWeights.entrySet(); + for (Map.Entry entry : entries) { + weights.put(DateUtil.getWeek2(patients.getLastMenses(), DateUtil.parseYMD(entry.getKey())), entry.getValue()); + } + } + + setReport(map, weights, patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights()); CollectionUtils.removeNullValue(map); return RespBuilder.buildSuccess(map); @@ -243,7 +244,16 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient setRecipe(week, map); // 设置食谱 setGuide(week, map); // 设置指南 } - setReport(map, patientWeight.getWeights(), patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights()); + + Map dayWeights = patientWeight.getDayWeights(); + Map weights = new HashMap<>(); + if (MapUtils.isNotEmpty(dayWeights)) { + Set> entries = dayWeights.entrySet(); + for (Map.Entry entry : entries) { + weights.put(DateUtil.getWeek2(patients.getLastMenses(), DateUtil.parseYMD(entry.getKey())), entry.getValue()); + } + } + setReport(map, weights, patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights()); CollectionUtils.removeNullValue(map); return RespBuilder.buildSuccess(map); } @@ -256,7 +266,16 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient if(patientWeight != null) { Map map = new HashMap<>(); map.put("beforeWeight", patientWeight.getBeforeWeight()); - setAppReport(map, patientWeight.getWeights(), patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights()); + Patients patients = mongoTemplate.findById(patientId, Patients.class); + Map dayWeights = patientWeight.getDayWeights(); + Map weights = new HashMap<>(); + if (MapUtils.isNotEmpty(dayWeights)) { + Set> entries = dayWeights.entrySet(); + for (Map.Entry entry : entries) { + weights.put(DateUtil.getWeek2(patients.getLastMenses(), DateUtil.parseYMD(entry.getKey())), entry.getValue()); + } + } + setAppReport(map, weights, patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights()); return RespBuilder.buildSuccess(map); } return RespBuilder.buildSuccess(); @@ -267,7 +286,6 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient String nowWeight = patientWeight.getNowWeight(); Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientWeight.getPatientId())), PatientWeight.class); - Map weights = new HashMap<>(); Map dayWeights = new HashMap<>(); if(pw == null && StringUtils.isEmpty(patientWeight.getBeforeWeight())) { return RespBuilder.buildErro(ResponseCode.NEED_ADD_PATIENT_WEIGHT); @@ -276,9 +294,6 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient return RespBuilder.buildErro(ResponseCode.PATIENT_WEIGHT_IS_EXIST); } if(pw != null) { - if(MapUtils.isNotEmpty(pw.getWeights())) { - weights = pw.getWeights(); - } if(MapUtils.isNotEmpty(pw.getDayWeights())) { dayWeights = pw.getDayWeights(); } @@ -286,10 +301,6 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient pw.setNowWeight(nowWeight); pw.setBmi(getBmi(patientWeight.getNowWeight(), pw.getBeforeHeight())); pw.setDayWeights(dayWeights); - if(patients != null && StringUtils.isNotEmpty(nowWeight)) { - weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); - } - pw.setWeights(weights); pw.setBmi(getBmi(patientWeight.getNowWeight(), pw.getBeforeHeight())); Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(pw)); mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(pw.getId())), update, PatientWeight.class); @@ -299,10 +310,6 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient if(StringUtils.isEmpty(patientWeight.getId()) && patients != null) { patientWeight.setCreated(new Date()); patientWeight.setHospitalId(patients.getHospitalId()); - if(StringUtils.isNotBlank(patientWeight.getPatientId()) && StringUtils.isNotEmpty(patientWeight.getNowWeight())) { - weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); - } - patientWeight.setWeights(weights); if(StringUtils.isNotBlank(patientWeight.getNowWeight()) && patientWeight.getBeforeHeight() != null) { patientWeight.setBmi(getBmi(patientWeight.getNowWeight(), patientWeight.getBeforeHeight())); }