Commit 456bb321a84411d81be1f20642abf1b86c2085d5

Authored by wtt
1 parent 108755280b

update

Showing 3 changed files with 188 additions and 48 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java View file @ 456bb32
... ... @@ -792,7 +792,7 @@
792 792 }
793 793 List <Patients> ps = patientsService.queryPatientBySort(pq, riskPatientsQueryRequest.getSort(), riskPatientsQueryRequest.getOrder());
794 794 if (CollectionUtils.isNotEmpty(ps)) {
795   - data = convertToQuanWeight(ps,null);
  795 + data = convertToQuanWeight(ps);
796 796 }
797 797 }
798 798 }
... ... @@ -884,7 +884,7 @@
884 884 }
885 885 List <Patients> ps = patientsService.queryPatientBySort(pq, riskPatientsQueryRequest.getSort(), riskPatientsQueryRequest.getOrder());
886 886 if(CollectionUtils.isNotEmpty(ps)){
887   - data = convertToQuanWeight(ps,"judaer");//judaer巨大儿管理
  887 + data = convertToHugeQuanWeight(ps);//巨大儿管理
888 888 }
889 889 }
890 890 }
... ... @@ -1498,7 +1498,7 @@
1498 1498 }
1499 1499 return data;
1500 1500 }
1501   - private List<Map> convertToQuanWeight(List<Patients> patientses,String type) {
  1501 + private List<Map> convertToQuanWeight(List<Patients> patientses) {
1502 1502 List<Map> data = new ArrayList<>();
1503 1503 int batchSize = 4;
1504 1504 int end = 0;
... ... @@ -1508,7 +1508,28 @@
1508 1508 if (end > patientses.size()) {
1509 1509 end = patientses.size();
1510 1510 }
1511   - listFuture.add(commonThreadPool.submit(new QuanWeightWorker(patientses.subList(i, end),mongoTemplate,commonService,basicConfigService,type)));
  1511 + listFuture.add(commonThreadPool.submit(new QuanWeightWorker(patientses.subList(i, end),mongoTemplate,commonService,basicConfigService)));
  1512 + }
  1513 + for (Future f : listFuture) {
  1514 + try {
  1515 + data.addAll(( List<Map>) f.get(30, TimeUnit.SECONDS));
  1516 + } catch (Exception e) {
  1517 + ExceptionUtils.catchException(e, "convertToQuanWeight get result Future error.");
  1518 + }
  1519 + }
  1520 + return data;
  1521 + }
  1522 + private List<Map> convertToHugeQuanWeight(List<Patients> patientses) {
  1523 + List<Map> data = new ArrayList<>();
  1524 + int batchSize = 4;
  1525 + int end = 0;
  1526 + List<Future> listFuture = new ArrayList<>();
  1527 + for (int i = 0; i < patientses.size(); i += batchSize) {
  1528 + end = (end + batchSize);
  1529 + if (end > patientses.size()) {
  1530 + end = patientses.size();
  1531 + }
  1532 + listFuture.add(commonThreadPool.submit(new HugeQuanWeightWorker(patientses.subList(i, end),mongoTemplate,commonService,basicConfigService)));
1512 1533 }
1513 1534 for (Future f : listFuture) {
1514 1535 try {
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/HugeQuanWeightWorker.java View file @ 456bb32
  1 +package com.lyms.platform.operate.web.worker;
  2 +
  3 +import com.lyms.platform.biz.service.BasicConfigService;
  4 +import com.lyms.platform.biz.service.CommonService;
  5 +import com.lyms.platform.common.utils.DateUtil;
  6 +import com.lyms.platform.common.utils.StringUtils;
  7 +import com.lyms.platform.operate.web.facade.PatientFacade;
  8 +import com.lyms.platform.pojo.MaternalDeliverModel;
  9 +import com.lyms.platform.pojo.PatientWeight;
  10 +import com.lyms.platform.pojo.Patients;
  11 +import org.apache.commons.collections.CollectionUtils;
  12 +import org.slf4j.Logger;
  13 +import org.slf4j.LoggerFactory;
  14 +import org.springframework.data.mongodb.core.MongoTemplate;
  15 +import org.springframework.data.mongodb.core.query.Criteria;
  16 +import org.springframework.data.mongodb.core.query.Query;
  17 +
  18 +import java.util.*;
  19 +import java.util.concurrent.Callable;
  20 +
  21 +/**
  22 + * 巨大儿
  23 + *
  24 + * @Author: 武涛涛
  25 + * @Date: 2021/1/4 9:28
  26 + */
  27 +public class HugeQuanWeightWorker implements Callable<List<Map>> {
  28 +
  29 + private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class);
  30 +
  31 + private List<Patients> patientses;
  32 + private MongoTemplate mongoTemplate;
  33 + private CommonService commonService;
  34 + private BasicConfigService basicConfigService;
  35 +
  36 + public HugeQuanWeightWorker(List<Patients> patientses,
  37 + MongoTemplate mongoTemplate,
  38 + CommonService commonService,
  39 + BasicConfigService basicConfigService
  40 + ) {
  41 + this.patientses = patientses;
  42 + this.mongoTemplate = mongoTemplate;
  43 + this.commonService = commonService;
  44 + this.basicConfigService = basicConfigService;
  45 + }
  46 +
  47 + @Override
  48 + public List<Map> call() throws Exception {
  49 + List<Map> data = new ArrayList<>();
  50 + for (Patients patients : patientses)
  51 + if (StringUtils.isNotEmpty(patients.getId())) {
  52 + Map map = new HashMap();
  53 + map.put("fmDate", DateUtil.getyyyy_MM_dd(patients.getFmDate()));
  54 + if (patients.getFmWeek() != null) {
  55 + String dueWeek = "";
  56 + String week = (patients.getFmWeek() / 7) + "";
  57 + int day = (patients.getFmWeek() % 7);
  58 + dueWeek = "孕" + week + "周" + (day > 0 ? "+" + day + "天" : "");
  59 + map.put("fmWeek", dueWeek);
  60 + } else {
  61 + map.put("fmWeek", "");
  62 + }
  63 + map.put("username", patients.getUsername());
  64 + map.put("age", patients.getAge());
  65 + map.put("phone", patients.getPhone());
  66 + map.put("currentWeek", patients.getType() == 3 ? "已分娩" : DateUtil.getWeekDesc(patients.getLastMenses(), new Date()));
  67 + String risk = getRiskFactor(patients.getRiskFactorId());
  68 + if (org.apache.commons.lang.StringUtils.isEmpty(risk)) {
  69 + risk = (org.apache.commons.lang.StringUtils.isEmpty(patients.getoRiskFactor()) ? "" : patients.getoRiskFactor());
  70 + } else {
  71 + risk = risk + (org.apache.commons.lang.StringUtils.isEmpty(patients.getoRiskFactor()) ? "" : "," + patients.getoRiskFactor());
  72 + }
  73 +// String rFactor = commonService.resloveFactor(JsonUtil.toList(patients.getRiskLevelId(), String.class));
  74 + map.put("riskFactor", risk);
  75 + map.put("patientId", patients.getId());
  76 + map.put("pid", patients.getPid());
  77 + map.put("cardNo", patients.getCardNo());
  78 +
  79 +
  80 + List<PatientWeight> patientWeightList = mongoTemplate.find(Query.query(Criteria.where("patientId").is(patients.getId()).and("yn").ne("0")), PatientWeight.class);
  81 + if (CollectionUtils.isNotEmpty(patientWeightList)) {
  82 + PatientWeight patientWeight = patientWeightList.get(0);
  83 + if (patientWeight != null && StringUtils.isNotEmpty(patientWeight.getBmi())) {
  84 + map.put("bmi", patientWeight.getBmi());
  85 + map.put("beforeHeight", patientWeight.getBeforeHeight());
  86 + map.put("beforeWeight", patientWeight.getBeforeWeight());
  87 + map.put("dayWeights", patientWeight.getDayWeights());
  88 + if (patientWeight.getDayWeights() != null) {
  89 + int ii = 1;
  90 + for (Map.Entry<String, String> entry : patientWeight.getDayWeights().entrySet()) {
  91 + String mapKey = entry.getKey();
  92 + String mapValue = entry.getValue();
  93 + map.put("dayWeights" + ii++, mapKey + "/" + mapValue);
  94 + }
  95 + }
  96 + }
  97 +
  98 + }
  99 + Query querymd = Query.query(Criteria.where("parentId").is(patients.getId()).and("yn").ne("0")
  100 + .and("baby").elemMatch(Criteria.where("babyWeight").gte("4000")));
  101 + List<MaternalDeliverModel> deliverModels = mongoTemplate.find(querymd, MaternalDeliverModel.class);
  102 + if (CollectionUtils.isNotEmpty(deliverModels)) {
  103 + MaternalDeliverModel maternalDeliverModel = deliverModels.get(0);
  104 + List<MaternalDeliverModel.Baby> baby = maternalDeliverModel.getBaby();
  105 + for (int i = 0; i < baby.size(); i++) {
  106 + MaternalDeliverModel.Baby baby1 = baby.get(i);
  107 + map.put("babyWeight", baby1.getBabyWeight());
  108 +
  109 + }
  110 + }
  111 + data.add(map);
  112 + }
  113 + return data;
  114 + }
  115 +
  116 +
  117 + public static List filter(List<Map> level) {
  118 + List list = new ArrayList();
  119 + List addEdList = new ArrayList();
  120 + if (CollectionUtils.isNotEmpty(level)) {
  121 + for (Map map : level) {
  122 + if (!addEdList.contains(map.get("name"))) {
  123 + list.add(map);
  124 + addEdList.add(map.get("name"));
  125 + }
  126 + }
  127 + }
  128 +
  129 + return list;
  130 + }
  131 +
  132 +
  133 + private String getRiskFactor(List<String> list) {
  134 + String riskFactor = "";
  135 + if (list != null && list.size() > 0) {
  136 + for (String s : list) {
  137 + try {
  138 + riskFactor += basicConfigService.getOneBasicConfigById(s).getName();
  139 + riskFactor += ",";
  140 + } catch (Exception e) {
  141 + riskFactor += "";
  142 + }
  143 + }
  144 + }
  145 + if (riskFactor.length() > 0) {
  146 + return riskFactor.substring(0, riskFactor.length() - 1);
  147 + }
  148 + return riskFactor;
  149 + }
  150 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanWeightWorker.java View file @ 456bb32
... ... @@ -22,6 +22,8 @@
22 22 import java.util.concurrent.Callable;
23 23  
24 24 /**
  25 + * 孕期体重异常管理
  26 + *
25 27 * @Author: 武涛涛
26 28 * @Date: 2021/1/4 9:28
27 29 */
28 30  
29 31  
30 32  
... ... @@ -32,19 +34,17 @@
32 34 private List<Patients> patientses;
33 35 private MongoTemplate mongoTemplate;
34 36 private CommonService commonService;
35   - private String type;
36 37 private BasicConfigService basicConfigService;
  38 +
37 39 public QuanWeightWorker(List<Patients> patientses,
38 40 MongoTemplate mongoTemplate,
39 41 CommonService commonService,
40   - BasicConfigService basicConfigService,
41   - String type
  42 + BasicConfigService basicConfigService
42 43 ) {
43 44 this.patientses = patientses;
44 45 this.mongoTemplate = mongoTemplate;
45 46 this.commonService = commonService;
46 47 this.basicConfigService = basicConfigService;
47   - this.type = type;
48 48 }
49 49  
50 50 @Override
... ... @@ -57,39 +57,8 @@
57 57 PatientWeight patientWeight = patientWeightList.get(0);
58 58 if (patientWeight != null && com.lyms.platform.common.utils.StringUtils.isNotEmpty(patientWeight.getBmi())) {
59 59 Map map = new HashMap();
60   - if(StringUtils.isEmpty(type)){
61   - //-------------------------孕期体重异常管理---字段----------------------
62   - puliMap(patients, patientWeight, map);
63   - data.add(map);
64   -
65   - }else if("judaer".equals(type)) {
66   - //-------------------------巨大儿管理---字段----------------------
67   - map.put("fmDate", DateUtil.getyyyy_MM_dd(patients.getFmDate()));
68   - if (patients.getFmWeek() != null) {
69   - String dueWeek = "";
70   - String week = (patients.getFmWeek() / 7) + "";
71   - int day = (patients.getFmWeek() % 7);
72   - dueWeek = "孕" + week + "周" + (day > 0 ? "+" + day + "天" : "");
73   - map.put("fmWeek", dueWeek);
74   - } else {
75   - map.put("fmWeek", "");
76   - }
77   - Query querymd = Query.query(Criteria.where("parentId").is(patients.getId()).and("yn").ne("0")
78   - .and("baby").elemMatch(Criteria.where("babyWeight").gte("4000")));
79   - List<MaternalDeliverModel> deliverModels = mongoTemplate.find(querymd, MaternalDeliverModel.class);
80   - if(CollectionUtils.isNotEmpty(deliverModels)){
81   - MaternalDeliverModel maternalDeliverModel = deliverModels.get(0);
82   - List<MaternalDeliverModel.Baby> baby = maternalDeliverModel.getBaby();
83   - for (int i = 0; i < baby.size() ; i++) {
84   - MaternalDeliverModel.Baby baby1 = baby.get(i);
85   - map.put("babyWeight", baby1.getBabyWeight());
86   - puliMap(patients, patientWeight, map);
87   - data.add(map);
88   - }
89   - }
90   -
91   - }
92   -
  60 + puliMap(patients, patientWeight, map);
  61 + data.add(map);
93 62 }
94 63  
95 64 }
96 65  
... ... @@ -116,11 +85,11 @@
116 85 map.put("dayWeights", patientWeight.getDayWeights());
117 86 if (patientWeight.getDayWeights() != null) {
118 87 int i = 1;
119   - for(Map.Entry<String, String> entry : patientWeight.getDayWeights().entrySet()){
  88 + for (Map.Entry<String, String> entry : patientWeight.getDayWeights().entrySet()) {
120 89 String mapKey = entry.getKey();
121 90 String mapValue = entry.getValue();
122 91 // System.out.println(mapKey + "/" + mapValue);
123   - map.put("dayWeights"+i++, mapKey + "/" + mapValue);
  92 + map.put("dayWeights" + i++, mapKey + "/" + mapValue);
124 93 }
125 94  
126 95 }
127 96  
... ... @@ -132,12 +101,12 @@
132 101  
133 102 }
134 103  
135   - public static List filter(List<java.util.Map> level){
  104 + public static List filter(List<java.util.Map> level) {
136 105 List list = new ArrayList();
137   - List addEdList = new ArrayList();
138   - if(CollectionUtils.isNotEmpty(level)){
139   - for(java.util.Map map :level){
140   - if(!addEdList.contains(map.get("name"))){
  106 + List addEdList = new ArrayList();
  107 + if (CollectionUtils.isNotEmpty(level)) {
  108 + for (java.util.Map map : level) {
  109 + if (!addEdList.contains(map.get("name"))) {
141 110 list.add(map);
142 111 addEdList.add(map.get("name"));
143 112 }