Commit 01615015514bb2789e4c16ac65edc8f21424977d
1 parent
2644dbf0b4
Exists in
master
and in
6 other branches
追访相关
Showing 1 changed file with 27 additions and 22 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/TrackDownServiceImpl.java
View file @
0161501
| ... | ... | @@ -200,12 +200,13 @@ |
| 200 | 200 | @Override |
| 201 | 201 | public BaseResponse list(String provinceId, String cityId, String areaId, String streetId, String key, Integer trackType, Integer page, Integer limit, Integer userId) { |
| 202 | 202 | PageResult pageResult = null; |
| 203 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
| 204 | + Criteria patientCriteria = new Criteria(); | |
| 203 | 205 | List<Map<String, Object>> restList = new ArrayList<>(); |
| 204 | 206 | boolean flag = false; // 判断需不需要对patients进行查询 |
| 205 | 207 | Set<String> parentIds = new HashSet<>(); |
| 206 | 208 | if(StringUtils.isNotEmpty(provinceId) || StringUtils.isNotEmpty(cityId) || StringUtils.isNotEmpty(areaId) || StringUtils.isNotEmpty(streetId) || StringUtils.isNotEmpty(key)) { |
| 207 | 209 | flag = true; |
| 208 | - Criteria patientCriteria = new Criteria(); | |
| 209 | 210 | if(StringUtils.isNotEmpty(provinceId)) { |
| 210 | 211 | patientCriteria.and("provinceRegisterId").is(provinceId); |
| 211 | 212 | } |
| ... | ... | @@ -221,7 +222,7 @@ |
| 221 | 222 | if(StringUtils.isNotEmpty(key)) { |
| 222 | 223 | patientCriteria.orOperator(Criteria.where("phone").regex(key), Criteria.where("username").regex(key), Criteria.where("cardNo").is(key)); |
| 223 | 224 | } |
| 224 | - List<Patients> patients = mongoTemplate.find(Query.query(patientCriteria.and("yn").is(1)), Patients.class); | |
| 225 | + List<Patients> patients = mongoTemplate.find(Query.query(patientCriteria.and("yn").is(1).and("hospitalId").is(hospitalId)), Patients.class); | |
| 225 | 226 | for (Patients patient : patients) { |
| 226 | 227 | parentIds.add(patient.getId()); |
| 227 | 228 | } |
| ... | ... | @@ -242,7 +243,7 @@ |
| 242 | 243 | c.and("streetId").is(streetId); |
| 243 | 244 | } |
| 244 | 245 | List<TrackDown> trackDowns = mongoTemplate.find(Query.query(Criteria.where("yn").is(1).and("trackDownTransfer").in(Arrays.asList(2, 3)) |
| 245 | - .and("trackDownDateType").is(TrackDownDateEnums.A.getId())), TrackDown.class); | |
| 246 | + .and("trackDownDateType").is(TrackDownDateEnums.B.getId()).and("hospitalId").is(hospitalId)), TrackDown.class); | |
| 246 | 247 | List<String> residentIds = new ArrayList<>(); |
| 247 | 248 | for (TrackDown trackDown : trackDowns) { |
| 248 | 249 | residentIds.add(trackDown.getId()); |
| 249 | 250 | |
| 250 | 251 | |
| ... | ... | @@ -267,30 +268,34 @@ |
| 267 | 268 | restList.add(temp); |
| 268 | 269 | } |
| 269 | 270 | } else { |
| 271 | + pageResult = findMongoPage(Patients.class, Query.query(patientCriteria), page, limit); | |
| 272 | + List<Patients> patients = (List<Patients>) pageResult.getGrid(); | |
| 273 | + for (Patients patient : patients) { | |
| 274 | + Map<String, Object> temp = new HashMap<>(); | |
| 275 | + temp.put("username", patient.getUsername()); | |
| 276 | + temp.put("age", DateUtil.getAge(patient.getBirth())); | |
| 277 | + temp.put("cardNo", StringUtils.encryCardNo(patient.getCardNo())); | |
| 278 | + temp.put("residenceAddress", mongoUtil.findAddressName(patient.getProvinceId(), patient.getCityId(), patient.getAreaId(), patient.getStreetId())); /** 居住地 */ | |
| 279 | + temp.put("phone", StringUtils.encryPhone(patient.getPhone())); | |
| 280 | + temp.put("id", patient.getId()); | |
| 281 | + TrackDown trackDown = mongoTemplate.findOne(Query.query(Criteria.where("yn").is(1).and("parentId").is(patient.getId())).with(new Sort(Sort.Direction.DESC, "created")), TrackDown.class); | |
| 282 | + if(trackDown != null) { | |
| 283 | + temp.put("end", StringUtils.isEmpty(trackDown.getResult()) ? "--" : trackDown.getResult()); // 婚检追访结果 | |
| 284 | + temp.put("trackDownTime", trackDown == null ? "--" : DateUtil.getyyyy_MM_dd(trackDown.getTrackDownDate())); // 追访时间 | |
| 285 | + temp.put("yyTime", trackDown == null ? "--" : DateUtil.getyyyy_MM_dd(trackDown.getReservatDate())); // 预约时间 | |
| 286 | + } else { | |
| 287 | + temp.put("end", "--"); // 婚检追访结果 | |
| 288 | + temp.put("trackDownTime", "--"); // 追访时间 | |
| 289 | + temp.put("yyTime", "--"); // 预约时间 | |
| 290 | + } | |
| 291 | + restList.add(temp); | |
| 292 | + } | |
| 270 | 293 | Criteria trackDowncCriteria = new Criteria(); |
| 271 | 294 | if(flag) { |
| 272 | 295 | trackDowncCriteria.and("parentId").in(parentIds); |
| 273 | 296 | } |
| 274 | - trackDowncCriteria.and("yn").is(1).and("trackDownTransfer").in(Arrays.asList(2, 3)); | |
| 275 | - pageResult = findMongoPage(TrackDown.class, Query.query(trackDowncCriteria).with(new Sort(Sort.Direction.DESC, "created")), page, limit); | |
| 276 | - List<TrackDown> trackDowns = (List<TrackDown>) pageResult.getGrid(); | |
| 277 | - for (TrackDown trackDown : trackDowns) { | |
| 278 | - Map<String, Object> temp = new HashMap<>(); | |
| 297 | +// trackDowncCriteria.and("yn").is(1).and("trackDownTransfer").in(Arrays.asList(2, 3)).and("hospitalId").is(hospitalId); | |
| 279 | 298 | |
| 280 | - temp.put("id", trackDown.getId()); | |
| 281 | - temp.put("parentId", trackDown.getParentId()); | |
| 282 | - Patients patients = mongoTemplate.findById(trackDown.getParentId(), Patients.class); | |
| 283 | - if(patients != null) { | |
| 284 | - temp.put("username", patients.getUsername()); | |
| 285 | - temp.put("age", DateUtil.getAge(patients.getBirth())); | |
| 286 | - temp.put("cardNo", StringUtils.encryCardNo(patients.getCardNo())); | |
| 287 | - temp.put("residenceAddress", mongoUtil.findAddressName(patients.getProvinceId(), patients.getCityId(), patients.getAreaId(), patients.getStreetId())); /** 居住地 */ | |
| 288 | - temp.put("phone", StringUtils.encryPhone(patients.getPhone())); | |
| 289 | - } | |
| 290 | - temp.put("end", trackDown.getResult()); // 婚检追访结果 | |
| 291 | - temp.put("trackDownTime", trackDown == null ? "--" : DateUtil.getyyyy_MM_dd(trackDown.getTrackDownDate())); // 追访时间 | |
| 292 | - temp.put("yyTime", trackDown == null ? "--" : DateUtil.getyyyy_MM_dd(trackDown.getReservatDate())); // 预约时间 | |
| 293 | - } | |
| 294 | 299 | } |
| 295 | 300 | pageResult.setGrid(restList); |
| 296 | 301 | return RespBuilder.buildSuccess(pageResult); |