Commit b6f7aad3354d7e8579cc17c842b3dd8ea3032adf
1 parent
b7b73683a5
Exists in
master
and in
1 other branch
优化
Showing 1 changed file with 13 additions and 6 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
View file @
b6f7aad
... | ... | @@ -200,33 +200,40 @@ |
200 | 200 | |
201 | 201 | @Override |
202 | 202 | public BaseResponse list(String key, String vcCardNo, Integer currentWeekStart, Integer currentWeekEnd, Integer age, Integer page, Integer limit, Integer userId) { |
203 | + boolean flag = false; | |
203 | 204 | List<String> hospital = groupsFacade.findGroupHospital(userId, true) ; |
204 | 205 | Criteria criteria = Criteria.where("yn").ne("0").and("hospitalId").in(hospital); |
205 | 206 | Criteria pCriteria = Criteria.where("yn").ne("0").and("hospitalId").in(hospital); |
206 | 207 | if(StringUtils.isNotBlank(key)) { |
207 | 208 | pCriteria.orOperator(Criteria.where("phone").regex(key), Criteria.where("username").regex(key), Criteria.where("cardNo").is(key)); |
209 | + flag = true; | |
208 | 210 | } |
209 | 211 | if(StringUtils.isNotBlank(vcCardNo)) { |
210 | 212 | pCriteria.and("vcCardNo").is(vcCardNo); |
213 | + flag = true; | |
211 | 214 | } |
212 | 215 | if(currentWeekStart != null && currentWeekEnd != null) { |
213 | 216 | Date start = DateUtil.getWeekStart(currentWeekEnd); |
214 | 217 | Date end = DateUtil.getWeekEnd(currentWeekStart); |
215 | 218 | pCriteria.and("lastMenses").gt(start).lte(end); |
219 | + flag = true; | |
216 | 220 | } |
217 | 221 | if(age != null) { |
218 | 222 | Date start = DateUtil.getBeforeAge(age); |
219 | 223 | Date end = DateUtil.getBeforeAge(age + 1); |
220 | 224 | pCriteria.and("birth").gt(end).lte(start); |
225 | + flag = true; | |
221 | 226 | } |
222 | - List<Patients> patients = mongoTemplate.find(Query.query(pCriteria), Patients.class); | |
223 | - List<String> ids = new ArrayList<>(); | |
224 | - if(CollectionUtils.isNotEmpty(patients)) { | |
225 | - for (Patients patient : patients) { | |
226 | - ids.add(patient.getId()); | |
227 | + if(flag) { | |
228 | + List<Patients> patients = mongoTemplate.find(Query.query(pCriteria), Patients.class); | |
229 | + List<String> ids = new ArrayList<>(); | |
230 | + if(CollectionUtils.isNotEmpty(patients)) { | |
231 | + for (Patients patient : patients) { | |
232 | + ids.add(patient.getId()); | |
233 | + } | |
227 | 234 | } |
235 | + criteria.and("patientId").in(ids); | |
228 | 236 | } |
229 | - criteria.and("patientId").in(ids); | |
230 | 237 | |
231 | 238 | PageResult pageResult = findMongoPage(PatientWeight.class, new Query(criteria).with(new Sort(Sort.Direction.DESC, "created")), page, limit); |
232 | 239 | List<PatientWeight> patientWeights = (List<PatientWeight>) pageResult.getGrid(); |