Commit 8f44bf38d574f4e7591e7f88904d03650a7bab20

Authored by dongqin
1 parent 733dc9b0dc

实时追访记录

Showing 1 changed file with 6 additions and 108 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BabyAfterVisitServiceImpl.java View file @ 8f44bf3
... ... @@ -293,11 +293,6 @@
293 293 @Override
294 294 public BaseResponse getBuildListPage(BabyAfterVisitBuildListRequest request, Integer userId) {
295 295 String type = request.getType();
296   - //boolean isOk = checkOverdueDataByType(type);
297   - //if (!isOk) {
298   - // return new BaseResponse("检查逾期数据异常", ErrorCodeConstants.SYSTEM_ERROR);
299   - //}
300   -
301 296 Query query = new Query();
302 297 String hospitalId = autoMatchFacade.getHospitalId(userId);
303 298 query.addCriteria(Criteria.where("hospitalId").is(hospitalId));
... ... @@ -450,7 +445,7 @@
450 445 Date appointmentTime = model.getAppointmentTime();
451 446 if (appointmentTime != null) {
452 447 objectMap.put("appointmentTimeStr", DateUtil.getyyyy_MM_dd(appointmentTime));
453   - objectMap.put("overdueDay", DateUtil.daysBetween(new Date(), appointmentTime));
  448 + objectMap.put("overdueDay", DateUtil.daysBetween(appointmentTime, new Date()));
454 449 }
455 450  
456 451 // 追访时间
... ... @@ -732,7 +727,9 @@
732 727 if (one != null) {
733 728 Integer yn = one.getYn();
734 729 if (YnEnums.YES.getId() == yn) {
735   - mongoTemplate.updateFirst(query, Update.update("appointmentTime", babyModel.getNextDate()), BabyAfterVisitInfoModel.class);
  730 + Date nextDate = babyModel.getNextDate();
  731 + nextDate = nextDate == null ? new Date() : nextDate;
  732 + mongoTemplate.updateFirst(query, Update.update("appointmentTime", nextDate), BabyAfterVisitInfoModel.class);
736 733 }
737 734 }
738 735 }
... ... @@ -744,105 +741,6 @@
744 741 mongoTemplate.insert(infoModels, BabyAfterVisitInfoModel.class);
745 742 }
746 743  
747   - // 儿保检查/眼保检查- 将预约时间更改为null
748   - /* if (Objects.equals(STATUS_TYPE_UPDATE, statusType)) {
749   - // 儿保检查
750   - if (Objects.equals(TYPE_CHECK, type)) {
751   - // 条件:当前创建为最新数据的id == 当前更新的数据id ,更新对应的字段为null
752   - BabyCheckModel babyCheckModel = (BabyCheckModel) model;
753   - AggregationResults<Map> maps = mongoTemplate.aggregate(
754   - Aggregation.newAggregation(Aggregation.group("buildId").max("created").as("created").addToSet("id").as("babyCheckId")),
755   - BabyCheckModel.class, Map.class);
756   - List<Map> mappedResults = maps.getMappedResults();
757   - if (CollectionUtils.isNotEmpty(mappedResults)) {
758   - Map map = mappedResults.get(mappedResults.size() - 1);
759   - String babyCheckId = map.get("babyCheckId").toString();
760   - String babyCheckModelId = babyCheckModel.getId();
761   - logger.info("babyCheckId : {}, babyCheckModelId : {}", babyCheckId, babyCheckModelId);
762   - if (Objects.equals(babyCheckId, babyCheckModelId)) {
763   - String buildId = babyCheckModel.getBuildId();
764   - Query query = Query.query(Criteria.where(BABY_ID).is(buildId).and("type").is(typeStr));
765   - Class<BabyAfterVisitInfoModel> modelClass = BabyAfterVisitInfoModel.class;
766   - boolean yesExists = mongoTemplate.exists(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_YES)), modelClass);
767   - if (yesExists) {
768   - mongoTemplate.updateFirst(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_YES)), Update.update("appointmentTime", null), modelClass);
769   - } else {
770   - boolean noExists = mongoTemplate.exists(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_NO)), modelClass);
771   - if (noExists) {
772   - // 更新 yn 预约时间
773   - mongoTemplate.updateFirst(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_NO)),Update.update("yn", STATUS_TYPE_YES), modelClass);
774   - mongoTemplate.updateFirst(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_YES)), Update.update("appointmentTime", null), modelClass);
775   - } else {
776   - BabyAfterVisitInfoModel infoModel = new BabyAfterVisitInfoModel();
777   - BabyModel one = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(buildId)), BabyModel.class);
778   - if (null != one) {
779   - BeanUtils.copy(one, infoModel);
780   - infoModel.setBabyId(one.getId());
781   - infoModel.setId(null);
782   - infoModel.setType("2");
783   - infoModel.setYn(1);
784   - infoModel.setAppointmentTime(new Date());
785   - infoModel.setCreateTime(new Date());
786   - mongoTemplate.insert(infoModel);
787   - logger.info("新增儿保追访数据成功: {}", infoModel.toString());
788   - }
789   - }
790   - }
791   - }
792   - }
793   - }
794   -
795   - // 眼保检查
796   - if (Objects.equals(TYPE_EYE_CHECK, type)) {
797   - // 条件:当前创建为最新数据的id == 当前更新的数据id ,更新对应的字段为null
798   - BabyEyeCheck babyEyeCheck = (BabyEyeCheck) model;
799   - AggregationResults<Map> maps = mongoTemplate.aggregate(Aggregation.newAggregation(Aggregation.group(BABY_ID).max("created").as("created").addToSet("id").as("babyEyeCheckId")),
800   - BabyEyeCheck.class, Map.class);
801   - List<Map> mappedResults = maps.getMappedResults();
802   - if (CollectionUtils.isNotEmpty(mappedResults)) {
803   - Map map = mappedResults.get(mappedResults.size() - 1);
804   - String babyEyeCheckId = map.get("babyEyeCheckId").toString();
805   - String modelId = babyEyeCheck.getId();
806   - logger.info("babyEyeCheckId : {}, modelId : {}", babyEyeCheckId, modelId);
807   - if (Objects.equals(babyEyeCheckId, modelId)) {
808   - Query query = Query.query(Criteria.where(BABY_ID).is(babyEyeCheck.getBabyId()).and("type").is(typeStr));
809   - boolean yesExists = mongoTemplate.exists(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_YES)), BabyAfterVisitInfoModel.class);
810   - if (yesExists) {
811   - // 存在则之间更新预约时间
812   - mongoTemplate.updateFirst(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_YES)), Update.update("appointmentTime", null), BabyAfterVisitInfoModel.class);
813   - }
814   -
815   - if (!yesExists){
816   - // 不存在,检查yn为no的是否存在
817   - boolean noExists = mongoTemplate.exists(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_NO)), BabyAfterVisitInfoModel.class);
818   - if (noExists) {
819   - // 更新 yn 预约时间
820   - mongoTemplate.updateFirst(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_NO)), Update.update("yn", STATUS_TYPE_YES), BabyAfterVisitInfoModel.class);
821   - mongoTemplate.updateFirst(query.addCriteria(Criteria.where("yn").is(STATUS_TYPE_YES)), Update.update("appointmentTime", null), BabyAfterVisitInfoModel.class);
822   - }
823   - if (!noExists){
824   - String babyId = babyEyeCheck.getBabyId();
825   - BabyModel one = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(babyId)), BabyModel.class);
826   - if (null == one) {
827   - logger.error("建档数据不存在 babyId: {}", babyId);
828   - throw new BusinessException(ErrorCodeConstants.BUSINESS_ERROR + "", "建档数据不存在");
829   - }
830   - BabyAfterVisitInfoModel infoModel = new BabyAfterVisitInfoModel();
831   - BeanUtils.copy(one, infoModel);
832   - infoModel.setBabyId(one.getId());
833   - infoModel.setType("3");
834   - infoModel.setYn(1);
835   - infoModel.setAppointmentTime(new Date());
836   - infoModel.setCreateTime(new Date());
837   - infoModel.setId(null);
838   - mongoTemplate.insert(infoModel);
839   - logger.info("新增眼保追访数据成功: {}", infoModel.toString());
840   - }
841   - }
842   - }
843   - }
844   - }
845   - }*/
846 744 logger.info("已自动添加到追访列表中");
847 745 }
848 746  
849 747  
... ... @@ -904,9 +802,9 @@
904 802 }
905 803 BabyAfterVisitInfoDetailModel model = request;
906 804 model.setCreateTime(new Date());
907   - model.setAfterVisitTime(new Date(afterVisitTime.getTime() - 28800000));
  805 + model.setAfterVisitTime(new Date(afterVisitTime.getTime()));
908 806 if (Objects.nonNull(appointmentTime)) {
909   - model.setAppointmentTime(new Date(appointmentTime.getTime() - 28800000));
  807 + model.setAppointmentTime(new Date(appointmentTime.getTime()));
910 808 }
911 809 model.setYn(1);
912 810 mongoTemplate.insert(model);