Commit 10bda53833952f7f73028882ca2947d56af06385

Authored by liquanyu
1 parent 6da698e78e

update code

Showing 2 changed files with 269 additions and 0 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/CheckPointCountWorker.java View file @ 10bda53
  1 +package com.lyms.platform.operate.web.worker;
  2 +
  3 +import com.lyms.platform.biz.service.AntenatalExaminationService;
  4 +import com.lyms.platform.biz.service.BasicConfigService;
  5 +import com.lyms.platform.biz.service.PatientsService;
  6 +import com.lyms.platform.common.enums.YnEnums;
  7 +import com.lyms.platform.common.utils.StringUtils;
  8 +import com.lyms.platform.permission.model.Organization;
  9 +import com.lyms.platform.permission.service.OrganizationService;
  10 +import com.lyms.platform.pojo.BasicConfig;
  11 +import com.lyms.platform.query.AntExChuQuery;
  12 +import com.lyms.platform.query.AntExQuery;
  13 +import com.lyms.platform.query.PatientsQuery;
  14 +import org.apache.commons.collections.CollectionUtils;
  15 +
  16 +import java.util.*;
  17 +import java.util.concurrent.*;
  18 +
  19 +/**
  20 + * Created by Administrator on 2017-07-07.
  21 + */
  22 +public class CheckPointCountWorker implements Callable{
  23 +
  24 + private static List<Integer> weeks = new ArrayList<>();
  25 + static {
  26 + weeks.add(0);
  27 + weeks.add(16);
  28 + weeks.add(21);
  29 + weeks.add(28);
  30 + weeks.add(37);
  31 + }
  32 + private static ExecutorService pool = Executors.newFixedThreadPool(5);
  33 + private PatientsService patientsService;
  34 + private AntenatalExaminationService antenatalExaminationService;
  35 + private OrganizationService organizationService;
  36 + private BasicConfigService basicConfigService;
  37 + private List<String> hospitalIds;
  38 + private Date startTime;
  39 + private Date endTime;
  40 + private Integer pointType;
  41 +
  42 + public CheckPointCountWorker(PatientsService patientsService,
  43 + AntenatalExaminationService antenatalExaminationService,
  44 + OrganizationService organizationService,
  45 + BasicConfigService basicConfigService,
  46 + List<String> hospitalIds,
  47 + Date startTime,
  48 + Date endTime,
  49 + Integer pointType)
  50 + {
  51 + this.patientsService = patientsService;
  52 + this.antenatalExaminationService = antenatalExaminationService;
  53 + this.organizationService = organizationService;
  54 + this.basicConfigService = basicConfigService;
  55 + this.hospitalIds = hospitalIds;
  56 + this.startTime = startTime;
  57 + this.endTime = endTime;
  58 + this.endTime = endTime;
  59 + this.pointType = pointType;
  60 + }
  61 +
  62 +
  63 + @Override
  64 + public List<Map<String, Object>> call() throws Exception {
  65 +
  66 + List<Map<String, Object>> checkPointtList = new ArrayList<>();
  67 + if (CollectionUtils.isNotEmpty(hospitalIds)) {
  68 + for (String hId : hospitalIds) {
  69 +
  70 + Map<String, Object> map = getHospitalInfo(hId);
  71 +
  72 + PatientsQuery patientsQuery = new PatientsQuery();
  73 + patientsQuery.setYn(YnEnums.YES.getId());
  74 + patientsQuery.setHospitalId(hId);
  75 +
  76 + List buildType = new ArrayList();
  77 + buildType.add(0);
  78 + buildType.add(2);
  79 + patientsQuery.setSmsBuildTypeList(buildType);
  80 + //ๅˆ†ๅจฉ็Šถๆ€
  81 + patientsQuery.setDueStatus(0);
  82 +
  83 + patientsQuery.setBookbuildingDateStart(startTime);
  84 + patientsQuery.setBookbuildingDateEnd(endTime);
  85 +
  86 + //ๅปบๆกฃไบบๆ•ฐ
  87 + int buildCount = patientsService.queryPatientCount(patientsQuery);
  88 +
  89 + AntExChuQuery antExChuQuery1 = new AntExChuQuery();
  90 + antExChuQuery1.setHospitalId(hId);
  91 + antExChuQuery1.setYn(YnEnums.YES.getId());
  92 + int chuCount = antenatalExaminationService.queryAntExChuCount(antExChuQuery1.convertToQuery());
  93 +
  94 + AntExQuery antExQuery = new AntExQuery();
  95 + antExQuery.setHospitalId(hId);
  96 + antExQuery.setYn(YnEnums.YES.getId());
  97 + int exCount = antenatalExaminationService.queryAntenatalExaminationCount(antExQuery.convertToQuery());
  98 +
  99 + if (buildCount == 0 && chuCount == 0 && exCount == 0)
  100 + {
  101 + continue;
  102 + }
  103 + List<Future> futures = new ArrayList<>();
  104 + for (int week : weeks)
  105 + {
  106 + CheckWeeksNumWorker callable = new CheckWeeksNumWorker(antenatalExaminationService,hId,
  107 + startTime, endTime, week,pointType);
  108 + futures.add(pool.submit(callable));
  109 + }
  110 +
  111 +
  112 + Map<String,Integer> result = new HashMap<>();
  113 + if (CollectionUtils.isNotEmpty(futures))
  114 + {
  115 + for (Future f : futures)
  116 + {
  117 + result.putAll((Map)f.get());
  118 + }
  119 + }
  120 +
  121 +
  122 + int itemnum12 = result.get("itemnum12");
  123 + int itemnum20 = result.get("itemnum20");
  124 + int itemnum24 = result.get("itemnum24");
  125 + int itemnum36 = result.get("itemnum36");
  126 + int itemnum40 = result.get("itemnum40");
  127 + int cjNum = itemnum12+itemnum20+itemnum24+itemnum36+itemnum40;
  128 + if (buildCount == 0 && cjNum == 0)
  129 + {
  130 + continue;
  131 + }
  132 + map.put("JD_NUM", buildCount);
  133 + map.put("CJ_NUM", cjNum);
  134 + map.put("NUM_12", itemnum12);
  135 + map.put("NUM_16", itemnum20);
  136 + map.put("NUM_24", itemnum24);
  137 + map.put("NUM_36", itemnum36);
  138 + map.put("NUM_40", itemnum40);
  139 + checkPointtList.add(map);
  140 + }
  141 +
  142 + }
  143 + return checkPointtList;
  144 + }
  145 +
  146 +
  147 + /**
  148 + * ่Žทๅ–ๅŒป้™ข็š„ไฟกๆฏ
  149 + *
  150 + * @param hospitalId
  151 + * @return
  152 + */
  153 + private Map<String, Object> getHospitalInfo(String hospitalId) {
  154 + Map<String, Object> map = new HashMap<>();
  155 + if (StringUtils.isNotEmpty(hospitalId) && StringUtils.isNum(hospitalId)) {
  156 + Organization organization = organizationService.getOrganization(Integer.parseInt(hospitalId));
  157 + if (organization != null) {
  158 + String provinceId = organization.getProvinceId();
  159 + if (StringUtils.isNotEmpty(provinceId)) {
  160 + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(provinceId);
  161 + if (basicConfig != null) {
  162 + map.put("PROVINCE", basicConfig.getName());
  163 + map.put("PROVINCE_ID", provinceId);
  164 + }
  165 + }
  166 +
  167 + String cityId = organization.getCityId();
  168 + if (StringUtils.isNotEmpty(cityId)) {
  169 + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(cityId);
  170 + if (basicConfig != null) {
  171 + map.put("CITY", basicConfig.getName());
  172 + map.put("CITY_ID", cityId);
  173 + }
  174 + }
  175 +
  176 + String areaId = organization.getAreaId();
  177 + if (StringUtils.isNotEmpty(areaId)) {
  178 + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(areaId);
  179 + if (basicConfig != null) {
  180 + map.put("AREA_COUNTY", basicConfig.getName());
  181 + map.put("AREA_COUNTY_ID", areaId);
  182 + }
  183 + }
  184 +
  185 + map.put("YCY_STSTEM_ID", hospitalId);
  186 + map.put("HOSPITAL_NAME", organization.getName());
  187 +
  188 + }
  189 + }
  190 + return map;
  191 + }
  192 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/CheckWeeksNumWorker.java View file @ 10bda53
  1 +package com.lyms.platform.operate.web.worker;
  2 +
  3 +import com.lyms.platform.biz.service.AntenatalExaminationService;
  4 +
  5 +import java.util.Date;
  6 +import java.util.HashMap;
  7 +import java.util.List;
  8 +import java.util.Map;
  9 +import java.util.concurrent.Callable;
  10 +
  11 +/**
  12 + * Created by Administrator on 2017-07-07.
  13 + */
  14 +public class CheckWeeksNumWorker implements Callable<Map<String,Integer>> {
  15 +
  16 +
  17 + private AntenatalExaminationService antenatalExaminationService;
  18 + private String hospitalId;
  19 + private Date startTime;
  20 + private Date endTime;
  21 + private int week;
  22 + private Integer pointType;
  23 + public CheckWeeksNumWorker(AntenatalExaminationService antenatalExaminationService, String hospitalId,
  24 + Date startTime,Date endTime,int week,Integer pointType)
  25 + {
  26 + this.antenatalExaminationService = antenatalExaminationService;
  27 + this.hospitalId = hospitalId;
  28 + this.startTime = startTime;
  29 + this.endTime = endTime;
  30 + this.week = week;
  31 + this.pointType = pointType;
  32 + }
  33 +
  34 + /**
  35 + * weeks.add(0);
  36 + weeks.add(16);
  37 + weeks.add(21);
  38 + weeks.add(28);
  39 + weeks.add(37);
  40 + * @return
  41 + * @throws Exception
  42 + */
  43 + @Override
  44 + public Map<String,Integer> call() throws Exception {
  45 + Map<String,Integer> map = new HashMap<>();
  46 +
  47 + long start = System.currentTimeMillis();
  48 +
  49 + if (week == 0)
  50 + {
  51 + int itemnum12 = antenatalExaminationService.queryWeekPointCount(0, 12, hospitalId, startTime, endTime, pointType);
  52 + map.put("itemnum12",itemnum12);
  53 + }
  54 + else if (week == 16)
  55 + {
  56 + int itemnum20 = antenatalExaminationService.queryWeekPointCount(16, 20, hospitalId, startTime, endTime, pointType);
  57 + map.put("itemnum20",itemnum20);
  58 + }
  59 + else if (week == 21)
  60 + {
  61 + int itemnum24 = antenatalExaminationService.queryWeekPointCount(21, 24, hospitalId, startTime, endTime, pointType);
  62 + map.put("itemnum24",itemnum24);
  63 + }
  64 + else if (week == 28)
  65 + {
  66 + int itemnum36 = antenatalExaminationService.queryWeekPointCount(28, 36, hospitalId, startTime, endTime, pointType);
  67 + map.put("itemnum36",itemnum36);
  68 + }
  69 + else if (week == 37)
  70 + {
  71 + int itemnum40 = antenatalExaminationService.queryWeekPointCount(37, 40, hospitalId, startTime,endTime, pointType);
  72 + map.put("itemnum40",itemnum40);
  73 + }
  74 + System.out.println(week+"==="+hospitalId+"---------"+ (System.currentTimeMillis()-start));
  75 + return map;
  76 + }
  77 +}