Commit 94963ae0fa9cdbd8b01c5a9c76a740d990d6384f

Authored by jiangjiazhi
1 parent 87186c8f55

分娩作废产检劵

Showing 2 changed files with 114 additions and 47 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntExRecordFacade.java View file @ 94963ae
... ... @@ -18,6 +18,8 @@
18 18 import com.lyms.platform.operate.web.utils.FunvCommonUtil;
19 19 import com.lyms.platform.operate.web.utils.UnitConstants;
20 20 import com.lyms.platform.operate.web.utils.UnitUtils;
  21 +import com.lyms.platform.operate.web.worker.AntExRecordWorker;
  22 +import com.lyms.platform.operate.web.worker.WorkHR;
21 23 import com.lyms.platform.permission.model.Organization;
22 24 import com.lyms.platform.permission.model.OrganizationQuery;
23 25 import com.lyms.platform.permission.model.Users;
24 26  
... ... @@ -29,12 +31,16 @@
29 31 import org.apache.commons.collections.MapUtils;
30 32 import org.apache.commons.lang.math.NumberUtils;
31 33 import org.springframework.beans.factory.annotation.Autowired;
  34 +import org.springframework.beans.factory.annotation.Qualifier;
  35 +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
32 36 import org.springframework.stereotype.Component;
33 37  
34 38 import javax.servlet.http.HttpServletResponse;
35 39 import java.io.IOException;
36 40 import java.io.OutputStream;
37 41 import java.util.*;
  42 +import java.util.concurrent.Future;
  43 +import java.util.concurrent.TimeUnit;
38 44  
39 45 /**
40 46 * 产检管理
... ... @@ -61,6 +67,9 @@
61 67 private OrganizationService organizationService;
62 68 @Autowired
63 69 private DataPermissionService dataPermissionService;
  70 + @Autowired
  71 + @Qualifier("commonThreadPool")
  72 + private ThreadPoolTaskExecutor commonThreadPool;
64 73  
65 74 public void syncAntRecordToList(String hospitalId) {
66 75 recordService.syncAntRecordToList(hospitalId);
... ... @@ -203,6 +212,30 @@
203 212 return antExRecordQuery;
204 213 }
205 214  
  215 +
  216 + private List convertToHighRisk(List<Patients> patientses, Integer userId, String hospital) {
  217 + List data = new ArrayList<>();
  218 + int batchSize = 4;
  219 + int end = 0;
  220 + List<Future> listFuture = new ArrayList<>();
  221 + for (int i = 0; i < patientses.size(); i += batchSize) {
  222 + end = (end + batchSize);
  223 + if (end > patientses.size()) {
  224 + end = patientses.size();
  225 + }
  226 + listFuture.add(commonThreadPool.submit(new WorkHR(patientses.subList(i, end), usersService, hospital, basicConfigService, antExService, patientsService, organizationService)));
  227 + }
  228 + for (Future f : listFuture) {
  229 + try {
  230 + data.addAll((List) f.get(30, TimeUnit.SECONDS));
  231 + } catch (Exception e) {
  232 + ExceptionUtils.catchException(e, "convertToHighRisk get result Future error.");
  233 + }
  234 + }
  235 + return data;
  236 + }
  237 +
  238 +
206 239 /**
207 240 * 产检管理
208 241 *
... ... @@ -214,8 +247,7 @@
214 247 List<AntExManagerResult> data = new ArrayList<>();
215 248 List<AntExRecordModel> antExRecordModelList = recordService.queryAntExRecords(antExRecordQuery);
216 249 if (CollectionUtils.isNotEmpty(antExRecordModelList)) {
217   - for (AntExRecordModel e : antExRecordModelList) {
218   - AntExManagerResult antExManagerResult = new AntExManagerResult();
  250 + /*AntExManagerResult antExManagerResult = new AntExManagerResult();
219 251 antExManagerResult.convertToResult(e);
220 252 if (isRegion) {
221 253 //产检医院
222 254  
223 255  
... ... @@ -270,10 +302,26 @@
270 302 antExManagerResult.setChTimes(dichi);
271 303 //高危因素
272 304 antExManagerResult.setrLevel(commonService.findRiskLevel(e.gethLevel()));
273   - antExManagerResult.setRiskFactor(commonService.resloveFactor(e.gethRisk()));
  305 + antExManagerResult.setRiskFactor(commonService.resloveFactor(e.gethRisk()));*/
