Commit 0de21de7849f0a1482ccf513b5d618fed06c3142
1 parent
d0a31a271b
Exists in
master
and in
1 other branch
修改新电子病历
Showing 7 changed files with 243 additions and 107 deletions
- 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 @
0de21de
| ... | ... | @@ -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 @
0de21de
| ... | ... | @@ -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 @
0de21de
| ... | ... | @@ -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 @
0de21de
| ... | ... | @@ -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 @
0de21de
platform-job-index/src/main/java/com/lyms/platform/job/index/restore/data/SyncDataWork.java
View file @
0de21de
| ... | ... | @@ -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(5, 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,123 @@ | 
| 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 | + patientsQuery1.setNeed("1"); | |
| 292 | + patientsQuery1.setLimit(500); | |
| 293 | + if(-1!=lastSyncTime){ | |
| 294 | + patientsQuery1.setGteModified(new Date(lastSyncTime)); | |
| 295 | + } | |
| 244 | 296 | |
| 245 | - //门诊患者 | |
| 246 | - doctorUsersPatientsMaps.setGroupId(4); | |
| 247 | - //设置为待处理 | |
| 248 | - doctorUsersPatientsMaps.setStatus(1); | |
| 249 | - doctorUsersPatientsMaps.setStatusName("待处理"); | |
| 297 | + List<Patients> patientses = yunBookbuildingService.queryPregnantWithQuery(patientsQuery1); | |
| 298 | + while (CollectionUtils.isNotEmpty(patientses)) { | |
| 299 | + for (Patients patients : patientses) { | |
| 300 | + com.lymsh.mommybaby.maindata.model.Patients mamiPatient = ConvertHelper.convertPatient(patients); | |
| 301 | + DoctorUsersPatientsMaps doctorUsersPatientsMaps = new DoctorUsersPatientsMaps(); | |
| 302 | + doctorUsersPatientsMaps.setCreated(new Date()); | |
| 303 | + doctorUsersPatientsMaps.setYn(YnEnums.YES.getId()); | |
| 250 | 304 | |
| 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 | - } | |
| 305 | + //门诊患者 | |
| 306 | + doctorUsersPatientsMaps.setGroupId(4); | |
| 307 | + //设置为待处理 | |
| 308 | + doctorUsersPatientsMaps.setStatus(1); | |
| 309 | + doctorUsersPatientsMaps.setStatusName("待处理"); | |
| 258 | 310 | |
| 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 | - } | |
| 311 | + //增加建档记录 | |
| 312 | + patientsService.aouPatients(mamiPatient); | |
| 313 | + doctorUsersPatientsMaps.setPatientId(mamiPatient.getId()); | |
| 314 | + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 315 | + doctorUsersPatientsMaps.setDoctorUserId(userMapping.get(Integer.valueOf(patients.getBookbuildingDoctor()))); | |
| 316 | + doctorUsersPatientsMapsService.aouDoctorUsersPatientsMaps(doctorUsersPatientsMaps); | |
| 273 | 317 | } | 
| 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()); | |
| 318 | + | |
| 319 | + AntExChuQuery antExChuQuery = new AntExChuQuery(); | |
| 320 | + antExChuQuery.setYn(YnEnums.YES.getId()); | |
| 321 | + antExChuQuery.setParentId(patients.getId()); | |
| 322 | + if(-1!=lastSyncTime){ | |
| 323 | + antExChuQuery.setGteModified(new Date(lastSyncTime)); | |
| 324 | + } | |
| 325 | + | |
| 326 | + List<AntExChuModel> antExChuModel = antenatalExaminationService.queryAntExChu(antExChuQuery); | |
| 327 | + if (CollectionUtils.isEmpty(antExChuModel)) { | |
| 328 | + continue; | |
| 329 | + } | |
| 330 | + for (AntExChuModel antExChuModel1 : antExChuModel) { | |
| 331 | + Reports reports = ConvertHelper.convertAntExChu(antExChuModel1, patients.getLastMenses()); | |
| 332 | + if (NumberUtils.isNumber(antExChuModel1.getProdDoctor())) { | |
| 333 | + Users users = usersService.getUsers(Integer.valueOf(antExChuModel1.getProdDoctor())); | |
| 334 | + if (null != users) { | |
| 335 | + reports.setDoctorName(users.getName()); | |
| 336 | + } | |
| 281 | 337 | } | 
| 338 | + reports.setPatientId(mamiPatient.getId()); | |
| 339 | + reports.setAge(patients.getAge()); | |
| 340 | + reports.setRealName(patients.getUsername()); | |
| 341 | + if (StringUtils.isNotEmpty(patients.getHospitalId())) { | |
| 342 | + Organization organization = organizationService.getOrganization(NumberUtils.toInt(patients.getHospitalId())); | |
| 343 | + if (null != organization) { | |
| 344 | + reports.setHospitalName(organization.getName()); | |
| 345 | + } | |
| 346 | + } | |
| 347 | + reportsService.aouReports(reports); | |
| 348 | + com.lymsh.mommybaby.maindata.model.Patients p = new com.lymsh.mommybaby.maindata.model.Patients(); | |
| 349 | + p.setLastReportId(reports.getId()); | |
| 350 | + p.setLastReportDoctorName(reports.getDoctorName()); | |
| 351 | + p.setId(mamiPatient.getId()); | |
| 352 | + patientsService.updatePatients(p); | |
| 282 | 353 | } | 
| 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 | 354 | } | 
| 290 | 355 | } | 
| 356 | + } catch (Exception e) { | |
| 357 | + e.printStackTrace(); | |
| 358 | + } finally { | |
| 359 | + countDownLatch.countDown(); | |
| 291 | 360 | } | 
| 292 | 361 | } | 
| 293 | 362 | } |