Commit 34060a2b55e819fd89bd8f5fb181a2e1d33effaf
1 parent
37fc2cf68e
Exists in
master
and in
1 other branch
修改转诊
Showing 4 changed files with 684 additions and 111 deletions
- platform-job-index/src/main/java/com/lyms/platform/job/index/restore/data/ConvertHelper.java
- platform-job-index/src/main/java/com/lyms/platform/job/index/restore/data/HighScoreResult.java
- platform-job-index/src/main/java/com/lyms/platform/job/index/restore/data/Runner.java
- platform-job-index/src/main/java/com/lyms/platform/job/index/restore/data/SyncDataWork.java
platform-job-index/src/main/java/com/lyms/platform/job/index/restore/data/ConvertHelper.java
View file @
34060a2
... | ... | @@ -6,9 +6,7 @@ |
6 | 6 | import com.lyms.platform.common.utils.ReflectionUtils; |
7 | 7 | import com.lyms.platform.common.utils.StringUtils; |
8 | 8 | import com.lyms.platform.permission.model.Organization; |
9 | -import com.lyms.platform.pojo.AntExChuModel; | |
10 | -import com.lyms.platform.pojo.AntenatalExaminationModel; | |
11 | -import com.lyms.platform.pojo.Patients; | |
9 | +import com.lyms.platform.pojo.*; | |
12 | 10 | import com.lymsh.mommybaby.maindata.model.DoctorUsers; |
13 | 11 | import com.lymsh.mommybaby.maindata.model.Hospitals; |
14 | 12 | import com.lymsh.mommybaby.maindata.model.Reports; |
15 | 13 | |
... | ... | @@ -97,7 +95,32 @@ |
97 | 95 | e.printStackTrace(); |
98 | 96 | } |
99 | 97 | } |
98 | + public static com.lymsh.mommybaby.maindata.model.Patients convertToMamiBaby(BabyModel babyModel) { | |
99 | + com.lymsh.mommybaby.maindata.model.Patients patients = new com.lymsh.mommybaby.maindata.model.Patients(); | |
100 | + //新生儿类型为2 | |
101 | + patients.setType(2); | |
102 | + patients.setForeignId(babyModel.getId()); | |
103 | + patients.setGender(babyModel.getSex()); | |
104 | + patients.setCreated(babyModel.getCreated()); | |
105 | + patients.setModified(babyModel.getModified()); | |
106 | + patients.setYn(babyModel.getYn()); | |
107 | + patients.setBirth(babyModel.getBirth()); | |
108 | + patients.setDueDate(babyModel.getDueDate()); | |
109 | + patients.setAge(DateUtil.getAge(babyModel.getBirth())); | |
110 | + patients.setPublishId(0); | |
111 | + patients.setPublishName(AUTO_WORKER); | |
112 | + patients.setServiceType(babyModel.getServiceType()); | |
113 | + patients.setUsername(babyModel.getName()); | |
114 | + return patients; | |
115 | + } | |
100 | 116 | |
117 | + public static Reports convertToBabyCheck(BabyCheckModel babyCheckModel,BabyModel babyModel) { | |
118 | + Reports reports = new Reports(); | |
119 | + reports.setYn(babyCheckModel.getYn()); | |
120 | + reports.setType(2); | |
121 | + reports.setAge(DateUtil.getAge(babyModel.getBirth())); | |
122 | + return reports; | |
123 | + } | |
101 | 124 | /** |
102 | 125 | * mongo的建档信息转换成mysql的患者信息 |
103 | 126 | * |
... | ... | @@ -120,7 +143,7 @@ |
120 | 143 | localPatient.setVip(patients.getVip()); |
121 | 144 | localPatient.setCrisis(0); |
122 | 145 | //孕妇 |
123 | - localPatient.setType(1); | |
146 | + localPatient.setType(patients.getType()); | |
124 | 147 | localPatient.setPublishId(0); |
125 | 148 | localPatient.setPublishName(AUTO_WORKER); |
126 | 149 | return localPatient; |
... | ... | @@ -198,13 +221,7 @@ |
198 | 221 | reports.setCheckType(3); |
199 | 222 | reports.setPublishName(AUTO_WORKER); |
200 | 223 | reports.setNextCheckTime(antExChuModel.getNextCheckTime()); |
201 | - Integer dueWeek = null; | |
202 | - if (null != antExChuModel.getcDueWeek()) { | |
203 | - dueWeek = NumberUtils.toInt(antExChuModel.getcDueWeek()); | |
204 | - } else { | |
205 | - dueWeek = DateUtil.getWeek(lastMenses, antExChuModel.getCheckTime()); | |
206 | - } | |
207 | - reports.setWeeks(dueWeek); | |
224 | + reports.setWeeks(DateUtil.getWeek(lastMenses, antExChuModel.getCheckTime())); | |
208 | 225 | reports.setResult(convertAntExChuResult(antExChuModel, map, doctorUserName)); |
209 | 226 | |
210 | 227 | return reports; |
... | ... | @@ -231,13 +248,8 @@ |
231 | 248 | reports.setCheckType(3); |
232 | 249 | reports.setPublishName(AUTO_WORKER); |
233 | 250 | reports.setNextCheckTime(antExChuModel.getNextCheckTime()); |
234 | - Integer dueWeek = null; | |
235 | - if (null != antExChuModel.getcDueWeek()) { | |
236 | - dueWeek = NumberUtils.toInt(antExChuModel.getcDueWeek()); | |
237 | - } else { | |
238 | - dueWeek = DateUtil.getWeek(lastMenses, antExChuModel.getCheckDate()); | |
239 | - } | |
240 | - reports.setWeeks(dueWeek); | |
251 | + | |
252 | + reports.setWeeks(DateUtil.getWeek(lastMenses, antExChuModel.getCheckDate())); | |
241 | 253 | reports.setResult(convertAntExResult(antExChuModel,rhMap,doctorUserName)); |
242 | 254 | return reports; |
243 | 255 | } |
244 | 256 | |
... | ... | @@ -274,12 +286,12 @@ |
274 | 286 | //高压 |
275 | 287 | if (StringUtils.isNotEmpty(szy)) { |
276 | 288 | java.util.Map<String, Object> dataMap1 = new HashMap<>(); |
277 | - dataMap1.put("k", "血压(低压)"); | |
289 | + dataMap1.put("k", "血压低压"); | |
278 | 290 | dataMap1.put("v", szy+"mmHg"); |
279 | 291 | list.add(dataMap1); |
280 | 292 | } |
281 | 293 | if (StringUtils.isNotEmpty(ssy)) { |
282 | - dataMap.put("k", "高压"); | |
294 | + dataMap.put("k", "血压(高)"); | |
283 | 295 | dataMap.put("v", ssy+"mmHg"); |
284 | 296 | list.add(dataMap); |
285 | 297 | } |
286 | 298 | |
287 | 299 | |
288 | 300 | |
... | ... | @@ -363,15 +375,15 @@ |
363 | 375 | if(null!=obj1){ |
364 | 376 | szy= map.get("szy").toString(); |
365 | 377 | } |
366 | - if (StringUtils.isNotEmpty(ssy)) { | |
378 | + if (StringUtils.isNotEmpty(szy)) { | |
367 | 379 | java.util.Map<String, Object> dataMap1 = new HashMap<>(); |
368 | 380 | dataMap1.put("k", "血压(低压)"); |
369 | - dataMap1.put("v", ssy +"mmHg"); | |
381 | + dataMap1.put("v", szy +"mmHg"); | |
370 | 382 | list.add(dataMap1); |
371 | 383 | } |
372 | - if (StringUtils.isNotEmpty(szy)) { | |
384 | + if (StringUtils.isNotEmpty(ssy)) { | |
373 | 385 | dataMap.put("k", "高压"); |
374 | - dataMap.put("v", szy+ "mmHg"); | |
386 | + dataMap.put("v", ssy+ "mmHg"); | |
375 | 387 | list.add(dataMap); |
376 | 388 | } |
377 | 389 | } |
platform-job-index/src/main/java/com/lyms/platform/job/index/restore/data/HighScoreResult.java
View file @
34060a2
1 | +package com.lyms.platform.job.index.restore.data; | |
2 | + | |
3 | +import com.lyms.platform.common.utils.StringUtils; | |
4 | + | |
5 | +import java.util.ArrayList; | |
6 | +import java.util.Collections; | |
7 | +import java.util.List; | |
8 | + | |
9 | +/** | |
10 | + * Created by Administrator on 2016/8/2 0002. | |
11 | + */ | |
12 | +public class HighScoreResult { | |
13 | + | |
14 | + //高危因素 | |
15 | + private List highRisk = new ArrayList(); | |
16 | + //风险等级颜色 | |
17 | + private List level = new ArrayList(); | |
18 | + //高危评分 | |
19 | + private Integer score = 0; | |
20 | + | |
21 | + public List getHighRisk() { | |
22 | + return highRisk; | |
23 | + } | |
24 | + | |
25 | + public List getLevel() { | |
26 | + return /*filter(*/level/*)*/; | |
27 | + } | |
28 | + | |
29 | + public static List filter(List<java.util.Map> level){ | |
30 | + List list = new ArrayList(); | |
31 | + List addEdList = new ArrayList(); | |
32 | + for(java.util.Map map :level){ | |
33 | + if(!addEdList.contains(map.get("name"))){ | |
34 | + list.add(map); | |
35 | + addEdList.add(map.get("name")); | |
36 | + } | |
37 | + } | |
38 | + return list; | |
39 | + } | |
40 | + | |
41 | + public void setLevel(List level) { | |
42 | + this.level = level; | |
43 | + } | |
44 | + | |
45 | + public void setHighRisk(List highRisk) { | |
46 | + this.highRisk = highRisk; | |
47 | + } | |
48 | + | |
49 | + public Integer getScore() { | |
50 | + if (null == score) { | |
51 | + return 0; | |
52 | + } | |
53 | + return score; | |
54 | + } | |
55 | + | |
56 | + | |
57 | + public String getScoreStr(){ | |
58 | + if(null==score || 0==score){ | |
59 | + return ""; | |
60 | + } | |
61 | + return score+""; | |
62 | + } | |
63 | + | |
64 | + public List<String> getLevelId() { | |
65 | + if (null == level) { | |
66 | + return Collections.emptyList(); | |
67 | + } | |
68 | + List<String> idList = new ArrayList<>(); | |
69 | + for (int i1 = 0; i1 < level.size(); i1++) { | |
70 | + java.util.Map<String, String> map = (java.util.Map<String, String>) level.get(i1); | |
71 | + String name = map.get("id"); | |
72 | + if (StringUtils.isNotEmpty(name)) { | |
73 | + idList.add(name); | |
74 | + } | |
75 | + } | |
76 | + return idList; | |
77 | + } | |
78 | + | |
79 | + public List<String> getHighId() { | |
80 | + if (null == highRisk) { | |
81 | + return Collections.emptyList(); | |
82 | + } | |
83 | + List<String> idList = new ArrayList<>(); | |
84 | + for (int i1 = 0; i1 < highRisk.size(); i1++) { | |
85 | + java.util.Map<String, String> map = (java.util.Map<String, String>) highRisk.get(i1); | |
86 | + String id = map.get("id"); | |
87 | + if (StringUtils.isNotEmpty(id)) { | |
88 | + idList.add(id); | |
89 | + } | |
90 | + } | |
91 | + return idList; | |
92 | + } | |
93 | + | |
94 | + public String getOtherHigh(){ | |
95 | + if (null == highRisk) { | |
96 | + return ""; | |
97 | + } | |
98 | + StringBuilder stringBuilder=new StringBuilder(); | |
99 | + for (int i1 = 0; i1 < highRisk.size(); i1++) { | |
100 | + java.util.Map<String, String> map = (java.util.Map<String, String>) highRisk.get(i1); | |
101 | + String id = map.get("id"); | |
102 | + if (StringUtils.isEmpty(id)) { | |
103 | + stringBuilder.append(map.get("name")).append(","); | |
104 | + } | |
105 | + } | |
106 | + if(stringBuilder.length()>0){ | |
107 | + stringBuilder.setLength(stringBuilder.length()-1); | |
108 | + } | |
109 | + return stringBuilder.toString(); | |
110 | + } | |
111 | + | |
112 | + public void setScore(Integer score) { | |
113 | + this.score = score; | |
114 | + } | |
115 | + | |
116 | + public String getLevelStr() { | |
117 | + StringBuilder stringBuilder = new StringBuilder(); | |
118 | + if (null == level) { | |
119 | + return ""; | |
120 | + } | |
121 | + for (int i1 = 0; i1 < level.size(); i1++) { | |
122 | + java.util.Map<String, String> map = (java.util.Map<String, String>) level.get(i1); | |
123 | + String name = map.get("name"); | |
124 | + if (stringBuilder.indexOf(name) == -1) { | |
125 | + stringBuilder.append(map.get("name")).append(", "); | |
126 | + } | |
127 | + } | |
128 | + if (stringBuilder.length() >= 2) { | |
129 | + stringBuilder.setLength(stringBuilder.length() - 2); | |
130 | + } | |
131 | + return stringBuilder.toString(); | |
132 | + } | |
133 | + | |
134 | + public String getLevelStr(List levelList) { | |
135 | + StringBuilder stringBuilder = new StringBuilder(); | |
136 | + if (null == levelList) { | |
137 | + return ""; | |
138 | + } | |
139 | + for (int i1 = 0; i1 < levelList.size(); i1++) { | |
140 | + java.util.Map<String, String> map = (java.util.Map<String, String>) levelList.get(i1); | |
141 | + String name = map.get("name"); | |
142 | + if (stringBuilder.indexOf(name) == -1) { | |
143 | + stringBuilder.append(map.get("name")).append(", "); | |
144 | + } | |
145 | + } | |
146 | + if (stringBuilder.length() >= 2) { | |
147 | + stringBuilder.setLength(stringBuilder.length() - 2); | |
148 | + } | |
149 | + return stringBuilder.toString(); | |
150 | + } | |
151 | + public String gethighRiskStr() { | |
152 | + StringBuilder stringBuilder = new StringBuilder(); | |
153 | + if (null == highRisk) { | |
154 | + return ""; | |
155 | + } | |
156 | + for (int i1 = 0; i1 < highRisk.size(); i1++) { | |
157 | + java.util.Map<String, String> map = (java.util.Map<String, String>) highRisk.get(i1); | |
158 | + stringBuilder.append(map.get("name")).append(", "); | |
159 | + } | |
160 | + if (stringBuilder.length() >= 2) { | |
161 | + stringBuilder.setLength(stringBuilder.length() - 2); | |
162 | + } | |
163 | + return stringBuilder.toString(); | |
164 | + } | |
165 | + public List gethighRiskList(){ | |
166 | + List<String> list=new ArrayList<>(); | |
167 | + if (null == highRisk) { | |
168 | + return list; | |
169 | + } | |
170 | + for (int i1 = 0; i1 < highRisk.size(); i1++) { | |
171 | + java.util.Map<String, String> map = (java.util.Map<String, String>) highRisk.get(i1); | |
172 | + list.add(map.get("name")); | |
173 | + } | |
174 | + return list; | |
175 | + } | |
176 | +} |
platform-job-index/src/main/java/com/lyms/platform/job/index/restore/data/Runner.java
View file @
34060a2
1 | 1 | package com.lyms.platform.job.index.restore.data; |
2 | 2 | |
3 | +import com.lyms.platform.common.enums.YnEnums; | |
4 | +import com.lyms.platform.query.PatientsQuery; | |
3 | 5 | import org.apache.log4j.PropertyConfigurator; |
4 | 6 | import org.springframework.context.ApplicationContext; |
5 | 7 | import org.springframework.context.support.ClassPathXmlApplicationContext; |
6 | 8 | |
9 | +import java.util.Date; | |
10 | + | |
7 | 11 | /** |
8 | 12 | * Created by Administrator on 2016/9/29 0029. |
9 | 13 | */ |
10 | 14 | public class Runner { |
11 | 15 | public static void main(String[] args)throws Exception{ |
12 | - PropertyConfigurator.configure("D:\git resouce\regional-platform\platform-job-index\target\classes\log4j_config.xml"); | |
16 | + /* PropertyConfigurator.configure("D:\git resouce\regional-platform\platform-job-index\target\classes\log4j_config.xml"); | |
13 | 17 | ApplicationContext applicationContext=new ClassPathXmlApplicationContext("classpath:/spring/applicationContext-sync-data.xml"); |
14 | 18 | SyncDataWork syncDataWork = applicationContext.getBean(SyncDataWork.class); |
15 | - syncDataWork.sync(); | |
19 | + syncDataWork.sync();*/ | |
20 | + | |
21 | + long lastSyncTime=System.currentTimeMillis(); | |
22 | + PatientsQuery patientsQuery1 = new PatientsQuery(); | |
23 | + patientsQuery1.setYn(YnEnums.YES.getId()); | |
24 | +// patientsQuery1.setHospitalId(hospitalId); | |
25 | + if (-1 != lastSyncTime) { | |
26 | + patientsQuery1.setGteModified(new Date(lastSyncTime)); | |
27 | + patientsQuery1.setGteCreated(new Date(lastSyncTime)); | |
28 | + } | |
29 | + patientsQuery1.setCreated(new Date()); | |
30 | + System.out.println(patientsQuery1.convertToQuery().convertToMongoQuery());; | |
16 | 31 | } |
17 | 32 | } |
platform-job-index/src/main/java/com/lyms/platform/job/index/restore/data/SyncDataWork.java
View file @
34060a2
1 | 1 | package com.lyms.platform.job.index.restore.data; |
2 | 2 | |
3 | -import com.lyms.platform.biz.service.AntenatalExaminationService; | |
4 | -import com.lyms.platform.biz.service.BasicConfigService; | |
5 | -import com.lyms.platform.biz.service.YunBookbuildingService; | |
3 | +import com.lyms.platform.biz.service.*; | |
4 | +import com.lyms.platform.common.enums.RiskDefaultTypeEnum; | |
6 | 5 | import com.lyms.platform.common.enums.YnEnums; |
7 | 6 | import com.lyms.platform.common.utils.DateUtil; |
7 | +import com.lyms.platform.common.utils.JsonUtil; | |
8 | 8 | import com.lyms.platform.common.utils.SystemConfig; |
9 | 9 | import com.lyms.platform.permission.model.Organization; |
10 | 10 | import com.lyms.platform.permission.model.OrganizationQuery; |
11 | 11 | import com.lyms.platform.permission.model.Users; |
12 | 12 | import com.lyms.platform.permission.model.UsersQuery; |
13 | 13 | import com.lyms.platform.permission.service.OrganizationService; |
14 | -import com.lyms.platform.pojo.AntExChuModel; | |
15 | -import com.lyms.platform.pojo.AntenatalExaminationModel; | |
16 | -import com.lyms.platform.pojo.BasicConfig; | |
17 | -import com.lyms.platform.pojo.Patients; | |
18 | -import com.lyms.platform.query.AntExChuQuery; | |
19 | -import com.lyms.platform.query.AntExQuery; | |
20 | -import com.lyms.platform.query.BasicConfigQuery; | |
14 | +import com.lyms.platform.pojo.*; | |
15 | +import com.lyms.platform.query.*; | |
21 | 16 | import com.lyms.platform.query.PatientsQuery; |
17 | +import com.lymsh.mommybaby.maindata.enumdata.RiskColorEnum; | |
22 | 18 | import com.lymsh.mommybaby.maindata.enumdata.YnEnum; |
23 | 19 | import com.lymsh.mommybaby.maindata.model.*; |
20 | +import com.lymsh.mommybaby.maindata.model.Patients; | |
24 | 21 | import com.lymsh.mommybaby.maindata.service.*; |
22 | +import com.lymsh.mommybaby.maindata.service.PatientsService; | |
25 | 23 | import org.apache.commons.collections.CollectionUtils; |
26 | -import org.apache.commons.io.FileUtils; | |
27 | 24 | import org.apache.commons.lang.StringUtils; |
28 | 25 | import org.apache.commons.lang.math.NumberUtils; |
29 | 26 | import org.slf4j.Logger; |
30 | 27 | import org.slf4j.LoggerFactory; |
31 | -import org.springframework.beans.factory.annotation.Autowire; | |
32 | 28 | import org.springframework.beans.factory.annotation.Autowired; |
33 | 29 | import org.springframework.beans.factory.annotation.Value; |
34 | 30 | import org.springframework.stereotype.Component; |
35 | 31 | import org.springframework.util.StopWatch; |
36 | - | |
37 | 32 | import java.io.File; |
38 | 33 | import java.io.RandomAccessFile; |
39 | -import java.util.Date; | |
40 | -import java.util.HashMap; | |
41 | -import java.util.List; | |
34 | +import java.util.*; | |
42 | 35 | import java.util.concurrent.CountDownLatch; |
43 | 36 | import java.util.concurrent.LinkedBlockingQueue; |
44 | 37 | import java.util.concurrent.ThreadPoolExecutor; |
... | ... | @@ -54,6 +47,7 @@ |
54 | 47 | |
55 | 48 | |
56 | 49 | private Logger logger = LoggerFactory.getLogger("sync-data"); |
50 | + private Logger ERROR_LOGGER = LoggerFactory.getLogger("COMMON-ERROR"); | |
57 | 51 | |
58 | 52 | @Autowired |
59 | 53 | private OrganizationService organizationService; |
... | ... | @@ -98,6 +92,14 @@ |
98 | 92 | private DoctorUsersPatientsMapsService doctorUsersPatientsMapsService; |
99 | 93 | @Autowired |
100 | 94 | private MembersService membersService; |
95 | + @Autowired | |
96 | + private RiskDetailsService riskDetailsService; | |
97 | + @Autowired | |
98 | + private RisksService risksService; | |
99 | + @Autowired | |
100 | + private BabyCheckService babyCheckService; | |
101 | + @Autowired | |
102 | + private BabyService babyService; | |
101 | 103 | |
102 | 104 | @Value("#{configProperties['file.path']}") |
103 | 105 | private String FILE_PATH; |
104 | 106 | |
... | ... | @@ -111,12 +113,21 @@ |
111 | 113 | private java.util.Map<String, Integer> mamiRegions = new HashMap<>(); |
112 | 114 | //高危因素 |
113 | 115 | private java.util.Map<String, String> bgHighRisk = new HashMap<>(); |
114 | - | |
116 | + private static Map<String, RiskColorEnum> map = new HashMap<>(); | |
115 | 117 | /** |
116 | 118 | * mongo 里面省市区的id |
117 | 119 | */ |
118 | 120 | public static final String CHINA_BASIC_ID = "f6c505dd-835a-43d7-b0bb-fdb9eb0b7b31"; |
119 | 121 | |
122 | + | |
123 | + static { | |
124 | + map.put("橙色", RiskColorEnum.Orange); | |
125 | + map.put("黄色", RiskColorEnum.Yellow); | |
126 | + map.put("红色", RiskColorEnum.Red); | |
127 | + map.put("紫色", RiskColorEnum.Purple); | |
128 | + map.put("绿色", RiskColorEnum.Green); | |
129 | + } | |
130 | + | |
120 | 131 | private long readLastSyncTime() { |
121 | 132 | try { |
122 | 133 | if (-1 != lastSyncTime) { |
... | ... | @@ -221,6 +232,35 @@ |
221 | 232 | return hospitals; |
222 | 233 | } |
223 | 234 | |
235 | + private void loadRpBaby(String hospitalId) { | |
236 | + BabyModelQuery babyModelQuery = new BabyModelQuery(); | |
237 | + babyModelQuery.setHospitalId(hospitalId); | |
238 | + babyModelQuery.setYn(YnEnums.YES.getId()); | |
239 | + if (-1 != lastSyncTime) { | |
240 | + babyModelQuery.setGteModified(new Date(lastSyncTime)); | |
241 | + babyModelQuery.setGteCreated(new Date(lastSyncTime)); | |
242 | + } | |
243 | + List<BabyModel> babyModels= babyService.queryBabyWithQuery(babyModelQuery); | |
244 | + if(CollectionUtils.isNotEmpty(babyModels)){ | |
245 | + for(BabyModel babyModel:babyModels){ | |
246 | + Patients patients= ConvertHelper.convertToMamiBaby(babyModel); | |
247 | + patientsService.aouPatients(patients); | |
248 | + | |
249 | + BabyCheckModelQuery babyCheckModelQuery=new BabyCheckModelQuery(); | |
250 | + babyCheckModelQuery.setYn(YnEnums.YES.getId()); | |
251 | + babyCheckModelQuery.setBuildId(babyModel.getId()); | |
252 | + babyCheckModelQuery.setHospitalId(hospitalId); | |
253 | + List<BabyCheckModel> babyCheckModels= babyCheckService.queryBabyCheckRecord(babyCheckModelQuery); | |
254 | + if(CollectionUtils.isNotEmpty(babyCheckModels)){ | |
255 | + for(BabyCheckModel babyCheckModel:babyCheckModels){ | |
256 | + Reports reports= ConvertHelper.convertToBabyCheck(babyCheckModel, babyModel); | |
257 | + reportsService.aouReports(reports); | |
258 | + } | |
259 | + } | |
260 | + } | |
261 | + } | |
262 | + } | |
263 | + | |
224 | 264 | public void sync() throws InterruptedException { |
225 | 265 | long l = System.currentTimeMillis(); |
226 | 266 | //获取最后一次同步的时间 如果为-1就表示是全量同步 |
... | ... | @@ -236,7 +276,6 @@ |
236 | 276 | //查询符合条件的机构 |
237 | 277 | List<Organization> organizationList = organizationService.queryOrganization(organizationQuery); |
238 | 278 | CountDownLatch countDownLatch = null; |
239 | - ; | |
240 | 279 | if (CollectionUtils.isNotEmpty(organizationList)) { |
241 | 280 | Hospitals hospitals = null; |
242 | 281 | countDownLatch = new CountDownLatch(organizationList.size()); |
243 | 282 | |
244 | 283 | |
... | ... | @@ -263,14 +302,33 @@ |
263 | 302 | countDownLatch.await(); |
264 | 303 | //持久化最后一次同步时间 |
265 | 304 | writeLastSyncTime(); |
266 | - clearAll(); | |
305 | +// clearAll(); | |
306 | + //单独同步秦皇岛 | |
307 | + syncQHDWork(); | |
267 | 308 | logger.info("sync end costTime:" + (System.currentTimeMillis() - l) + " ms."); |
268 | 309 | } |
269 | - private void clearAll(){ | |
310 | + | |
311 | + private void clearAll() { | |
270 | 312 | orgMapToId.clear(); |
271 | 313 | mamiRegions.clear(); |
272 | 314 | bgHighRisk.clear(); |
273 | 315 | } |
316 | + | |
317 | + private void syncQHDWork() { | |
318 | + Timer timer = new Timer(); | |
319 | + timer.schedule(new TimerTask() { | |
320 | + @Override | |
321 | + public void run() { | |
322 | + logger.info("syncQHDWork start ." + DateUtil.getymdhm(new Date())); | |
323 | + CountDownLatch countDownLatch = new CountDownLatch(1); | |
324 | + String hospitalId = "216"; | |
325 | + new SyncWork(hospitalId, countDownLatch).start(); | |
326 | + logger.info("syncQHDWork end ." + DateUtil.getymdhm(new Date())); | |
327 | + } | |
328 | + }, 600000, 300000); | |
329 | + } | |
330 | + | |
331 | + | |
274 | 332 | /** |
275 | 333 | * 执行同步的工作线程 |
276 | 334 | */ |
277 | 335 | |
278 | 336 | |
279 | 337 | |
... | ... | @@ -287,61 +345,68 @@ |
287 | 345 | this.countDownLatch = countDownLatch; |
288 | 346 | } |
289 | 347 | |
348 | + /** | |
349 | + * 查询医院下的用户 | |
350 | + * | |
351 | + * @return | |
352 | + */ | |
353 | + private List<Users> queryUser() { | |
354 | + StopWatch stopWatch = new StopWatch("SyncWork-" + hospitalId); | |
355 | + //查询出该医院所以的医生用户 | |
356 | + UsersQuery usersQuery = new UsersQuery(); | |
357 | + usersQuery.setYn(YnEnums.YES.getId()); | |
358 | + usersQuery.setOrgId(Integer.valueOf(hospitalId)); | |
359 | + /* if (-1 != lastSyncTime) { | |
360 | + usersQuery.setGteModified(new Date(lastSyncTime)); | |
361 | + usersQuery.setGteCreated(new Date(lastSyncTime)); | |
362 | + }*/ | |
363 | + stopWatch.start("queryUsers"); | |
364 | + List<Users> userses = usersService.queryUsers(usersQuery); | |
365 | + stopWatch.stop(); | |
366 | + logger.info(stopWatch.toString()); | |
367 | + return userses; | |
368 | + } | |
369 | + | |
370 | + private void loadDoctorUsers() { | |
371 | + List<Users> userses = queryUser(); | |
372 | + DoctorUsers doctorUsers = null; | |
373 | + if (CollectionUtils.isNotEmpty(userses)) { | |
374 | + for (Users users : userses) { | |
375 | + DoctorUsersQuery doctorUsersQuery = new DoctorUsersQuery(); | |
376 | + doctorUsersQuery.setYn(YnEnums.YES.getId()); | |
377 | + doctorUsersQuery.setHospitalId(orgMapToId.get(hospitalId)); | |
378 | + doctorUsersQuery.setUsername(users.getName()); | |
379 | + StopWatch stopWatch1 = new StopWatch("SyncWork-" + hospitalId + ",userId:" + users.getId()); | |
380 | + stopWatch1.start("queryDoctorUsers"); | |
381 | + List<DoctorUsers> doctorUsersList = doctorUsersService.queryDoctorUsers(doctorUsersQuery); | |
382 | + stopWatch1.stop(); | |
383 | + if (CollectionUtils.isNotEmpty(doctorUsersList)) { | |
384 | + doctorUsers = doctorUsersList.get(0); | |
385 | + } else { | |
386 | + //医生用户转换 | |
387 | + doctorUsers = ConvertHelper.convertUsers(users); | |
388 | + doctorUsers.setHospitalId(orgMapToId.get(hospitalId)); | |
389 | + stopWatch1.start("addDoctorUsers"); | |
390 | + doctorUsersService.addDoctorUsers(doctorUsers); | |
391 | + stopWatch1.stop(); | |
392 | + } | |
393 | + if (null != doctorUsers) { | |
394 | + userMapping.put(users.getId(), doctorUsers.getId()); | |
395 | + } | |
396 | + logger.info(stopWatch1.toString()); | |
397 | + } | |
398 | + logger.info("hospitalId" + hospitalId + ",userMapping :" + userMapping); | |
399 | + } | |
400 | + } | |
401 | + | |
290 | 402 | @Override |
291 | 403 | public void run() { |
292 | 404 | try { |
293 | 405 | long l = System.currentTimeMillis(); |
294 | - logger.info("begin sync work hospital:" + hospitalId + ",at time " + DateUtil.getyyyy_MM_dd(new Date())); | |
295 | - StopWatch stopWatch = new StopWatch("SyncWork-" + hospitalId); | |
296 | - //查询出该医院所以的医生用户 | |
297 | - UsersQuery usersQuery = new UsersQuery(); | |
298 | - usersQuery.setYn(YnEnums.YES.getId()); | |
299 | - usersQuery.setOrgId(Integer.valueOf(hospitalId)); | |
300 | - if (-1 != lastSyncTime) { | |
301 | - usersQuery.setGteModified(new Date(lastSyncTime)); | |
302 | - usersQuery.setGteCreated(new Date(lastSyncTime)); | |
303 | - } | |
304 | - stopWatch.start("queryUsers"); | |
305 | - List<Users> userses = usersService.queryUsers(usersQuery); | |
306 | - stopWatch.stop(); | |
307 | - logger.info(stopWatch.toString()); | |
308 | - DoctorUsers doctorUsers = null; | |
406 | + logger.info("begin sync work hospital:" + hospitalId + ",at time " + DateUtil.getyyyy_MM_dd_hms(new Date())); | |
309 | 407 | |
310 | - if (CollectionUtils.isNotEmpty(userses)) { | |
311 | - for (Users users : userses) { | |
312 | - DoctorUsersQuery doctorUsersQuery = new DoctorUsersQuery(); | |
313 | -// doctorUsersQuery.setForeignId(users.getId() + ""); | |
314 | - doctorUsersQuery.setYn(YnEnums.YES.getId()); | |
315 | - doctorUsersQuery.setHospitalId(orgMapToId.get(hospitalId)); | |
316 | - doctorUsersQuery.setUsername(users.getName()); | |
317 | - StopWatch stopWatch1 = new StopWatch("SyncWork-" + hospitalId + ",userId:" + users.getId()); | |
318 | - stopWatch1.start("queryDoctorUsers"); | |
319 | - List<DoctorUsers> doctorUsersList = doctorUsersService.queryDoctorUsers(doctorUsersQuery); | |
320 | - stopWatch1.stop(); | |
321 | - if (CollectionUtils.isNotEmpty(doctorUsersList)) { | |
322 | - doctorUsers = doctorUsersList.get(0); | |
323 | - /* doctorUsers = ConvertHelper.convertUsers(users); | |
324 | - doctorUsers.setHospitalId(orgMapToId.get(hospitalId)); | |
325 | - stopWatch1.start("updateDoctorUsers"); | |
326 | - doctorUsersService.updateDoctorUsers(doctorUsers); | |
327 | - stopWatch1.stop();*/ | |
328 | - } else { | |
329 | - //医生用户转换 | |
330 | - doctorUsers = ConvertHelper.convertUsers(users); | |
331 | - doctorUsers.setHospitalId(orgMapToId.get(hospitalId)); | |
332 | - stopWatch1.start("addDoctorUsers"); | |
333 | - doctorUsersService.addDoctorUsers(doctorUsers); | |
334 | - stopWatch1.stop(); | |
335 | - } | |
408 | + loadDoctorUsers(); | |
336 | 409 | |
337 | - if (null != doctorUsers) { | |
338 | - userMapping.put(users.getId(), doctorUsers.getId()); | |
339 | - } | |
340 | - logger.info(stopWatch1.toString()); | |
341 | - } | |
342 | - logger.info("hospitalId" + hospitalId + ",userMapping :" + userMapping); | |
343 | - } | |
344 | - | |
345 | 410 | PatientsQuery patientsQuery1 = new PatientsQuery(); |
346 | 411 | patientsQuery1.setYn(YnEnums.YES.getId()); |
347 | 412 | patientsQuery1.setHospitalId(hospitalId); |
348 | 413 | |
349 | 414 | |
... | ... | @@ -351,14 +416,23 @@ |
351 | 416 | } |
352 | 417 | StopWatch stopWatch2 = new StopWatch("SyncWork-" + hospitalId + "-query patient"); |
353 | 418 | stopWatch2.start("queryPregnantWithQuery"); |
354 | - List<Patients> patientses = yunBookbuildingService.queryPregnantWithQuery(patientsQuery1); | |
419 | + List<com.lyms.platform.pojo.Patients> patientses = yunBookbuildingService.queryPregnantWithQuery(patientsQuery1); | |
355 | 420 | stopWatch2.stop(); |
356 | 421 | logger.info(stopWatch2.toString()); |
357 | 422 | logger.info("query patient by hospitalId:" + hospitalId + ", list size :" + patientses.size()); |
358 | 423 | if (CollectionUtils.isNotEmpty(patientses)) { |
359 | - for (Patients patients : patientses) { | |
424 | + for (com.lyms.platform.pojo.Patients patients : patientses) { | |
360 | 425 | StopWatch stopWatch3 = new StopWatch("SyncWork-" + hospitalId + "-patient-" + patients.getId()); |
361 | 426 | com.lymsh.mommybaby.maindata.model.Patients mamiPatient = ConvertHelper.convertPatient(patients); |
427 | + if (StringUtils.isNotEmpty(mamiPatient.getPhone())) { | |
428 | + MembersQuery membersQuery = new MembersQuery(); | |
429 | + membersQuery.setPhone(mamiPatient.getPhone()); | |
430 | + List<Members> memberses = membersService.queryMembers(membersQuery); | |
431 | + if (CollectionUtils.isNotEmpty(memberses)) { | |
432 | + mamiPatient.setMemberId(memberses.get(0).getId()); | |
433 | + } | |
434 | + } | |
435 | + | |
362 | 436 | stopWatch3.start("aouPatients"); |
363 | 437 | //增加建档记录 |
364 | 438 | patientsService.aouPatients(mamiPatient); |
... | ... | @@ -366,14 +440,6 @@ |
366 | 440 | //绑定用户 |
367 | 441 | bandingMember(mamiPatient); |
368 | 442 | |
369 | - AntExChuQuery antExChuQuery = new AntExChuQuery(); | |
370 | - antExChuQuery.setYn(YnEnums.YES.getId()); | |
371 | - antExChuQuery.setParentId(patients.getId()); | |
372 | - if (-1 != lastSyncTime) { | |
373 | - antExChuQuery.setGteModified(new Date(lastSyncTime)); | |
374 | - antExChuQuery.setGteCreated(new Date(lastSyncTime)); | |
375 | - } | |
376 | - | |
377 | 443 | DoctorUsersPatientsMaps doctorUsersPatientsMaps = new DoctorUsersPatientsMaps(); |
378 | 444 | doctorUsersPatientsMaps.setCreated(new Date()); |
379 | 445 | doctorUsersPatientsMaps.setYn(YnEnums.YES.getId()); |
... | ... | @@ -392,7 +458,6 @@ |
392 | 458 | doctorUsersPatientsMaps.setStatus(1); |
393 | 459 | doctorUsersPatientsMaps.setStatusName("待处理"); |
394 | 460 | |
395 | - | |
396 | 461 | doctorUsersPatientsMaps.setPatientId(mamiPatient.getId()); |
397 | 462 | if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { |
398 | 463 | doctorUsersPatientsMaps.setDoctorUserId(userMapping.get(Integer.valueOf(patients.getBookbuildingDoctor()))); |
399 | 464 | |
400 | 465 | |
... | ... | @@ -401,13 +466,21 @@ |
401 | 466 | stopWatch3.stop(); |
402 | 467 | } |
403 | 468 | |
469 | + AntExChuQuery antExChuQuery = new AntExChuQuery(); | |
470 | + antExChuQuery.setYn(YnEnums.YES.getId()); | |
471 | + antExChuQuery.setParentId(patients.getId()); | |
472 | + if (-1 != lastSyncTime) { | |
473 | + antExChuQuery.setGteModified(new Date(lastSyncTime)); | |
474 | + antExChuQuery.setGteCreated(new Date(lastSyncTime)); | |
475 | + } | |
404 | 476 | List<AntExChuModel> antExChuModel = antenatalExaminationService.queryAntExChu(antExChuQuery); |
405 | 477 | if (CollectionUtils.isEmpty(antExChuModel)) { |
406 | 478 | continue; |
407 | 479 | } |
480 | + | |
481 | + handLastRisk(patients, mamiPatient.getId()); | |
408 | 482 | String doctorUserName = null; |
409 | 483 | for (AntExChuModel antExChuModel1 : antExChuModel) { |
410 | - | |
411 | 484 | Integer doctorUserId = userMapping.get(Integer.valueOf(antExChuModel1.getProdDoctor())); |
412 | 485 | if (null != doctorUserId) { |
413 | 486 | DoctorUsers doctorUsers1 = doctorUsersService.getDoctorUsers(doctorUserId); |
414 | 487 | |
... | ... | @@ -415,8 +488,10 @@ |
415 | 488 | doctorUserName = doctorUsers1.getUsername(); |
416 | 489 | } |
417 | 490 | } |
491 | + /* stopWatch3.start("handlRiskChu"); | |
492 | + handlRiskChu(antExChuModel1, mamiPatient.getId()); | |
493 | + stopWatch3.stop();*/ | |
418 | 494 | |
419 | - | |
420 | 495 | Reports reports = ConvertHelper.convertAntExChu(antExChuModel1, patients.getLastMenses(), bgHighRisk, doctorUserName); |
421 | 496 | if (NumberUtils.isNumber(antExChuModel1.getProdDoctor())) { |
422 | 497 | Users users = usersService.getUsers(Integer.valueOf(antExChuModel1.getProdDoctor())); |
... | ... | @@ -436,6 +511,8 @@ |
436 | 511 | stopWatch3.start("aouReports"); |
437 | 512 | reportsService.aouReports(reports); |
438 | 513 | stopWatch3.stop(); |
514 | + | |
515 | + | |
439 | 516 | com.lymsh.mommybaby.maindata.model.Patients p = new com.lymsh.mommybaby.maindata.model.Patients(); |
440 | 517 | p.setLastReportId(reports.getId()); |
441 | 518 | p.setLastReportDoctorName(reports.getDoctorName()); |
... | ... | @@ -492,8 +569,9 @@ |
492 | 569 | doctorUserName = doctorUsers1.getUsername(); |
493 | 570 | } |
494 | 571 | } |
495 | - | |
496 | - | |
572 | + /* stopWatch3.start("handRiskFu"); | |
573 | + handRiskFu(ant, mamiPatient.getId()); | |
574 | + stopWatch3.stop();*/ | |
497 | 575 | Reports reports = ConvertHelper.convertAntExChu(ant, patients.getLastMenses(), bgHighRisk, doctorUserName); |
498 | 576 | |
499 | 577 | if (NumberUtils.isNumber(ant.getCheckDoctor())) { |
500 | 578 | |
... | ... | @@ -556,12 +634,304 @@ |
556 | 634 | } |
557 | 635 | logger.info("hospital " + hospitalId + ",costTime:" + (System.currentTimeMillis() - l)); |
558 | 636 | } catch (Exception e) { |
559 | - e.printStackTrace(); | |
637 | + ERROR_LOGGER.error("sync worker error.hospitalId:" + hospitalId, e); | |
560 | 638 | } finally { |
561 | 639 | countDownLatch.countDown(); |
562 | 640 | } |
563 | 641 | } |
564 | 642 | } |
643 | + | |
644 | + private void handRiskFu(AntenatalExaminationModel antEx, Integer patientId) { | |
645 | + Risks risks = new Risks(); | |
646 | + risks.setCreated(antEx.getCreated()); | |
647 | + risks.setYn(YnEnums.YES.getId()); | |
648 | + risks.setModified(antEx.getModified()); | |
649 | + | |
650 | + risks.setPatientId(patientId); | |
651 | + List list2 = JsonUtil.toList(antEx.getRiskFactor(), List.class); | |
652 | + HighScoreResult highScoreResult = queryRisk(list2, patientId); | |
653 | + | |
654 | + if (null != antEx && !"{}".equals(antEx.getOtherRisk())) { | |
655 | + Map map = JsonUtil.str2Obj(antEx.getOtherRisk(), Map.class); | |
656 | + //风险因素 | |
657 | + Map map1 = new HashMap(); | |
658 | + map1.put("id", ""); | |
659 | + Object obj = map.get("fxysu"); | |
660 | + if (null != obj && !"null".equals(obj.toString()) && !"".equals(obj.toString())) { | |
661 | + map1.put("name", map.get("fxysu")); | |
662 | + highScoreResult.getHighRisk().add(map1); | |
663 | + } | |
664 | + RiskDetails riskDetails = new RiskDetails(); | |
665 | + //风险评分 | |
666 | + Object idObj = map.get("fxpf"); | |
667 | + if (null != idObj && !"null".equals(idObj.toString()) && !"".equals(idObj.toString())) { | |
668 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(idObj.toString()); | |
669 | + riskDetails.setScore(NumberUtils.toInt(basicConfig.getName())); | |
670 | + highScoreResult.setScore(highScoreResult.getScore() + NumberUtils.toInt(basicConfig.getName(), 0)); | |
671 | + } | |
672 | + Object idObj1 = map.get("fyyse"); | |
673 | + if (null != idObj1 && !"null".equals(idObj1.toString()) && !"".equals(idObj1.toString())) { | |
674 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(idObj1.toString()); | |
675 | + if (null != basicConfig) { | |
676 | + Map<String, Object> map2 = new HashMap<>(); | |
677 | + map2.put("id", basicConfig.getId()); | |
678 | + String name = basicConfig.getName(); | |
679 | + if (name.indexOf("预警") > -1) { | |
680 | + name = name.replace("预警", ""); | |
681 | + } | |
682 | + map2.put("name", name); | |
683 | + RiskColorEnum riskColorEnum = SyncDataWork.map.get(name); | |
684 | + riskDetails.setCrisis(riskColorEnum == null ? null : riskColorEnum.getId()); | |
685 | + map2.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
686 | + highScoreResult.getLevel().add(map2); | |
687 | + } | |
688 | + } | |
689 | + Object obj1 = map1.get("name"); | |
690 | + if (null != obj1) { | |
691 | + riskDetails.setTitle(map1.get("name").toString()); | |
692 | + riskDetails.setPublishName("system-worker"); | |
693 | + riskDetails.setPublishId(0); | |
694 | + riskDetails.setYn(YnEnums.YES.getId()); | |
695 | + riskDetails.setCreated(new Date()); | |
696 | + riskDetails.setModified(new Date()); | |
697 | + riskDetails.setPatientId(patientId); | |
698 | + if (StringUtils.isNotEmpty(riskDetails.getTitle())) { | |
699 | + riskDetailsService.addRiskDetails(riskDetails); | |
700 | + } | |
701 | + } | |
702 | + } | |
703 | + String srt = highScoreResult.gethighRiskStr(); | |
704 | + risks.setTitle(srt); | |
705 | + risks.setReason(srt); | |
706 | + Integer crisis = null; | |
707 | + if (CollectionUtils.isNotEmpty(highScoreResult.getLevel())) { | |
708 | + crisis = 0; | |
709 | + for (Object map1 : highScoreResult.getLevel()) { | |
710 | + Map<String, Object> tmp = (Map<String, Object>) map1; | |
711 | + String name = tmp.get("name") == null ? null : (String) tmp.get("name"); | |
712 | + if (null != name) { | |
713 | + RiskColorEnum colorEnum = map.get(name); | |
714 | + crisis = crisis & colorEnum.getId(); | |
715 | + } | |
716 | + } | |
717 | + } | |
718 | + if (StringUtils.isNotEmpty(risks.getTitle())) { | |
719 | + risks.setCrisis(crisis); | |
720 | + risks.setPublishId(0); | |
721 | + risks.setPublishName("system-worker"); | |
722 | + risksService.addRisks(risks); | |
723 | + } | |
724 | + } | |
725 | + | |
726 | + private void handLastRisk(com.lyms.platform.pojo.Patients patients, Integer patientId) { | |
727 | + risksService.deleteRisk(patientId); | |
728 | + riskDetailsService.deleteRiskDetails(patientId); | |
729 | + StringBuilder sb = new StringBuilder(); | |
730 | + List<RiskColorEnum> data = new ArrayList<>(); | |
731 | + try { | |
732 | + int score = 0; | |
733 | + RiskColorEnum riskColorEnum = null; | |
734 | + if (CollectionUtils.isNotEmpty(patients.getRiskFactorId())) { | |
735 | + for (String id : patients.getRiskFactorId()) { | |
736 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(id); | |
737 | + if (null != basicConfig) { | |
738 | + RiskDetails riskDetails = new RiskDetails(); | |
739 | + if (StringUtils.isNotEmpty(basicConfig.getCode())) { | |
740 | + score += NumberUtils.toInt(basicConfig.getCode(), 0); | |
741 | + riskDetails.setScore(NumberUtils.toInt(basicConfig.getCode())); | |
742 | + } | |
743 | + BasicConfig basicConfig1 = basicConfigService.getOneBasicConfigById(basicConfig.getParentId()); | |
744 | + sb.append(basicConfig.getName()).append('、'); | |
745 | + String name = basicConfig1.getName(); | |
746 | + if (name.indexOf("预警") > -1) { | |
747 | + name = name.replace("预警", ""); | |
748 | + } | |
749 | + riskColorEnum = SyncDataWork.map.get(name); | |
750 | + if (null != riskColorEnum) { | |
751 | + data.add(riskColorEnum); | |
752 | + } | |
753 | + riskDetails.setCreated(new Date()); | |
754 | + riskDetails.setYn(YnEnums.YES.getId()); | |
755 | + riskDetails.setModified(new Date()); | |
756 | + riskDetails.setPatientId(patientId); | |
757 | + riskDetails.setTitle(basicConfig.getName()); | |
758 | + riskDetails.setCrisis(riskColorEnum == null ? null : riskColorEnum.getId()); | |
759 | + riskDetails.setPublishId(0); | |
760 | + riskDetails.setPublishName("system-worker"); | |
761 | + riskDetailsService.addRiskDetails(riskDetails); | |
762 | + } | |
763 | + } | |
764 | + } | |
765 | + | |
766 | + } catch (Exception e) { | |
767 | + ERROR_LOGGER.error("convert high risk error.", e); | |
768 | + } | |
769 | + Risks risks = new Risks(); | |
770 | + risks.setCreated(new Date()); | |
771 | + risks.setYn(YnEnums.YES.getId()); | |
772 | + risks.setModified(new Date()); | |
773 | + risks.setPatientId(patientId); | |
774 | + | |
775 | + String srt = sb.toString(); | |
776 | + risks.setTitle(srt); | |
777 | + risks.setReason(srt); | |
778 | + Integer crisis = null; | |
779 | + if (CollectionUtils.isNotEmpty(data)) { | |
780 | + crisis = 0; | |
781 | + for (RiskColorEnum risk : data) { | |
782 | + crisis = crisis & risk.getId(); | |
783 | + } | |
784 | + } | |
785 | + risks.setCrisis(crisis); | |
786 | + risks.setPublishId(0); | |
787 | + risks.setPublishName("system-worker"); | |
788 | + risksService.addRisks(risks); | |
789 | + } | |
790 | + | |
791 | + | |
792 | + private void handlRiskChu(AntExChuModel antExChuModel, Integer patientId) { | |
793 | + | |
794 | + risksService.deleteRisk(patientId); | |
795 | + riskDetailsService.deleteRiskDetails(patientId); | |
796 | + Risks risks = new Risks(); | |
797 | + risks.setCreated(antExChuModel.getCreated()); | |
798 | + risks.setYn(YnEnums.YES.getId()); | |
799 | + risks.setModified(antExChuModel.getModified()); | |
800 | + | |
801 | + risks.setPatientId(patientId); | |
802 | + HighScoreResult highScoreResult = new HighScoreResult(); | |
803 | + try { | |
804 | + List list2 = JsonUtil.toList(antExChuModel.getHighrisk(), List.class); | |
805 | + highScoreResult = queryRisk(list2, patientId); | |
806 | + } catch (Exception e) { | |
807 | + ERROR_LOGGER.error("convert high risk error.", e); | |
808 | + } | |
809 | + | |
810 | + if (null != antExChuModel && !"{}".equals(antExChuModel.getOtherHighRisk())) { | |
811 | + Map map = JsonUtil.str2Obj(antExChuModel.getOtherHighRisk(), Map.class); | |
812 | + //风险因素 | |
813 | + Map map1 = new HashMap(); | |
814 | + map1.put("id", ""); | |
815 | + Object obj = map.get("fxysu"); | |
816 | + if (null != obj && !"null".equals(obj.toString()) && !"".equals(obj.toString())) { | |
817 | + map1.put("name", map.get("fxysu")); | |
818 | + highScoreResult.getHighRisk().add(map1); | |
819 | + } | |
820 | + RiskDetails riskDetails = new RiskDetails(); | |
821 | + //风险评分 | |
822 | + Object idObj = map.get("fxpf"); | |
823 | + if (null != idObj && !"null".equals(idObj.toString()) && !"".equals(idObj.toString())) { | |
824 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(idObj.toString()); | |
825 | + riskDetails.setScore(NumberUtils.toInt(basicConfig.getName())); | |
826 | + highScoreResult.setScore(highScoreResult.getScore() + NumberUtils.toInt(basicConfig.getName(), 0)); | |
827 | + } | |
828 | + Object idObj1 = map.get("fyyse"); | |
829 | + if (null != idObj1 && !"null".equals(idObj1.toString()) && !"".equals(idObj1.toString())) { | |
830 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(idObj1.toString()); | |
831 | + if (null != basicConfig) { | |
832 | + Map<String, Object> map2 = new HashMap<>(); | |
833 | + map2.put("id", basicConfig.getId()); | |
834 | + String name = basicConfig.getName(); | |
835 | + if (name.indexOf("预警") > -1) { | |
836 | + name = name.replace("预警", ""); | |
837 | + } | |
838 | + map2.put("name", name); | |
839 | + RiskColorEnum riskColorEnum = SyncDataWork.map.get(name); | |
840 | + riskDetails.setCrisis(riskColorEnum == null ? null : riskColorEnum.getId()); | |
841 | + map2.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
842 | + highScoreResult.getLevel().add(map2); | |
843 | + } | |
844 | + } | |
845 | + Object obj1 = map1.get("name"); | |
846 | + if (null != obj1) { | |
847 | + riskDetails.setTitle(obj1.toString()); | |
848 | + riskDetails.setPublishName("system-worker"); | |
849 | + riskDetails.setPublishId(0); | |
850 | + riskDetails.setYn(YnEnums.YES.getId()); | |
851 | + riskDetails.setCreated(new Date()); | |
852 | + riskDetails.setModified(new Date()); | |
853 | + riskDetails.setPatientId(patientId); | |
854 | + riskDetailsService.addRiskDetails(riskDetails); | |
855 | + } | |
856 | + } | |
857 | + String srt = highScoreResult.gethighRiskStr(); | |
858 | + risks.setTitle(srt); | |
859 | + risks.setReason(srt); | |
860 | + Integer crisis = null; | |
861 | + if (CollectionUtils.isNotEmpty(highScoreResult.getLevel())) { | |
862 | + crisis = 0; | |
863 | + for (Object map1 : highScoreResult.getLevel()) { | |
864 | + Map<String, Object> tmp = (Map<String, Object>) map1; | |
865 | + String name = tmp.get("name") == null ? null : (String) tmp.get("name"); | |
866 | + if (null != name) { | |
867 | + RiskColorEnum colorEnum = map.get(name); | |
868 | + crisis = crisis & colorEnum.getId(); | |
869 | + } | |
870 | + } | |
871 | + } | |
872 | + risks.setCrisis(crisis); | |
873 | + risks.setPublishId(0); | |
874 | + risks.setPublishName("system-worker"); | |
875 | + risksService.addRisks(risks); | |
876 | + } | |
877 | + | |
878 | + public HighScoreResult queryRisk(List<String> id, Integer parentId) { | |
879 | + HighScoreResult highScoreResult = new HighScoreResult(); | |
880 | + BasicConfigQuery basicConfigQuery = new BasicConfigQuery(); | |
881 | + List data = new ArrayList(); | |
882 | + List dat1a = new ArrayList(); | |
883 | + Integer score = null; | |
884 | + if (CollectionUtils.isNotEmpty(id)) { | |
885 | + score = 0; | |
886 | + for (String i : id) { | |
887 | + basicConfigQuery.setId(i); | |
888 | + List<BasicConfig> basicConfigs = basicConfigService.queryBasicConfig(basicConfigQuery); | |
889 | + if (CollectionUtils.isNotEmpty(basicConfigs)) { | |
890 | + Integer crisis = null; | |
891 | + for (BasicConfig basicConfig : basicConfigs) { | |
892 | + Map<String, Object> map = new HashMap<>(); | |
893 | + map.put("id", basicConfig.getId()); | |
894 | + map.put("name", basicConfig.getName()); | |
895 | + map.put("code", basicConfig.getCode()); | |
896 | + RiskDetails riskDetails = new RiskDetails(); | |
897 | + if (StringUtils.isNotEmpty(basicConfig.getCode())) { | |
898 | + score += NumberUtils.toInt(basicConfig.getCode(), 0); | |
899 | + riskDetails.setScore(NumberUtils.toInt(basicConfig.getCode())); | |
900 | + } | |
901 | + riskDetails.setCreated(new Date()); | |
902 | + riskDetails.setYn(YnEnums.YES.getId()); | |
903 | + riskDetails.setModified(new Date()); | |
904 | + riskDetails.setPatientId(parentId); | |
905 | + riskDetails.setTitle(basicConfig.getName()); | |
906 | + | |
907 | + riskDetails.setPublishId(0); | |
908 | + riskDetails.setPublishName("system-worker"); | |
909 | + BasicConfig basicConfig1 = basicConfigService.getOneBasicConfigById(basicConfig.getParentId()); | |
910 | + if (null != basicConfig1) { | |
911 | + Map<String, Object> map1 = new HashMap<>(); | |
912 | + map1.put("id", basicConfig1.getId()); | |
913 | + String name = basicConfig1.getName(); | |
914 | + if (name.indexOf("预警") > -1) { | |
915 | + name = name.replace("预警", ""); | |
916 | + } | |
917 | + map1.put("name", name); | |
918 | + crisis = SyncDataWork.map.get(name) == null ? null : SyncDataWork.map.get(name).getId(); | |
919 | + map1.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
920 | + dat1a.add(map1); | |
921 | + } | |
922 | + riskDetails.setCrisis(crisis); | |
923 | + riskDetailsService.addRiskDetails(riskDetails); | |
924 | + data.add(map); | |
925 | + } | |
926 | + } | |
927 | + } | |
928 | + } | |
929 | + highScoreResult.setHighRisk(data); | |
930 | + highScoreResult.setScore(score); | |
931 | + highScoreResult.setLevel(dat1a); | |
932 | + return highScoreResult; | |
933 | + } | |
934 | + | |
565 | 935 | |
566 | 936 | private void bandingMember(com.lymsh.mommybaby.maindata.model.Patients patients) { |
567 | 937 | MembersQuery membersQuery = new MembersQuery(); |