Commit 4bad647b08b1ca7e14e911d25156a14d057ade81

Authored by liquanyu
1 parent d2ab14d58e

高危排名统计

Showing 5 changed files with 181 additions and 1 deletions

platform-common/src/main/java/com/lyms/platform/common/enums/TrackDownDateEnums.java View file @ 4bad647
... ... @@ -12,7 +12,7 @@
12 12 F(6, "产后访视",10),
13 13 G(7, "产后复查",11),
14 14 H(8, "产前检查转出",5),
15   - I(9, "产前筛查转出",5),
  15 + I(9, "产前筛查转出",3),
16 16 J(10, "产后访视转出",-1),
17 17 K(11, "产后复查转出",-1),
18 18 L(12, "孕预期体重异常管理",12),
platform-common/src/main/java/com/lyms/platform/common/utils/StringUtils.java View file @ 4bad647
... ... @@ -2,6 +2,7 @@
2 2  
3 3 import java.math.BigDecimal;
4 4 import java.text.DecimalFormat;
  5 +import java.text.NumberFormat;
5 6 import java.text.ParseException;
6 7 import java.text.SimpleDateFormat;
7 8 import java.util.*;
... ... @@ -440,6 +441,15 @@
440 441 return sb.toString();
441 442 }
442 443 return "";
  444 + }
  445 +
  446 + public static String getPercent(int num,int num2)
  447 + {
  448 + NumberFormat numberFormat = NumberFormat.getInstance();
  449 + // 设置精确到小数点后2位
  450 + numberFormat.setMaximumFractionDigits(2);
  451 + String result = numberFormat.format((float)num/(float)num2*100);
  452 + return result;
443 453 }
444 454 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RiskReportController.java View file @ 4bad647
... ... @@ -59,6 +59,23 @@
59 59  
60 60  
61 61 /**
  62 + * 高危因素前十名
  63 + * @param patientsQueryRequest
  64 + * @param request
  65 + * @return
  66 + */
  67 + @RequestMapping(method = RequestMethod.GET, value = "/queryRiskSortCount")
  68 + @ResponseBody
  69 + @TokenRequired
  70 + public BaseResponse queryRiskSortCount(@Valid RiskPatientsQueryRequest patientsQueryRequest,HttpServletRequest request) {
  71 + LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
  72 + return riskReportFacade.queryRiskSortCount(patientsQueryRequest,loginState.getId());
  73 +
  74 + }
  75 +
  76 +
  77 +
  78 + /**
62 79 * 区域高危孕妇统计报表
63 80 * @return
64 81 */
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/RiskReportFacade.java View file @ 4bad647
... ... @@ -13,8 +13,10 @@
13 13 import com.lyms.platform.operate.web.request.RiskBabysQueryRequest;
14 14 import com.lyms.platform.operate.web.request.RiskPatientsCountRequest;
15 15 import com.lyms.platform.operate.web.request.RiskPatientsQueryRequest;
  16 +import com.lyms.platform.operate.web.result.PatientRiskSortResult;
16 17 import com.lyms.platform.operate.web.result.RiskReportResult;
17 18 import com.lyms.platform.operate.web.utils.*;
  19 +import com.lyms.platform.operate.web.worker.QuanPatientWorker;
18 20 import com.lyms.platform.permission.model.Organization;
19 21 import com.lyms.platform.permission.model.OrganizationQuery;
20 22 import com.lyms.platform.permission.service.OrganizationService;
... ... @@ -36,6 +38,7 @@
36 38 import java.text.DecimalFormat;
37 39 import java.util.*;
38 40 import java.util.concurrent.*;
  41 +import java.util.concurrent.atomic.AtomicInteger;
