From 1f3b9e0144714338d780136bdf71a9fd83f4bd98 Mon Sep 17 00:00:00 2001 From: "litao@lymsh.com" Date: Mon, 18 Sep 2017 13:49:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=93=E9=87=8D=E7=AE=A1=E7=90=86=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/lyms/platform/pojo/PatientWeight.java | 62 ++-------------------- .../web/service/impl/PatientWeightServiceImpl.java | 50 +++++++++-------- 2 files changed, 32 insertions(+), 80 deletions(-) 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 97c1ab2..ff1b04c 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 @@ -24,7 +24,7 @@ public class PatientWeight { private String patientId; - // 证件号 + /* // 证件号 private String cardNo; // 就诊卡号 @@ -39,8 +39,10 @@ public class PatientWeight { // 生日 private Date birth; + private Date lastMenses; + // 证件类型 - private String pcerteTypeId; + private String pcerteTypeId;*/ // 孕前体重 private String beforeWeight; @@ -61,7 +63,6 @@ public class PatientWeight { private String bmi; - private Date lastMenses; public Map getWeights() { return weights; @@ -71,38 +72,6 @@ public class PatientWeight { this.weights = weights; } - public String getVcCardNo() { - return vcCardNo; - } - - public void setVcCardNo(String vcCardNo) { - this.vcCardNo = vcCardNo; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - public Date getBirth() { - return birth; - } - - public void setBirth(Date birth) { - this.birth = birth; - } - public String getBmi() { return bmi; } @@ -199,27 +168,4 @@ public class PatientWeight { this.bregmaticOther = bregmaticOther; } - public Date getLastMenses() { - return lastMenses; - } - - public void setLastMenses(Date lastMenses) { - this.lastMenses = lastMenses; - } - - public String getCardNo() { - return cardNo; - } - - public void setCardNo(String cardNo) { - this.cardNo = cardNo; - } - - public String getPcerteTypeId() { - return pcerteTypeId; - } - - public void setPcerteTypeId(String pcerteTypeId) { - this.pcerteTypeId = pcerteTypeId; - } } 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 1a2598f..911f5c7 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 @@ -86,31 +86,27 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient public BaseResponse addOrUpdate(Integer userId, PatientWeight patientWeight) { String hospitalId = autoMatchFacade.getHospitalId(userId); String nowWeight = patientWeight.getNowWeight(); + Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientWeight.getPatientId()).and("hospitalId").is(hospitalId)), PatientWeight.class); Map weights = new HashMap<>(); if(pw != null) { if(MapUtils.isNotEmpty(pw.getWeights())) { weights = pw.getWeights(); } - weights.put(DateUtil.getWeek(pw.getLastMenses(), new Date()), nowWeight); + if(patients != null) { + weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); + } pw.setWeights(weights); Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(pw)); mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(pw.getId())), update, PatientWeight.class); return RespBuilder.buildSuccess(pw.getId()); } - if(StringUtils.isEmpty(patientWeight.getId())) { + if(StringUtils.isEmpty(patientWeight.getId()) && patients != null) { patientWeight.setHospitalId(hospitalId); patientWeight.setOperaterId(userId.toString()); patientWeight.setCreated(new Date()); if(StringUtils.isNotBlank(patientWeight.getPatientId())) { - Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); - patientWeight.setLastMenses(patients.getLastMenses()); - patientWeight.setVcCardNo(patients.getVcCardNo()); - patientWeight.setCardNo(patients.getCardNo()); - patientWeight.setBirth(patients.getBirth()); - patientWeight.setUsername(patients.getUsername()); - patientWeight.setPhone(patients.getPhone()); weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); patientWeight.setWeights(weights); } @@ -132,42 +128,52 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient public BaseResponse list(String key, String vcCardNo, Integer currentWeekStart, Integer currentWeekEnd, Integer age, Integer page, Integer limit, Integer userId) { String hospitalId = autoMatchFacade.getHospitalId(userId); Criteria criteria = Criteria.where("yn").ne("0").and("hospitalId").is(hospitalId); + Criteria pCriteria = Criteria.where("yn").ne("0").and("hospitalId").is(hospitalId); if(StringUtils.isNotBlank(key)) { - criteria.orOperator(Criteria.where("phone").regex(key), Criteria.where("username").regex(key), Criteria.where("cardNo").is(key)); + pCriteria.orOperator(Criteria.where("phone").regex(key), Criteria.where("username").regex(key), Criteria.where("cardNo").is(key)); } if(StringUtils.isNotBlank(vcCardNo)) { - criteria.and("vcCardNo").is(vcCardNo); + pCriteria.and("vcCardNo").is(vcCardNo); } if(currentWeekStart != null && currentWeekEnd != null) { Date start = DateUtil.getWeekStart(currentWeekEnd); Date end = DateUtil.getWeekEnd(currentWeekStart); - criteria.and("lastMenses").gt(start).lte(end); + pCriteria.and("lastMenses").gt(start).lte(end); } if(age != null) { Date start = DateUtil.getBeforeAge(1); Date end = DateUtil.getBeforeAge(2); - criteria.and("birth").lte(start).gt(end); + pCriteria.and("birth").lte(start).gt(end); } + List patients = mongoTemplate.find(Query.query(pCriteria), Patients.class); + List ids = new ArrayList<>(); + if(CollectionUtils.isNotEmpty(patients)) { + for (Patients patient : patients) { + ids.add(patient.getId()); + } + } + criteria.and("patientId").in(ids); + PageResult pageResult = findMongoPage(PatientWeight.class, new Query(criteria).with(new Sort(Sort.Direction.DESC, "checkTime")), page, limit); List patientWeights = (List) pageResult.getGrid(); List> restMap = new ArrayList<>(); if(CollectionUtils.isNotEmpty(patientWeights)) { for (PatientWeight patientWeight : patientWeights) { - Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); + Patients p = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); if(patients != null) { Map temp = new HashMap<>(); temp.put("id", patientWeight.getId()); - temp.put("username", patients.getUsername()); - temp.put("age", DateUtil.getAge(patients.getBirth())); - temp.put("week", DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); + temp.put("username", p.getUsername()); + temp.put("age", DateUtil.getAge(p.getBirth())); + temp.put("week", DateUtil.getWeekDesc(p.getLastMenses(), new Date())); temp.put("beforeWeight", patientWeight.getBeforeWeight()); temp.put("beforeHeight", patientWeight.getBeforeHeight()); temp.put("bim", patientWeight.getBmi()); // 体质指数(BMI)=体重(kg)÷身高^2(m) temp.put("nowWeight", patientWeight.getNowWeight()); - temp.put("vcCardNo", patients.getVcCardNo()); - temp.put("pcerteTypeId", patients.getPcerteTypeId()); - temp.put("cardNo", patients.getCardNo()); + temp.put("vcCardNo", p.getVcCardNo()); + temp.put("pcerteTypeId", p.getPcerteTypeId()); + temp.put("cardNo", p.getCardNo()); restMap.add(temp); } } @@ -244,8 +250,8 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient map.put("beforeWeight", patientWeight.getBeforeWeight()); map.put("bmi", patientWeight.getBmi()); map.put("nowWeight", patientWeight.getNowWeight()); - map.put("pregnancy", DateUtil.getWeekDesc(patientWeight.getLastMenses(), new Date())); - Integer week = DateUtil.getWeek(patientWeight.getLastMenses(), new Date()); + map.put("pregnancy", DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); + Integer week = DateUtil.getWeek(patients.getLastMenses(), new Date()); if(week != null) { setInfo(week, map); // 设置孕期相关营养信息 setRecipe(week, map); // 设置食谱 -- 1.8.3.1