diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java index 6affa4d..9e718c4 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java @@ -288,47 +288,62 @@ public class TestController { @RequestMapping(value = "/syncPatNextTime", method = RequestMethod.GET) @ResponseBody - public String syncPatNextTime() { + public String syncPatNextTime(@RequestParam(required = true) String hid) { PatientsQuery patientQuery = new PatientsQuery(); patientQuery.setYn(YnEnums.YES.getId()); -// patientQuery.setHospitalId("221"); + patientQuery.setHospitalId(hid); patientQuery.setType(1); List patientses = patientsService.queryPatient(patientQuery); - if (CollectionUtils.isNotEmpty(patientses)) - { - for (Patients pat : patientses) { - AntExChuQuery antExChuQuery = new AntExChuQuery(); - antExChuQuery.setYn(YnEnums.YES.getId()); - antExChuQuery.setHospitalId(pat.getHospitalId()); - antExChuQuery.setParentId(pat.getId()); - List chus = antenatalExaminationService.queryAntExChu(antExChuQuery); - if (CollectionUtils.isNotEmpty(chus)) { - Date nextTime = null; - AntExChuModel chu = chus.get(0); - if (chu != null) + int batchSize = 1000; + int end = 0; + for (int i = 0; i < patientses.size(); i += batchSize) { + end = (end + batchSize); + if (end > patientses.size()) { + end = patientses.size(); + } + System.out.println("start:" + i + ",end:" + end); + final List tempList = patientses.subList(i, end); + new Thread(new Runnable() { + @Override + public void run() { + if (CollectionUtils.isNotEmpty(tempList)) { - nextTime = chu.getNextCheckTime(); - - AntExQuery antExQuery = new AntExQuery(); - antExQuery.setParentId(pat.getId()); - antExQuery.setYn(YnEnums.YES.getId()); - antExQuery.setHospitalId(pat.getHospitalId()); - List list = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); - if (CollectionUtils.isNotEmpty(list)) - { - AntenatalExaminationModel ae = list.get(0); - if (ae != null) - { - nextTime = ae.getNextCheckTime(); + for (Patients pat : tempList) { + AntExChuQuery antExChuQuery = new AntExChuQuery(); + antExChuQuery.setYn(YnEnums.YES.getId()); + antExChuQuery.setHospitalId(pat.getHospitalId()); + antExChuQuery.setParentId(pat.getId()); + List chus = antenatalExaminationService.queryAntExChu(antExChuQuery); + if (CollectionUtils.isNotEmpty(chus)) { + Date nextTime = null; + AntExChuModel chu = chus.get(0); + if (chu != null) + { + nextTime = chu.getNextCheckTime(); + AntExQuery antExQuery = new AntExQuery(); + antExQuery.setParentId(pat.getId()); + antExQuery.setYn(YnEnums.YES.getId()); + antExQuery.setHospitalId(pat.getHospitalId()); + List list = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); + if (CollectionUtils.isNotEmpty(list)) + { + AntenatalExaminationModel ae = list.get(0); + if (ae != null) + { + nextTime = ae.getNextCheckTime(); + } + } + patientsService.updatePatientOneCol(pat.getId(), nextTime); + + } + } } - patientsService.updatePatientOneCol(pat.getId(), nextTime); - } - } - } + }); } + return "syncPatNextTime finish"; }