Commit c0f9f7e22f8a0be7fb94d72b641bba7ba2503998
Exists in
master
and in
8 other branches
Merge remote-tracking branch 'origin/master'
Showing 3 changed files
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PredictedStatisticsFacade.java
View file @
c0f9f7e
... | ... | @@ -93,7 +93,7 @@ |
93 | 93 | predictedStatisticsQueryModel.setRiskLevelNameString(getRiskLevelString(riskLevelResultModelList)); |
94 | 94 | predictedStatisticsQueryModel.setRiskFactor(getRiskFactor(patients.getRiskFactorId())); |
95 | 95 | predictedStatisticsQueryModel.setLastCheckEmployee(getLastCheckEmployee(patients.getLastCheckEmployeeId())); |
96 | - predictedStatisticsQueryModel.setGestationalWeeks(getGestationalWeeks(patients.getLastMenses())); | |
96 | + predictedStatisticsQueryModel.setGestationalWeeks(getGestationalWeeks(patients.getLastMenses(), patients.getType(), patients.getDueStatus())); | |
97 | 97 | predictedStatisticsQueryModelList.add(predictedStatisticsQueryModel); |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | 101 | |
102 | 102 | |
... | ... | @@ -149,21 +149,30 @@ |
149 | 149 | |
150 | 150 | } |
151 | 151 | |
152 | - private static String getGestationalWeeks(Date date) { | |
153 | - String str = ""; | |
152 | + private static String getGestationalWeeks(Date date, int type, int dueStatus) { | |
153 | + if (type == 3) { | |
154 | + if (dueStatus == 0) { | |
155 | + return "已分娩"; | |
156 | + } else if (dueStatus == 1) { | |
157 | + return "终止妊娠"; | |
158 | + } else { | |
159 | + return ""; | |
160 | + } | |
161 | + } | |
154 | 162 | try { |
163 | + String str = "孕"; | |
155 | 164 | long s = new Date().getTime() - date.getTime(); |
156 | 165 | long d = s / (60 * 60 * 24 * 1000); |
157 | 166 | int day = (int) d; |
158 | 167 | int w = day / 7; |
159 | 168 | int dd = day % 7; |
160 | - str += "孕" + w + "周"; | |
169 | + str += w + "周"; | |
161 | 170 | if (dd != 0) { |
162 | 171 | str += "+" + dd + "天"; |
163 | 172 | } |
164 | 173 | return str; |
165 | 174 | } catch (Exception e) { |
166 | - return str; | |
175 | + return ""; | |
167 | 176 | } |
168 | 177 | } |
169 | 178 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/RiskReportFacade.java
View file @
c0f9f7e
... | ... | @@ -117,25 +117,9 @@ |
117 | 117 | { |
118 | 118 | continue; |
119 | 119 | } |
120 | - | |
121 | - PatientsQuery query = new PatientsQuery(); | |
122 | - query.setYn(YnEnums.YES.getId()); | |
123 | - query.setBuildTypeList(patientsQuery.getBuildTypeList()); | |
124 | - query.setHospitalId(patientsQuery.getHospitalId()); | |
125 | - query.setDueStatus(patientsQuery.getDueStatus()); | |
126 | - //高危等级 | |
127 | - query.setrLevel(patientsQuery.getrLevel()); | |
128 | - //产检医生 | |
129 | - query.setLastCheckEmployeeId(patientsQuery.getLastCheckEmployeeId()); | |
130 | - query.setDueDateStart(patientsQuery.getDueDateStart()); | |
131 | - query.setDueDateEnd(patientsQuery.getDueDateEnd()); | |
132 | - | |
133 | - query.setBookbuildingDateStart(patientsQuery.getBookbuildingDateStart()); | |
134 | - query.setBookbuildingDateEnd(patientsQuery.getBookbuildingDateEnd()); | |
135 | - | |
136 | 120 | Callable c = new HiskCountTask( basicConfigService, |
137 | 121 | patientsService, levelConfig, |
138 | - query, | |
122 | + patientsQuery, | |
139 | 123 | allPatientCount); |
140 | 124 | Future f = pool.submit(c); |
141 | 125 | futures.add(f); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/HiskCountTask.java
View file @
c0f9f7e
... | ... | @@ -4,8 +4,10 @@ |
4 | 4 | import com.lyms.platform.biz.service.PatientsService; |
5 | 5 | import com.lyms.platform.common.enums.RiskDefaultTypeEnum; |
6 | 6 | import com.lyms.platform.common.enums.YnEnums; |
7 | +import com.lyms.platform.common.utils.ExceptionUtils; | |
7 | 8 | import com.lyms.platform.common.utils.SystemConfig; |
8 | 9 | import com.lyms.platform.operate.web.result.RiskReportResult; |
10 | +import com.lyms.platform.operate.web.worker.WorkHR; | |
9 | 11 | import com.lyms.platform.pojo.BasicConfig; |
10 | 12 | import com.lyms.platform.query.BasicConfigQuery; |
11 | 13 | import com.lyms.platform.query.PatientsQuery; |
12 | 14 | |
... | ... | @@ -16,13 +18,15 @@ |
16 | 18 | import java.util.HashMap; |
17 | 19 | import java.util.List; |
18 | 20 | import java.util.Map; |
19 | -import java.util.concurrent.Callable; | |
21 | +import java.util.concurrent.*; | |
20 | 22 | |
21 | 23 | /** |
22 | 24 | * Created by Administrator on 2016/11/30. |
23 | 25 | */ |
24 | 26 | public class HiskCountTask implements Callable { |
25 | 27 | |
28 | + private static ExecutorService pool = Executors.newFixedThreadPool(4); | |
29 | + | |
26 | 30 | private PatientsService patientsService; |
27 | 31 | private BasicConfigService basicConfigService; |
28 | 32 | private BasicConfig levelConfig; |
29 | 33 | |
30 | 34 | |
31 | 35 | |
32 | 36 | |
33 | 37 | |
34 | 38 | |
35 | 39 | |
... | ... | @@ -52,39 +56,88 @@ |
52 | 56 | List<BasicConfig> riskConfig = basicConfigService.queryBasicConfig(basicConfigQuery); |
53 | 57 | |
54 | 58 | if (CollectionUtils.isNotEmpty(riskConfig)) { |
55 | - for (BasicConfig config : riskConfig) { | |
56 | - patientsQuery.setrFactor(config.getId()); | |
57 | - //单个高危因素孕产妇条数 | |
58 | - int riskPatientCount = patientsService.queryPatientCount(patientsQuery); | |
59 | - if (riskPatientCount > 0) | |
59 | + | |
60 | + int batchSize = 3; | |
61 | + int end = 0; | |
62 | + List<Future> futures = new ArrayList<>(); | |
63 | + for (int i = 0; i < riskConfig.size(); i += batchSize) { | |
64 | + end = (end + batchSize); | |
65 | + if (end > riskConfig.size()) { | |
66 | + end = riskConfig.size(); | |
67 | + } | |
68 | + | |
69 | + final List<BasicConfig> configs = riskConfig.subList(i, end); | |
70 | + Callable c = new Callable() | |
60 | 71 | { |
61 | - RiskReportResult risk = new RiskReportResult(); | |
62 | - risk.setHighRiskId(config.getId()); | |
63 | - risk.setHighRisk(config.getName()); | |
64 | - risk.setRiskCount(String.valueOf(riskPatientCount)); | |
72 | + @Override | |
73 | + public List<RiskReportResult> call() throws Exception { | |
74 | + List<RiskReportResult> datas = new ArrayList<>(); | |
65 | 75 | |
66 | - DecimalFormat df = new DecimalFormat("0.00"); | |
67 | - String percent = df.format((double)riskPatientCount/allPatientCount*100)+"%"; | |
68 | - risk.setPercent(percent); | |
76 | + for (BasicConfig config : configs) { | |
77 | + PatientsQuery query = new PatientsQuery(); | |
78 | + query.setYn(YnEnums.YES.getId()); | |
79 | + query.setBuildTypeList(patientsQuery.getBuildTypeList()); | |
80 | + query.setHospitalId(patientsQuery.getHospitalId()); | |
81 | + query.setDueStatus(patientsQuery.getDueStatus()); | |
82 | + //高危等级 | |
83 | + query.setrLevel(patientsQuery.getrLevel()); | |
84 | + //产检医生 | |
85 | + query.setLastCheckEmployeeId(patientsQuery.getLastCheckEmployeeId()); | |
86 | + query.setDueDateStart(patientsQuery.getDueDateStart()); | |
87 | + query.setDueDateEnd(patientsQuery.getDueDateEnd()); | |
69 | 88 | |
70 | - if (null != levelConfig) { | |
71 | - List level = new ArrayList(); | |
72 | - Map map = new HashMap(); | |
73 | - String name = levelConfig.getName(); | |
74 | - if (name.indexOf("预警") > -1) { | |
75 | - name = name.replace("预警", ""); | |
89 | + query.setBookbuildingDateStart(patientsQuery.getBookbuildingDateStart()); | |
90 | + query.setBookbuildingDateEnd(patientsQuery.getBookbuildingDateEnd()); | |
91 | + | |
92 | + query.setrFactor(config.getId()); | |
93 | + //单个高危因素孕产妇条数 | |
94 | + int riskPatientCount = patientsService.queryPatientCount(query); | |
95 | + if (riskPatientCount > 0) | |
96 | + { | |
97 | + RiskReportResult risk = new RiskReportResult(); | |
98 | + risk.setHighRiskId(config.getId()); | |
99 | + risk.setHighRisk(config.getName()); | |
100 | + risk.setRiskCount(String.valueOf(riskPatientCount)); | |
101 | + | |
102 | + DecimalFormat df = new DecimalFormat("0.00"); | |
103 | + String percent = df.format((double)riskPatientCount/allPatientCount*100)+"%"; | |
104 | + risk.setPercent(percent); | |
105 | + | |
106 | + if (null != levelConfig) { | |
107 | + List level = new ArrayList(); | |
108 | + Map map = new HashMap(); | |
109 | + String name = levelConfig.getName(); | |
110 | + if (name.indexOf("预警") > -1) { | |
111 | + name = name.replace("预警", ""); | |
112 | + } | |
113 | + map.put("name", name); | |
114 | + map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
115 | + level.add(map); | |
116 | + risk.setHighLevel(level); | |
117 | + } | |
118 | + | |
119 | + datas.add(risk); | |
120 | + } | |
76 | 121 | } |
77 | - map.put("name", name); | |
78 | - map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
79 | - level.add(map); | |
80 | - risk.setHighLevel(level); | |
122 | + | |
123 | + return datas; | |
81 | 124 | } |
125 | + }; | |
82 | 126 | |
83 | - results.add(risk); | |
127 | + Future f = pool.submit(c); | |
128 | + futures.add(f); | |
129 | + } | |
130 | + for (Future f : futures) { | |
131 | + try { | |
132 | + results.addAll((List) f.get(30, TimeUnit.SECONDS)); | |
133 | + } catch (Exception e) { | |
134 | + ExceptionUtils.catchException(e, "patient hisk count."); | |
84 | 135 | } |
85 | 136 | } |
86 | 137 | } |
87 | 138 | return results; |
88 | 139 | } |
140 | + | |
141 | + | |
89 | 142 | } |