274 306  
275   - data.add(antExManagerResult);
  307 +
  308 + int batchSize = 4;
  309 + int end = 0;
  310 + List<Future> listFuture = new ArrayList<>();
  311 + for (int i = 0; i < antExRecordModelList.size(); i += batchSize) {
  312 + end = (end + batchSize);
  313 + if (end > antExRecordModelList.size()) {
  314 + end = antExRecordModelList.size();
  315 + }
  316 + listFuture.add(commonThreadPool.submit(new AntExRecordWorker(antExRecordModelList.subList(i, end), isRegion, organizationService, usersService, recordService, commonService, hospital, basicConfigService)));
276 317 }
  318 + for (Future f : listFuture) {
  319 + try {
  320 + data.addAll((List) f.get(30, TimeUnit.SECONDS));
  321 + } catch (Exception e) {
  322 + ExceptionUtils.catchException(e, "antexrecord findList get result future error.");
  323 + }
  324 + }
277 325 }
278 326 return new BaseListResponse().setData(data).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setPageInfo(antExRecordQuery.getPageInfo());
279 327 }
280 328  
281 329  
282 330  
283 331  
284 332  
285 333  
286 334  
287 335  
288 336  
289 337  
... ... @@ -553,62 +601,62 @@
553 601  
554 602  
555 603 //查询复诊接口
556   - public BaseObjectResponse findAntenatalExamination(String id){
  604 + public BaseObjectResponse findAntenatalExamination(String id) {
557 605  
558 606 BaseObjectResponse br = new BaseObjectResponse();
559   - if (org.apache.commons.lang.StringUtils.isEmpty(id)){
  607 + if (org.apache.commons.lang.StringUtils.isEmpty(id)) {
560 608 br.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR);
561 609 br.setErrormsg("id为空");
562 610 return br;
563 611 }
564 612  
565 613 AntenatalExaminationModel data = antExService.findOneById(id);
566   - if (data==null || data.getYn()==YnEnums.NO.getId()){
  614 + if (data == null || data.getYn() == YnEnums.NO.getId()) {
567 615 br.setErrorcode(ErrorCodeConstants.NO_DATA);
568 616 br.setErrormsg("没有查询到数据");
569 617 return br;
570 618 }
571 619  
572 620  
573   - if (org.apache.commons.lang.StringUtils.isEmpty(data.getParentId())){
  621 + if (org.apache.commons.lang.StringUtils.isEmpty(data.getParentId())) {
574 622 br.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR);
575 623 br.setErrormsg("数据异常");
576 624 return br;
577 625 }
578 626  
579 627 Patients patients = patientsService.findOnePatientById(data.getParentId());
580   - if (patients==null || patients.getYn()==YnEnums.NO.getId()){
  628 + if (patients == null || patients.getYn() == YnEnums.NO.getId()) {
581 629 br.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR);
582 630 br.setErrormsg("孕妇信息不存在");
583 631 return br;
584 632 }
585 633  
586   - Map<String,Object> map= new HashMap<>();
  634 + Map<String, Object> map = new HashMap<>();
587 635 /* 基本信息 */
588 636 //孕妇基本信息
589   - map.put("id",data.getId());
590   - map.put("username",patients.getUsername());
591   - map.put("birth",DateUtil.getyyyy_MM_dd(patients.getBirth()));
592   - map.put("age",DateUtil.getAge(patients.getBirth()));
593   - map.put("phone",patients.getPhone());
594   - map.put("fmWeek",patients.getFmWeek());
595   - map.put("dueDate",DateUtil.getyyyy_MM_dd(patients.getDueDate()));
596   - map.put("mremark",patients.getMremark());
597   - map.put("oRiskFactor",patients.getoRiskFactor());
598   - map.put("riskScore",patients.getRiskScore());
  637 + map.put("id", data.getId());
  638 + map.put("username", patients.getUsername());
  639 + map.put("birth", DateUtil.getyyyy_MM_dd(patients.getBirth()));
  640 + map.put("age", DateUtil.getAge(patients.getBirth()));
  641 + map.put("phone", patients.getPhone());
  642 + map.put("fmWeek", patients.getFmWeek());
  643 + map.put("dueDate", DateUtil.getyyyy_MM_dd(patients.getDueDate()));
  644 + map.put("mremark", patients.getMremark());
  645 + map.put("oRiskFactor", patients.getoRiskFactor());
  646 + map.put("riskScore", patients.getRiskScore());
599 647 //产检基本信息
600   - map.put("checkDate",DateUtil.getyyyy_MM_dd(data.getCheckDate()));
601   - map.put("currentDueDate",data.getCurrentDueDate());
  648 + map.put("checkDate", DateUtil.getyyyy_MM_dd(data.getCheckDate()));
  649 + map.put("currentDueDate", data.getCurrentDueDate());
602 650 map.put("checkDoctor", data.getCheckDoctor());
603 651 String hospital = "";
604   - if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getHospitalId())){
  652 + if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getHospitalId())) {
605 653 Organization organization = organizationService.getOrganization(Integer.parseInt(data.getHospitalId()));
606   - if (organization!=null && organization.getYn()==YnEnums.YES.getId()){
  654 + if (organization != null && organization.getYn() == YnEnums.YES.getId()) {
607 655 hospital = organization.getName();
608 656 }
609 657 }
610 658 map.put("hospital", hospital);
611   - map.put("nextCheckTime",DateUtil.getyyyy_MM_dd(data.getNextCheckTime()));
  659 + map.put("nextCheckTime", DateUtil.getyyyy_MM_dd(data.getNextCheckTime()));
612 660 map.put("cDueWeek", data.getcDueWeek());
613 661  
614 662 /* 复诊信息 */
615 663  
616 664  
617 665  
618 666  
619 667  
620 668  
621 669  
622 670  
623 671  
624 672  
625 673  
626 674  
... ... @@ -626,72 +674,69 @@
626 674 map.put("gongGao", UnitUtils.unitSplice(data.getGongGao(), UnitConstants.CM));
627 675 map.put("abdominalCircumference", UnitUtils.unitSplice(data.getAbdominalCircumference(), UnitConstants.CM));
628 676 String edema = "";
629   - if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getEdema())){
630   - for (FuZhongEnums fuZhongEnums:FuZhongEnums.values()){
631   - if (data.getEdema().equals(fuZhongEnums.getId())){
  677 + if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getEdema())) {
  678 + for (FuZhongEnums fuZhongEnums : FuZhongEnums.values()) {
  679 + if (data.getEdema().equals(fuZhongEnums.getId())) {
632 680 edema = fuZhongEnums.getName();
633 681 }
634 682 }
635 683 }
636   - map.put("edema",edema);
  684 + map.put("edema", edema);
637 685  
638 686 map.put("tireNumber", TaiShuEnums.getTitle(data.getTireNumber()));
639 687 //胎儿情况
640 688 List<Map> tireList = new ArrayList<>();
641   - if (CollectionUtils.isNotEmpty(data.getTireData())){
642   - for (Object temp : data.getTireData()){
643   - Map<String,String> tire = JsonUtil.getMap(temp.toString());
  689 + if (CollectionUtils.isNotEmpty(data.getTireData())) {
  690 + for (Object temp : data.getTireData()) {
  691 + Map<String, String> tire = JsonUtil.getMap(temp.toString());
644 692 String heartRate = tire.get("heartRate");
645 693 String fetalPosition = tire.get("fetalPosition");
646 694 String fetalPresentation = tire.get("fetalPresentation");
647 695 String join = tire.get("join");
648 696  
649   - Map<String,Object> tireMap = new HashMap<>();
650   - tireMap.put("heartRate",UnitUtils.unitSplice(heartRate, UnitConstants.CIFEN));
  697 + Map<String, Object> tireMap = new HashMap<>();
  698 + tireMap.put("heartRate", UnitUtils.unitSplice(heartRate, UnitConstants.CIFEN));
651 699 tireMap.put("fetalPosition", FetalPositionEnums.getTitle(fetalPosition));
652 700 tireMap.put("fetalPresentation", FetalEnums.getTitle(fetalPresentation));
653 701 tireMap.put("join", JoinEnums.getTitle(join));
654 702 tireList.add(tireMap);
655 703 }
656 704 }
657   - map.put("tireData",tireList);
  705 + map.put("tireData", tireList);
658 706  
659 707 /* 辅助信息 */
660 708 map.put("hemoglobin", UnitUtils.unitSplice(data.getHemoglobin(), UnitConstants.GL));
661   - map.put("urineProtein",data.getUrineProtein());
  709 + map.put("urineProtein", data.getUrineProtein());
662 710 map.put("bloodSugar", UnitUtils.unitSplice(data.getUrineProtein(), UnitConstants.MMOLL));
663   - map.put("bChao",data.getbChao());
  711 + map.put("bChao", data.getbChao());
664 712  
665 713 /* 诊断指导 */
666 714 String diagnosis = "";
667   - if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getDiagnosis())){
  715 + if (org.apache.commons.lang.StringUtils.isNotEmpty(data.getDiagnosis())) {
668 716 List<String> temp = JsonUtil.toList(data.getDiagnosis(), String.class);
669   - if (CollectionUtils.isNotEmpty(temp)){
  717 + if (CollectionUtils.isNotEmpty(temp)) {
670 718  
671 719 StringBuilder sb = new StringBuilder();
672 720  
673   - for (String sId : temp){
  721 + for (String sId : temp) {
674 722 sb.append(FunvCommonUtil.getBaseicConfigByid(sId, basicConfigService)).append(",");
675 723 }
676 724 if (sb.toString().endsWith(",")) {
677 725 diagnosis = sb.substring(0, sb.length() - 1);
678   - }else {
  726 + } else {
679 727 diagnosis = sb.toString();
680 728 }
681 729 }
682 730 }
683   - map.put("diagnosis",diagnosis);
684   - map.put("treatmentOpinion",data.getTreatmentOpinion());
685   - map.put("guide",data.getGuide());
  731 + map.put("diagnosis", diagnosis);
  732 + map.put("treatmentOpinion", data.getTreatmentOpinion());
  733 + map.put("guide", data.getGuide());
686 734  
687 735 br.setErrorcode(ErrorCodeConstants.SUCCESS);
688 736 br.setErrormsg("成功");
689 737 br.setData(map);
690 738 return br;
691 739 }
692   -
693   -
694   -
695 740  
696 741  
697 742 }
platform-operate-api/src/main/resources/spring/applicationContext.xml View file @ 94963ae
... ... @@ -53,5 +53,27 @@
53 53 </bean>
54 54 <bean id="localSession" class="com.lyms.platform.operate.web.session.strategy.LocalCacheSessionStrategy"/>
55 55 <bean id="usSession" class="com.lyms.platform.operate.web.session.strategy.UserCenterStrategy"/>
  56 +
  57 + <bean id="commonThreadPool" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
  58 + <!-- 核心线程数,默认为1 -->
  59 + <property name="corePoolSize" value="10" />
  60 +
  61 + <!-- 最大线程数,默认为Integer.MAX_VALUE -->
  62 + <property name="maxPoolSize" value="50" />
  63 + <!-- 队列最大长度,一般需要设置值>=notifyScheduledMainExecutor.maxNum;默认为Integer.MAX_VALUE
  64 + <property name="queueCapacity" value="1000" /> -->
  65 +
  66 + <!-- 线程池维护线程所允许的空闲时间,默认为60s -->
  67 + <property name="keepAliveSeconds" value="300" />
  68 +
  69 + <!-- 线程池对拒绝任务(无线程可用)的处理策略,目前只支持AbortPolicy、CallerRunsPolicy;默认为后者
  70 + <bean class="java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy" />
  71 + <property name="rejectedExecutionHandler">-->
  72 + <!-- AbortPolicy:直接抛出java.util.concurrent.RejectedExecutionException异常 -->
  73 + <!-- CallerRunsPolicy:主线程直接执行该任务,执行完之后尝试添加下一个任务到线程池中,可以有效降低向线程池内添加任务的速度 -->
  74 + <!-- DiscardOldestPolicy:抛弃旧的任务、暂不支持;会导致被丢弃的任务无法再次被执行 -->
  75 + <!-- DiscardPolicy:抛弃当前任务、暂不支持;会导致被丢弃的任务无法再次被执行 -->
  76 +
  77 + </bean>
56 78 </beans>