diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BabyEvaluationCriterionServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BabyEvaluationCriterionServiceImpl.java index c9128eb..bb87d70 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BabyEvaluationCriterionServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BabyEvaluationCriterionServiceImpl.java @@ -23,6 +23,7 @@ import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Update; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.*; /** @@ -47,7 +48,7 @@ public class BabyEvaluationCriterionServiceImpl implements BabyEvaluationCriteri /** - * 获取儿童神经心理发育检查项 最近五个月的检查项 + * 获取儿童神经心理发育检查项 最近三/四/五个月的检查项 * * @param babyId * @return @@ -66,43 +67,45 @@ public class BabyEvaluationCriterionServiceImpl implements BabyEvaluationCriteri } int month3 = getCurrentMonth(month, 3); if (month3 >= 3 && month3 <= 72) { + + // 大于等于3月龄 小于等于72月龄 int month2 = getCurrentMonth(month3, 2); int month1 = getCurrentMonth(month2, 2); int month4 = getCurrentMonth(month3, 4); int month5 = getCurrentMonth(month4, 4); months = new int[]{month1, month2, month3, month4, month5}; - //mapList = getListMap(months, babyId, checkMonth); - } - if (month3 < 3) { + }else if (month3 < 3) { if (month3 == 1) { + + // 等于1月龄 int month4 = getCurrentMonth(month3, 4); int month5 = getCurrentMonth(month4, 4); months = new int[] {month3, month4, month5}; - //mapList = getListMap(months); - } - if (month3 == 2) { + + }else if (month3 == 2) { + + // 等于2月龄 int month2 = getCurrentMonth(month3, 2); int month4 = getCurrentMonth(month3, 4); int month5 = getCurrentMonth(month4, 4); months = new int[] {month2, month3, month4, month5}; - //mapList = getListMap(months); } - } - - if (month3 > 72 && month3 <= 84) { + } else if (month3 > 72 && month3 <= 84) { if (month3 == 78) { + + // 等于78月龄 int month2 = getCurrentMonth(month3, 2); int month1 = getCurrentMonth(month2, 2); int month4 = getCurrentMonth(month3, 4); months = new int[]{month1, month2, month3, month4}; - //mapList = getListMap(months); - } - if (month3 == 84) { + + }else if (month3 == 84) { + + // 等于84月龄 int month2 = getCurrentMonth(month3, 2); int month1 = getCurrentMonth(month2, 2); months = new int[]{month1, month2, month3}; - //mapList = getListMap(months); } } stringObjectMap = getListMap(months, babyId, checkMonth); @@ -153,9 +156,12 @@ public class BabyEvaluationCriterionServiceImpl implements BabyEvaluationCriteri private Map getListMap(int [] months, String babyId, Integer checkMonth) { Map resultMap = new HashMap<>(16); String neuroPsychologicalId = null; - Double totalProjectVal = 0D; + // 智龄 + Integer mentalAge = 0; List> mapList = new LinkedList<>(); - for (int i = 0; i < months.length ; i++) { + for (int i = 0, size = months.length; i < size ; i++) { + // 当前本月的被勾选的总分数 + Double currentProjectVal = 0D; int currentMonth = months[i]; // 月龄对应的数据 Map objectMap = new HashMap<>(); @@ -181,7 +187,7 @@ public class BabyEvaluationCriterionServiceImpl implements BabyEvaluationCriteri and("babyId").is(babyId).and("yn").is(YnEnums.YES.getId()).and("checkMonth").is(checkMonth)), BabyNeuroPsychologicalModel.class); if (one != null) { isSelected = true; - totalProjectVal += projectVal; + currentProjectVal += projectVal; if (neuroPsychologicalId == null) { neuroPsychologicalId = one.getId(); } @@ -197,8 +203,39 @@ public class BabyEvaluationCriterionServiceImpl implements BabyEvaluationCriteri map.put("projectType", entry.getKey()); map.put("detailList", list); } + + int developmentQuotient = 0; + if (currentProjectVal > 0) { + mentalAge = new BigDecimal(currentProjectVal).divide(new BigDecimal(5), 0, BigDecimal.ROUND_HALF_UP).intValue(); + developmentQuotient = new BigDecimal(mentalAge).divide(new BigDecimal(checkMonth), 0, BigDecimal.ROUND_HALF_UP).intValue(); + developmentQuotient *= 100; + } + // 当前测试时月龄 + objectMap.put("checkMonth", checkMonth); + // 配置对应的月龄 objectMap.put("month", currentMonth); + // 领域组 objectMap.put("listGroup", listGroup); + BabyEvaluationCriterionModel criterionModel = mongoTemplate.findOne(Query.query(Criteria.where("type").is(2). + and("minBorder").lte(developmentQuotient).and("maxBorder").gte(developmentQuotient)), BabyEvaluationCriterionModel.class); + String aptitudeName = null,levelName = null; + if (criterionModel != null) { + aptitudeName = criterionModel.getAptitudeName(); + levelName = criterionModel.getLevelName(); + } + // 发育商、智能、等级评价 + objectMap.put("developmentQuotient", developmentQuotient); + objectMap.put("aptitudeName", aptitudeName); + objectMap.put("levelName", levelName); + + // 当前检查时间 + BabyNeuroPsychologicalModel one = mongoTemplate.findOne(Query.query( + Criteria.where("babyId").is(babyId).and("yn").is(YnEnums.YES.getId()).and("checkMonth").is(checkMonth)), BabyNeuroPsychologicalModel.class); + String currentCheckTime = one == null + ? "" + : (one.getUpdateTime() == null ? DateUtil.getYmd(one.getCreateTime()) : DateUtil.getYmd(one.getUpdateTime())); + objectMap.put("currentCheckTime", currentCheckTime); + mapList.add(objectMap); } resultMap.put("configs", mapList); @@ -246,10 +283,12 @@ public class BabyEvaluationCriterionServiceImpl implements BabyEvaluationCriteri with(new Sort(new Sort.Order(Sort.Direction.ASC, "createTime"))), BabyNeuroPsychologicalModel.class); List objectList = new ArrayList<>(); if (CollectionUtils.isNotEmpty(models)) { + // 若该儿童做过该项检查,一次查出 for (BabyNeuroPsychologicalModel model : models) { BaseResponse itemListByBabyId = getItemListByBabyId(model.getBabyId(), model.getCheckMonth()); if (itemListByBabyId.getErrorcode() != 0) { + // 出错直接return return itemListByBabyId; } List> mapList = (List>) itemListByBabyId.getObject(); @@ -260,6 +299,7 @@ public class BabyEvaluationCriterionServiceImpl implements BabyEvaluationCriteri return baseResponse; } else { + // 根据当前儿童显示项目领域的配置信息,以供save return getItemListByBabyId(babyId,null); } }