Commit 42cb87a58087b046bff238a9724fe739d54ba7b4
1 parent
3a74ded886
Exists in
master
and in
1 other branch
实时添加追访记录
Showing 6 changed files with 349 additions and 71 deletions
- platform-dal/src/main/java/com/lyms/platform/pojo/BabyAfterVisitInfoDetailModel.java
- platform-dal/src/main/java/com/lyms/platform/pojo/BabyAfterVisitInfoModel.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyAfterVisitController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/BabyAfterVisitService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BabyAfterVisitServiceImpl.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/BabyAfterVisitInfoModelWork.java
platform-dal/src/main/java/com/lyms/platform/pojo/BabyAfterVisitInfoDetailModel.java
View file @
42cb87a
| ... | ... | @@ -83,6 +83,16 @@ |
| 83 | 83 | */ |
| 84 | 84 | private Integer yn; |
| 85 | 85 | |
| 86 | + private String hospitalId; | |
| 87 | + | |
| 88 | + public String getHospitalId() { | |
| 89 | + return hospitalId; | |
| 90 | + } | |
| 91 | + | |
| 92 | + public void setHospitalId(String hospitalId) { | |
| 93 | + this.hospitalId = hospitalId; | |
| 94 | + } | |
| 95 | + | |
| 86 | 96 | public Integer getYn() { |
| 87 | 97 | return yn; |
| 88 | 98 | } |
platform-dal/src/main/java/com/lyms/platform/pojo/BabyAfterVisitInfoModel.java
View file @
42cb87a
| ... | ... | @@ -4,7 +4,6 @@ |
| 4 | 4 | import org.springframework.data.mongodb.core.mapping.Document; |
| 5 | 5 | |
| 6 | 6 | import java.util.Date; |
| 7 | -import java.util.List; | |
| 8 | 7 | |
| 9 | 8 | /** |
| 10 | 9 | * |
| ... | ... | @@ -80,7 +79,7 @@ |
| 80 | 79 | private String afterVisitUser; |
| 81 | 80 | |
| 82 | 81 | /** |
| 83 | - * 追访方式 | |
| 82 | + * 追访方式 1-电话追访 2-上门追访 3-短信追访 4-app追访 | |
| 84 | 83 | */ |
| 85 | 84 | private String afterVisitWay; |
| 86 | 85 | |
| 87 | 86 | |
| ... | ... | @@ -145,8 +144,17 @@ |
| 145 | 144 | */ |
| 146 | 145 | private String riskFactors; |
| 147 | 146 | |
| 147 | + private String hospitalId; | |
| 148 | + | |
| 148 | 149 | // TODO 2019/6/29 15:55 dongqing 参数未完 |
| 149 | 150 | |
| 151 | + public String getHospitalId() { | |
| 152 | + return hospitalId; | |
| 153 | + } | |
| 154 | + | |
| 155 | + public void setHospitalId(String hospitalId) { | |
| 156 | + this.hospitalId = hospitalId; | |
| 157 | + } | |
| 150 | 158 | |
| 151 | 159 | public String getDiagnosisMonths() { |
| 152 | 160 | return diagnosisMonths; |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyAfterVisitController.java
View file @
42cb87a
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/BabyAfterVisitService.java
View file @
42cb87a
| ... | ... | @@ -7,6 +7,9 @@ |
| 7 | 7 | import com.lyms.platform.operate.web.request.BabyAfterVisitInfoDetailListRequest; |
| 8 | 8 | import com.lyms.platform.operate.web.request.BabyAfterVisitInfoDetailRequest; |
| 9 | 9 | import com.lyms.platform.operate.web.request.BabyAfterVisitRequest; |
| 10 | +import com.lyms.platform.operate.web.service.impl.BabyAfterVisitServiceImpl; | |
| 11 | +import org.slf4j.Logger; | |
| 12 | +import org.slf4j.LoggerFactory; | |
| 10 | 13 | |
| 11 | 14 | import java.lang.reflect.InvocationTargetException; |
| 12 | 15 | import java.util.concurrent.ExecutionException; |
| 13 | 16 | |
| ... | ... | @@ -35,11 +38,17 @@ |
| 35 | 38 | public static final Integer STATUS_TYPE_TEMPORARY_DOCUMENT = 4; |
| 36 | 39 | /**状态:正式建档/已建档*/ |
| 37 | 40 | public static final Integer STATUS_TYPE_BUILD= 1; |
| 41 | + /**标识:儿保检查*/ | |
| 42 | + public static final Integer STATUS_TYPE_CHECK= 5; | |
| 43 | + /**标识:眼保检查*/ | |
| 44 | + public static final Integer STATUS_TYPE_EYE_CHECK= 6; | |
| 38 | 45 | |
| 39 | 46 | public static final String BABY_ID = "babyId"; |
| 40 | 47 | public static final String POSITIVE_PROJECT_TYPE = "yang"; |
| 41 | 48 | |
| 42 | 49 | public static ExpiryMap cacheMap = new ExpiryMap(1000 * 60 * 60 * 7); |
| 50 | + | |
| 51 | + Logger logger = LoggerFactory.getLogger(BabyAfterVisitServiceImpl.class); | |
| 43 | 52 | |
| 44 | 53 | /** |
| 45 | 54 | * 追访管理 - 追访列表 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BabyAfterVisitServiceImpl.java
View file @
42cb87a
| ... | ... | @@ -5,6 +5,8 @@ |
| 5 | 5 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
| 6 | 6 | import com.lyms.platform.common.enums.SexEnum; |
| 7 | 7 | import com.lyms.platform.common.enums.TrackDownTransferEnums; |
| 8 | +import com.lyms.platform.common.enums.YnEnums; | |
| 9 | +import com.lyms.platform.common.exception.BusinessException; | |
| 8 | 10 | import com.lyms.platform.common.result.BaseListResponse; |
| 9 | 11 | import com.lyms.platform.common.result.BaseModel; |
| 10 | 12 | import com.lyms.platform.common.result.BaseResponse; |
| 11 | 13 | |
| ... | ... | @@ -21,13 +23,13 @@ |
| 21 | 23 | import com.lyms.platform.permission.dao.master.MasterUsersMapper; |
| 22 | 24 | import com.lyms.platform.permission.model.Users; |
| 23 | 25 | import com.lyms.platform.pojo.*; |
| 24 | -import org.apache.log4j.Logger; | |
| 25 | 26 | import org.springframework.beans.factory.annotation.Autowired; |
| 26 | 27 | import org.springframework.data.domain.Sort; |
| 27 | 28 | import org.springframework.data.mongodb.core.MongoTemplate; |
| 28 | 29 | import org.springframework.data.mongodb.core.aggregation.Aggregation; |
| 29 | 30 | import org.springframework.data.mongodb.core.aggregation.AggregationOperation; |
| 30 | 31 | import org.springframework.data.mongodb.core.aggregation.AggregationResults; |
| 32 | +import org.springframework.data.mongodb.core.aggregation.MatchOperation; | |
| 31 | 33 | import org.springframework.data.mongodb.core.query.Criteria; |
| 32 | 34 | import org.springframework.data.mongodb.core.query.Query; |
| 33 | 35 | import org.springframework.data.mongodb.core.query.Update; |
| ... | ... | @@ -46,8 +48,6 @@ |
| 46 | 48 | @Service |
| 47 | 49 | public class BabyAfterVisitServiceImpl implements BabyAfterVisitService { |
| 48 | 50 | |
| 49 | - private Logger logger = Logger.getLogger(this.getClass()); | |
| 50 | - | |
| 51 | 51 | @Autowired |
| 52 | 52 | private MongoTemplate mongoTemplate; |
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | |
| ... | ... | @@ -157,40 +157,37 @@ |
| 157 | 157 | // 儿保检查 ( 已建档未做儿保检查) |
| 158 | 158 | List<String> ids = new ArrayList<>(); |
| 159 | 159 | List<BabyAfterVisitInfoModel> infoCheckModels = new ArrayList<>(); |
| 160 | - Object object = cacheMap.get("buildId"); | |
| 161 | - if (null != object) { | |
| 162 | - ids = (List<String>) object; | |
| 163 | - } else { | |
| 164 | - Query query = new Query(); | |
| 165 | - query.addCriteria(Criteria.where("yn").ne(0).and("dataStatus").ne(1)); | |
| 166 | - query.addCriteria(Criteria.where("nextDate").exists(false).and("weakSon").exists(false).and("highRisk").exists(false)); | |
| 167 | - List<BabyModel> babyModels = mongoTemplate.find(query, BabyModel.class); | |
| 168 | - for (BabyModel model : babyModels) { | |
| 169 | - String modelId = model.getId(); | |
| 170 | - ids.add(modelId); | |
| 171 | - } | |
| 172 | 160 | |
| 173 | - // 儿保 (sysdate < 下次预约时间) or ( 已做儿保检查 and 下次预约时间 == null) | |
| 174 | - AggregationOperation group = Aggregation.group("buildId").max("created").as("created").addToSet("id").as("babyCheckIds"); | |
| 175 | - Aggregation aggregation = Aggregation.newAggregation(group); | |
| 176 | - AggregationResults<Map> aggregate = mongoTemplate.aggregate(aggregation, BabyCheckModel.class, Map.class); | |
| 177 | - List<Map> mappedResults = aggregate.getMappedResults(); | |
| 178 | - for (Map mappedResult : mappedResults) { | |
| 179 | - List babyCheckIds = (List) mappedResult.get("babyCheckIds"); | |
| 180 | - // 根据建档id分组,获取最新的儿保检查数据 | |
| 181 | - Object babyCheckId = babyCheckIds.get(babyCheckIds.size() - 1); | |
| 182 | - BabyCheckModel babyCheckModel = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(babyCheckId).orOperator(Criteria.where("nextDate").gte(new Date()), Criteria.where("nextDate").exists(false))), BabyCheckModel.class); | |
| 183 | - if (null != babyCheckModel) { | |
| 184 | - String buildId = babyCheckModel.getBuildId(); | |
| 185 | - boolean contains = ids.contains(babyId); | |
| 186 | - if (!contains) { | |
| 187 | - ids.add(buildId); | |
| 188 | - } | |
| 161 | + Query query = new Query(); | |
| 162 | + query.addCriteria(Criteria.where("created").gte(startDate).lt(endDate)); | |
| 163 | + query.addCriteria(Criteria.where("yn").ne(0).and("dataStatus").ne(1)); | |
| 164 | + query.addCriteria(Criteria.where("nextDate").exists(false).and("weakSon").exists(false).and("highRisk").exists(false)); | |
| 165 | + List<BabyModel> babyModels = mongoTemplate.find(query, BabyModel.class); | |
| 166 | + for (BabyModel model : babyModels) { | |
| 167 | + String modelId = model.getId(); | |
| 168 | + ids.add(modelId); | |
| 169 | + } | |
| 170 | + | |
| 171 | + // 儿保 (sysdate < 下次预约时间) or ( 已做儿保检查 and 下次预约时间 == null) | |
| 172 | + MatchOperation match = Aggregation.match(Criteria.where("created").gte(startDate).lt(endDate)); | |
| 173 | + AggregationOperation group = Aggregation.group("buildId").max("created").as("created").addToSet("id").as("babyCheckIds"); | |
| 174 | + Aggregation aggregation = Aggregation.newAggregation(match ,group); | |
| 175 | + AggregationResults<Map> aggregate = mongoTemplate.aggregate(aggregation, BabyCheckModel.class, Map.class); | |
| 176 | + List<Map> mappedResults = aggregate.getMappedResults(); | |
| 177 | + for (Map mappedResult : mappedResults) { | |
| 178 | + List babyCheckIds = (List) mappedResult.get("babyCheckIds"); | |
| 179 | + // 根据建档id分组,获取最新的儿保检查数据 | |
| 180 | + Object babyCheckId = babyCheckIds.get(babyCheckIds.size() - 1); | |
| 181 | + BabyCheckModel babyCheckModel = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(babyCheckId).orOperator(Criteria.where("nextDate").gte(new Date()), | |
| 182 | + Criteria.where("nextDate").exists(false))), BabyCheckModel.class); | |
| 183 | + if (null != babyCheckModel) { | |
| 184 | + String buildId = babyCheckModel.getBuildId(); | |
| 185 | + boolean contains = ids.contains(babyId); | |
| 186 | + if (!contains) { | |
| 187 | + ids.add(buildId); | |
| 189 | 188 | } |
| 190 | 189 | } |
| 191 | - cacheMap.put("buildId", ids); | |
| 192 | 190 | } |
| 193 | - | |
| 194 | 191 | setSyncAfterVisitInfoList( ids, infoCheckModels, afterVisitQuery, TYPE_CHECK, startDate, endDate); |
| 195 | 192 | mongoTemplate.insert(infoCheckModels, BabyAfterVisitInfoModel.class); |
| 196 | 193 | map.put("infoModels-check-size", infoCheckModels.size()); |
| ... | ... | @@ -198,7 +195,8 @@ |
| 198 | 195 | // 眼保检查 |
| 199 | 196 | List<BabyAfterVisitInfoModel> infoEyeCheckModels = new ArrayList<>(); |
| 200 | 197 | Query eyeQuery = new Query(); |
| 201 | - eyeQuery.addCriteria(Criteria.where("yn").ne(0).and("dataStatus").ne(1).and("created").gte(startDate).lte(endDate)); | |
| 198 | + eyeQuery.addCriteria(Criteria.where("created").gte(startDate).lt(endDate)); | |
| 199 | + eyeQuery.addCriteria(Criteria.where("yn").ne(0).and("dataStatus").ne(1)); | |
| 202 | 200 | List<BabyModel> eyeBabyModels = mongoTemplate.find(eyeQuery, BabyModel.class); |
| 203 | 201 | List<String> babyIds = new ArrayList<>(); |
| 204 | 202 | for (BabyModel babyModel : eyeBabyModels) { |
| ... | ... | @@ -209,11 +207,12 @@ |
| 209 | 207 | } |
| 210 | 208 | } |
| 211 | 209 | // sysdate < 下次预约时间 已做眼保检查 and 下次预约时间 == null |
| 212 | - AggregationOperation group = Aggregation.group(BABY_ID).max("created").as("created").addToSet("id").as("babyEyeCheckIds"); | |
| 213 | - Aggregation aggregation = Aggregation.newAggregation(group); | |
| 214 | - AggregationResults<Map> aggregate = mongoTemplate.aggregate(aggregation, BabyEyeCheck.class, Map.class); | |
| 215 | - List<Map> mappedResults = aggregate.getMappedResults(); | |
| 216 | - for (Map mappedResult : mappedResults) { | |
| 210 | + MatchOperation eyeMatch = Aggregation.match(Criteria.where("created").gte(startDate).lt(endDate)); | |
| 211 | + AggregationOperation eyeGroup = Aggregation.group(BABY_ID).max("created").as("created").addToSet("id").as("babyEyeCheckIds"); | |
| 212 | + Aggregation eyeAggregation = Aggregation.newAggregation(eyeMatch, eyeGroup); | |
| 213 | + AggregationResults<Map> eyeAggregate = mongoTemplate.aggregate(eyeAggregation, BabyEyeCheck.class, Map.class); | |
| 214 | + List<Map> eyeMappedResults = eyeAggregate.getMappedResults(); | |
| 215 | + for (Map mappedResult : eyeMappedResults) { | |
| 217 | 216 | List babyEyeCheckIds = (List) mappedResult.get("babyEyeCheckIds"); |
| 218 | 217 | Object babyEyeCheckId = babyEyeCheckIds.get(babyEyeCheckIds.size() - 1); |
| 219 | 218 | BabyEyeCheck babyEyeCheck = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(babyEyeCheckId). |
| ... | ... | @@ -231,7 +230,7 @@ |
| 231 | 230 | mongoTemplate.insert(infoEyeCheckModels, BabyAfterVisitInfoModel.class); |
| 232 | 231 | map.put("infoModels-eyeCheck-size", infoEyeCheckModels.size()); |
| 233 | 232 | |
| 234 | - // TODO 2019/7/5 11:48 dongqing 听力筛查, 郝总都不知道需求是怎么样的 | |
| 233 | + // TODO 2019/7/2 11:48 dongqing 听力筛查, 郝总都不知道需求是怎么样的 | |
| 235 | 234 | |
| 236 | 235 | response.setObject(map); |
| 237 | 236 | return response; |
| 238 | 237 | |
| ... | ... | @@ -281,8 +280,13 @@ |
| 281 | 280 | */ |
| 282 | 281 | @Override |
| 283 | 282 | public BaseResponse getBuildListPage(BabyAfterVisitBuildListRequest request) { |
| 284 | - Query query = new Query(); | |
| 285 | 283 | String type = request.getType(); |
| 284 | + boolean isOk = checkOverdueDataByType(type); | |
| 285 | + if (!isOk) { | |
| 286 | + return new BaseResponse("检查逾期数据异常", ErrorCodeConstants.SYSTEM_ERROR); | |
| 287 | + } | |
| 288 | + | |
| 289 | + Query query = new Query(); | |
| 286 | 290 | if (Objects.isNull(type)) { |
| 287 | 291 | return new BaseResponse("参数缺失", ErrorCodeConstants.PARAMETER_ERROR); |
| 288 | 292 | } |
| ... | ... | @@ -412,7 +416,6 @@ |
| 412 | 416 | query.addCriteria(Criteria.where("positiveProject").regex(pattern)); |
| 413 | 417 | } |
| 414 | 418 | |
| 415 | - | |
| 416 | 419 | // 组装分页query |
| 417 | 420 | long count = mongoTemplate.count(query, BabyAfterVisitInfoModel.class); |
| 418 | 421 | request.mysqlBuild((int) count); |
| 419 | 422 | |
| 420 | 423 | |
| ... | ... | @@ -424,11 +427,54 @@ |
| 424 | 427 | Map<String, Object> objectMap = BeanUtils.objectToObjectMap(model); |
| 425 | 428 | objectMap.put("sexStr", SexEnum.getTextById(model.getSex())); |
| 426 | 429 | objectMap.put("birthStr", DateUtil.getyyyy_MM_dd(model.getBirth())); |
| 427 | - objectMap.put("appointmentTimeStr", DateUtil.getyyyy_MM_dd(model.getAppointmentTime())); | |
| 428 | 430 | objectMap.put("monthsAge", DateUtil.getBabyMonthAge(model.getBirth(), new Date())); |
| 429 | 431 | objectMap.put("mphone",model.getMphone().replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2")); |
| 430 | - mapList.add(objectMap); | |
| 431 | 432 | |
| 433 | + // 预约时间 | |
| 434 | + Date appointmentTime = model.getAppointmentTime(); | |
| 435 | + if (appointmentTime != null) { | |
| 436 | + objectMap.put("appointmentTimeStr", DateUtil.getyyyy_MM_dd(appointmentTime)); | |
| 437 | + } | |
| 438 | + | |
| 439 | + // 追访时间 | |
| 440 | + Date afterVisitTime = model.getAfterVisitTime(); | |
| 441 | + if (afterVisitTime != null) { | |
| 442 | + objectMap.put("afterVisitTimeStr", DateUtil.getyyyy_MM_dd(afterVisitTime)); | |
| 443 | + } | |
| 444 | + // 追访人 | |
| 445 | + String afterVisitUser = model.getAfterVisitUser(); | |
| 446 | + if (StringUtils.isNotEmpty(afterVisitUser)) { | |
| 447 | + Users users = usersMapper.getUsers(Integer.parseInt(afterVisitUser)); | |
| 448 | + if (users != null) { | |
| 449 | + objectMap.put("afterVisitUserStr", users.getName()); | |
| 450 | + } | |
| 451 | + } | |
| 452 | + // 阳性项目 | |
| 453 | + String positives = model.getPositiveProject(); | |
| 454 | + if (StringUtils.isNotEmpty(positives)) { | |
| 455 | + objectMap.put("positiveProjectStr", positives); | |
| 456 | + } | |
| 457 | + // 检查医生 | |
| 458 | + String doctor = model.getCheckDoctor(); | |
| 459 | + if (StringUtils.isNotEmpty(doctor)) { | |
| 460 | + Users users = usersMapper.getUsers(Integer.parseInt(doctor)); | |
| 461 | + if (users != null) { | |
| 462 | + objectMap.put("checkDoctorStr", users.getName()); | |
| 463 | + } | |
| 464 | + } | |
| 465 | + // 检查日期 | |
| 466 | + Date checkTime = model.getCheckTime(); | |
| 467 | + if (checkTime != null) { | |
| 468 | + objectMap.put("checkTimeStr", DateUtil.getyyyy_MM_dd(checkTime)); | |
| 469 | + } | |
| 470 | + // 诊断时间 | |
| 471 | + Date diagnosisTime = model.getDiagnosisTime(); | |
| 472 | + if (diagnosisTime != null) { | |
| 473 | + objectMap.put("diagnosisTimeStr", DateUtil.getyyyy_MM_dd(diagnosisTime)); | |
| 474 | + } | |
| 475 | + | |
| 476 | + | |
| 477 | + mapList.add(objectMap); | |
| 432 | 478 | } |
| 433 | 479 | |
| 434 | 480 | baseListResponse.setPageInfo(request.getPageInfo()); |
| ... | ... | @@ -437,6 +483,91 @@ |
| 437 | 483 | } |
| 438 | 484 | |
| 439 | 485 | /** |
| 486 | + * 检查预约时间是否存在已逾期,若是则添加到追访表中 | |
| 487 | + * @param type 类型 | |
| 488 | + * @return | |
| 489 | + */ | |
| 490 | + private boolean checkOverdueDataByType(String type) { | |
| 491 | + try { | |
| 492 | + Class<BabyAfterVisitInfoModel> infoModelClass = BabyAfterVisitInfoModel.class; | |
| 493 | + if (TYPE_CHECK.equals(type)) { | |
| 494 | + // 儿保检查 | |
| 495 | + Class<BabyCheckModel> checkModelClass = BabyCheckModel.class; | |
| 496 | + List<BabyCheckModel> babyCheckModels = mongoTemplate.find(Query.query(Criteria.where("nextDate").gt(new Date()).and("yn").is(YnEnums.YES.getId())), checkModelClass); | |
| 497 | + List<BabyAfterVisitInfoModel> models = new ArrayList<>(1024); | |
| 498 | + if (CollectionUtils.isNotEmpty(babyCheckModels)) { | |
| 499 | + for (BabyCheckModel model : babyCheckModels) { | |
| 500 | + String buildId = model.getBuildId(); | |
| 501 | + boolean exists = mongoTemplate.exists(Query.query(Criteria.where(BABY_ID).is(buildId).and(type).is(type)), infoModelClass); | |
| 502 | + if (!exists) { | |
| 503 | + BabyAfterVisitInfoModel infoModel = getBabyAfterVisitInfoModel(type, model, buildId); | |
| 504 | + models.add(infoModel); | |
| 505 | + } | |
| 506 | + } | |
| 507 | + if (babyCheckModels.size() > 0) { | |
| 508 | + mongoTemplate.insert(models, infoModelClass); | |
| 509 | + } | |
| 510 | + } | |
| 511 | + } | |
| 512 | + if (TYPE_EYE_CHECK.equals(type)) { | |
| 513 | + // 眼保检查 | |
| 514 | + Class<BabyEyeCheck> eyeCheckClass = BabyEyeCheck.class; | |
| 515 | + List<BabyEyeCheck> babyCheckModels = mongoTemplate.find(Query.query(Criteria.where("nextCheckTime").gt(new Date()).and("yn").is(YnEnums.YES.getId())), eyeCheckClass); | |
| 516 | + List<BabyAfterVisitInfoModel> models = new ArrayList<>(1024); | |
| 517 | + if (CollectionUtils.isNotEmpty(babyCheckModels)) { | |
| 518 | + for (BabyEyeCheck model : babyCheckModels) { | |
| 519 | + String buildId = model.getBabyId(); | |
| 520 | + boolean exists = mongoTemplate.exists(Query.query(Criteria.where(BABY_ID).is(buildId).and(type).is(type)), infoModelClass); | |
| 521 | + if (!exists) { | |
| 522 | + BabyAfterVisitInfoModel infoModel = getBabyAfterVisitInfoModel(type, model, buildId); | |
| 523 | + models.add(infoModel); | |
| 524 | + } | |
| 525 | + } | |
| 526 | + if (babyCheckModels.size() > 0) { | |
| 527 | + mongoTemplate.insert(models, infoModelClass); | |
| 528 | + } | |
| 529 | + } | |
| 530 | + } | |
| 531 | + return true; | |
| 532 | + } catch (Exception e) { | |
| 533 | + logger.error("检查预约时间是否存在已逾期 异常", e.getStackTrace()); | |
| 534 | + return false; | |
| 535 | + } | |
| 536 | + | |
| 537 | + } | |
| 538 | + | |
| 539 | + /** | |
| 540 | + * 获取 BabyAfterVisitInfoModel 实体类 | |
| 541 | + * @param type | |
| 542 | + * @param model | |
| 543 | + * @param buildId | |
| 544 | + * @return | |
| 545 | + */ | |
| 546 | + private BabyAfterVisitInfoModel getBabyAfterVisitInfoModel(String type, BaseModel model, String buildId) { | |
| 547 | + BabyAfterVisitInfoModel infoModel = new BabyAfterVisitInfoModel(); | |
| 548 | + if (model instanceof BabyCheckModel) { | |
| 549 | + BabyCheckModel checkModel = (BabyCheckModel) model; | |
| 550 | + BeanUtils.copy(checkModel, infoModel); | |
| 551 | + BabyModel babyModel = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(buildId)), BabyModel.class); | |
| 552 | + BeanUtils.copy(babyModel, infoModel); | |
| 553 | + infoModel.setAppointmentTime(checkModel.getNextDate()); | |
| 554 | + } | |
| 555 | + if (model instanceof BabyEyeCheck) { | |
| 556 | + BabyEyeCheck eyeCheck = (BabyEyeCheck) model; | |
| 557 | + BeanUtils.copy(eyeCheck, infoModel); | |
| 558 | + BabyModel babyModel = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(buildId)), BabyModel.class); | |
| 559 | + BeanUtils.copy(babyModel, infoModel); | |
| 560 | + infoModel.setAppointmentTime(eyeCheck.getNextCheckTime()); | |
| 561 | + } | |
| 562 | + infoModel.setType(type); | |
| 563 | + infoModel.setCreateTime(new Date()); | |
| 564 | + infoModel.setYn(STATUS_TYPE_YES); | |
| 565 | + infoModel.setBabyId(buildId); | |
| 566 | + infoModel.setId(null); | |
| 567 | + return infoModel; | |
| 568 | + } | |
| 569 | + | |
| 570 | + /** | |
| 440 | 571 | * 递归获取预约建档的儿童信息 |
| 441 | 572 | * |
| 442 | 573 | * @param ids 建档ids - 针对儿保检查 |
| ... | ... | @@ -448,7 +579,8 @@ |
| 448 | 579 | * @throws ExecutionException |
| 449 | 580 | * @throws InterruptedException |
| 450 | 581 | */ |
| 451 | - private void setSyncAfterVisitInfoList(List<String> ids , List<BabyAfterVisitInfoModel> infoModels, BabyAfterVisitRequest afterVisitQuery, Integer type, Date startDate, Date endDate) throws ExecutionException, InterruptedException { | |
| 582 | + private void setSyncAfterVisitInfoList(List<String> ids , List<BabyAfterVisitInfoModel> infoModels, BabyAfterVisitRequest afterVisitQuery, Integer type, Date startDate, Date endDate) | |
| 583 | + throws ExecutionException, InterruptedException { | |
| 452 | 584 | Query query = new Query(); |
| 453 | 585 | query.addCriteria(Criteria.where("created").gte(startDate).lte(endDate)); |
| 454 | 586 | long count = 0L; |
| ... | ... | @@ -581,7 +713,10 @@ |
| 581 | 713 | |
| 582 | 714 | |
| 583 | 715 | /** |
| 584 | - * 在产妇分娩(MatDeliverFacade)、儿童建档(BabyBookbuildingFacade)、儿保检查保存(BabyCheckFacade)、眼保检查(BabyEyeCheckServiceImpl) | |
| 716 | + * 在产妇分娩(MatDeliverFacade)、 | |
| 717 | + * 儿童建档(BabyBookbuildingFacade)、 | |
| 718 | + * 儿保检查保存(BabyCheckFacade)、 | |
| 719 | + * 眼保检查(BabyEyeCheckServiceImpl) | |
| 585 | 720 | * |
| 586 | 721 | * @param model BabyAfterVisitStatisticsModel or BabyAfterVisitInfoModel |
| 587 | 722 | * @param type 0-追访概况、1-档案转正、2-儿保检查、3-眼保检查 |
| 588 | 723 | |
| ... | ... | @@ -599,14 +734,15 @@ |
| 599 | 734 | }); |
| 600 | 735 | String typeStr = type.toString(); |
| 601 | 736 | List<BabyModel> models = new ArrayList<>(); |
| 602 | - BabyModel babyModel = (BabyModel) model; | |
| 603 | - String babyModelId = babyModel.getId(); | |
| 604 | - babyModel = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(babyModelId)), BabyModel.class); | |
| 605 | - models.add(babyModel); | |
| 606 | - | |
| 607 | - // addOrUpdate | |
| 737 | + String babyModelId; | |
| 738 | + // 追访概况 addOrUpdate | |
| 608 | 739 | if (Objects.equals(TYPE_STATISTICS, type)) { |
| 609 | 740 | |
| 741 | + BabyModel babyModel = (BabyModel) model; | |
| 742 | + babyModelId = babyModel.getId(); | |
| 743 | + babyModel = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(babyModelId)), BabyModel.class); | |
| 744 | + models.add(babyModel); | |
| 745 | + // 正式建档/已建档 | |
| 610 | 746 | if (Objects.equals(STATUS_TYPE_BUILD, statusType)) { |
| 611 | 747 | |
| 612 | 748 | // 将追访概况中的建档状态由临时建档改为正式建档 |
| 613 | 749 | |
| 614 | 750 | |
| 615 | 751 | |
| 616 | 752 | |
| 617 | 753 | |
| ... | ... | @@ -616,20 +752,37 @@ |
| 616 | 752 | mongoTemplate.updateFirst(query, Update.update("highRiskType", STATUS_TYPE_BUILD), BabyAfterVisitStatisticsModel.class); |
| 617 | 753 | } |
| 618 | 754 | } |
| 755 | + // 预建档/临时建档 | |
| 619 | 756 | if (Objects.equals(STATUS_TYPE_TEMPORARY_DOCUMENT, statusType)) { |
| 620 | - | |
| 621 | 757 | // 新增数据 |
| 622 | 758 | Future<List<BabyAfterVisitStatisticsModel>> listFuture = service.submit(new BabyAfterVisitStatisticsModelWork(models, mongoTemplate, screenMapper)); |
| 623 | 759 | List<BabyAfterVisitStatisticsModel> statisticsModels = listFuture.get(); |
| 624 | 760 | mongoTemplate.insert(statisticsModels, BabyAfterVisitStatisticsModel.class); |
| 625 | 761 | } |
| 762 | + // 更新儿保数量 | |
| 763 | + if (Objects.equals(STATUS_TYPE_CHECK, statusType)) { | |
| 764 | + BabyAfterVisitStatisticsModel one = mongoTemplate.findOne(Query.query(Criteria.where(BABY_ID).is(babyModelId)), BabyAfterVisitStatisticsModel.class); | |
| 765 | + if (one != null) { | |
| 766 | + Integer checkSize = one.getCheckSize(); | |
| 767 | + checkSize ++; | |
| 768 | + mongoTemplate.updateFirst(Query.query(Criteria.where(BABY_ID).is(babyModelId)), Update.update("checkSize", checkSize), BabyAfterVisitStatisticsModel.class); | |
| 769 | + } | |
| 770 | + } | |
| 771 | + // 更新眼保数量 | |
| 772 | + if (Objects.equals(STATUS_TYPE_EYE_CHECK, statusType)) { | |
| 773 | + | |
| 774 | + } | |
| 626 | 775 | logger.info("已更新到追访概况中"); |
| 627 | 776 | |
| 628 | 777 | } |
| 629 | 778 | |
| 630 | - // addOrUpdate | |
| 779 | + // 档案转正、儿保检查、眼保检查 addOrUpdate | |
| 631 | 780 | if (Objects.equals(TYPE_BUILD, type) || Objects.equals(TYPE_CHECK, type) || Objects.equals(TYPE_EYE_CHECK, type)) { |
| 781 | + | |
| 632 | 782 | if (Objects.equals(STATUS_TYPE_NO, statusType)) { |
| 783 | + BabyModel babyModel = (BabyModel) model; | |
| 784 | + babyModelId = babyModel.getId(); | |
| 785 | + models.add(babyModel); | |
| 633 | 786 | |
| 634 | 787 | // 将状态正常更新为作废 |
| 635 | 788 | Query query = Query.query(Criteria.where(BABY_ID).is(babyModelId).and("type").is(typeStr)); |
| 636 | 789 | |
| 637 | 790 | |
| 638 | 791 | |
| 639 | 792 | |
| 640 | 793 | |
| 641 | 794 | |
| 642 | 795 | |
| 643 | 796 | |
| 644 | 797 | |
| 645 | 798 | |
| 646 | 799 | |
| ... | ... | @@ -639,36 +792,125 @@ |
| 639 | 792 | } |
| 640 | 793 | } |
| 641 | 794 | if (Objects.equals(STATUS_TYPE_YES, statusType)) { |
| 642 | - | |
| 795 | + BabyModel babyModel = (BabyModel) model; | |
| 796 | + models.add(babyModel); | |
| 643 | 797 | // 新增数据 |
| 644 | 798 | Future<List<BabyAfterVisitInfoModel>> listFuture = service.submit(new BabyAfterVisitInfoModelWork(models, mongoTemplate, type)); |
| 645 | 799 | List<BabyAfterVisitInfoModel> infoModels = listFuture.get(); |
| 646 | 800 | mongoTemplate.insert(infoModels, BabyAfterVisitInfoModel.class); |
| 647 | 801 | } |
| 648 | 802 | |
| 649 | - // 将预约时间更改为null | |
| 803 | + // 儿保检查/眼保检查- 将预约时间更改为null | |
| 650 | 804 | if (Objects.equals(STATUS_TYPE_UPDATE, statusType)) { |
| 805 | + // 儿保检查 | |
| 651 | 806 | if (Objects.equals(TYPE_CHECK, type)) { |
| 807 | + // 条件:当前创建为最新数据的id == 当前更新的数据id ,更新对应的字段为null | |
| 652 | 808 | BabyCheckModel babyCheckModel = (BabyCheckModel) model; |
| 653 | - mongoTemplate.updateFirst(Query.query(Criteria.where(BABY_ID).is(babyCheckModel.getBuildId()).and("type").is(typeStr)), Update.update("appointmentTime", null), BabyAfterVisitInfoModel.class); | |
| 809 | + AggregationResults<Map> maps = mongoTemplate.aggregate( | |
| 810 | + Aggregation.newAggregation(Aggregation.group("buildId").max("created").as("created").addToSet("id").as("babyCheckId")), | |
| 811 | + BabyCheckModel.class, Map.class); | |
| 812 | + List<Map> mappedResults = maps.getMappedResults(); | |
| 813 | + if (CollectionUtils.isNotEmpty(mappedResults)) { | |
| 814 | + Map map = mappedResults.get(mappedResults.size() - 1); | |
| 815 | + String babyCheckId = map.get("babyCheckId").toString(); | |
| 816 | + String babyCheckModelId = babyCheckModel.getId(); | |
| 817 | + logger.info("babyCheckId : {}, babyCheckModelId : {}", babyCheckId, babyCheckModelId); | |
| 818 | + if (Objects.equals(babyCheckId, babyCheckModelId)) { | |
| 819 | + String buildId = babyCheckModel.getBuildId(); | |
| 820 | + Query query = Query.query(Criteria.where(BABY_ID).is(buildId).and("type").is(typeStr)); | |
| 821 | + Class<BabyAfterVisitInfoModel> modelClass = BabyAfterVisitInfoModel.class; | |
| 822 | + boolean yesExists = mongoTemplate.exists(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_YES)), modelClass); | |
| 823 | + if (yesExists) { | |
| 824 | + mongoTemplate.updateFirst(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_YES)), Update.update("appointmentTime", null), modelClass); | |
| 825 | + } else { | |
| 826 | + boolean noExists = mongoTemplate.exists(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_NO)), modelClass); | |
| 827 | + if (noExists) { | |
| 828 | + // 更新 yn 预约时间 | |
| 829 | + mongoTemplate.updateFirst(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_NO)),Update.update("yn", STATUS_TYPE_YES), modelClass); | |
| 830 | + mongoTemplate.updateFirst(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_YES)), Update.update("appointmentTime", null), modelClass); | |
| 831 | + } else { | |
| 832 | + BabyAfterVisitInfoModel infoModel = new BabyAfterVisitInfoModel(); | |
| 833 | + BabyModel one = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(buildId)), BabyModel.class); | |
| 834 | + if (null != one) { | |
| 835 | + BeanUtils.copy(one, infoModel); | |
| 836 | + infoModel.setBabyId(one.getId()); | |
| 837 | + infoModel.setId(null); | |
| 838 | + infoModel.setType("2"); | |
| 839 | + infoModel.setYn(1); | |
| 840 | + infoModel.setAppointmentTime(new Date()); | |
| 841 | + infoModel.setCreateTime(new Date()); | |
| 842 | + mongoTemplate.insert(infoModel); | |
| 843 | + logger.info("新增儿保追访数据成功: {}", infoModel.toString()); | |
| 844 | + } | |
| 845 | + } | |
| 846 | + } | |
| 847 | + } | |
| 848 | + } | |
| 654 | 849 | } |
| 850 | + | |
| 851 | + // 眼保检查 | |
| 655 | 852 | if (Objects.equals(TYPE_EYE_CHECK, type)) { |
| 853 | + // 条件:当前创建为最新数据的id == 当前更新的数据id ,更新对应的字段为null | |
| 656 | 854 | BabyEyeCheck babyEyeCheck = (BabyEyeCheck) model; |
| 657 | - mongoTemplate.updateFirst(Query.query(Criteria.where(BABY_ID).is(babyEyeCheck.getBabyId()).and("type").is(typeStr)), Update.update("appointmentTime", null), BabyAfterVisitInfoModel.class); | |
| 658 | - } | |
| 855 | + AggregationResults<Map> maps = mongoTemplate.aggregate(Aggregation.newAggregation(Aggregation.group(BABY_ID).max("created").as("created").addToSet("id").as("babyEyeCheckId")), | |
| 856 | + BabyEyeCheck.class, Map.class); | |
| 857 | + List<Map> mappedResults = maps.getMappedResults(); | |
| 858 | + if (CollectionUtils.isNotEmpty(mappedResults)) { | |
| 859 | + Map map = mappedResults.get(mappedResults.size() - 1); | |
| 860 | + String babyEyeCheckId = map.get("babyEyeCheckId").toString(); | |
| 861 | + String modelId = babyEyeCheck.getId(); | |
| 862 | + logger.info("babyEyeCheckId : {}, modelId : {}", babyEyeCheckId, modelId); | |
| 863 | + if (Objects.equals(babyEyeCheckId, modelId)) { | |
| 864 | + Query query = Query.query(Criteria.where(BABY_ID).is(babyEyeCheck.getBabyId()).and("type").is(typeStr)); | |
| 865 | + boolean yesExists = mongoTemplate.exists(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_YES)), BabyAfterVisitInfoModel.class); | |
| 866 | + if (yesExists) { | |
| 867 | + // 存在则之间更新预约时间 | |
| 868 | + mongoTemplate.updateFirst(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_YES)), Update.update("appointmentTime", null), BabyAfterVisitInfoModel.class); | |
| 869 | + } | |
| 659 | 870 | |
| 871 | + if (!yesExists){ | |
| 872 | + // 不存在,检查yn为no的是否存在 | |
| 873 | + boolean noExists = mongoTemplate.exists(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_NO)), BabyAfterVisitInfoModel.class); | |
| 874 | + if (noExists) { | |
| 875 | + // 更新 yn 预约时间 | |
| 876 | + mongoTemplate.updateFirst(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_NO)), Update.update("yn", STATUS_TYPE_YES), BabyAfterVisitInfoModel.class); | |
| 877 | + mongoTemplate.updateFirst(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_YES)), Update.update("appointmentTime", null), BabyAfterVisitInfoModel.class); | |
| 878 | + } | |
| 879 | + if (!noExists){ | |
| 880 | + String babyId = babyEyeCheck.getBabyId(); | |
| 881 | + BabyModel one = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(babyId)), BabyModel.class); | |
| 882 | + if (null == one) { | |
| 883 | + logger.error("建档数据不存在 babyId: {}", babyId); | |
| 884 | + throw new BusinessException(ErrorCodeConstants.BUSINESS_ERROR + "", "建档数据不存在"); | |
| 885 | + } | |
| 886 | + BabyAfterVisitInfoModel infoModel = new BabyAfterVisitInfoModel(); | |
| 887 | + BeanUtils.copy(one, infoModel); | |
| 888 | + infoModel.setBabyId(one.getId()); | |
| 889 | + infoModel.setType("3"); | |
| 890 | + infoModel.setYn(1); | |
| 891 | + infoModel.setAppointmentTime(new Date()); | |
| 892 | + infoModel.setCreateTime(new Date()); | |
| 893 | + infoModel.setId(null); | |
| 894 | + mongoTemplate.insert(infoModel); | |
| 895 | + logger.info("新增眼保追访数据成功: {}", infoModel.toString()); | |
| 896 | + } | |
| 897 | + } | |
| 898 | + } | |
| 899 | + } | |
| 900 | + } | |
| 660 | 901 | } |
| 661 | 902 | logger.info("已自动添加到追访列表中"); |
| 662 | 903 | } |
| 904 | + | |
| 663 | 905 | } catch (Exception e) { |
| 664 | 906 | e.printStackTrace(); |
| 665 | - logger.error("追访失败",e); | |
| 907 | + logger.error("追访失败",e.getStackTrace()); | |
| 666 | 908 | } |
| 667 | 909 | } |
| 668 | 910 | /** |
| 669 | 911 | * 档案转正/儿保检查/眼保检查/听力筛查 - 新增追访记录 |
| 670 | 912 | * |
| 671 | - * @param request | |
| 913 | + * @param request 参数 | |
| 672 | 914 | * @return |
| 673 | 915 | */ |
| 674 | 916 | @Override |
| ... | ... | @@ -708,6 +950,22 @@ |
| 708 | 950 | Update update = MongoConvertHelper |
| 709 | 951 | .convertToNativeUpdate(ReflectionUtils.getUpdateField(visitInfoModel)); |
| 710 | 952 | mongoTemplate.updateFirst(Query.query(Criteria.where("_id").is(visitInfoModel.getId())), update, BabyAfterVisitInfoModel.class); |
| 953 | + if (afterVisitWorkflow.equals(TrackDownTransferEnums.B.getId())) { | |
| 954 | + // 停止当前流程 | |
| 955 | + mongoTemplate.updateFirst(Query.query(Criteria.where(BABY_ID).is(babyId).and("type").is(type)), Update.update("yn", 2), BabyAfterVisitInfoModel.class); | |
| 956 | + } | |
| 957 | + | |
| 958 | + if (afterVisitWorkflow.equals(TrackDownTransferEnums.C.getId())) { | |
| 959 | + // 终止所有流程 | |
| 960 | + int parseInt = Integer.parseInt(type); | |
| 961 | + if (parseInt == TYPE_CHECK) { | |
| 962 | + mongoTemplate.updateFirst(Query.query(Criteria.where(BABY_ID).is(babyId).and("type").is("3")), Update.update("yn", 2), BabyAfterVisitInfoModel.class); | |
| 963 | + } | |
| 964 | + if (parseInt == TYPE_EYE_CHECK) { | |
| 965 | + mongoTemplate.updateFirst(Query.query(Criteria.where(BABY_ID).is(babyId).and("type").is("2")), Update.update("yn", 2), BabyAfterVisitInfoModel.class); | |
| 966 | + } | |
| 967 | + } | |
| 968 | + | |
| 711 | 969 | return new BaseResponse(); |
| 712 | 970 | } |
| 713 | 971 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/BabyAfterVisitInfoModelWork.java
View file @
42cb87a
| ... | ... | @@ -75,13 +75,6 @@ |
| 75 | 75 | babyAfterVisitInfoModel.setCheckTime(babyEyeCheck.getCheckTime()); |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | - /* List<AggregationOperation> operations = new ArrayList<>(); | |
| 79 | - operations.add(Aggregation.group(BABY_ID).max("created").as("created")); | |
| 80 | - operations.add(Aggregation.match(Criteria.where(BABY_ID).is(babyId).and("type").is(typeStr))); | |
| 81 | - Aggregation aggregation = Aggregation.newAggregation(operations); | |
| 82 | - AggregationResults<BabyEyeCheck> aggregate = mongoTemplate.aggregate(aggregation, BabyEyeCheck.class, BabyEyeCheck.class); | |
| 83 | - List<BabyEyeCheck> mappedResults = aggregate.getMappedResults();*/ | |
| 84 | - | |
| 85 | 78 | } |
| 86 | 79 | babyAfterVisitInfoModel.setType(typeStr); |
| 87 | 80 | babyAfterVisitInfoModel.setId(null); |