Commit 563ad80415d216e0ef01cd084e7ea936f5f003a3
1 parent
b28cd56768
Exists in
master
and in
1 other branch
批量处理最后产检医生
Showing 4 changed files with 86 additions and 5 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IPatientDao.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PatientDaoImpl.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PatientsService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IPatientDao.java
View file @
563ad80
... | ... | @@ -34,6 +34,8 @@ |
34 | 34 | |
35 | 35 | void updatePatientOneCol(String id, Object colValue); |
36 | 36 | |
37 | + void updatePatientLastCheckEmployeeIdOne(String id, String lastCheckEmployeeId); | |
38 | + | |
37 | 39 | List<PredictedStatisticsCountModel> predictedStatistics(); |
38 | 40 | |
39 | 41 | List<HashMap> aggregateOne(MongoQuery mongoQuery); |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PatientDaoImpl.java
View file @
563ad80
... | ... | @@ -43,6 +43,11 @@ |
43 | 43 | } |
44 | 44 | |
45 | 45 | @Override |
46 | + public void updatePatientLastCheckEmployeeIdOne(String id, String lastCheckEmployeeId){ | |
47 | + this.mongoTemplate.updateFirst(new Query(Criteria.where("id").is(id)), Update.update("lastCheckEmployeeId", lastCheckEmployeeId), Patients.class); | |
48 | + } | |
49 | + | |
50 | + @Override | |
46 | 51 | public List<PredictedStatisticsCountModel> predictedStatistics() { |
47 | 52 | // List<PredictedStatisticsCountModel> predictedStatisticsCountModelList = new ArrayList<>(); |
48 | 53 | // DBCollection dbCollection = this.mongoTemplate.getCollection("lyms_patient"); |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PatientsService.java
View file @
563ad80
... | ... | @@ -117,6 +117,10 @@ |
117 | 117 | iPatientDao.updatePatientOneCol(id,colValue); |
118 | 118 | } |
119 | 119 | |
120 | + public void updatePatientLastCheckEmployeeIdOne(String id, String lastCheckEmployeeId) { | |
121 | + iPatientDao.updatePatientLastCheckEmployeeIdOne(id, lastCheckEmployeeId); | |
122 | + } | |
123 | + | |
120 | 124 | /** |
121 | 125 | * 满足孕15+3至20+6之间和有产筛申请单的数据 |
122 | 126 | */ |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
View file @
563ad80
1 | 1 | package com.lyms.platform.operate.web.controller; |
2 | 2 | |
3 | 3 | import com.lyms.hospitalapi.qhdfy.QhdfyHisService; |
4 | -import com.lyms.platform.biz.JdbcUtil; | |
5 | 4 | import com.lyms.platform.biz.service.AntenatalExaminationService; |
6 | 5 | import com.lyms.platform.biz.service.AssayConfigService; |
7 | 6 | import com.lyms.platform.biz.service.PatientsService; |
... | ... | @@ -9,7 +8,6 @@ |
9 | 8 | import com.lyms.platform.common.enums.YnEnums; |
10 | 9 | import com.lyms.platform.common.utils.DateUtil; |
11 | 10 | import com.lyms.platform.common.utils.JsonUtil; |
12 | -import com.lyms.platform.common.utils.StringUtils; | |
13 | 11 | import com.lyms.platform.operate.web.service.SyncDataTaskService; |
14 | 12 | import com.lyms.platform.permission.service.OrganizationService; |
15 | 13 | import com.lyms.platform.pojo.AntExChuModel; |
... | ... | @@ -21,6 +19,7 @@ |
21 | 19 | import com.lyms.platform.query.PatientsQuery; |
22 | 20 | import org.apache.commons.collections.CollectionUtils; |
23 | 21 | import org.apache.commons.io.FileUtils; |
22 | +import org.apache.commons.lang.StringUtils; | |
24 | 23 | import org.springframework.beans.factory.annotation.Autowired; |
25 | 24 | import org.springframework.data.domain.Sort; |
26 | 25 | import org.springframework.data.mongodb.core.MongoTemplate; |
... | ... | @@ -31,8 +30,6 @@ |
31 | 30 | import org.springframework.web.bind.annotation.ResponseBody; |
32 | 31 | |
33 | 32 | import java.io.File; |
34 | -import java.io.IOException; | |
35 | -import java.text.CollationElementIterator; | |
36 | 33 | import java.util.*; |
37 | 34 | |
38 | 35 | /** |
39 | 36 | |
... | ... | @@ -341,10 +338,83 @@ |
341 | 338 | } |
342 | 339 | } |
343 | 340 | } |
344 | - }); | |
341 | + }).start(); | |
345 | 342 | } |
346 | 343 | |
347 | 344 | return "syncPatNextTime finish"; |
345 | + } | |
346 | + | |
347 | + @ResponseBody | |
348 | + @RequestMapping(value = "/syncPatientsLastCheckEmployeeId", method = RequestMethod.GET) | |
349 | + public void syncPatientsLastCheckEmployeeId(@RequestParam String hospitalId, | |
350 | + @RequestParam(required = false) int batchSize) { | |
351 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
352 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
353 | + // 医院id | |
354 | + patientsQuery.setHospitalId(hospitalId); | |
355 | + List<Integer> typeList = new ArrayList<>(); | |
356 | + // 孕妇 | |
357 | + typeList.add(1); | |
358 | + // 产妇 | |
359 | + typeList.add(3); | |
360 | + patientsQuery.setTypeList(typeList); | |
361 | + // 查询 | |
362 | + List<Patients> patientsList = patientsService.queryPatient(patientsQuery); | |
363 | + System.out.println("本次读取了【" + patientsList.size() + "】条数据"); | |
364 | + | |
365 | + if (batchSize == 0) { | |
366 | + batchSize = 1000; | |
367 | + } | |
368 | + int end = 0; | |
369 | + | |
370 | + for (int i = 0; i < patientsList.size(); i += batchSize) { | |
371 | + end = (end + batchSize); | |
372 | + if (end > patientsList.size()) { | |
373 | + end = patientsList.size(); | |
374 | + } | |
375 | + final List<Patients> tempList = patientsList.subList(i, end); | |
376 | + new Thread(new Runnable() { | |
377 | + @Override | |
378 | + public void run() { | |
379 | + if (CollectionUtils.isNotEmpty(tempList)) { | |
380 | + for (Patients patients : tempList) { | |
381 | + | |
382 | + String id = patients.getId(); | |
383 | + String hospitalId = patients.getHospitalId(); | |
384 | + | |
385 | + String lastCheckEmployeeId = null; | |
386 | + String flag; | |
387 | + | |
388 | + // 查询复诊,如果没有再查询初诊 | |
389 | + AntExQuery antExQuery = new AntExQuery(); | |
390 | + antExQuery.setYn(YnEnums.YES.getId()); | |
391 | + antExQuery.setParentId(id); | |
392 | + antExQuery.setHospitalId(hospitalId); | |
393 | + List<AntenatalExaminationModel> antenatalExaminationModelList = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); | |
394 | + if (CollectionUtils.isNotEmpty(antenatalExaminationModelList)) { | |
395 | + lastCheckEmployeeId = antenatalExaminationModelList.get(0).getCheckDoctor(); | |
396 | + flag = "复诊"; | |
397 | + } else { | |
398 | + // 查询初诊 | |
399 | + AntExChuQuery antExChuQuery = new AntExChuQuery(); | |
400 | + antExChuQuery.setYn(YnEnums.YES.getId()); | |
401 | + antExChuQuery.setParentId(id); | |
402 | + antExChuQuery.setHospitalId(hospitalId); | |
403 | + List<AntExChuModel> antExChuModelList = antenatalExaminationService.queryAntExChu(antExChuQuery); | |
404 | + if (antExChuModelList.size() == 1) { | |
405 | + lastCheckEmployeeId = antExChuModelList.get(0).getProdDoctor(); | |
406 | + } | |
407 | + flag = "初诊"; | |
408 | + } | |
409 | + if (!StringUtils.isEmpty(lastCheckEmployeeId)) { | |
410 | + patientsService.updatePatientLastCheckEmployeeIdOne(id, lastCheckEmployeeId); | |
411 | + System.out.println("更新lyms_patient:id=" + id + ",lastCheckEmployeeId=" + lastCheckEmployeeId + ",来自" + flag); | |
412 | + } | |
413 | + } | |
414 | + } | |
415 | + } | |
416 | + }).start(); | |
417 | + } | |
348 | 418 | } |
349 | 419 | |
350 | 420 | @RequestMapping(value = "/initCardNo", method = RequestMethod.GET) |