From 31f5aec848ba6a57da84fe5d7e003fd3a379627b Mon Sep 17 00:00:00 2001 From: "litao@lymsh.com" Date: Wed, 18 Oct 2017 14:58:08 +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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/lyms/platform/pojo/PatientWeight.java | 13 ++++-- .../web/service/impl/PatientWeightServiceImpl.java | 48 +++++++++++++++++++--- 2 files changed, 53 insertions(+), 8 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 bcec2be..ddcd7f8 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 @@ -4,16 +4,23 @@ import com.lyms.platform.beans.SerialIdEnum; import com.lyms.platform.common.result.BaseModel; import org.springframework.data.mongodb.core.mapping.Document; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import java.util.*; /** * 孕产妇体重管理 */ @Document(collection="lyms_patient_weight") public class PatientWeight extends BaseModel { + // 存储 key=年月日 value=时间+医院+体重 + private List> dayWeights2 = new ArrayList<>(); + public List> getDayWeights2() { + return dayWeights2; + } + + public void setDayWeights2(List> dayWeights2) { + this.dayWeights2 = dayWeights2; + } private static final long serialVersionUID = SerialIdEnum.PatientWeight.getCid(); 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 ce238a4..470383b 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 @@ -14,6 +14,7 @@ import com.lyms.platform.operate.web.service.PatientWeightService; import com.lyms.platform.operate.web.utils.CollectionUtils; import com.lyms.platform.operate.web.utils.MathUtil; import com.lyms.platform.operate.web.utils.MongoUtil; +import com.lyms.platform.permission.dao.master.CouponMapper; import com.lyms.platform.pojo.PatientWeight; import com.lyms.platform.pojo.Patients; import net.sf.json.JSONObject; @@ -48,6 +49,9 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient @Autowired private PatientsService patientsService; + @Autowired + private CouponMapper couponMapper; + /** * 最低:0~13 : 0~1.9 13~40 1.9~11.9 * 最高: 0~2.2 2.2~15.9 @@ -65,7 +69,8 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient 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); +// PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientWeight.getPatientId()).and("hospitalId").is(hospitalId)), PatientWeight.class); + PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientWeight.getPatientId())), PatientWeight.class); if(pw == null && StringUtils.isEmpty(patientWeight.getBeforeWeight())) { patients = mongoTemplate.findOne(Query.query(Criteria.where("source").is(patientWeight.getPatientId()).and("hospitalId").is(hospitalId).and("enable").is("2")), Patients.class); if(patients == null) { @@ -75,9 +80,9 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patients.getId()).and("hospitalId").is(hospitalId)), PatientWeight.class); } - if(pw != null && StringUtils.isNotEmpty(patientWeight.getBeforeWeight())) { + /* if(pw != null && StringUtils.isNotEmpty(patientWeight.getBeforeWeight())) { return RespBuilder.buildErro(ResponseCode.PATIENT_WEIGHT_IS_EXIST); - } + }*/ if(patients != null && !hospitalId.equals(patients.getHospitalId())) {// 隐藏建档 patients.setId(null); @@ -90,6 +95,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient patientWeight.setPatientId(patients.getId()); } Map dayWeights = new LinkedHashMap<>(); + List> dayWeights2 = new ArrayList<>(); if(pw != null) { if(MapUtils.isNotEmpty(pw.getDayWeights())) { dayWeights = pw.getDayWeights(); @@ -97,8 +103,30 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient dayWeights.put(DateUtil.getyyyy_MM_dd(new Date()), nowWeight); pw.setDayWeights(dayWeights); pw.setNowWeight(patientWeight.getNowWeight()); -// Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(pw)); -// mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(pw.getId())), update, PatientWeight.class); + + String ymdDate = DateUtil.getyyyy_MM_dd(new Date()); + boolean flag = true; + if(CollectionUtils.isNotEmpty(pw.getDayWeights2())) { + dayWeights2 = pw.getDayWeights2(); + } + for (Map map : dayWeights2) { + if(map.containsKey(ymdDate)) { + flag = false; + map.put("hospitalId", hospitalId); + map.put("hospitalName", couponMapper.getHospitalName(hospitalId)); + map.put("date", ymdDate); + map.put("nowWeight", nowWeight); + } + } + if(flag) { + Map m = new HashMap<>(); + m.put("hospitalId", hospitalId); + m.put("hospitalName", couponMapper.getHospitalName(hospitalId)); + m.put("date", ymdDate); + m.put("nowWeight", nowWeight); + dayWeights2.add(m); + } + pw.setDayWeights2(dayWeights2); patientWeightService2.update(Query.query(Criteria.where("id").is(pw.getId())), pw); return RespBuilder.buildSuccess(pw.getId()); } @@ -117,6 +145,16 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient } patientWeight.setYn("1"); // mongoTemplate.save(patientWeight); + + + Map m = new HashMap<>(); + m.put("hospitalId", hospitalId); + m.put("hospitalName", couponMapper.getHospitalName(hospitalId)); + m.put("date", DateUtil.getyyyy_MM_dd(new Date())); + m.put("nowWeight", nowWeight); + dayWeights2.add(m); + patientWeight.setDayWeights2(dayWeights2); + patientWeightService2.add(patientWeight); return RespBuilder.buildSuccess(patientWeight.getId()); } else { -- 1.8.3.1