Commit 3e83c8128f12f4addcfe08b84d7c48af6f95b7c4
1 parent
dafeb79cc5
Exists in
master
and in
6 other branches
孕妇追访历史数据处理
Showing 4 changed files with 140 additions and 28 deletions
- platform-dal/src/main/java/com/lyms/platform/query/ResidentsArchiveQuery.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TrackDownController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/TrackDownFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/ChaseVisitHistory.java
platform-dal/src/main/java/com/lyms/platform/query/ResidentsArchiveQuery.java
View file @
3e83c81
| ... | ... | @@ -101,6 +101,11 @@ |
| 101 | 101 | private String id; |
| 102 | 102 | //创建时间 |
| 103 | 103 | private Date created; |
| 104 | + | |
| 105 | + private Date createdStart; | |
| 106 | + | |
| 107 | + private Date createdEnd; | |
| 108 | + | |
| 104 | 109 | //修改时间 |
| 105 | 110 | private Date modified; |
| 106 | 111 | //有效标识符(1: 有效 2: 无效) |
| 107 | 112 | |
| ... | ... | @@ -127,7 +132,22 @@ |
| 127 | 132 | //追访状态 0 正常 1. 待追访 2.已终止 |
| 128 | 133 | private Integer followupStatus; |
| 129 | 134 | |
| 135 | + public Date getCreatedStart() { | |
| 136 | + return createdStart; | |
| 137 | + } | |
| 130 | 138 | |
| 139 | + public void setCreatedStart(Date createdStart) { | |
| 140 | + this.createdStart = createdStart; | |
| 141 | + } | |
| 142 | + | |
| 143 | + public Date getCreatedEnd() { | |
| 144 | + return createdEnd; | |
| 145 | + } | |
| 146 | + | |
| 147 | + public void setCreatedEnd(Date createdEnd) { | |
| 148 | + this.createdEnd = createdEnd; | |
| 149 | + } | |
| 150 | + | |
| 131 | 151 | public Integer getFollowupStatus() { |
| 132 | 152 | return followupStatus; |
| 133 | 153 | } |
| ... | ... | @@ -270,6 +290,16 @@ |
| 270 | 290 | c1 = Criteria.where("buildDay").gte(buildDateStart).lte(buildDateEnd); |
| 271 | 291 | } |
| 272 | 292 | } |
| 293 | + | |
| 294 | + | |
| 295 | + if (null != createdStart && null != createdEnd) { | |
| 296 | + if (null != c1) { | |
| 297 | + c1 = c1.where("created").gte(createdStart).lte(createdEnd); | |
| 298 | + } else { | |
| 299 | + c1 = Criteria.where("created").gte(createdStart).lte(createdEnd); | |
| 300 | + } | |
| 301 | + } | |
| 302 | + | |
| 273 | 303 | |
| 274 | 304 | if (null != ageMin) { |
| 275 | 305 | c1 = Criteria.where("age").gte(ageMin); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TrackDownController.java
View file @
3e83c81
| ... | ... | @@ -146,8 +146,8 @@ |
| 146 | 146 | * 孕妇追访管理历史数据处理 |
| 147 | 147 | */ |
| 148 | 148 | @RequestMapping(value = "/historyData", method = RequestMethod.GET) |
| 149 | - public void historyData(Date startTime, Date endTime) { | |
| 150 | - downFacade.historyData(startTime, endTime); | |
| 149 | + public void historyData(Date startTime, Date endTime, String hospitalId) { | |
| 150 | + downFacade.historyData(startTime, endTime, hospitalId); | |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/TrackDownFacade.java
View file @
3e83c81
| ... | ... | @@ -13,6 +13,8 @@ |
| 13 | 13 | import com.lyms.platform.operate.web.result.HighScoreResult; |
| 14 | 14 | import com.lyms.platform.operate.web.utils.CommonsHelper; |
| 15 | 15 | import com.lyms.platform.operate.web.utils.ResponseUtil; |
| 16 | +import com.lyms.platform.operate.web.worker.ChaseVisitHistory; | |
| 17 | +import com.lyms.platform.operate.web.worker.babyStatisticalProbabilityWorker; | |
| 16 | 18 | import com.lyms.platform.permission.model.ServiceListQuery; |
| 17 | 19 | import com.lyms.platform.pojo.*; |
| 18 | 20 | import com.lyms.platform.query.*; |
| 19 | 21 | |
| ... | ... | @@ -20,10 +22,12 @@ |
| 20 | 22 | import org.slf4j.Logger; |
| 21 | 23 | import org.slf4j.LoggerFactory; |
| 22 | 24 | import org.springframework.beans.factory.annotation.Autowired; |
| 25 | +import org.springframework.beans.factory.annotation.Qualifier; | |
| 23 | 26 | import org.springframework.data.domain.Sort; |
| 24 | 27 | import org.springframework.data.mongodb.core.MongoTemplate; |
| 25 | 28 | import org.springframework.data.mongodb.core.query.Criteria; |
| 26 | 29 | import org.springframework.data.mongodb.core.query.Query; |
| 30 | +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | |
| 27 | 31 | import org.springframework.stereotype.Component; |
| 28 | 32 | |
| 29 | 33 | import javax.annotation.PostConstruct; |
| ... | ... | @@ -31,6 +35,8 @@ |
| 31 | 35 | import javax.servlet.http.HttpServletResponse; |
| 32 | 36 | import java.text.SimpleDateFormat; |
| 33 | 37 | import java.util.*; |
| 38 | +import java.util.concurrent.Callable; | |
| 39 | +import java.util.concurrent.Future; | |
| 34 | 40 | |
| 35 | 41 | |
| 36 | 42 | /** |
| 37 | 43 | |
| 38 | 44 | |
| 39 | 45 | |
| 40 | 46 | |
| ... | ... | @@ -1090,33 +1096,53 @@ |
| 1090 | 1096 | * 孕妇追访历史数据处理 |
| 1091 | 1097 | */ |
| 1092 | 1098 | |
| 1093 | - private long start; | |
| 1099 | + @Autowired | |
| 1100 | + @Qualifier("commonThreadPool") | |
| 1101 | + private ThreadPoolTaskExecutor commonThreadPool; | |
| 1094 | 1102 | |
| 1095 | - public void historyData(Date startTime, Date endTime) { | |
| 1096 | - //1.处理妇女表中的预约字段 | |
| 1097 | - List<TrackDownRecord> trackDownRecord = mongoTemplate.find(Query.query(Criteria.where("created").gte(startTime).lte(endTime)), TrackDownRecord.class); | |
| 1098 | - System.out.println(trackDownRecord.size()); | |
| 1099 | - TrackDownRecord trackDown = new TrackDownRecord(); | |
| 1100 | - ResidentsArchiveModel residentsArchiveModel = new ResidentsArchiveModel(); | |
| 1101 | - Patients patients = new Patients(); | |
| 1103 | + @Autowired | |
| 1104 | + private PremaritalCheckupService premaritalCheckupService; | |
| 1102 | 1105 | |
| 1103 | - System.out.println(System.currentTimeMillis()); | |
| 1104 | - start = System.currentTimeMillis(); | |
| 1105 | - for (TrackDownRecord track : trackDownRecord) { | |
| 1106 | - System.out.println("id:" + track.getId()); | |
| 1107 | - trackDown.setAppointmentDate(track.getCreated()); | |
| 1108 | - trackDown.setStop("0"); | |
| 1109 | - residentsArchiveModel.setStop("0"); | |
| 1110 | - residentsArchiveModel.setFollowupTime(track.getCreated()); | |
| 1111 | - patients.setStop("0"); | |
| 1112 | - patients.setFollowupTime(track.getCreated()); | |
| 1113 | - patientsService.updatePatientOne(patients, track.getParentId()); | |
| 1114 | - residentsArchiveService.updateResident(residentsArchiveModel, track.getResidentsArchiveId()); | |
| 1115 | - trackDownRecordService.updateTrackDown(trackDown, track.getId()); | |
| 1106 | + public void historyData(Date startTime, Date endTime, String hospitalId) { | |
| 1107 | + if (null != startTime && null != endTime && StringUtils.isNotEmpty(hospitalId)) { | |
| 1108 | + //1.处理是否妇女是否有婚检 | |
| 1109 | + ResidentsArchiveQuery query = new ResidentsArchiveQuery(); | |
| 1110 | + List<Map<String, Integer>> dataRequest = new ArrayList<>(); | |
| 1111 | + query.setCreatedStart(startTime); | |
| 1112 | + query.setCreatedEnd(endTime); | |
| 1113 | + query.setHospitalId(hospitalId); | |
| 1114 | + List<ResidentsArchiveModel> archiveModels = residentsArchiveService.queryResident(query); | |
| 1115 | + if (CollectionUtils.isNotEmpty(archiveModels)) { | |
| 1116 | + int batchSize = 5; | |
| 1117 | + int ends = 0; | |
| 1118 | + List<Future> futures = new ArrayList<>(); | |
| 1119 | + for (int i = 0; i < archiveModels.size(); i += batchSize) { | |
| 1120 | + ends = (ends + batchSize); | |
| 1121 | + if (ends > archiveModels.size()) { | |
| 1122 | + ends = archiveModels.size(); | |
| 1123 | + } | |
| 1124 | + List<ResidentsArchiveModel> mlist = archiveModels.subList(i, ends); | |
| 1125 | + Callable c = new ChaseVisitHistory(mlist, residentsArchiveService,mongoTemplate); | |
| 1126 | + Future f = commonThreadPool.submit(c); | |
| 1127 | + if (f != null) { | |
| 1128 | + futures.add(f); | |
| 1129 | + } | |
| 1130 | + } | |
| 1131 | + if (CollectionUtils.isNotEmpty(futures)) { | |
| 1132 | + for (Future f : futures) { | |
| 1133 | + try { | |
| 1134 | + dataRequest.add((Map<String, Integer>) f.get()); | |
| 1135 | + } catch (Exception e) { | |
| 1136 | + ExceptionUtils.catchException(e, "fm list error."); | |
| 1137 | + } | |
| 1138 | + } | |
| 1139 | + } | |
| 1140 | + } | |
| 1141 | + | |
| 1142 | + | |
| 1116 | 1143 | } |
| 1117 | - System.out.println("结束时间:" + (System.currentTimeMillis() - start)); | |
| 1118 | - } | |
| 1119 | 1144 | |
| 1145 | + } | |
| 1120 | 1146 | |
| 1121 | 1147 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/ChaseVisitHistory.java
View file @
3e83c81
| 1 | +package com.lyms.platform.operate.web.worker; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.service.PremaritalCheckupService; | |
| 4 | +import com.lyms.platform.biz.service.ResidentsArchiveService; | |
| 5 | +import com.lyms.platform.common.utils.StringUtils; | |
| 6 | +import com.lyms.platform.pojo.Patients; | |
| 7 | +import com.lyms.platform.pojo.PremaritalCheckup; | |
| 8 | +import com.lyms.platform.pojo.ResidentsArchiveModel; | |
| 9 | +import com.lyms.platform.query.PremaritalCheckupQuery; | |
| 10 | +import org.springframework.data.mongodb.core.MongoTemplate; | |
| 11 | +import org.springframework.data.mongodb.core.query.Criteria; | |
| 12 | +import org.springframework.data.mongodb.core.query.Query; | |
| 13 | + | |
| 14 | +import java.util.List; | |
| 15 | +import java.util.Map; | |
| 16 | +import java.util.concurrent.Callable; | |
| 17 | + | |
| 18 | +public class ChaseVisitHistory implements Callable<Map<String, Integer>> { | |
| 19 | + | |
| 20 | + private List<ResidentsArchiveModel> archiveModel; | |
| 21 | + | |
| 22 | + private ResidentsArchiveService residentsArchiveService; | |
| 23 | + | |
| 24 | + private MongoTemplate mongoTemplate; | |
| 25 | + | |
| 26 | + public ChaseVisitHistory(List<ResidentsArchiveModel> archiveModel, ResidentsArchiveService residentsArchiveService, MongoTemplate mongoTemplate) { | |
| 27 | + this.archiveModel = archiveModel; | |
| 28 | + this.residentsArchiveService = residentsArchiveService; | |
| 29 | + this.mongoTemplate = mongoTemplate; | |
| 30 | + | |
| 31 | + } | |
| 32 | + | |
| 33 | + @Override | |
| 34 | + public Map<String, Integer> call() throws Exception { | |
| 35 | + for (ResidentsArchiveModel archive : archiveModel) { | |
| 36 | + PremaritalCheckup checkup = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(archive.getId())), PremaritalCheckup.class); | |
| 37 | + if (null != checkup) { | |
| 38 | + archive.setCheckup("1"); | |
| 39 | + } else { | |
| 40 | + archive.setCheckup("0"); | |
| 41 | + } | |
| 42 | + Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("cardNo").is(archive.getCertificateNum())), Patients.class); | |
| 43 | + if (null != patients) { | |
| 44 | + archive.setPregnantBuild("1"); | |
| 45 | + } else { | |
| 46 | + archive.setPregnantBuild("0"); | |
| 47 | + } | |
| 48 | + //默认正常 | |
| 49 | + archive.setStop("0"); | |
| 50 | + | |
| 51 | + residentsArchiveService.updateResident(archive, archive.getId()); | |
| 52 | + | |
| 53 | + } | |
| 54 | + return null; | |
| 55 | + } | |
| 56 | +} |