39 42  
40 43 @Component
41 44 public class RiskReportFacade {
... ... @@ -551,6 +554,114 @@
551 554 .setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(datas);
552 555 }
553 556  
  557 +
  558 +
  559 + public BaseResponse queryRiskSortCount(final RiskPatientsQueryRequest patientsQueryRequest, Integer userId) {
  560 +
  561 + final String hospitalId = autoMatchFacade.getHospitalId(userId);
  562 + BasicConfigQuery basicConfigQuery = new BasicConfigQuery();
  563 + basicConfigQuery.setYn(YnEnums.YES.getId());
  564 + basicConfigQuery.setTypeId(SystemConfig.HIGH_RISK_ID);
  565 + basicConfigQuery.setEnable(1);
  566 + List<PatientRiskSortResult> data = new ArrayList <>();
  567 + List<BasicConfig> riskLevelConfig = basicConfigService.queryBasicConfig(basicConfigQuery);
  568 +
  569 + if (CollectionUtils.isNotEmpty(riskLevelConfig)) {
  570 +
  571 + int batchSize = 20;
  572 + int end = 0;
  573 + List <Future> listFuture = new ArrayList <>();
  574 + for (int i = 0; i < riskLevelConfig.size(); i += batchSize) {
  575 + end = (end + batchSize);
  576 + if (end > riskLevelConfig.size()) {
  577 + end = riskLevelConfig.size();
  578 + }
  579 + final List<BasicConfig> risks = riskLevelConfig.subList(i, end);
  580 + listFuture.add(commonThreadPool.submit(new Callable() {
  581 + @Override
  582 + public Object call() throws Exception {
  583 + if (CollectionUtils.isNotEmpty(risks))
  584 + {
  585 + List<PatientRiskSortResult> data1 = new ArrayList <>();
  586 + for (BasicConfig config : risks)
  587 + {
  588 + if("d42eec03-aa86-45b8-a4e0-78a0ff365fb6".equals(config.getId()))
  589 + {
  590 + continue;
  591 + }
  592 +
  593 + PatientsQuery patientsQuery = new PatientsQuery();
  594 + patientsQuery.setYn(YnEnums.YES.getId());
  595 + patientsQuery.setBuildTypeList(Arrays.asList(0,2));
  596 + patientsQuery.setHospitalId(hospitalId);
  597 + patientsQuery.setrFactor(config.getId());
  598 +
  599 + if (StringUtils.isNotEmpty(patientsQueryRequest.getType())) {
  600 + if ("2".equals(patientsQueryRequest.getType())) {
  601 + //1孕妇
  602 + patientsQuery.setType(1);
  603 + } else if ("3".equals(patientsQueryRequest.getType())) {
  604 + //3产妇
  605 + patientsQuery.setType(3);
  606 + }
  607 + }
  608 + patientsQuery.setNorFactor(Boolean.TRUE);
  609 +
  610 +
  611 + //建档时间
  612 + if (StringUtils.isNotEmpty(patientsQueryRequest.getBuildTime())) {
  613 +
  614 + String nextDateStr = patientsQueryRequest.getBuildTime();
  615 + String[] dates = nextDateStr.split(" - ");
  616 +
  617 + patientsQuery.setBookbuildingDateStart(DateUtil.parseYMD(dates[0]));
  618 + if (dates.length == 2) {
  619 + patientsQuery.setBookbuildingDateEnd(DateUtil.parseYMD(dates[1]));
  620 + }
  621 + }
  622 +
  623 + //总的孕妇条数(国家标准高危)
  624 + int allPatientCount = patientsService.queryPatientCount(patientsQuery);
  625 + if (allPatientCount == 0)
  626 + {
  627 + continue;
  628 + }
  629 + data1.add(new PatientRiskSortResult(config.getName(),allPatientCount));
  630 + }
  631 + return data1;
  632 + }
  633 + return null;
  634 + }
  635 + }));
  636 + }
  637 + for (Future f : listFuture) {
  638 + try {
  639 + data.addAll((List) f.get(30, TimeUnit.SECONDS));
  640 + } catch (Exception e) {
  641 + ExceptionUtils.catchException(e, "convertToQuanPatient get result Future error.");
  642 + }
  643 + }
  644 + Collections.sort(data);
  645 + if (data.size() >=10)
  646 + {
  647 + data = data.subList(0,10);
  648 + int all = 0;
  649 + for (PatientRiskSortResult result : data)
  650 + {
  651 + all+=result.getCount();
  652 + }
  653 + for (PatientRiskSortResult result : data)
  654 + {
  655 + result.setPercent(StringUtils.getPercent(result.getCount(),all));
  656 + }
  657 + }
  658 +
  659 + }
  660 + return new BaseListResponse()
  661 + .setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(data);
  662 + }
  663 +
  664 +
554 665 //无层级关系
555 666 public void configSignData(RiskReportResult bs, int allPatientCount) {
556 667 DecimalFormat df = new DecimalFormat("0.00");
... ... @@ -1365,6 +1476,7 @@
1365 1476  
1366 1477 return hids;
1367 1478 }
  1479 +
1368 1480  
1369 1481  
1370 1482 //计算占比
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/PatientRiskSortResult.java View file @ 4bad647
  1 +package com.lyms.platform.operate.web.result;
  2 +
  3 +public class PatientRiskSortResult implements Comparable<PatientRiskSortResult>{
  4 + private String riskName;
  5 + private Integer count;
  6 + private String percent;
  7 +
  8 + public PatientRiskSortResult(String riskName, Integer count) {
  9 + this.riskName = riskName;
  10 + this.count = count;
  11 + }
  12 +
  13 + public Integer getCount() {
  14 + return count;
  15 + }
  16 +
  17 + public void setCount(Integer count) {
  18 + this.count = count;
  19 + }
  20 +
  21 + public String getRiskName() {
  22 + return riskName;
  23 + }
  24 +
  25 + public void setRiskName(String riskName) {
  26 + this.riskName = riskName;
  27 + }
  28 +
  29 + public String getPercent() {
  30 + return percent;
  31 + }
  32 +
  33 + public void setPercent(String percent) {
  34 + this.percent = percent;
  35 + }
  36 +
  37 + @Override
  38 + public int compareTo(PatientRiskSortResult o) {
  39 + return o.getCount().compareTo(this.getCount());
  40 + }
  41 +}