Commit 89dde92e84d98aa6dce9908ad6fdd1b69e2dccbc

Authored by [wangbo]
1 parent a47d4ef484

临时修改 董勤回来逻辑上在处理

Showing 1 changed file with 44 additions and 42 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BabyAfterVisitServiceImpl.java View file @ 89dde92
... ... @@ -43,7 +43,6 @@
43 43 import java.util.regex.Pattern;
44 44  
45 45 /**
46   - *
47 46 * @Author dongqin
48 47 * @Description 儿童访视管理业务实现类
49 48 * @Date 10:17 2019/6/25
... ... @@ -167,7 +166,7 @@
167 166  
168 167 // 档案转正
169 168 List<BabyAfterVisitInfoModel> infoModels = new ArrayList<>();
170   - setSyncAfterVisitInfoList( null, infoModels, afterVisitQuery, TYPE_BUILD, startDate, endDate, hospitalId);
  169 + setSyncAfterVisitInfoList(null, infoModels, afterVisitQuery, TYPE_BUILD, startDate, endDate, hospitalId);
171 170 mongoTemplate.insert(infoModels, BabyAfterVisitInfoModel.class);
172 171 map.put("infoModels-build", infoModels.size());
173 172  
174 173  
... ... @@ -188,13 +187,13 @@
188 187 // 儿保 (sysdate < 下次预约时间) or ( 已做儿保检查 and 下次预约时间 == null)
189 188 MatchOperation match = Aggregation.match(Criteria.where("created").gte(startDate).lt(endDate));
190 189 AggregationOperation group = Aggregation.group("buildId").max("created").as("created").addToSet("id").as("babyCheckIds");
191   - Aggregation aggregation = Aggregation.newAggregation(match ,group);
  190 + Aggregation aggregation = Aggregation.newAggregation(match, group);
192 191 AggregationResults<Map> aggregate = mongoTemplate.aggregate(aggregation, BabyCheckModel.class, Map.class);
193 192 List<Map> mappedResults = aggregate.getMappedResults();
194 193 for (Map mappedResult : mappedResults) {
195 194 List babyCheckIds = (List) mappedResult.get("babyCheckIds");
196 195 // 根据建档id分组,获取最新的儿保检查数据
197   - Object babyCheckId = babyCheckIds.get(babyCheckIds.size() - 1);
  196 + Object babyCheckId = babyCheckIds.get(babyCheckIds.size() - 1);
198 197 BabyCheckModel babyCheckModel = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(babyCheckId).orOperator(Criteria.where("nextDate").gte(new Date()),
199 198 Criteria.where("nextDate").exists(false))), BabyCheckModel.class);
200 199 if (null != babyCheckModel) {
... ... @@ -205,7 +204,7 @@
205 204 }
206 205 }
207 206 }
208   - setSyncAfterVisitInfoList( ids, infoCheckModels, afterVisitQuery, TYPE_CHECK, startDate, endDate, hospitalId);
  207 + setSyncAfterVisitInfoList(ids, infoCheckModels, afterVisitQuery, TYPE_CHECK, startDate, endDate, hospitalId);
209 208 mongoTemplate.insert(infoCheckModels, BabyAfterVisitInfoModel.class);
210 209 map.put("infoModels-check-size", infoCheckModels.size());
211 210  
... ... @@ -292,7 +291,6 @@
292 291 }
293 292  
294 293  
295   -
296 294 /**
297 295 * 档案转正列表/儿保检查/眼保检查/听力筛查
298 296 *
... ... @@ -368,8 +366,8 @@
368 366 String startCheckTime = request.getStartCheckTime();
369 367 String endCheckTime = request.getEndCheckTime();
370 368 if (StringUtils.isNotEmpty(startCheckTime) && StringUtils.isNotEmpty(endCheckTime)) {
371   - startCheckTime += " 00:00:00";
372   - endCheckTime += " 23:59:59";
  369 + startCheckTime += " 00:00:00";
  370 + endCheckTime += " 23:59:59";
373 371 Date startDate = DateUtil.parseYMDHMS(startCheckTime);
374 372 Date endDate = DateUtil.parseYMDHMS(endCheckTime);
375 373 query.addCriteria(Criteria.where("checkTime").gte(startDate).lte(endDate));
... ... @@ -390,7 +388,7 @@
390 388 // 阳性项目
391 389 String positiveProject = request.getPositiveProject();
392 390 if (StringUtils.isNotEmpty(positiveProject)) {
393   - Pattern pattern = Pattern.compile("^.*"+positiveProject+".*$", Pattern.CASE_INSENSITIVE);
  391 + Pattern pattern = Pattern.compile("^.*" + positiveProject + ".*$", Pattern.CASE_INSENSITIVE);
394 392 query.addCriteria(Criteria.where("positiveProject").regex(pattern));
395 393 }
396 394  
397 395  
398 396  
399 397  
400 398  
... ... @@ -458,23 +456,26 @@
458 456 query.addCriteria(Criteria.where("appointmentTime").gte(start).lte(end));
459 457 }
460 458 }
461   - if (!appointmentTimeBoolean && !nonNull) {
462   - query.addCriteria(Criteria.where("appointmentTime").lt(new Date()));
463   - }
464   -
  459 + //临时处理等待董勤回来处理
  460 + boolean flag = true;
465 461 // 追访结果 1-显示 当前时间 > 预约时间
466 462 // 2-显示 当前时间 < 预约时间
467 463 String afterVisitResult = request.getAfterVisitResult();
468 464 if (Objects.equals("1", afterVisitResult)) {
469 465 if (!appointmentTimeBoolean && !nonNull) {
470 466 query.addCriteria(Criteria.where("appointmentTime").lte(new Date()));
  467 + flag = false;
471 468 }
472   - } else if (Objects.equals("2", afterVisitResult)){
  469 + } else if (Objects.equals("2", afterVisitResult)) {
473 470 if (!appointmentTimeBoolean && !nonNull) {
474 471 query.addCriteria(Criteria.where("appointmentTime").gt(new Date()));
  472 + flag = false;
475 473 }
476 474 }
477 475  
  476 + if (!appointmentTimeBoolean && !nonNull && flag) {
  477 + query.addCriteria(Criteria.where("appointmentTime").lt(new Date()));
  478 + }
478 479  
479 480 // 组装分页query
480 481 long count = mongoTemplate.count(query, BabyAfterVisitInfoModel.class);
... ... @@ -489,7 +490,7 @@
489 490 objectMap.put("birthStr", DateUtil.getyyyy_MM_dd(model.getBirth()));
490 491 objectMap.put("monthsAge", DateUtil.getBabyMonthAge(model.getBirth(), new Date()));
491 492 // 脱敏处理
492   - objectMap.put("mphone","1".equals(request.getIsEncrypt()) ? EncryptUtil.numberEncrypt(model.getMphone()) : model.getMphone());
  493 + objectMap.put("mphone", "1".equals(request.getIsEncrypt()) ? EncryptUtil.numberEncrypt(model.getMphone()) : model.getMphone());
493 494  
494 495 // 预约时间
495 496 Date appointmentTime = model.getAppointmentTime();
... ... @@ -543,7 +544,7 @@
543 544 return baseListResponse;
544 545 }
545 546  
546   - private Date getEndDate(Integer beyondDay){
  547 + private Date getEndDate(Integer beyondDay) {
547 548 Calendar instance = Calendar.getInstance();
548 549 instance.setTime(new Date());
549 550 instance.add(Calendar.DATE, -beyondDay);
550 551  
551 552  
... ... @@ -596,16 +597,16 @@
596 597 /**
597 598 * 递归获取预约建档的儿童信息
598 599 *
599   - * @param ids 建档ids - 针对儿保检查
600   - * @param infoModels 接受的集合
  600 + * @param ids 建档ids - 针对儿保检查
  601 + * @param infoModels 接受的集合
601 602 * @param afterVisitQuery query对象
602   - * @param type 类型
603   - * @param startDate 开始时间
604   - * @param endDate 结束时间
  603 + * @param type 类型
  604 + * @param startDate 开始时间
  605 + * @param endDate 结束时间
605 606 * @throws ExecutionException
606 607 * @throws InterruptedException
607 608 */
608   - private void setSyncAfterVisitInfoList(List<String> ids , List<BabyAfterVisitInfoModel> infoModels, BabyAfterVisitRequest afterVisitQuery, Integer type, Date startDate, Date endDate, String hospitalId)
  609 + private void setSyncAfterVisitInfoList(List<String> ids, List<BabyAfterVisitInfoModel> infoModels, BabyAfterVisitRequest afterVisitQuery, Integer type, Date startDate, Date endDate, String hospitalId)
