Commit 8e0f6ce04b2a25a92857fe1daf7755df64cd9454

Authored by wtt
1 parent 3417ee0e40

update

Showing 3 changed files with 266 additions and 5 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyEvaluationCriterionController.java View file @ 8e0f6ce
... ... @@ -58,7 +58,19 @@
58 58 return babyEvaluationCriterionService.query(getUserId(request), jsonObject, false);
59 59 }
60 60  
61   -
  61 + /**
  62 + * 根据查询号查询儿童(承德环境)
  63 + *
  64 + * @param jsonObject
  65 + * @param request
  66 + * @return
  67 + */
  68 + @ResponseBody
  69 + @TokenRequired
  70 + @RequestMapping(method = RequestMethod.POST, value = "/queryCddz")
  71 + private BaseResponse queryCddz(@RequestBody JSONObject jsonObject, HttpServletRequest request) {
  72 + return babyEvaluationCriterionService.queryCddz(getUserId(request), jsonObject, false);
  73 + }
62 74 /**
63 75 * 保存or更新神经心理项目
64 76 *
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/BabyEvaluationCriterionService.java View file @ 8e0f6ce
... ... @@ -23,6 +23,7 @@
23 23 * @return
24 24 */
25 25 BaseResponse query(Integer userId, JSONObject jsonObject, boolean isPush);
  26 + BaseResponse queryCddz(Integer userId, JSONObject jsonObject, boolean isPush);
26 27  
27 28 /**
28 29 * 保存or更新神经心理项目
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BabyEvaluationCriterionServiceImpl.java View file @ 8e0f6ce
... ... @@ -18,14 +18,12 @@
18 18 import org.springframework.beans.factory.annotation.Autowired;
19 19 import org.springframework.data.domain.Sort;
20 20 import org.springframework.data.mongodb.core.MongoTemplate;
21   -import org.springframework.data.mongodb.core.aggregation.Aggregation;
22   -import org.springframework.data.mongodb.core.aggregation.AggregationResults;
23   -import org.springframework.data.mongodb.core.aggregation.GroupOperation;
24   -import org.springframework.data.mongodb.core.aggregation.MatchOperation;
  21 +import org.springframework.data.mongodb.core.aggregation.*;
25 22 import org.springframework.data.mongodb.core.query.Criteria;
26 23 import org.springframework.data.mongodb.core.query.Query;
27 24 import org.springframework.data.mongodb.core.query.Update;
28 25 import org.springframework.stereotype.Service;
  26 +import scala.Int;
29 27  
30 28 import java.math.BigDecimal;
31 29 import java.text.DecimalFormat;
32 30  
... ... @@ -78,7 +76,56 @@
78 76 baseResponse.setObject(stringObjectMap);
79 77 return baseResponse;
80 78 }
  79 + public BaseResponse getItemListByBabyIdCddz(String babyId, Integer checkMonth, String id) {
  80 + Map<String, Object> stringObjectMap = new HashMap<>();
  81 + int [] months = null;
  82 + if (StringUtils.isNotEmpty(babyId)) {
  83 + BabyModel babyModel = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(babyId)), BabyModel.class);
  84 + if (null != babyModel) {
  85 + Date birth = babyModel.getBirth();
  86 + Integer month = checkMonth == null ? DateUtil.getBabyAgeMonth(birth, new Date()) : checkMonth;
  87 + if (month > 84) {
  88 + return new BaseResponse().setErrorcode(ErrorCodeConstants.PARAMETER_ERROR).setErrormsg("操作失败,当前儿童年龄大于7岁");
  89 + }
  90 + if (month > 0)
  91 + {
  92 + List <Integer> intsCddz = getIntsCddz(3);//获取儿童测量评估标准 所有的月龄集合
  93 + stringObjectMap = getListMapCddz(intsCddz, babyId, checkMonth, id);
  94 + }
81 95  
  96 + }
  97 + }
  98 + BaseResponse baseResponse = new BaseResponse();
  99 + baseResponse.setObject(stringObjectMap);
  100 + return baseResponse;
  101 + }
  102 +
  103 + /**
  104 + * 获取 儿童测量评估标准 所有的月龄集合
  105 + *
  106 + * @param type 3/儿童神经心理发育
  107 + * @Author: 武涛涛
  108 + * @Date: 2021/4/15 15:01
  109 + */
  110 + private List <Integer> getIntsCddz( Integer type) {
  111 + Criteria cm = Criteria.where("type").in(type).and("yn").ne(YnEnums.NO.getId());
  112 + AggregationOperation matchM = Aggregation.match(cm);
  113 + AggregationOperation groupM = Aggregation.group("month");//.count().as("gwegllCount");
  114 + AggregationOperation fieldsM = Aggregation.project("month");
  115 + Aggregation aggregationM = Aggregation.newAggregation(matchM, groupM, fieldsM);
  116 + AggregationResults <HashMap> resultM = this.mongoTemplate.aggregate(aggregationM,
  117 + "lyms_baby_evaluationCriterion", HashMap.class);//BabyEvaluationCriterionModel HashMap
  118 + List <Integer> integerList = new ArrayList <>();
  119 + if (resultM != null && CollectionUtils.isNotEmpty(resultM.getMappedResults())) {
  120 + for (HashMap hashMap: resultM.getMappedResults() ) {
  121 + if(hashMap.containsKey("_id")){
  122 + integerList.add((Integer) hashMap.get("_id"));
  123 + }
  124 + }
  125 + }
  126 + Collections.sort(integerList);
  127 + return integerList;
  128 + }
