Commit e3828b9a00d94195f7b1407896d76e79f2fe8c1c
Exists in
master
and in
8 other branches
Merge remote-tracking branch 'origin/master'
Showing 4 changed files
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RiskReportController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/RiskReportFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/RiskReportResult.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/HiskCountTask.java
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RiskReportController.java
View file @
e3828b9
| 1 | 1 | package com.lyms.platform.operate.web.controller; |
| 2 | 2 | |
| 3 | +import com.lyms.platform.common.annotation.TokenRequired; | |
| 3 | 4 | import com.lyms.platform.common.base.BaseController; |
| 4 | 5 | import com.lyms.platform.common.base.LoginContext; |
| 5 | 6 | import com.lyms.platform.common.result.BaseResponse; |
| ... | ... | @@ -30,6 +31,7 @@ |
| 30 | 31 | */ |
| 31 | 32 | @RequestMapping(method = RequestMethod.GET, value = "/queryRiskReportCount") |
| 32 | 33 | @ResponseBody |
| 34 | + @TokenRequired | |
| 33 | 35 | public BaseResponse queryRiskReportCount(@Valid RiskPatientsQueryRequest patientsQueryRequest,HttpServletRequest request) { |
| 34 | 36 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
| 35 | 37 | return riskReportFacade.queryRiskReportCount(patientsQueryRequest,loginState.getId()); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/RiskReportFacade.java
View file @
e3828b9
| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | import com.lyms.platform.common.enums.SexEnum; |
| 8 | 8 | import com.lyms.platform.common.enums.WyTypeEnums; |
| 9 | 9 | import com.lyms.platform.common.enums.YnEnums; |
| 10 | +import com.lyms.platform.common.result.BaseListResponse; | |
| 10 | 11 | import com.lyms.platform.common.result.BaseObjectResponse; |
| 11 | 12 | import com.lyms.platform.common.result.BaseResponse; |
| 12 | 13 | import com.lyms.platform.common.utils.DateUtil; |
| ... | ... | @@ -16,6 +17,7 @@ |
| 16 | 17 | import com.lyms.platform.operate.web.request.BabyCheckRequest; |
| 17 | 18 | import com.lyms.platform.operate.web.request.RiskPatientsQueryRequest; |
| 18 | 19 | import com.lyms.platform.operate.web.result.*; |
| 20 | +import com.lyms.platform.operate.web.utils.HiskCountTask; | |
| 19 | 21 | import com.lyms.platform.permission.model.Organization; |
| 20 | 22 | import com.lyms.platform.permission.model.Users; |
| 21 | 23 | import com.lyms.platform.permission.service.OrganizationService; |
| ... | ... | @@ -29,6 +31,7 @@ |
| 29 | 31 | |
| 30 | 32 | import java.text.DecimalFormat; |
| 31 | 33 | import java.util.*; |
| 34 | +import java.util.concurrent.*; | |
| 32 | 35 | |
| 33 | 36 | @Component |
| 34 | 37 | public class RiskReportFacade { |
| ... | ... | @@ -50,7 +53,7 @@ |
| 50 | 53 | * 查询高危统计,该统计的高危是已经有孕妇有此高危 |
| 51 | 54 | * @return |
| 52 | 55 | */ |
| 53 | - public BaseObjectResponse queryRiskReportCount(RiskPatientsQueryRequest riskPatientsQueryRequest,Integer userId) { | |
| 56 | + public BaseListResponse queryRiskReportCount(RiskPatientsQueryRequest riskPatientsQueryRequest,Integer userId) { | |
| 54 | 57 | |
| 55 | 58 | // String hospitalId = "242"; |
| 56 | 59 | String hospitalId = autoMatchFacade.getHospitalId(userId); |
| 57 | 60 | |
| 58 | 61 | |
| 59 | 62 | |
| 60 | 63 | |
| 61 | 64 | |
| ... | ... | @@ -98,44 +101,46 @@ |
| 98 | 101 | //总的孕妇条数 |
| 99 | 102 | int allPatientCount = patientsService.queryPatientCount(patientsQuery); |
| 100 | 103 | |
| 101 | - List<RiskReportResult> results = new ArrayList<>(); | |
| 104 | + List results = new ArrayList<>(); | |
| 102 | 105 | |
| 103 | 106 | BasicConfigQuery basicConfigQuery = new BasicConfigQuery(); |
| 104 | 107 | basicConfigQuery.setYn(YnEnums.YES.getId()); |
| 105 | 108 | basicConfigQuery.setParentId(SystemConfig.HIGH_RISK_ID); |
| 106 | 109 | basicConfigQuery.setEnable(1); |
| 107 | 110 | |
| 111 | + List<Future> futures = new ArrayList<>(); | |
| 108 | 112 | List<BasicConfig> riskLevelConfig = basicConfigService.queryBasicConfig(basicConfigQuery); |
| 109 | 113 | if (CollectionUtils.isNotEmpty(riskLevelConfig)) |
| 110 | 114 | { |
| 115 | + ExecutorService pool = Executors.newFixedThreadPool(riskLevelConfig.size()); | |
| 111 | 116 | for(BasicConfig levelConfig : riskLevelConfig) |
| 112 | 117 | { |
| 113 | - basicConfigQuery.setParentId(levelConfig.getId()); | |
| 114 | - List<BasicConfig> riskConfig = basicConfigService.queryBasicConfig(basicConfigQuery); | |
| 118 | + Callable c = new HiskCountTask( basicConfigService, | |
| 119 | + patientsService, levelConfig, | |
| 120 | + patientsQuery, | |
| 121 | + allPatientCount); | |
| 122 | + Future f = pool.submit(c); | |
| 123 | + futures.add(f); | |
| 124 | + } | |
| 125 | + // 关闭线程池 | |
| 126 | + pool.shutdown(); | |
| 127 | + } | |
| 115 | 128 | |
| 116 | - if (CollectionUtils.isNotEmpty(riskConfig)) { | |
| 117 | - for (BasicConfig config : riskConfig) { | |
| 118 | - patientsQuery.setrFactor(config.getId()); | |
| 119 | - //单个高危孕妇条数 | |
| 120 | - int riskPatientCount = patientsService.queryPatientCount(patientsQuery); | |
| 121 | - if (riskPatientCount > 0) | |
| 122 | - { | |
| 123 | - RiskReportResult risk = new RiskReportResult(); | |
| 124 | - risk.setHighRiskId(config.getId()); | |
| 125 | - risk.setHighRisk(config.getName()); | |
| 126 | - risk.setRiskCount(String.valueOf(riskPatientCount)); | |
| 127 | - | |
| 128 | - DecimalFormat df = new DecimalFormat("0.00"); | |
| 129 | - String percent = df.format((double)riskPatientCount/allPatientCount*100)+"%"; | |
| 130 | - risk.setPercent(percent); | |
| 131 | - risk.setHighLevel(levelConfig.getName()); | |
| 132 | - results.add(risk); | |
| 133 | - } | |
| 134 | - } | |
| 129 | + if (CollectionUtils.isNotEmpty(futures)) | |
| 130 | + { | |
| 131 | + for (Future f : futures) | |
| 132 | + { | |
| 133 | + try { | |
| 134 | + results.add(f.get()); | |
| 135 | + } catch (InterruptedException e) { | |
| 136 | + e.printStackTrace(); | |
| 137 | + } catch (ExecutionException e) { | |
| 138 | + e.printStackTrace(); | |
| 135 | 139 | } |
| 136 | 140 | } |
| 137 | 141 | } |
| 138 | - return new BaseObjectResponse() | |
| 142 | + | |
| 143 | + return new BaseListResponse() | |
| 139 | 144 | .setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(results); |
| 140 | 145 | } |
| 141 | 146 | // |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/RiskReportResult.java
View file @
e3828b9
| 1 | 1 | package com.lyms.platform.operate.web.result; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import java.util.List; | |
| 5 | + | |
| 4 | 6 | /** |
| 5 | 7 | * 高危报表结果 |
| 6 | 8 | * Created by lqy on 2016/11/28 |
| ... | ... | @@ -11,7 +13,7 @@ |
| 11 | 13 | private String highRiskId; |
| 12 | 14 | |
| 13 | 15 | //风险等级 |
| 14 | - private String highLevel; | |
| 16 | + private List highLevel; | |
| 15 | 17 | |
| 16 | 18 | //高危因素 |
| 17 | 19 | private String highRisk; |
| 18 | 20 | |
| ... | ... | @@ -30,11 +32,11 @@ |
| 30 | 32 | this.highRiskId = highRiskId; |
| 31 | 33 | } |
| 32 | 34 | |
| 33 | - public String getHighLevel() { | |
| 35 | + public List getHighLevel() { | |
| 34 | 36 | return highLevel; |
| 35 | 37 | } |
| 36 | 38 | |
| 37 | - public void setHighLevel(String highLevel) { | |
| 39 | + public void setHighLevel(List highLevel) { | |
| 38 | 40 | this.highLevel = highLevel; |
| 39 | 41 | } |
| 40 | 42 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/HiskCountTask.java
View file @
e3828b9
| 1 | +package com.lyms.platform.operate.web.utils; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.service.BasicConfigService; | |
| 4 | +import com.lyms.platform.biz.service.PatientsService; | |
| 5 | +import com.lyms.platform.common.enums.RiskDefaultTypeEnum; | |
| 6 | +import com.lyms.platform.common.enums.YnEnums; | |
| 7 | +import com.lyms.platform.common.utils.SystemConfig; | |
| 8 | +import com.lyms.platform.operate.web.result.RiskReportResult; | |
| 9 | +import com.lyms.platform.pojo.BasicConfig; | |
| 10 | +import com.lyms.platform.query.BasicConfigQuery; | |
| 11 | +import com.lyms.platform.query.PatientsQuery; | |
| 12 | +import org.apache.commons.collections.CollectionUtils; | |
| 13 | + | |
| 14 | +import java.text.DecimalFormat; | |
| 15 | +import java.util.ArrayList; | |
| 16 | +import java.util.HashMap; | |
| 17 | +import java.util.List; | |
| 18 | +import java.util.Map; | |
| 19 | +import java.util.concurrent.Callable; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * Created by Administrator on 2016/11/30. | |
| 23 | + */ | |
| 24 | +public class HiskCountTask implements Callable { | |
| 25 | + | |
| 26 | + private PatientsService patientsService; | |
| 27 | + private BasicConfigService basicConfigService; | |
| 28 | + private BasicConfig basicConfig; | |
| 29 | + private PatientsQuery patientsQuery; | |
| 30 | + private int allPatientCount; | |
| 31 | + | |
| 32 | + public HiskCountTask(BasicConfigService basicConfigService, | |
| 33 | + PatientsService patientsService,BasicConfig basicConfig, | |
| 34 | + PatientsQuery patientsQuery, | |
| 35 | + int allPatientCount) | |
| 36 | + { | |
| 37 | + this.basicConfigService = basicConfigService; | |
| 38 | + this.patientsService = patientsService; | |
| 39 | + this.basicConfig = basicConfig; | |
| 40 | + this.patientsQuery = patientsQuery; | |
| 41 | + this.allPatientCount = allPatientCount; | |
| 42 | + } | |
| 43 | + @Override | |
| 44 | + public List<RiskReportResult> call() throws Exception { | |
| 45 | + | |
| 46 | + BasicConfigQuery basicConfigQuery = new BasicConfigQuery(); | |
| 47 | + basicConfigQuery.setYn(YnEnums.YES.getId()); | |
| 48 | + basicConfigQuery.setParentId(SystemConfig.HIGH_RISK_ID); | |
| 49 | + basicConfigQuery.setEnable(1); | |
| 50 | + | |
| 51 | + List<RiskReportResult> results = new ArrayList<>(); | |
| 52 | + basicConfigQuery.setParentId(basicConfig.getId()); | |
| 53 | + List<BasicConfig> riskConfig = basicConfigService.queryBasicConfig(basicConfigQuery); | |
| 54 | + | |
| 55 | + if (CollectionUtils.isNotEmpty(riskConfig)) { | |
| 56 | + for (BasicConfig config : riskConfig) { | |
| 57 | + patientsQuery.setrFactor(config.getId()); | |
| 58 | + //单个高危孕妇条数 | |
| 59 | + int riskPatientCount = patientsService.queryPatientCount(patientsQuery); | |
| 60 | + if (riskPatientCount > 0) | |
| 61 | + { | |
| 62 | + RiskReportResult risk = new RiskReportResult(); | |
| 63 | + risk.setHighRiskId(config.getId()); | |
| 64 | + risk.setHighRisk(config.getName()); | |
| 65 | + risk.setRiskCount(String.valueOf(riskPatientCount)); | |
| 66 | + | |
| 67 | + DecimalFormat df = new DecimalFormat("0.00"); | |
| 68 | + String percent = df.format((double)riskPatientCount/allPatientCount*100)+"%"; | |
| 69 | + risk.setPercent(percent); | |
| 70 | + | |
| 71 | + if (null != basicConfig) { | |
| 72 | + List level = new ArrayList(); | |
| 73 | + Map map = new HashMap(); | |
| 74 | + String name = basicConfig.getName(); | |
| 75 | + if (name.indexOf("预警") > -1) { | |
| 76 | + name = name.replace("预警", ""); | |
| 77 | + } | |
| 78 | + map.put("name", name); | |
| 79 | + map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
| 80 | + level.add(map); | |
| 81 | + risk.setHighLevel(level); | |
| 82 | + } | |
| 83 | + | |
| 84 | + results.add(risk); | |
| 85 | + } | |
| 86 | + } | |
| 87 | + } | |
| 88 | + return results; | |
| 89 | + } | |
| 90 | +} |