609 610 throws ExecutionException, InterruptedException {
610 611 Query query = new Query();
611 612 query.addCriteria(Criteria.where("created").gte(startDate).lte(endDate));
612 613  
613 614  
614 615  
... ... @@ -670,16 +671,16 @@
670 671 if (Objects.equals(lastPage, currentPage)) {
671 672 return;
672 673 }
673   - for (int i = currentPage+ 1; i <= lastPage ; i++) {
  674 + for (int i = currentPage + 1; i <= lastPage; i++) {
674 675 afterVisitQuery.setPage(i);
675 676 if (TYPE_BUILD.equals(type)) {
676   - setSyncAfterVisitInfoList( null, infoModels, afterVisitQuery, type, startDate, endDate, hospitalId);
  677 + setSyncAfterVisitInfoList(null, infoModels, afterVisitQuery, type, startDate, endDate, hospitalId);
677 678 }
678 679 if (TYPE_CHECK.equals(type)) {
679   - setSyncAfterVisitInfoList( ids, infoModels, afterVisitQuery, type, startDate, endDate, hospitalId);
  680 + setSyncAfterVisitInfoList(ids, infoModels, afterVisitQuery, type, startDate, endDate, hospitalId);
680 681 }
681 682 if (TYPE_EYE_CHECK.equals(type)) {
682   - setSyncAfterVisitInfoList( ids, infoModels, afterVisitQuery, type, startDate, endDate, hospitalId);
  683 + setSyncAfterVisitInfoList(ids, infoModels, afterVisitQuery, type, startDate, endDate, hospitalId);
683 684 }
684 685  
685 686 }
... ... @@ -737,7 +738,7 @@
737 738 if (Objects.equals(lastPage, currentPage)) {
738 739 return;
739 740 }
740   - for (int i = currentPage+ 1; i <= lastPage ; i++) {
  741 + for (int i = currentPage + 1; i <= lastPage; i++) {
741 742 afterVisitQuery.setPage(i);
742 743 setSyncList(statisticsModels, afterVisitQuery, startDate, endDate, hospitalId);
743 744 }
744 745  
745 746  
... ... @@ -750,21 +751,21 @@
750 751 * 儿保检查保存(BabyCheckFacade)、
751 752 * 眼保检查(BabyEyeCheckServiceImpl)
752 753 *
753   - * @param model BabyAfterVisitStatisticsModel or BabyAfterVisitInfoModel
754   - * @param type 0-追访概况、1-档案转正、2-儿保检查、3-眼保检查
  754 + * @param model BabyAfterVisitStatisticsModel or BabyAfterVisitInfoModel
  755 + * @param type 0-追访概况、1-档案转正、2-儿保检查、3-眼保检查
755 756 * @param statusType 1- 状态:正常 2-状态:作废 4-状态:预建档/临时建档 1-状态:正式建档/已建档
756 757 */
757 758 @Override
758   - public void addOrUpdateAfterVisitData(BaseModel model, Integer type, Integer statusType){
  759 + public void addOrUpdateAfterVisitData(BaseModel model, Integer type, Integer statusType) {
759 760 try {
760 761 ExecutorService service = new ThreadPoolExecutor(1, 1, 0, TimeUnit.MILLISECONDS,
761   - new ArrayBlockingQueue<Runnable>(1),
762   - new RejectedExecutionHandler() {
763   - @Override
764   - public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
765   - System.out.println("请稍后尝试");
766   - }
767   - });
  762 + new ArrayBlockingQueue<Runnable>(1),
  763 + new RejectedExecutionHandler() {
  764 + @Override
  765 + public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
  766 + System.out.println("请稍后尝试");
  767 + }
  768 + });
768 769 String typeStr = type.toString();
769 770 List<BabyModel> models = new ArrayList<>();
770 771 String babyModelId;
... ... @@ -802,7 +803,7 @@
802 803 BabyAfterVisitStatisticsModel one = mongoTemplate.findOne(Query.query(Criteria.where(BABY_ID).is(babyModelId).and("yn").is(1)), BabyAfterVisitStatisticsModel.class);
803 804 if (one != null) {
804 805 Integer checkSize = one.getCheckSize();
805   - checkSize ++;
  806 + checkSize++;
806 807 mongoTemplate.updateFirst(Query.query(Criteria.where(BABY_ID).is(babyModelId).and("yn").is(1)), Update.update("checkSize", checkSize), BabyAfterVisitStatisticsModel.class);
807 808 }
808 809 }
... ... @@ -811,7 +812,7 @@
811 812 BabyAfterVisitStatisticsModel one = mongoTemplate.findOne(Query.query(Criteria.where(BABY_ID).is(babyModelId).and("yn").is(1)), BabyAfterVisitStatisticsModel.class);
812 813 if (one != null) {
813 814 Integer eyeCheckSize = one.getEyeCheckSize();
814   - eyeCheckSize ++;
  815 + eyeCheckSize++;
815 816 mongoTemplate.updateFirst(Query.query(Criteria.where(BABY_ID).is(babyModelId).and("yn").is(1)), Update.update("eyeCheckSize", eyeCheckSize), BabyAfterVisitStatisticsModel.class);
816 817 }
817 818 }
... ... @@ -820,7 +821,7 @@
820 821 }
821 822  
822 823 // 档案转正、儿保检查 addOrUpdate
823   - if (Objects.equals(TYPE_BUILD, type) || Objects.equals(TYPE_CHECK, type) ) {
  824 + if (Objects.equals(TYPE_BUILD, type) || Objects.equals(TYPE_CHECK, type)) {
824 825  
825 826 if (Objects.equals(STATUS_TYPE_NO, statusType)) {
826 827 BabyModel babyModel = (BabyModel) model;
... ... @@ -879,7 +880,7 @@
879 880 }
880 881 List<String> projectStrs = InitDataUtils.getPositiveProjectByKey(babyEyeCheck);
881 882 if (CollectionUtils.isNotEmpty(projectStrs)) {
882   - String join = org.apache.commons.lang.StringUtils.join(projectStrs,",");
  883 + String join = org.apache.commons.lang.StringUtils.join(projectStrs, ",");
883 884 update.set("positiveProject", join);
884 885 }
885 886  
886 887  
... ... @@ -898,9 +899,10 @@
898 899 }
899 900 } catch (Exception e) {
900 901 e.printStackTrace();
901   - logger.error("追访失败",e.getStackTrace());
  902 + logger.error("追访失败", e.getStackTrace());
902 903 }
903 904 }
  905 +
904 906 /**
905 907 * 档案转正/儿保检查/眼保检查/听力筛查 - 新增追访记录
906 908 *