From 61d2b82f399639cd8f57bfb4d78f4371d78dbbcf Mon Sep 17 00:00:00 2001 From: liquanyu Date: Tue, 29 Nov 2016 14:31:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=B8=8B=E6=AC=A1=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operate/web/controller/TestController.java | 77 +++++++++++++--------- 1 file changed, 46 insertions(+), 31 deletions(-) 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"; } -- 1.8.3.1