Commit 67b52e9cc91b19280fc9d7b57107fe4bd5c137b8
Exists in
master
and in
6 other branches
Merge remote-tracking branch 'origin/master'
Showing 2 changed files
platform-dal/src/main/java/com/lyms/platform/pojo/PatientWeight.java
View file @
67b52e9
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 | |
25 | 25 | private String patientId; |
26 | 26 | |
27 | - // 证件号 | |
27 | + /* // 证件号 | |
28 | 28 | private String cardNo; |
29 | 29 | |
30 | 30 | // 就诊卡号 |
31 | 31 | |
... | ... | @@ -39,8 +39,10 @@ |
39 | 39 | // 生日 |
40 | 40 | private Date birth; |
41 | 41 | |
42 | + private Date lastMenses; | |
43 | + | |
42 | 44 | // 证件类型 |
43 | - private String pcerteTypeId; | |
45 | + private String pcerteTypeId;*/ | |
44 | 46 | |
45 | 47 | // 孕前体重 |
46 | 48 | private String beforeWeight; |
... | ... | @@ -61,7 +63,6 @@ |
61 | 63 | |
62 | 64 | private String bmi; |
63 | 65 | |
64 | - private Date lastMenses; | |
65 | 66 | |
66 | 67 | public Map<Integer, String> getWeights() { |
67 | 68 | return weights; |
... | ... | @@ -71,38 +72,6 @@ |
71 | 72 | this.weights = weights; |
72 | 73 | } |
73 | 74 | |
74 | - public String getVcCardNo() { | |
75 | - return vcCardNo; | |
76 | - } | |
77 | - | |
78 | - public void setVcCardNo(String vcCardNo) { | |
79 | - this.vcCardNo = vcCardNo; | |
80 | - } | |
81 | - | |
82 | - public String getUsername() { | |
83 | - return username; | |
84 | - } | |
85 | - | |
86 | - public void setUsername(String username) { | |
87 | - this.username = username; | |
88 | - } | |
89 | - | |
90 | - public String getPhone() { | |
91 | - return phone; | |
92 | - } | |
93 | - | |
94 | - public void setPhone(String phone) { | |
95 | - this.phone = phone; | |
96 | - } | |
97 | - | |
98 | - public Date getBirth() { | |
99 | - return birth; | |
100 | - } | |
101 | - | |
102 | - public void setBirth(Date birth) { | |
103 | - this.birth = birth; | |
104 | - } | |
105 | - | |
106 | 75 | public String getBmi() { |
107 | 76 | return bmi; |
108 | 77 | } |
... | ... | @@ -199,28 +168,5 @@ |
199 | 168 | this.bregmaticOther = bregmaticOther; |
200 | 169 | } |
201 | 170 | |
202 | - public Date getLastMenses() { | |
203 | - return lastMenses; | |
204 | - } | |
205 | - | |
206 | - public void setLastMenses(Date lastMenses) { | |
207 | - this.lastMenses = lastMenses; | |
208 | - } | |
209 | - | |
210 | - public String getCardNo() { | |
211 | - return cardNo; | |
212 | - } | |
213 | - | |
214 | - public void setCardNo(String cardNo) { | |
215 | - this.cardNo = cardNo; | |
216 | - } | |
217 | - | |
218 | - public String getPcerteTypeId() { | |
219 | - return pcerteTypeId; | |
220 | - } | |
221 | - | |
222 | - public void setPcerteTypeId(String pcerteTypeId) { | |
223 | - this.pcerteTypeId = pcerteTypeId; | |
224 | - } | |
225 | 171 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
View file @
67b52e9
... | ... | @@ -86,31 +86,27 @@ |
86 | 86 | public BaseResponse addOrUpdate(Integer userId, PatientWeight patientWeight) { |
87 | 87 | String hospitalId = autoMatchFacade.getHospitalId(userId); |
88 | 88 | String nowWeight = patientWeight.getNowWeight(); |
89 | + Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); | |
89 | 90 | PatientWeight pw = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientWeight.getPatientId()).and("hospitalId").is(hospitalId)), PatientWeight.class); |
90 | 91 | Map<Integer, String> weights = new HashMap<>(); |
91 | 92 | if(pw != null) { |
92 | 93 | if(MapUtils.isNotEmpty(pw.getWeights())) { |
93 | 94 | weights = pw.getWeights(); |
94 | 95 | } |
95 | - weights.put(DateUtil.getWeek(pw.getLastMenses(), new Date()), nowWeight); | |
96 | + if(patients != null) { | |
97 | + weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); | |
98 | + } | |
96 | 99 | pw.setWeights(weights); |
97 | 100 | Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(pw)); |
98 | 101 | mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(pw.getId())), update, PatientWeight.class); |
99 | 102 | return RespBuilder.buildSuccess(pw.getId()); |
100 | 103 | } |
101 | 104 | |
102 | - if(StringUtils.isEmpty(patientWeight.getId())) { | |
105 | + if(StringUtils.isEmpty(patientWeight.getId()) && patients != null) { | |
103 | 106 | patientWeight.setHospitalId(hospitalId); |
104 | 107 | patientWeight.setOperaterId(userId.toString()); |
105 | 108 | patientWeight.setCreated(new Date()); |
106 | 109 | if(StringUtils.isNotBlank(patientWeight.getPatientId())) { |
107 | - Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); | |
108 | - patientWeight.setLastMenses(patients.getLastMenses()); | |
109 | - patientWeight.setVcCardNo(patients.getVcCardNo()); | |
110 | - patientWeight.setCardNo(patients.getCardNo()); | |
111 | - patientWeight.setBirth(patients.getBirth()); | |
112 | - patientWeight.setUsername(patients.getUsername()); | |
113 | - patientWeight.setPhone(patients.getPhone()); | |
114 | 110 | weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); |
115 | 111 | patientWeight.setWeights(weights); |
116 | 112 | } |
117 | 113 | |
118 | 114 | |
119 | 115 | |
120 | 116 | |
121 | 117 | |
122 | 118 | |
123 | 119 | |
124 | 120 | |
... | ... | @@ -132,42 +128,52 @@ |
132 | 128 | public BaseResponse list(String key, String vcCardNo, Integer currentWeekStart, Integer currentWeekEnd, Integer age, Integer page, Integer limit, Integer userId) { |
133 | 129 | String hospitalId = autoMatchFacade.getHospitalId(userId); |
134 | 130 | Criteria criteria = Criteria.where("yn").ne("0").and("hospitalId").is(hospitalId); |
131 | + Criteria pCriteria = Criteria.where("yn").ne("0").and("hospitalId").is(hospitalId); | |
135 | 132 | if(StringUtils.isNotBlank(key)) { |
136 | - criteria.orOperator(Criteria.where("phone").regex(key), Criteria.where("username").regex(key), Criteria.where("cardNo").is(key)); | |
133 | + pCriteria.orOperator(Criteria.where("phone").regex(key), Criteria.where("username").regex(key), Criteria.where("cardNo").is(key)); | |
137 | 134 | } |
138 | 135 | if(StringUtils.isNotBlank(vcCardNo)) { |
139 | - criteria.and("vcCardNo").is(vcCardNo); | |
136 | + pCriteria.and("vcCardNo").is(vcCardNo); | |
140 | 137 | } |
141 | 138 | if(currentWeekStart != null && currentWeekEnd != null) { |
142 | 139 | Date start = DateUtil.getWeekStart(currentWeekEnd); |
143 | 140 | Date end = DateUtil.getWeekEnd(currentWeekStart); |
144 | - criteria.and("lastMenses").gt(start).lte(end); | |
141 | + pCriteria.and("lastMenses").gt(start).lte(end); | |
145 | 142 | } |
146 | 143 | if(age != null) { |
147 | 144 | Date start = DateUtil.getBeforeAge(1); |
148 | 145 | Date end = DateUtil.getBeforeAge(2); |
149 | - criteria.and("birth").lte(start).gt(end); | |
146 | + pCriteria.and("birth").lte(start).gt(end); | |
150 | 147 | } |
148 | + List<Patients> patients = mongoTemplate.find(Query.query(pCriteria), Patients.class); | |
149 | + List<String> ids = new ArrayList<>(); | |
150 | + if(CollectionUtils.isNotEmpty(patients)) { | |
151 | + for (Patients patient : patients) { | |
152 | + ids.add(patient.getId()); | |
153 | + } | |
154 | + } | |
155 | + criteria.and("patientId").in(ids); | |
156 | + | |
151 | 157 | PageResult pageResult = findMongoPage(PatientWeight.class, new Query(criteria).with(new Sort(Sort.Direction.DESC, "checkTime")), page, limit); |
152 | 158 | List<PatientWeight> patientWeights = (List<PatientWeight>) pageResult.getGrid(); |
153 | 159 | List<Map<String, Object>> restMap = new ArrayList<>(); |
154 | 160 | if(CollectionUtils.isNotEmpty(patientWeights)) { |
155 | 161 | for (PatientWeight patientWeight : patientWeights) { |
156 | - Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); | |
162 | + Patients p = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); | |
157 | 163 | if(patients != null) { |
158 | 164 | Map<String, Object> temp = new HashMap<>(); |
159 | 165 | temp.put("id", patientWeight.getId()); |
160 | - temp.put("username", patients.getUsername()); | |
161 | - temp.put("age", DateUtil.getAge(patients.getBirth())); | |
162 | - temp.put("week", DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); | |
166 | + temp.put("username", p.getUsername()); | |
167 | + temp.put("age", DateUtil.getAge(p.getBirth())); | |
168 | + temp.put("week", DateUtil.getWeekDesc(p.getLastMenses(), new Date())); | |
163 | 169 | temp.put("beforeWeight", patientWeight.getBeforeWeight()); |
164 | 170 | temp.put("beforeHeight", patientWeight.getBeforeHeight()); |
165 | 171 | temp.put("bim", patientWeight.getBmi()); // 体质指数(BMI)=体重(kg)÷身高^2(m) |
166 | 172 | temp.put("nowWeight", patientWeight.getNowWeight()); |
167 | 173 | |
168 | - temp.put("vcCardNo", patients.getVcCardNo()); | |
169 | - temp.put("pcerteTypeId", patients.getPcerteTypeId()); | |
170 | - temp.put("cardNo", patients.getCardNo()); | |
174 | + temp.put("vcCardNo", p.getVcCardNo()); | |
175 | + temp.put("pcerteTypeId", p.getPcerteTypeId()); | |
176 | + temp.put("cardNo", p.getCardNo()); | |
171 | 177 | restMap.add(temp); |
172 | 178 | } |
173 | 179 | } |
... | ... | @@ -244,8 +250,8 @@ |
244 | 250 | map.put("beforeWeight", patientWeight.getBeforeWeight()); |
245 | 251 | map.put("bmi", patientWeight.getBmi()); |
246 | 252 | map.put("nowWeight", patientWeight.getNowWeight()); |
247 | - map.put("pregnancy", DateUtil.getWeekDesc(patientWeight.getLastMenses(), new Date())); | |
248 | - Integer week = DateUtil.getWeek(patientWeight.getLastMenses(), new Date()); | |
253 | + map.put("pregnancy", DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); | |
254 | + Integer week = DateUtil.getWeek(patients.getLastMenses(), new Date()); | |
249 | 255 | if(week != null) { |
250 | 256 | setInfo(week, map); // 设置孕期相关营养信息 |
251 | 257 | setRecipe(week, map); // 设置食谱 |