82 129 private int[] getInts(int[] months, Integer month) {
83 130 int month3 = getCurrentMonth(month, 3, 3);
84 131 if (month3 >= 3 && month3 <= 72) {
85 132  
... ... @@ -238,7 +285,92 @@
238 285 resultMap.put("configs", mapList);
239 286 return resultMap;
240 287 }
  288 + /**
  289 + * 和以前的规则一样,只是这里是 List <Integer> months
  290 + *
  291 + * @param months
  292 + * @param babyId
  293 + * @param checkMonth
  294 + * @param id
  295 + * @Author: 武涛涛
  296 + * @Date: 2021/4/15 15:01
  297 + */
  298 + private Map<String, Object> getListMapCddz( List <Integer> months, String babyId, Integer checkMonth, String id) {
  299 + Map<String, Object> resultMap = new HashMap<>();
  300 + String neuroPsychologicalId = null;
241 301  
  302 +
  303 + // 当前本月的被勾选的总分数
  304 + List<Map<String, Object>> mapList = new LinkedList<>();
  305 + for (int i = 0, size = months.size(); i < size ; i++) {
  306 +
  307 + int currentMonth = months.get(i);
  308 + // 月龄对应的数据
  309 + Map<String, Object> objectMap = new HashMap<>();
  310 + Query query = Query.query(Criteria.where("month").is(currentMonth).and("yn").is(YnEnums.YES.getId()).and("type").is(3));
  311 + query.with(new Sort(new Sort.Order(Sort.Direction.DESC, "month")));
  312 +
  313 + List<BabyEvaluationCriterionModel > babyEvaluationCriterionModels = mongoTemplate.find(query, BabyEvaluationCriterionModel.class);
  314 + Map<Integer, List<BabyEvaluationCriterionModel>> listGroup = getListGroup(babyEvaluationCriterionModels);
  315 + List<Map<String, Object>> listGroupMaps = new LinkedList<>();
  316 + Set<Map.Entry<Integer, List<BabyEvaluationCriterionModel>>> entries = listGroup.entrySet();
  317 + for (Map.Entry<Integer, List<BabyEvaluationCriterionModel>> entry : entries) {
  318 + Map<String, Object> map = new HashMap<>();
  319 + List<BabyEvaluationCriterionModel> models = entry.getValue();
  320 + Iterator<BabyEvaluationCriterionModel> iterator = models.iterator();
  321 + List<Map<String, Object>> list = new LinkedList<>();
  322 + while (iterator.hasNext()) {
  323 + BabyEvaluationCriterionModel next = iterator.next();
  324 + final String configId = next.getId();
  325 + boolean isSelected = false;
  326 + Double projectVal = next.getProjectVal();
  327 + if (checkMonth != null) {
  328 + BabyNeuroPsychologicalModel one = mongoTemplate.findOne(Query.query(
  329 + Criteria.where("configId").in(new ArrayList<String>(){{add(configId);}}).
  330 + and("_id").is(id)), BabyNeuroPsychologicalModel.class);
  331 + if (one != null) {
  332 + isSelected = true;
  333 + String oneId = one.getId();
  334 + if (neuroPsychologicalId == null) {
  335 + neuroPsychologicalId = oneId;
  336 + }
  337 + }
  338 + }
  339 + Map<String, Object> m = new HashMap<>(16);
  340 + m.put("configId", configId);
  341 + m.put("projectName", next.getProjectName());
  342 + m.put("projectVal", projectVal);
  343 + m.put("isSelected", isSelected);
  344 + list.add(m);
  345 + }
  346 + map.put("projectType", entry.getKey());
  347 + map.put("detailList", list);
  348 + listGroupMaps.add(map);
  349 + }
  350 +
  351 +
  352 + // 当前测试时月龄
  353 + objectMap.put("checkMonth", checkMonth);
  354 + // 配置对应的月龄
  355 + objectMap.put("month", currentMonth);
  356 + // 领域组
  357 + objectMap.put("listGroup", listGroupMaps);
  358 +
  359 +
  360 + // 当前检查时间
  361 + BabyNeuroPsychologicalModel one = mongoTemplate.findOne(Query.query(
  362 + Criteria.where("babyId").is(babyId).and("yn").is(YnEnums.YES.getId()).and("checkMonth").is(checkMonth)), BabyNeuroPsychologicalModel.class);
  363 + String currentCheckTime = one == null
  364 + ? ""
  365 + : (one.getUpdateTime() == null ? DateUtil.getYmd(one.getCreateTime()) : DateUtil.getYmd(one.getUpdateTime()));
  366 + objectMap.put("currentCheckTime", currentCheckTime);
  367 +
  368 + mapList.add(objectMap);
  369 + }
  370 + resultMap.put("configs", mapList);
  371 + return resultMap;
  372 + }
  373 +
242 374 /**
243 375 *
244 376 * @param checkMonth 月龄
... ... @@ -439,6 +571,122 @@
439 571  
440 572 // 根据当前儿童显示项目领域的配置信息,以供 add
441 573 Map<String, Object> objectMap = (Map<String, Object>) getItemListByBabyId(babyId, checkMonth, null).getObject();
  574 + objectMap.put("checkTimeStr", "");
  575 + objectMap.put("checkMonth", checkMonthStr);
  576 +
  577 + objectList.add(objectMap);
  578 + baseResponse.setObject(objectList);
  579 + return baseResponse;
  580 +
  581 + }
  582 +
  583 + /**
  584 + * 获取儿童神经心理发育检查项(承德环境)
  585 + *
  586 + * @param userId
  587 + * @param jsonObject
  588 + * @return
  589 + */
  590 + @Override
  591 + public BaseResponse queryCddz(Integer userId, JSONObject jsonObject, boolean isPush) {
  592 + String hospitalId = autoMatchFacade.getHospitalId(userId);
  593 + String babyId = jsonObject.getString("babyId");
  594 + BaseResponse baseResponse = new BaseResponse();
  595 + if (StringUtils.isEmpty(babyId)) {
  596 + return new BaseResponse().setErrorcode(ErrorCodeConstants.PARAMETER_ERROR).setErrormsg("参数缺失");
  597 + }
  598 + List<BabyNeuroPsychologicalModel> models = mongoTemplate.find(Query.query(Criteria.where("babyId").is(babyId).and("hospitalId").is(hospitalId).and("yn").is(YnEnums.YES.getId())).
  599 + with(new Sort(new Sort.Order(Sort.Direction.ASC, "createTime"))), BabyNeuroPsychologicalModel.class);
  600 + List<Object> objectList = new ArrayList<>();
  601 + Integer checkMonth = null;
  602 + String checkMonthStr = "";
  603 +
  604 + if (CollectionUtils.isNotEmpty(models)) {
  605 +
  606 + if (isPush){
  607 + BabyNeuroPsychologicalModel model = models.get(models.size() - 1);
  608 + BaseResponse response = getItemListByBabyIdCddz(model.getBabyId(), model.getCheckMonth(), model.getId());
  609 + return response;
  610 + } else {
  611 + // 若该儿童做过该项检查,一次查出
  612 + for (BabyNeuroPsychologicalModel model : models) {
  613 + BaseResponse itemListByBabyId = getItemListByBabyIdCddz(model.getBabyId(), model.getCheckMonth(), model.getId());
  614 + if (itemListByBabyId.getErrorcode() != 0) {
  615 + // 出错直接return
  616 + return itemListByBabyId;
  617 + }
  618 + Map<String, Object> objectMap = (Map<String, Object>) itemListByBabyId.getObject();
  619 + objectMap.put("checkTimeStr", DateUtil.getyyyy_MM_dd(model.getCreateTime()));
  620 + BabyModel babyModel = mongoTemplate.findOne(Query.query(Criteria.where("id").is(babyId)), BabyModel.class);
  621 + if (babyModel != null) {
  622 + checkMonthStr = DateUtil.getBabyMonthAge(babyModel.getBirth(), model.getCreateTime());
  623 + }
  624 + objectMap.put("checkMonth", checkMonthStr);
  625 + objectMap.put("id", model.getId());
  626 +
  627 + // 发育商、智能、等级评价
  628 + objectMap.put("developmentQuotient", model.getDevelopmentQuotient());
  629 + objectMap.put("aptitudeName", model.getAptitudeName());
  630 + objectMap.put("levelName", model.getLevelName());
  631 +
  632 + // 智龄
  633 + int double1Dq = 0,
  634 + double2Dq = 0,
  635 + double3Dq = 0,
  636 + double4Dq = 0,
  637 + double5Dq = 0;
  638 + Double double1Z = 0.00D,
  639 + double2Z = 0.00D,
  640 + double3Z = 0.00D,
  641 + double4Z = 0.00D,
  642 + double5Z = 0.00D;
  643 + Double zl = 0.00D;
  644 +
  645 + for (String configId : model.getConfigId()) {
  646 + BabyEvaluationCriterionModel criterionModel = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(configId)), BabyEvaluationCriterionModel.class);
  647 + zl += criterionModel.getProjectVal();
  648 + // 1/大动作 2/精细动作 3/适应能力 4/语音 5/社交行为
  649 + if (criterionModel != null) {
  650 + if (1 == criterionModel.getProjectType()) {
  651 + double1Z += criterionModel.getProjectVal();
  652 + } else if (2 == criterionModel.getProjectType()) {
  653 + double2Z += criterionModel.getProjectVal();
  654 + } else if (3 == criterionModel.getProjectType()) {
  655 + double3Z += criterionModel.getProjectVal();
  656 + } else if (4 == criterionModel.getProjectType()) {
  657 + double4Z += criterionModel.getProjectVal();
  658 + } else if (5 == criterionModel.getProjectType()) {
  659 + double5Z += criterionModel.getProjectVal();
  660 + }
  661 + }
  662 + }
  663 + Integer month = model.getCheckMonth();
  664 + int [] months = null;
  665 + months = getInts(months, month);
  666 + int month1 = months[0];
  667 + List<BabyEvaluationCriterionModel> ecmodels = mongoTemplate.find(Query.query(Criteria.where("month").lt(month1).and("type").is(3)), BabyEvaluationCriterionModel.class);
  668 + for (BabyEvaluationCriterionModel m : ecmodels) {
  669 + zl += m.getProjectVal();
  670 + }
  671 +
  672 + DecimalFormat df = new DecimalFormat("0.00");
  673 + String zlStr = "";
  674 + if (zl != 0.00) {
  675 + zlStr = String.format(df.format(zl / 5));
  676 + }
  677 + Map<String, Object> reportMap = getStringObjectMap(DateUtil.getBabyAgeMonth(model.getBirth(), new Date() ),
  678 + double1Dq, double2Dq, double3Dq, double4Dq, double5Dq, double1Z, double2Z, double3Z, double4Z, double5Z);
  679 +
  680 + // 智龄、报表
  681 + objectMap.put("zlStr", zlStr);
  682 + objectMap.put("report", reportMap);
  683 + objectList.add(objectMap);
  684 + }
  685 + }
  686 + }
  687 +
  688 + // 根据当前儿童显示项目领域的配置信息,以供 add
  689 + Map<String, Object> objectMap = (Map<String, Object>) getItemListByBabyIdCddz(babyId, checkMonth, null).getObject();
442 690 objectMap.put("checkTimeStr", "");
443 691 objectMap.put("checkMonth", checkMonthStr);
444 692