From 10bda53833952f7f73028882ca2947d56af06385 Mon Sep 17 00:00:00 2001 From: liquanyu Date: Mon, 24 Jul 2017 10:32:53 +0800 Subject: [PATCH] update code --- .../operate/web/worker/CheckPointCountWorker.java | 192 +++++++++++++++++++++ .../operate/web/worker/CheckWeeksNumWorker.java | 77 +++++++++ 2 files changed, 269 insertions(+) create mode 100644 platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/CheckPointCountWorker.java create mode 100644 platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/CheckWeeksNumWorker.java diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/CheckPointCountWorker.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/CheckPointCountWorker.java new file mode 100644 index 0000000..be9b18a --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/CheckPointCountWorker.java @@ -0,0 +1,192 @@ +package com.lyms.platform.operate.web.worker; + +import com.lyms.platform.biz.service.AntenatalExaminationService; +import com.lyms.platform.biz.service.BasicConfigService; +import com.lyms.platform.biz.service.PatientsService; +import com.lyms.platform.common.enums.YnEnums; +import com.lyms.platform.common.utils.StringUtils; +import com.lyms.platform.permission.model.Organization; +import com.lyms.platform.permission.service.OrganizationService; +import com.lyms.platform.pojo.BasicConfig; +import com.lyms.platform.query.AntExChuQuery; +import com.lyms.platform.query.AntExQuery; +import com.lyms.platform.query.PatientsQuery; +import org.apache.commons.collections.CollectionUtils; + +import java.util.*; +import java.util.concurrent.*; + +/** + * Created by Administrator on 2017-07-07. + */ +public class CheckPointCountWorker implements Callable{ + + private static List weeks = new ArrayList<>(); + static { + weeks.add(0); + weeks.add(16); + weeks.add(21); + weeks.add(28); + weeks.add(37); + } + private static ExecutorService pool = Executors.newFixedThreadPool(5); + private PatientsService patientsService; + private AntenatalExaminationService antenatalExaminationService; + private OrganizationService organizationService; + private BasicConfigService basicConfigService; + private List hospitalIds; + private Date startTime; + private Date endTime; + private Integer pointType; + + public CheckPointCountWorker(PatientsService patientsService, + AntenatalExaminationService antenatalExaminationService, + OrganizationService organizationService, + BasicConfigService basicConfigService, + List hospitalIds, + Date startTime, + Date endTime, + Integer pointType) + { + this.patientsService = patientsService; + this.antenatalExaminationService = antenatalExaminationService; + this.organizationService = organizationService; + this.basicConfigService = basicConfigService; + this.hospitalIds = hospitalIds; + this.startTime = startTime; + this.endTime = endTime; + this.endTime = endTime; + this.pointType = pointType; + } + + + @Override + public List> call() throws Exception { + + List> checkPointtList = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(hospitalIds)) { + for (String hId : hospitalIds) { + + Map map = getHospitalInfo(hId); + + PatientsQuery patientsQuery = new PatientsQuery(); + patientsQuery.setYn(YnEnums.YES.getId()); + patientsQuery.setHospitalId(hId); + + List buildType = new ArrayList(); + buildType.add(0); + buildType.add(2); + patientsQuery.setSmsBuildTypeList(buildType); + //分娩状态 + patientsQuery.setDueStatus(0); + + patientsQuery.setBookbuildingDateStart(startTime); + patientsQuery.setBookbuildingDateEnd(endTime); + + //建档人数 + int buildCount = patientsService.queryPatientCount(patientsQuery); + + AntExChuQuery antExChuQuery1 = new AntExChuQuery(); + antExChuQuery1.setHospitalId(hId); + antExChuQuery1.setYn(YnEnums.YES.getId()); + int chuCount = antenatalExaminationService.queryAntExChuCount(antExChuQuery1.convertToQuery()); + + AntExQuery antExQuery = new AntExQuery(); + antExQuery.setHospitalId(hId); + antExQuery.setYn(YnEnums.YES.getId()); + int exCount = antenatalExaminationService.queryAntenatalExaminationCount(antExQuery.convertToQuery()); + + if (buildCount == 0 && chuCount == 0 && exCount == 0) + { + continue; + } + List futures = new ArrayList<>(); + for (int week : weeks) + { + CheckWeeksNumWorker callable = new CheckWeeksNumWorker(antenatalExaminationService,hId, + startTime, endTime, week,pointType); + futures.add(pool.submit(callable)); + } + + + Map result = new HashMap<>(); + if (CollectionUtils.isNotEmpty(futures)) + { + for (Future f : futures) + { + result.putAll((Map)f.get()); + } + } + + + int itemnum12 = result.get("itemnum12"); + int itemnum20 = result.get("itemnum20"); + int itemnum24 = result.get("itemnum24"); + int itemnum36 = result.get("itemnum36"); + int itemnum40 = result.get("itemnum40"); + int cjNum = itemnum12+itemnum20+itemnum24+itemnum36+itemnum40; + if (buildCount == 0 && cjNum == 0) + { + continue; + } + map.put("JD_NUM", buildCount); + map.put("CJ_NUM", cjNum); + map.put("NUM_12", itemnum12); + map.put("NUM_16", itemnum20); + map.put("NUM_24", itemnum24); + map.put("NUM_36", itemnum36); + map.put("NUM_40", itemnum40); + checkPointtList.add(map); + } + + } + return checkPointtList; + } + + + /** + * 获取医院的信息 + * + * @param hospitalId + * @return + */ + private Map getHospitalInfo(String hospitalId) { + Map map = new HashMap<>(); + if (StringUtils.isNotEmpty(hospitalId) && StringUtils.isNum(hospitalId)) { + Organization organization = organizationService.getOrganization(Integer.parseInt(hospitalId)); + if (organization != null) { + String provinceId = organization.getProvinceId(); + if (StringUtils.isNotEmpty(provinceId)) { + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(provinceId); + if (basicConfig != null) { + map.put("PROVINCE", basicConfig.getName()); + map.put("PROVINCE_ID", provinceId); + } + } + + String cityId = organization.getCityId(); + if (StringUtils.isNotEmpty(cityId)) { + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(cityId); + if (basicConfig != null) { + map.put("CITY", basicConfig.getName()); + map.put("CITY_ID", cityId); + } + } + + String areaId = organization.getAreaId(); + if (StringUtils.isNotEmpty(areaId)) { + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(areaId); + if (basicConfig != null) { + map.put("AREA_COUNTY", basicConfig.getName()); + map.put("AREA_COUNTY_ID", areaId); + } + } + + map.put("YCY_STSTEM_ID", hospitalId); + map.put("HOSPITAL_NAME", organization.getName()); + + } + } + return map; + } +} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/CheckWeeksNumWorker.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/CheckWeeksNumWorker.java new file mode 100644 index 0000000..e60b6a9 --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/CheckWeeksNumWorker.java @@ -0,0 +1,77 @@ +package com.lyms.platform.operate.web.worker; + +import com.lyms.platform.biz.service.AntenatalExaminationService; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; + +/** + * Created by Administrator on 2017-07-07. + */ +public class CheckWeeksNumWorker implements Callable> { + + + private AntenatalExaminationService antenatalExaminationService; + private String hospitalId; + private Date startTime; + private Date endTime; + private int week; + private Integer pointType; + public CheckWeeksNumWorker(AntenatalExaminationService antenatalExaminationService, String hospitalId, + Date startTime,Date endTime,int week,Integer pointType) + { + this.antenatalExaminationService = antenatalExaminationService; + this.hospitalId = hospitalId; + this.startTime = startTime; + this.endTime = endTime; + this.week = week; + this.pointType = pointType; + } + + /** + * weeks.add(0); + weeks.add(16); + weeks.add(21); + weeks.add(28); + weeks.add(37); + * @return + * @throws Exception + */ + @Override + public Map call() throws Exception { + Map map = new HashMap<>(); + + long start = System.currentTimeMillis(); + + if (week == 0) + { + int itemnum12 = antenatalExaminationService.queryWeekPointCount(0, 12, hospitalId, startTime, endTime, pointType); + map.put("itemnum12",itemnum12); + } + else if (week == 16) + { + int itemnum20 = antenatalExaminationService.queryWeekPointCount(16, 20, hospitalId, startTime, endTime, pointType); + map.put("itemnum20",itemnum20); + } + else if (week == 21) + { + int itemnum24 = antenatalExaminationService.queryWeekPointCount(21, 24, hospitalId, startTime, endTime, pointType); + map.put("itemnum24",itemnum24); + } + else if (week == 28) + { + int itemnum36 = antenatalExaminationService.queryWeekPointCount(28, 36, hospitalId, startTime, endTime, pointType); + map.put("itemnum36",itemnum36); + } + else if (week == 37) + { + int itemnum40 = antenatalExaminationService.queryWeekPointCount(37, 40, hospitalId, startTime,endTime, pointType); + map.put("itemnum40",itemnum40); + } + System.out.println(week+"==="+hospitalId+"---------"+ (System.currentTimeMillis()-start)); + return map; + } +} -- 1.8.3.1