Commit 31f5aec848ba6a57da84fe5d7e003fd3a379627b

Authored by litao@lymsh.com
1 parent 08725dd0b9
Exists in master and in 1 other branch dev

体重管理修改

Showing 2 changed files with 53 additions and 8 deletions

platform-dal/src/main/java/com/lyms/platform/pojo/PatientWeight.java View file @ 31f5aec
... ... @@ -4,16 +4,23 @@
4 4 import com.lyms.platform.common.result.BaseModel;
5 5 import org.springframework.data.mongodb.core.mapping.Document;
6 6  
7   -import java.util.Date;
8   -import java.util.HashMap;
9   -import java.util.Map;
  7 +import java.util.*;
10 8  
11 9 /**
12 10 * 孕产妇体重管理
13 11 */
14 12 @Document(collection="lyms_patient_weight")
15 13 public class PatientWeight extends BaseModel {
  14 + // 存储 key=年月日 value=时间+医院+体重
  15 + private List<Map<String, Object>> dayWeights2 = new ArrayList<>();
16 16  
  17 + public List<Map<String, Object>> getDayWeights2() {
  18 + return dayWeights2;
  19 + }
  20 +
  21 + public void setDayWeights2(List<Map<String, Object>> dayWeights2) {
  22 + this.dayWeights2 = dayWeights2;
  23 + }
17 24  
18 25 private static final long serialVersionUID = SerialIdEnum.PatientWeight.getCid();
19 26  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java View file @ 31f5aec
... ... @@ -14,6 +14,7 @@
14 14 import com.lyms.platform.operate.web.utils.CollectionUtils;
15 15 import com.lyms.platform.operate.web.utils.MathUtil;
16 16 import com.lyms.platform.operate.web.utils.MongoUtil;
  17 +import com.lyms.platform.permission.dao.master.CouponMapper;
17 18 import com.lyms.platform.pojo.PatientWeight;
18 19 import com.lyms.platform.pojo.Patients;
19 20 import net.sf.json.JSONObject;
... ... @@ -48,6 +49,9 @@
48 49 @Autowired
49 50 private PatientsService patientsService;
50 51  
  52 + @Autowired
  53 + private CouponMapper couponMapper;
  54 +
51 55 /**
52 56 * 最低:0~13 : 0~1.9 13~40 1.9~11.9
53 57 * 最高: 0~2.2 2.2~15.9
... ... @@ -65,7 +69,8 @@
65 69 String hospitalId = autoMatchFacade.getHospitalId(userId);
66 70 String nowWeight = patientWeight.getNowWeight();
67 71 Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class);
68   - PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientWeight.getPatientId()).and("hospitalId").is(hospitalId)), PatientWeight.class);
  72 +// PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientWeight.getPatientId()).and("hospitalId").is(hospitalId)), PatientWeight.class);
  73 + PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientWeight.getPatientId())), PatientWeight.class);
69 74 if(pw == null && StringUtils.isEmpty(patientWeight.getBeforeWeight())) {
70 75 patients = mongoTemplate.findOne(Query.query(Criteria.where("source").is(patientWeight.getPatientId()).and("hospitalId").is(hospitalId).and("enable").is("2")), Patients.class);
71 76 if(patients == null) {
72 77  
... ... @@ -75,9 +80,9 @@
75 80 pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patients.getId()).and("hospitalId").is(hospitalId)), PatientWeight.class);
76 81 }
77 82  
78   - if(pw != null && StringUtils.isNotEmpty(patientWeight.getBeforeWeight())) {
  83 + /* if(pw != null && StringUtils.isNotEmpty(patientWeight.getBeforeWeight())) {
79 84 return RespBuilder.buildErro(ResponseCode.PATIENT_WEIGHT_IS_EXIST);
80   - }
  85 + }*/
81 86  
82 87 if(patients != null && !hospitalId.equals(patients.getHospitalId())) {// 隐藏建档
83 88 patients.setId(null);
... ... @@ -90,6 +95,7 @@
90 95 patientWeight.setPatientId(patients.getId());
91 96 }
92 97 Map<String, String> dayWeights = new LinkedHashMap<>();
  98 + List<Map<String, Object>> dayWeights2 = new ArrayList<>();
93 99 if(pw != null) {
94 100 if(MapUtils.isNotEmpty(pw.getDayWeights())) {
95 101 dayWeights = pw.getDayWeights();
... ... @@ -97,8 +103,30 @@
97 103 dayWeights.put(DateUtil.getyyyy_MM_dd(new Date()), nowWeight);
98 104 pw.setDayWeights(dayWeights);
99 105 pw.setNowWeight(patientWeight.getNowWeight());
100   -// Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(pw));
101   -// mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(pw.getId())), update, PatientWeight.class);
  106 +
  107 + String ymdDate = DateUtil.getyyyy_MM_dd(new Date());
  108 + boolean flag = true;
  109 + if(CollectionUtils.isNotEmpty(pw.getDayWeights2())) {
  110 + dayWeights2 = pw.getDayWeights2();
  111 + }
  112 + for (Map<String, Object> map : dayWeights2) {
  113 + if(map.containsKey(ymdDate)) {
  114 + flag = false;
  115 + map.put("hospitalId", hospitalId);
  116 + map.put("hospitalName", couponMapper.getHospitalName(hospitalId));
  117 + map.put("date", ymdDate);
  118 + map.put("nowWeight", nowWeight);
  119 + }
  120 + }
  121 + if(flag) {
  122 + Map<String, Object> m = new HashMap<>();
  123 + m.put("hospitalId", hospitalId);
  124 + m.put("hospitalName", couponMapper.getHospitalName(hospitalId));
  125 + m.put("date", ymdDate);
  126 + m.put("nowWeight", nowWeight);
  127 + dayWeights2.add(m);
  128 + }
  129 + pw.setDayWeights2(dayWeights2);
102 130 patientWeightService2.update(Query.query(Criteria.where("id").is(pw.getId())), pw);
103 131 return RespBuilder.buildSuccess(pw.getId());
104 132 }
... ... @@ -117,6 +145,16 @@
117 145 }
118 146 patientWeight.setYn("1");
119 147 // mongoTemplate.save(patientWeight);
  148 +
  149 +
  150 + Map<String, Object> m = new HashMap<>();
  151 + m.put("hospitalId", hospitalId);
  152 + m.put("hospitalName", couponMapper.getHospitalName(hospitalId));
  153 + m.put("date", DateUtil.getyyyy_MM_dd(new Date()));
  154 + m.put("nowWeight", nowWeight);
  155 + dayWeights2.add(m);
  156 + patientWeight.setDayWeights2(dayWeights2);
  157 +
120 158 patientWeightService2.add(patientWeight);
121 159 return RespBuilder.buildSuccess(patientWeight.getId());
122 160 } else {