From f1f16f690eefbaffba92e03f58a9afd43ff2ef89 Mon Sep 17 00:00:00 2001 From: jiangjiazhi Date: Thu, 9 Mar 2017 18:01:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=B5=E5=AD=90=E7=97=85?= =?UTF-8?q?=E5=8E=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operate/web/worker/QuanPatientWorker.java | 80 +++++++++++++++------- 1 file changed, 54 insertions(+), 26 deletions(-) diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanPatientWorker.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanPatientWorker.java index 96085f1..2376ede 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanPatientWorker.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanPatientWorker.java @@ -68,15 +68,18 @@ public class QuanPatientWorker implements Callable> { @Override public List call() throws Exception { List data = new ArrayList<>(); - AntExChuQuery antExChuQuery = new AntExChuQuery(); AntExQuery antExQuery = new AntExQuery(); + antExQuery.setYn(YnEnums.YES.getId()); + AntExChuQuery antExChuQuery1 = new AntExChuQuery(); + + antExChuQuery1.setYn(YnEnums.YES.getId()); for (Patients patients : patientses) { StopWatch stopWatch = new StopWatch("QuanPatientWorker -" + patients.getId()); QuanPatientsResult quanPatientsResult = new QuanPatientsResult(); quanPatientsResult.convertToResult(patients); antExQuery.setPid(patients.getPid()); - antExQuery.setYn(YnEnums.YES.getId()); + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) { Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor())); @@ -90,17 +93,23 @@ public class QuanPatientWorker implements Callable> { } } quanPatientsResult.setbTime(DateUtil.getyyyy_MM_dd(patients.getBookbuildingDate())); - antExQuery.setHospitalId(null); stopWatch.start("query ant count"); + antExChuQuery1.setPid(patients.getPid()); + List chu = antExService.queryAntExChu(antExChuQuery1.convertToQuery()); //复诊次数 - List ant = antExService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); + List ant = null; + if (CollectionUtils.isNotEmpty(chu)) { + ant = antExService.queryAntenatalExamination(antExQuery.convertToQuery()); + } + //系统初诊次数 + int ichu = CollectionUtils.isEmpty(chu) ? 0 : chu.size(); + //系统复诊次数 int i = 0; - //系统初诊次数 - int ichu=0; if (CollectionUtils.isNotEmpty(ant)) { //复诊次数 i = ant.size(); + sort(ant); for (AntenatalExaminationModel a : ant) { try { if (StringUtils.isNotEmpty(a.getHospitalId())) { @@ -115,11 +124,6 @@ public class QuanPatientWorker implements Callable> { } } } else { - AntExChuQuery antExChuQuery1 = new AntExChuQuery(); - antExChuQuery1.setPid(patients.getPid()); - antExChuQuery1.setYn(YnEnums.YES.getId()); - List chu = antExService.queryAntExChu(antExChuQuery1); - ichu=chu.size(); for (AntExChuModel a : chu) { try { if (StringUtils.isNotEmpty(a.getHospitalId())) { @@ -134,23 +138,16 @@ public class QuanPatientWorker implements Callable> { } } } - antExChuQuery.setPid(patients.getPid()); - antExChuQuery.setYn(YnEnums.YES.getId()); - antExChuQuery.setHospitalId(null); - //初诊次数 - if(0==ichu){ - ichu = antExService.queryAntExChuCount(antExChuQuery.convertToQuery()); - } + quanPatientsResult.setcTimes(i + ichu); - antExChuQuery.setHospitalId(hospital); antExQuery.setHospitalId(hospital); //本院初诊 - int chi = antExService.queryAntExChuCount(antExChuQuery.convertToQuery()); + int chi = countAntChu(chu, hospital); //本院复诊 - int chb = capLocalHospital(hospital,ant); + int chb = capLocalHospital(hospital, ant); quanPatientsResult.setcHTimes(chi + chb); stopWatch.stop(); String nextCheckTime = ""; @@ -222,16 +219,47 @@ public class QuanPatientWorker implements Callable> { return data; } - private int capLocalHospital(String hospitalId,List list){ - if(CollectionUtils.isEmpty(list)){ + private int capLocalHospital(String hospitalId, List list) { + if (CollectionUtils.isEmpty(list)) { return 0; } - int count= 0; - for(AntenatalExaminationModel model:list){ - if(model.getHospitalId().equals(hospitalId)){ + int count = 0; + for (AntenatalExaminationModel model : list) { + if (model.getHospitalId().equals(hospitalId)) { + count++; + } + } + return count; + } + + //统计复查里面的本院检查数 + private int countAntChu(List list, String hospital) { + int count = 0; + if (CollectionUtils.isEmpty(list) || StringUtils.isEmpty(hospital)) { + return count; + } + for (AntExChuModel model : list) { + if (hospital.equals(model.getHospitalId())) { count++; } } return count; } + + private void sort(List list) { + if (CollectionUtils.isEmpty(list)) { + return; + } + Collections.sort(list, new Comparator() { + @Override + public int compare(AntenatalExaminationModel o1, AntenatalExaminationModel o2) { + if (o1.getCreated().getTime() > o2.getCreated().getTime()) { + return 1; + } else if (o1.getCreated().getTime() < o2.getCreated().getTime()) { + return -1; + } + return 0; + } + }); + } } \ No newline at end of file -- 1.8.3.1