Commit e3e172e3666e37943ac67a0e55f973889c11c65c

Authored by dongqin
1 parent 7fe5283cab

修复bug

Showing 1 changed file with 14 additions and 5 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BabyEvaluationCriterionServiceImpl.java View file @ e3e172e
... ... @@ -716,7 +716,7 @@
716 716 return new BaseResponse().setErrorcode(ErrorCodeConstants.NO_DATA).setErrormsg("未查到该儿童的建档数据");
717 717 }
718 718 Integer month = DateUtil.getBabyAgeMonth(babyModel.getBirth(), new Date());
719   - Integer currentMonth = getCurrentMonth(month, 3, 1);
  719 + //Integer currentMonth = getCurrentMonth(month, 3, 1);
720 720 model.setBirth(babyModel.getBirth());
721 721 model.setCardNo(babyModel.getCardNo());
722 722 model.setVcCardNo(babyModel.getVcCardNo());
... ... @@ -731,7 +731,7 @@
731 731 // 总分
732 732 model.setTotalScore(model.getStandingComponent() + model.getSeatComponent() + model.getSupineComponent() + model.getLieProstratComponent());
733 733 // 百分位
734   - BabyEvaluationCriterionModel babyEvaluationCriterionModel = getBabyEvaluationCriterionModel(model, currentMonth);
  734 + BabyEvaluationCriterionModel babyEvaluationCriterionModel = getBabyEvaluationCriterionModel(model, month);
735 735 model.setPercentileScore(babyEvaluationCriterionModel.getPercent());
736 736 mongoTemplate.insert(model);
737 737 }
... ... @@ -739,7 +739,7 @@
739 739 if (StringUtils.isNotEmpty(id)) {
740 740 Integer month = DateUtil.getBabyAgeMonth(model.getBirth(),
741 741 mongoTemplate.findOne(Query.query(Criteria.where("_id").is(id)), ExerciseAppraisalModel.class).getCreateTime());
742   - Integer currentMonth = getCurrentMonth(month, 3, 1);
  742 + //Integer currentMonth = getCurrentMonth(month, 3, 1);
743 743 model.setCreateUser(null);
744 744 model.setCreateTime(null);
745 745 model.setBirth(null);
... ... @@ -756,7 +756,7 @@
756 756 // 总分
757 757 model.setTotalScore(model.getStandingComponent() + model.getSeatComponent() + model.getSupineComponent() + model.getLieProstratComponent());
758 758 // 百分位
759   - BabyEvaluationCriterionModel babyEvaluationCriterionModel = getBabyEvaluationCriterionModel(model, currentMonth);
  759 + BabyEvaluationCriterionModel babyEvaluationCriterionModel = getBabyEvaluationCriterionModel(model, month);
760 760 model.setPercentileScore(babyEvaluationCriterionModel.getPercent());
761 761 Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(model));
762 762 mongoTemplate.updateFirst(Query.query(Criteria.where("_id").is(id)), update, ExerciseAppraisalModel.class);
763 763  
764 764  
... ... @@ -764,14 +764,23 @@
764 764 return new BaseResponse();
765 765 }
766 766  
  767 + /**
  768 + * 根据总分数和月龄匹配最符合的数据
  769 + *
  770 + * @param model
  771 + * @param month
  772 + * @return
  773 + */
767 774 private BabyEvaluationCriterionModel getBabyEvaluationCriterionModel(ExerciseAppraisalModel model, Integer month) {
768 775  
769 776 Integer totalScore = model.getTotalScore();
770 777  
  778 + // 获取边界最大和最小分数
771 779 List<BabyEvaluationCriterionModel> modelList = mongoTemplate.find(Query.query(Criteria.where("month").is(month).and("type").is(1)), BabyEvaluationCriterionModel.class);
772 780 BabyEvaluationCriterionModel evaluationCriterionModel = modelList.get(0);
773 781 Integer maxScore = evaluationCriterionModel.getMaxScore();
774 782 Integer minScore = evaluationCriterionModel.getMinScore();
  783 +
775 784 Integer scoreIndex = maxScore < totalScore ? maxScore : minScore > totalScore ? minScore : totalScore;
776 785 List<BabyEvaluationCriterionModel> criterionModel = mongoTemplate.find(Query.query(Criteria.where("score").gte(scoreIndex).and("month").is(month).and("type").is(1)).
777 786 with(new Sort(new Sort.Order(Sort.Direction.ASC, "minScore")) ), BabyEvaluationCriterionModel.class);
... ... @@ -841,7 +850,7 @@
841 850 // 总分
842 851 Integer startScore = param.getStartScore();
843 852 Integer endScore = param.getEndScore();
844   - if (startScore != null && endCheckTime != null && endScore >= startScore) {
  853 + if (startScore != null && endScore != null && endScore >= startScore) {
845 854 query.addCriteria(Criteria.where("totalScore").gte(startScore).lte(endScore));
846 855 }
847 856