Commit bc3ca147eef27e2db1f4296002f9670d189e5b00
Exists in
master
and in
8 other branches
Merge remote-tracking branch 'origin/master'
Showing 7 changed files
- platform-biz-service/src/main/java/com/lyms/platform/permission/model/UsersQuery.java
- platform-biz-service/src/main/resources/mainOrm/master/MasterUsers.xml
- platform-dal/src/main/java/com/lyms/platform/query/AntExChuQuery.java
- platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java
- platform-job-index/src/main/java/com/lyms/platform/job/index/TestSolr.java
- platform-job-index/src/main/java/com/lyms/platform/job/index/restore/data/SyncDataWork.java
- platform-job-index/src/main/resources/conf.properties
platform-biz-service/src/main/java/com/lyms/platform/permission/model/UsersQuery.java
View file @
bc3ca14
... | ... | @@ -21,6 +21,11 @@ |
21 | 21 | private String publishName; |
22 | 22 | private Integer yn; |
23 | 23 | private Integer enable; |
24 | + //大于修改时间 | |
25 | + private Date gteModified; | |
26 | + //大于创建时间 | |
27 | + private Date gteCreated; | |
28 | + | |
24 | 29 | private Date modified; |
25 | 30 | private Date created; |
26 | 31 | private String remarks; |
... | ... | @@ -35,6 +40,21 @@ |
35 | 40 | return otherAccount; |
36 | 41 | } |
37 | 42 | |
43 | + public Date getGteCreated() { | |
44 | + return gteCreated; | |
45 | + } | |
46 | + | |
47 | + public void setGteCreated(Date gteCreated) { | |
48 | + this.gteCreated = gteCreated; | |
49 | + } | |
50 | + | |
51 | + public Date getGteModified() { | |
52 | + return gteModified; | |
53 | + } | |
54 | + | |
55 | + public void setGteModified(Date gteModified) { | |
56 | + this.gteModified = gteModified; | |
57 | + } | |
38 | 58 | |
39 | 59 | public List<Integer> orgIds; //这些机构下的用户 |
40 | 60 |
platform-biz-service/src/main/resources/mainOrm/master/MasterUsers.xml
View file @
bc3ca14
... | ... | @@ -193,6 +193,13 @@ |
193 | 193 | <if test="created != null"> |
194 | 194 | and created = #{created,jdbcType=TIMESTAMP} |
195 | 195 | </if> |
196 | + <if test="gteModified != null"> | |
197 | + and modified >= #{gteModified,jdbcType=TIMESTAMP} | |
198 | + </if> | |
199 | + <if test="gteCreated != null"> | |
200 | + and created >= #{gteCreated,jdbcType=TIMESTAMP} | |
201 | + </if> | |
202 | + | |
196 | 203 | <if test="remarks != null and remarks != ''"> |
197 | 204 | and remarks = #{remarks,jdbcType=VARCHAR} |
198 | 205 | </if> |
platform-dal/src/main/java/com/lyms/platform/query/AntExChuQuery.java
View file @
bc3ca14
... | ... | @@ -24,9 +24,18 @@ |
24 | 24 | private Date nextCheckTime; |
25 | 25 | private Date nextCheckTimeStart; |
26 | 26 | private Date nextCheckTimeEnd; |
27 | - | |
27 | + //大于修改时间 | |
28 | + private Date gteModified; | |
28 | 29 | private String pid; |
29 | 30 | |
31 | + public Date getGteModified() { | |
32 | + return gteModified; | |
33 | + } | |
34 | + | |
35 | + public void setGteModified(Date gteModified) { | |
36 | + this.gteModified = gteModified; | |
37 | + } | |
38 | + | |
30 | 39 | public String getPid() { |
31 | 40 | return pid; |
32 | 41 | } |
... | ... | @@ -132,6 +141,14 @@ |
132 | 141 | c = c.where("nextCheckTime").gte(nextCheckTimeStart).lte(nextCheckTimeEnd); |
133 | 142 | } else { |
134 | 143 | c = Criteria.where("nextCheckTime").gte(nextCheckTimeStart).lte(nextCheckTimeEnd); |
144 | + } | |
145 | + } | |
146 | + | |
147 | + if(null!=gteModified){ | |
148 | + if (null != c) { | |
149 | + c = c.gte(gteModified); | |
150 | + } else { | |
151 | + c = Criteria.where("modified").gte(gteModified); | |
135 | 152 | } |
136 | 153 | } |
137 | 154 |
platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java
View file @
bc3ca14
... | ... | @@ -212,6 +212,18 @@ |
212 | 212 | private Date fmDateStart; |
213 | 213 | private Date fmDateEnd; |
214 | 214 | |
215 | + //大于修改时间 | |
216 | + private Date gteModified; | |
217 | + //大于创建时间 | |
218 | + | |
219 | + public Date getGteModified() { | |
220 | + return gteModified; | |
221 | + } | |
222 | + | |
223 | + public void setGteModified(Date gteModified) { | |
224 | + this.gteModified = gteModified; | |
225 | + } | |
226 | + | |
215 | 227 | public List<Integer> getBuildTypeList() { |
216 | 228 | return buildTypeList; |
217 | 229 | } |
... | ... | @@ -660,6 +672,14 @@ |
660 | 672 | c1 = c1.lte(bookbuildingDateEnd); |
661 | 673 | } else { |
662 | 674 | c1 = Criteria.where("bookbuildingDate").lte(bookbuildingDateEnd); |
675 | + } | |
676 | + } | |
677 | + | |
678 | + if (null != gteModified) { | |
679 | + if (null!=c1) { | |
680 | + c1 = c1.gte(gteModified); | |
681 | + } else { | |
682 | + c1 = Criteria.where("modified").gte(gteModified); | |
663 | 683 | } |
664 | 684 | } |
665 | 685 |
platform-job-index/src/main/java/com/lyms/platform/job/index/TestSolr.java
View file @
bc3ca14
platform-job-index/src/main/java/com/lyms/platform/job/index/restore/data/SyncDataWork.java
View file @
bc3ca14
... | ... | @@ -19,16 +19,21 @@ |
19 | 19 | import com.lymsh.mommybaby.maindata.model.*; |
20 | 20 | import com.lymsh.mommybaby.maindata.service.*; |
21 | 21 | import org.apache.commons.collections.CollectionUtils; |
22 | +import org.apache.commons.io.FileUtils; | |
22 | 23 | import org.apache.commons.lang.StringUtils; |
23 | 24 | import org.apache.commons.lang.math.NumberUtils; |
24 | 25 | import org.slf4j.Logger; |
25 | 26 | import org.slf4j.LoggerFactory; |
26 | 27 | import org.springframework.beans.factory.annotation.Autowired; |
28 | +import org.springframework.beans.factory.annotation.Value; | |
27 | 29 | import org.springframework.stereotype.Component; |
28 | 30 | |
31 | +import java.io.File; | |
32 | +import java.io.RandomAccessFile; | |
29 | 33 | import java.util.Date; |
30 | 34 | import java.util.HashMap; |
31 | 35 | import java.util.List; |
36 | +import java.util.concurrent.CountDownLatch; | |
32 | 37 | import java.util.concurrent.LinkedBlockingQueue; |
33 | 38 | import java.util.concurrent.ThreadPoolExecutor; |
34 | 39 | import java.util.concurrent.TimeUnit; |
... | ... | @@ -55,7 +60,8 @@ |
55 | 60 | /** |
56 | 61 | * 工作线程池 |
57 | 62 | */ |
58 | - private ThreadPoolExecutor workExecutor = new ThreadPoolExecutor(2, 5, 3, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(50)); | |
63 | + private ThreadPoolExecutor workExecutor = new ThreadPoolExecutor(8, 10, 1, TimeUnit.HOURS, new LinkedBlockingQueue<Runnable>(5000)); | |
64 | + | |
59 | 65 | @Autowired |
60 | 66 | private AntenatalExaminationService antenatalExaminationService; |
61 | 67 | |
... | ... | @@ -70,8 +76,6 @@ |
70 | 76 | * 妈咪贝比 |
71 | 77 | */ |
72 | 78 | @Autowired |
73 | - private UsersService mamiUsersService; | |
74 | - @Autowired | |
75 | 79 | private com.lyms.platform.permission.service.UsersService usersService; |
76 | 80 | /** |
77 | 81 | * 省 市 区 |
... | ... | @@ -86,7 +90,10 @@ |
86 | 90 | private ReportsService reportsService; |
87 | 91 | @Autowired |
88 | 92 | private DoctorUsersPatientsMapsService doctorUsersPatientsMapsService; |
89 | - | |
93 | + @Value("#{configProperties['file.path']}") | |
94 | + private String FILE_PATH; | |
95 | + //最后一次同步时间 | |
96 | + private long lastSyncTime=-1L; | |
90 | 97 | /** |
91 | 98 | * |
92 | 99 | */ |
93 | 100 | |
... | ... | @@ -99,7 +106,36 @@ |
99 | 106 | */ |
100 | 107 | public static final String CHINA_BASIC_ID = "f6c505dd-835a-43d7-b0bb-fdb9eb0b7b31"; |
101 | 108 | |
109 | + private long readLastSyncTime(){ | |
110 | + try { | |
111 | + if(-1!=lastSyncTime){ | |
112 | + return lastSyncTime; | |
113 | + } | |
114 | + RandomAccessFile randomAccessFile=new RandomAccessFile(new File(FILE_PATH),"rw"); | |
115 | + String line =randomAccessFile.readLine(); | |
116 | + if(StringUtils.isNotEmpty(line)){ | |
117 | + lastSyncTime = Long.valueOf(line); | |
118 | + } | |
119 | + }catch (Exception e){ | |
120 | + logger.error("read last sync time error.",e); | |
121 | + } | |
122 | + return lastSyncTime; | |
123 | + } | |
124 | + | |
102 | 125 | /** |
126 | + * 持久化最后一次同步时间 | |
127 | + */ | |
128 | + private void writeLastSyncTime(){ | |
129 | + try { | |
130 | + lastSyncTime=System.currentTimeMillis(); | |
131 | + RandomAccessFile randomAccessFile=new RandomAccessFile(new File(FILE_PATH),"rw"); | |
132 | + randomAccessFile.writeLong(lastSyncTime); | |
133 | + randomAccessFile.close(); | |
134 | + }catch (Exception e){ | |
135 | + logger.error("read last sync time error.",e); | |
136 | + } | |
137 | + } | |
138 | + /** | |
103 | 139 | * 加载全部省市区的数据到内存里面 |
104 | 140 | */ |
105 | 141 | private void loadMamiAllRegion() { |
106 | 142 | |
... | ... | @@ -131,8 +167,33 @@ |
131 | 167 | } |
132 | 168 | } |
133 | 169 | |
134 | - public void sync() { | |
170 | + private Hospitals fullHospital(Organization organization){ | |
171 | + Hospitals hospitals = ConvertHelper.convertHospital(organization); | |
172 | + if (null != organization.getAreaId()) { | |
173 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(organization.getAreaId()); | |
174 | + if (null != basicConfig) { | |
175 | + hospitals.setAreaId(mamiRegions.get(basicConfig.getName())); | |
176 | + } | |
177 | + } | |
178 | + if (null != organization.getCityId()) { | |
179 | + BasicConfig basicConfig1 = basicConfigService.getOneBasicConfigById(organization.getCityId()); | |
180 | + if (null != basicConfig1) { | |
181 | + hospitals.setCityId(mamiRegions.get(basicConfig1.getName())); | |
182 | + } | |
183 | + } | |
184 | + if (null != organization.getProvinceId()) { | |
185 | + BasicConfig basicConfig2 = basicConfigService.getOneBasicConfigById(organization.getProvinceId()); | |
186 | + if (null != basicConfig2) { | |
187 | + hospitals.setProvinceId(mamiRegions.get(basicConfig2.getName())); | |
188 | + } | |
189 | + } | |
190 | + return hospitals; | |
191 | + } | |
192 | + | |
193 | + public void sync() throws InterruptedException { | |
135 | 194 | long l = System.currentTimeMillis(); |
195 | + //获取最后一次同步的时间 如果为-1就表示是全量同步 | |
196 | + readLastSyncTime(); | |
136 | 197 | logger.info("start sync at " + DateUtil.getyyyy_MM_dd(new Date())); |
137 | 198 | //先加载省市区 |
138 | 199 | loadMamiAllRegion(); |
139 | 200 | |
140 | 201 | |
141 | 202 | |
... | ... | @@ -141,35 +202,21 @@ |
141 | 202 | organizationQuery.setYn(YnEnums.YES.getId()); |
142 | 203 | //查询符合条件的机构 |
143 | 204 | List<Organization> organizationList = organizationService.queryOrganization(organizationQuery); |
205 | + CountDownLatch countDownLatch=null;; | |
144 | 206 | if (CollectionUtils.isNotEmpty(organizationList)) { |
145 | 207 | Hospitals hospitals = null; |
208 | + countDownLatch =new CountDownLatch(organizationList.size()); | |
146 | 209 | for (Organization organization : organizationList) { |
147 | 210 | HospitalsQuery hospitalsQuery = new HospitalsQuery(); |
148 | 211 | hospitalsQuery.setForeignId(organization.getId() + ""); |
149 | 212 | hospitalsQuery.setYn(YnEnums.YES.getId()); |
150 | 213 | List<Hospitals> hospitalsList = hospitalsService.queryHospitals(hospitalsQuery); |
151 | 214 | if (CollectionUtils.isNotEmpty(hospitalsList)) { |
152 | - hospitals = hospitalsList.get(0); | |
215 | + hospitals = fullHospital(organization); | |
216 | + hospitals.setId(hospitalsList.get(0).getId()); | |
217 | + hospitalsService.updateHospitals(hospitals); | |
153 | 218 | } else { |
154 | - hospitals = ConvertHelper.convertHospital(organization); | |
155 | - if (null != organization.getAreaId()) { | |
156 | - BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(organization.getAreaId()); | |
157 | - if (null != basicConfig) { | |
158 | - hospitals.setAreaId(mamiRegions.get(basicConfig.getName())); | |
159 | - } | |
160 | - } | |
161 | - if (null != organization.getCityId()) { | |
162 | - BasicConfig basicConfig1 = basicConfigService.getOneBasicConfigById(organization.getCityId()); | |
163 | - if (null != basicConfig1) { | |
164 | - hospitals.setCityId(mamiRegions.get(basicConfig1.getName())); | |
165 | - } | |
166 | - } | |
167 | - if (null != organization.getProvinceId()) { | |
168 | - BasicConfig basicConfig2 = basicConfigService.getOneBasicConfigById(organization.getProvinceId()); | |
169 | - if (null != basicConfig2) { | |
170 | - hospitals.setProvinceId(mamiRegions.get(basicConfig2.getName())); | |
171 | - } | |
172 | - } | |
219 | + fullHospital(organization); | |
173 | 220 | hospitalsService.addHospitals(hospitals); |
174 | 221 | } |
175 | 222 | |
176 | 223 | |
... | ... | @@ -178,12 +225,13 @@ |
178 | 225 | } else { |
179 | 226 | logger.warn("add hospital don't id."); |
180 | 227 | } |
181 | - new SyncWork(organization.getId() + "").start(); | |
228 | + workExecutor.execute(new SyncWork(organization.getId() + "",countDownLatch)); | |
182 | 229 | } |
183 | 230 | } |
184 | - | |
185 | - | |
186 | - logger.info("sync end costTime:" + (System.currentTimeMillis() - l) + "ms."); | |
231 | + countDownLatch.await(); | |
232 | + //持久化最后一次同步时间 | |
233 | + writeLastSyncTime(); | |
234 | + logger.info("sync end costTime:" + (System.currentTimeMillis() - l) + " ms."); | |
187 | 235 | } |
188 | 236 | |
189 | 237 | /** |
190 | 238 | |
191 | 239 | |
192 | 240 | |
193 | 241 | |
194 | 242 | |
195 | 243 | |
196 | 244 | |
197 | 245 | |
198 | 246 | |
199 | 247 | |
200 | 248 | |
201 | 249 | |
202 | 250 | |
... | ... | @@ -192,102 +240,121 @@ |
192 | 240 | private class SyncWork extends Thread { |
193 | 241 | |
194 | 242 | private String hospitalId; |
243 | + private CountDownLatch countDownLatch; | |
195 | 244 | |
196 | 245 | private java.util.Map<Integer, Integer> userMapping = new HashMap<>(); |
197 | 246 | |
198 | - public SyncWork(String hospitalId) { | |
247 | + public SyncWork(String hospitalId,CountDownLatch countDownLatch) { | |
199 | 248 | this.hospitalId = hospitalId; |
249 | + this.countDownLatch=countDownLatch; | |
200 | 250 | } |
201 | 251 | |
202 | 252 | @Override |
203 | 253 | public void run() { |
204 | - logger.info("begin sync work hospital:" + hospitalId + ",at time " + DateUtil.getyyyy_MM_dd(new Date())); | |
205 | - //查询出该医院所以的医生用户 | |
206 | - UsersQuery usersQuery = new UsersQuery(); | |
207 | - usersQuery.setYn(YnEnums.YES.getId()); | |
208 | - usersQuery.setOrgId(Integer.valueOf(hospitalId)); | |
209 | - List<Users> userses = usersService.queryUsers(usersQuery); | |
210 | - DoctorUsers doctorUsers = null; | |
211 | - if (CollectionUtils.isNotEmpty(userses)) { | |
212 | - for (Users users : userses) { | |
213 | - DoctorUsersQuery doctorUsersQuery = new DoctorUsersQuery(); | |
214 | - doctorUsersQuery.setForeignId(users.getId() + ""); | |
215 | - doctorUsersQuery.setYn(YnEnums.YES.getId()); | |
216 | - List<DoctorUsers> doctorUsersList = doctorUsersService.queryDoctorUsers(doctorUsersQuery); | |
217 | - if (CollectionUtils.isNotEmpty(doctorUsersList)) { | |
218 | - doctorUsers = doctorUsersList.get(0); | |
219 | - } else { | |
220 | - //医生用户转换 | |
221 | - doctorUsers = ConvertHelper.convertUsers(users); | |
222 | - doctorUsers.setHospitalId(orgMapToId.get(hospitalId)); | |
223 | - } | |
254 | + try { | |
255 | + logger.info("begin sync work hospital:" + hospitalId + ",at time " + DateUtil.getyyyy_MM_dd(new Date())); | |
256 | + //查询出该医院所以的医生用户 | |
257 | + UsersQuery usersQuery = new UsersQuery(); | |
258 | + usersQuery.setYn(YnEnums.YES.getId()); | |
259 | + usersQuery.setOrgId(Integer.valueOf(hospitalId)); | |
260 | + if(-1!=lastSyncTime){ | |
261 | + usersQuery.setGteModified(new Date(lastSyncTime)); | |
262 | + } | |
263 | + List<Users> userses = usersService.queryUsers(usersQuery); | |
264 | + DoctorUsers doctorUsers = null; | |
265 | + if (CollectionUtils.isNotEmpty(userses)) { | |
266 | + for (Users users : userses) { | |
267 | + DoctorUsersQuery doctorUsersQuery = new DoctorUsersQuery(); | |
268 | + doctorUsersQuery.setForeignId(users.getId() + ""); | |
269 | + doctorUsersQuery.setYn(YnEnums.YES.getId()); | |
270 | + List<DoctorUsers> doctorUsersList = doctorUsersService.queryDoctorUsers(doctorUsersQuery); | |
271 | + if (CollectionUtils.isNotEmpty(doctorUsersList)) { | |
272 | + doctorUsers = ConvertHelper.convertUsers(users); | |
273 | + doctorUsers.setHospitalId(orgMapToId.get(hospitalId)); | |
274 | + doctorUsersService.updateDoctorUsers(doctorUsers); | |
275 | + } else { | |
276 | + //医生用户转换 | |
277 | + doctorUsers = ConvertHelper.convertUsers(users); | |
278 | + doctorUsers.setHospitalId(orgMapToId.get(hospitalId)); | |
279 | + doctorUsersService.addDoctorUsers(doctorUsers); | |
280 | + } | |
224 | 281 | |
225 | - if (null != doctorUsers) { | |
226 | - doctorUsersService.addDoctorUsers(doctorUsers); | |
227 | - userMapping.put(users.getId(), doctorUsers.getId()); | |
282 | + if (null != doctorUsers) { | |
283 | + userMapping.put(users.getId(), doctorUsers.getId()); | |
284 | + } | |
228 | 285 | } |
229 | 286 | } |
230 | - } | |
231 | 287 | |
232 | - PatientsQuery patientsQuery1 = new PatientsQuery(); | |
233 | - patientsQuery1.setYn(YnEnums.YES.getId()); | |
234 | - patientsQuery1.setHospitalId(hospitalId); | |
235 | - patientsQuery1.setNeed("1"); | |
236 | - patientsQuery1.setLimit(100); | |
237 | - List<Patients> patientses = yunBookbuildingService.queryPregnantWithQuery(patientsQuery1); | |
238 | - if (CollectionUtils.isNotEmpty(patientses)) { | |
239 | - for (Patients patients : patientses) { | |
240 | - com.lymsh.mommybaby.maindata.model.Patients mamiPatient = ConvertHelper.convertPatient(patients); | |
241 | - DoctorUsersPatientsMaps doctorUsersPatientsMaps = new DoctorUsersPatientsMaps(); | |
242 | - doctorUsersPatientsMaps.setCreated(new Date()); | |
243 | - doctorUsersPatientsMaps.setYn(YnEnums.YES.getId()); | |
288 | + PatientsQuery patientsQuery1 = new PatientsQuery(); | |
289 | + patientsQuery1.setYn(YnEnums.YES.getId()); | |
290 | + patientsQuery1.setHospitalId(hospitalId); | |
291 | + if(-1!=lastSyncTime){ | |
292 | + patientsQuery1.setGteModified(new Date(lastSyncTime)); | |
293 | + } | |
244 | 294 | |
245 | - //门诊患者 | |
246 | - doctorUsersPatientsMaps.setGroupId(4); | |
247 | - //设置为待处理 | |
248 | - doctorUsersPatientsMaps.setStatus(1); | |
249 | - doctorUsersPatientsMaps.setStatusName("待处理"); | |
295 | + List<Patients> patientses = yunBookbuildingService.queryPregnantWithQuery(patientsQuery1); | |
296 | + while (CollectionUtils.isNotEmpty(patientses)) { | |
297 | + for (Patients patients : patientses) { | |
298 | + com.lymsh.mommybaby.maindata.model.Patients mamiPatient = ConvertHelper.convertPatient(patients); | |
299 | + DoctorUsersPatientsMaps doctorUsersPatientsMaps = new DoctorUsersPatientsMaps(); | |
300 | + doctorUsersPatientsMaps.setCreated(new Date()); | |
301 | + doctorUsersPatientsMaps.setYn(YnEnums.YES.getId()); | |
250 | 302 | |
251 | - //增加建档记录 | |
252 | - patientsService.aouPatients(mamiPatient); | |
253 | - doctorUsersPatientsMaps.setPatientId(mamiPatient.getId()); | |
254 | - if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
255 | - doctorUsersPatientsMaps.setDoctorUserId(userMapping.get(Integer.valueOf(patients.getBookbuildingDoctor()))); | |
256 | - doctorUsersPatientsMapsService.aouDoctorUsersPatientsMaps(doctorUsersPatientsMaps); | |
257 | - } | |
303 | + //门诊患者 | |
304 | + doctorUsersPatientsMaps.setGroupId(4); | |
305 | + //设置为待处理 | |
306 | + doctorUsersPatientsMaps.setStatus(1); | |
307 | + doctorUsersPatientsMaps.setStatusName("待处理"); | |
258 | 308 | |
259 | - AntExChuQuery antExChuQuery = new AntExChuQuery(); | |
260 | - antExChuQuery.setYn(YnEnums.YES.getId()); | |
261 | - antExChuQuery.setParentId(patients.getId()); | |
262 | - List<AntExChuModel> antExChuModel = antenatalExaminationService.queryAntExChu(antExChuQuery); | |
263 | - if (CollectionUtils.isEmpty(antExChuModel)) { | |
264 | - continue; | |
265 | - } | |
266 | - for (AntExChuModel antExChuModel1 : antExChuModel) { | |
267 | - Reports reports = ConvertHelper.convertAntExChu(antExChuModel1, patients.getLastMenses()); | |
268 | - if (NumberUtils.isNumber(antExChuModel1.getProdDoctor())) { | |
269 | - Users users = usersService.getUsers(Integer.valueOf(antExChuModel1.getProdDoctor())); | |
270 | - if (null != users) { | |
271 | - reports.setDoctorName(users.getName()); | |
272 | - } | |
309 | + //增加建档记录 | |
310 | + patientsService.aouPatients(mamiPatient); | |
311 | + doctorUsersPatientsMaps.setPatientId(mamiPatient.getId()); | |
312 | + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
313 | + doctorUsersPatientsMaps.setDoctorUserId(userMapping.get(Integer.valueOf(patients.getBookbuildingDoctor()))); | |
314 | + doctorUsersPatientsMapsService.aouDoctorUsersPatientsMaps(doctorUsersPatientsMaps); | |
273 | 315 | } |
274 | - reports.setPatientId(mamiPatient.getId()); | |
275 | - reports.setAge(patients.getAge()); | |
276 | - reports.setRealName(patients.getUsername()); | |
277 | - if (StringUtils.isNotEmpty(patients.getHospitalId())) { | |
278 | - Organization organization = organizationService.getOrganization(NumberUtils.toInt(patients.getHospitalId())); | |
279 | - if (null != organization) { | |
280 | - reports.setHospitalName(organization.getName()); | |
316 | + | |
317 | + AntExChuQuery antExChuQuery = new AntExChuQuery(); | |
318 | + antExChuQuery.setYn(YnEnums.YES.getId()); | |
319 | + antExChuQuery.setParentId(patients.getId()); | |
320 | + if(-1!=lastSyncTime){ | |
321 | + antExChuQuery.setGteModified(new Date(lastSyncTime)); | |
322 | + } | |
323 | + | |
324 | + List<AntExChuModel> antExChuModel = antenatalExaminationService.queryAntExChu(antExChuQuery); | |
325 | + if (CollectionUtils.isEmpty(antExChuModel)) { | |
326 | + continue; | |
327 | + } | |
328 | + for (AntExChuModel antExChuModel1 : antExChuModel) { | |
329 | + Reports reports = ConvertHelper.convertAntExChu(antExChuModel1, patients.getLastMenses()); | |
330 | + if (NumberUtils.isNumber(antExChuModel1.getProdDoctor())) { | |
331 | + Users users = usersService.getUsers(Integer.valueOf(antExChuModel1.getProdDoctor())); | |
332 | + if (null != users) { | |
333 | + reports.setDoctorName(users.getName()); | |
334 | + } | |
281 | 335 | } |
336 | + reports.setPatientId(mamiPatient.getId()); | |
337 | + reports.setAge(patients.getAge()); | |
338 | + reports.setRealName(patients.getUsername()); | |
339 | + if (StringUtils.isNotEmpty(patients.getHospitalId())) { | |
340 | + Organization organization = organizationService.getOrganization(NumberUtils.toInt(patients.getHospitalId())); | |
341 | + if (null != organization) { | |
342 | + reports.setHospitalName(organization.getName()); | |
343 | + } | |
344 | + } | |
345 | + reportsService.aouReports(reports); | |
346 | + com.lymsh.mommybaby.maindata.model.Patients p = new com.lymsh.mommybaby.maindata.model.Patients(); | |
347 | + p.setLastReportId(reports.getId()); | |
348 | + p.setLastReportDoctorName(reports.getDoctorName()); | |
349 | + p.setId(mamiPatient.getId()); | |
350 | + patientsService.updatePatients(p); | |
282 | 351 | } |
283 | - reportsService.aouReports(reports); | |
284 | - com.lymsh.mommybaby.maindata.model.Patients p = new com.lymsh.mommybaby.maindata.model.Patients(); | |
285 | - p.setLastReportId(reports.getId()); | |
286 | - p.setLastReportDoctorName(reports.getDoctorName()); | |
287 | - p.setId(mamiPatient.getId()); | |
288 | - patientsService.updatePatients(p); | |
289 | 352 | } |
290 | 353 | } |
354 | + } catch (Exception e) { | |
355 | + e.printStackTrace(); | |
356 | + } finally { | |
357 | + countDownLatch.countDown(); | |
291 | 358 | } |
292 | 359 | } |
293 | 360 | } |