Commit 29c112084c14b2e025984f71f6bebc225d822fff
1 parent
cb60020cfa
Exists in
master
and in
6 other branches
update
Showing 3 changed files with 230 additions and 26 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
View file @
29c1120
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | |
3 | 3 | import com.lyms.platform.beans.MsgRequest; |
4 | 4 | import com.lyms.platform.biz.service.*; |
5 | +import com.lyms.platform.common.base.PageInfo; | |
5 | 6 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
6 | 7 | import com.lyms.platform.common.dao.operator.MongoCondition; |
7 | 8 | import com.lyms.platform.common.dao.operator.MongoOper; |
8 | 9 | |
... | ... | @@ -10,11 +11,13 @@ |
10 | 11 | import com.lyms.platform.common.result.BaseListResponse; |
11 | 12 | import com.lyms.platform.common.result.BaseObjectResponse; |
12 | 13 | import com.lyms.platform.common.result.BaseResponse; |
14 | +import com.lyms.platform.common.result.PageResult; | |
13 | 15 | import com.lyms.platform.common.utils.*; |
14 | 16 | import com.lyms.platform.operate.web.request.*; |
15 | 17 | import com.lyms.platform.operate.web.result.*; |
16 | 18 | import com.lyms.platform.operate.web.service.PatientWeightService; |
17 | 19 | import com.lyms.platform.operate.web.service.RareBloodGroupService; |
20 | +import com.lyms.platform.operate.web.service.impl.BaseServiceImpl; | |
18 | 21 | import com.lyms.platform.operate.web.utils.CommonsHelper; |
19 | 22 | import com.lyms.platform.operate.web.utils.JxlsUtils; |
20 | 23 | import com.lyms.platform.operate.web.worker.*; |
... | ... | @@ -50,7 +53,7 @@ |
50 | 53 | * Created by Administrator on 2016/4/22 0022. |
51 | 54 | */ |
52 | 55 | @Component |
53 | -public class PatientFacade { | |
56 | +public class PatientFacade extends BaseServiceImpl { | |
54 | 57 | private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class); |
55 | 58 | |
56 | 59 | public static final String HIS_VERSION = PropertiesUtils.getPropertyValue("his_version"); |
... | ... | @@ -762,6 +765,29 @@ |
762 | 765 | public BaseResponse queryAbnormalWeight(RiskPatientsQueryRequest riskPatientsQueryRequest, Integer userId,String need) { |
763 | 766 | |
764 | 767 | String hospital = autoMatchFacade.getHospitalId(userId); |
768 | + Query query = Query.query(Criteria.where("hospitalId").is(hospital).and("yn").ne("0")); | |
769 | + String formatBmi = ""; | |
770 | + if("1".equals(riskPatientsQueryRequest.getBmi())){ | |
771 | + formatBmi = String.format("function () { return this.bmi >= %s && this.bmi <= %s; }", "25", "28"); | |
772 | + }else if("2".equals(riskPatientsQueryRequest.getBmi())){ | |
773 | + formatBmi = String.format("function () { return this.bmi >= %s; }", "28"); | |
774 | + }else { | |
775 | + formatBmi = String.format("function () { return this.bmi >= %s; }", "25"); | |
776 | + } | |
777 | + query.addCriteria(Criteria.where("$where").is(formatBmi)); | |
778 | + PageResult pageResult = findMongoPage(PatientWeight.class, query.with(new Sort(Sort.Direction.DESC, "modified")), riskPatientsQueryRequest.getPage(), riskPatientsQueryRequest.getLimit()); | |
779 | + List<PatientWeight> patientWeightList = (List<PatientWeight>) pageResult.getGrid(); | |
780 | + List<Map> data = new ArrayList<>(); | |
781 | + if (CollectionUtils.isNotEmpty(patientWeightList)) { | |
782 | + data = convertToQuanWeight(patientWeightList); | |
783 | + } | |
784 | + return new BaseListResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS) | |
785 | + .setData(data).setPageInfo(new PageInfo(pageResult.getPage(), pageResult.getLastPage(), pageResult.getCount(), pageResult.getLimit())); | |
786 | + } | |
787 | +/* | |
788 | + public BaseResponse queryAbnormalWeight2(RiskPatientsQueryRequest riskPatientsQueryRequest, Integer userId,String need) { | |
789 | + | |
790 | + String hospital = autoMatchFacade.getHospitalId(userId); | |
765 | 791 | PatientsQuery pq = new PatientsQuery(); |
766 | 792 | PatientsQuery patientsQuery = new PatientsQuery(); |
767 | 793 | patientsQuery.setYn(YnEnums.YES.getId()); |
768 | 794 | |
... | ... | @@ -771,13 +797,22 @@ |
771 | 797 | patientsQuery.setrLevel(riskPatientsQueryRequest.getrLevel()); |
772 | 798 | patientsQuery.setrFactorList(com.lyms.platform.common.utils.StringUtils.covertToList(riskPatientsQueryRequest.getrFacotr(), String.class)); |
773 | 799 | patientsQuery.setHospitalId(hospital); |
800 | + | |
801 | + | |
802 | + | |
774 | 803 | List <Patients> patientses = patientsService.queryPatientBySort(patientsQuery, riskPatientsQueryRequest.getSort(), riskPatientsQueryRequest.getOrder()); |
775 | 804 | List<Map> data = new ArrayList<>(); |
776 | 805 | List<String> ids = new ArrayList<>(); |
777 | 806 | if (CollectionUtils.isNotEmpty(patientses)) { |
778 | 807 | for (Patients patients : patientses) { |
779 | 808 | if(com.lyms.platform.common.utils.StringUtils.isNotEmpty(patients.getId())){ |
780 | - List<PatientWeight> patientWeightList = mongoTemplate.find(Query.query(Criteria.where("patientId").is(patients.getId()).and("yn").ne("0")), PatientWeight.class); | |
809 | +// List<PatientWeight> patientWeightList = mongoTemplate.find(Query.query(Criteria.where("patientId").is(patients.getId()).and("yn").ne("0")), PatientWeight.class); | |
810 | + Query query = Query.query(Criteria.where("patientId").is(patients.getId()).and("yn").ne("0")); | |
811 | + query.addCriteria(Criteria.where("$where").is( | |
812 | + String.format("function () { return this.bmi >= %s && this.bmi <= %s; }", "25", "25"))); | |
813 | + | |
814 | + List<PatientWeight> patientWeightList = mongoTemplate.find(query, PatientWeight.class); | |
815 | + | |
781 | 816 | if(CollectionUtils.isNotEmpty(patientWeightList)){ |
782 | 817 | PatientWeight patientWeight = patientWeightList.get(0); |
783 | 818 | if(patientWeight!=null && com.lyms.platform.common.utils.StringUtils.isNotEmpty(patientWeight.getBmi())){ |
... | ... | @@ -811,6 +846,7 @@ |
811 | 846 | } |
812 | 847 | return new BaseListResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(data).setPageInfo(pq.getPageInfo()); |
813 | 848 | } |
849 | +*/ | |
814 | 850 | /** |
815 | 851 | * 巨大儿管理 |
816 | 852 | * @param riskPatientsQueryRequest |
817 | 853 | |
... | ... | @@ -1523,11 +1559,33 @@ |
1523 | 1559 | } |
1524 | 1560 | return data; |
1525 | 1561 | } |
1526 | - private List<Map> convertToQuanWeight(List<Patients> patientses) { | |
1562 | + private List<Map> convertToQuanWeight(List<PatientWeight> patientWeightList) { | |
1527 | 1563 | List<Map> data = new ArrayList<>(); |
1528 | 1564 | int batchSize = 4; |
1529 | 1565 | int end = 0; |
1530 | 1566 | List<Future> listFuture = new ArrayList<>(); |
1567 | + for (int i = 0; i < patientWeightList.size(); i += batchSize) { | |
1568 | + end = (end + batchSize); | |
1569 | + if (end > patientWeightList.size()) { | |
1570 | + end = patientWeightList.size(); | |
1571 | + } | |
1572 | + listFuture.add(commonThreadPool.submit(new QuanWeightWorker(patientWeightList.subList(i, end),mongoTemplate,commonService,basicConfigService,trackDownRecordService))); | |
1573 | + } | |
1574 | + for (Future f : listFuture) { | |
1575 | + try { | |
1576 | + data.addAll(( List<Map>) f.get(30, TimeUnit.SECONDS)); | |
1577 | + } catch (Exception e) { | |
1578 | + ExceptionUtils.catchException(e, "convertToQuanWeight get result Future error."); | |
1579 | + } | |
1580 | + } | |
1581 | + return data; | |
1582 | + } | |
1583 | +/* | |
1584 | + private List<Map> convertToQuanWeight2(List<Patients> patientses) { | |
1585 | + List<Map> data = new ArrayList<>(); | |
1586 | + int batchSize = 4; | |
1587 | + int end = 0; | |
1588 | + List<Future> listFuture = new ArrayList<>(); | |
1531 | 1589 | for (int i = 0; i < patientses.size(); i += batchSize) { |
1532 | 1590 | end = (end + batchSize); |
1533 | 1591 | if (end > patientses.size()) { |
... | ... | @@ -1544,6 +1602,7 @@ |
1544 | 1602 | } |
1545 | 1603 | return data; |
1546 | 1604 | } |
1605 | +*/ | |
1547 | 1606 | private List<Map> convertToHugeQuanWeight(List<Patients> patientses) { |
1548 | 1607 | List<Map> data = new ArrayList<>(); |
1549 | 1608 | int batchSize = 4; |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanWeightWorker.java
View file @
29c1120
... | ... | @@ -34,18 +34,18 @@ |
34 | 34 | |
35 | 35 | private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class); |
36 | 36 | |
37 | - private List<Patients> patientses; | |
37 | + private List<PatientWeight> patientWeightList; | |
38 | 38 | private MongoTemplate mongoTemplate; |
39 | 39 | private CommonService commonService; |
40 | 40 | private BasicConfigService basicConfigService; |
41 | 41 | private TrackDownRecordService trackDownRecordService; |
42 | - public QuanWeightWorker(List<Patients> patientses, | |
42 | + public QuanWeightWorker(List<PatientWeight> patientWeightList, | |
43 | 43 | MongoTemplate mongoTemplate, |
44 | 44 | CommonService commonService, |
45 | 45 | BasicConfigService basicConfigService, |
46 | 46 | TrackDownRecordService trackDownRecordService |
47 | 47 | ) { |
48 | - this.patientses = patientses; | |
48 | + this.patientWeightList = patientWeightList; | |
49 | 49 | this.mongoTemplate = mongoTemplate; |
50 | 50 | this.commonService = commonService; |
51 | 51 | this.basicConfigService = basicConfigService; |
52 | 52 | |
53 | 53 | |
54 | 54 | |
... | ... | @@ -55,29 +55,25 @@ |
55 | 55 | @Override |
56 | 56 | public List<Map> call() throws Exception { |
57 | 57 | List<Map> data = new ArrayList<>(); |
58 | - for (Patients patients : patientses) | |
59 | - if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(patients.getId())) { | |
60 | - List<PatientWeight> patientWeightList = mongoTemplate.find(Query.query(Criteria.where("patientId").is(patients.getId()).and("yn").ne("0")), PatientWeight.class); | |
61 | - if (CollectionUtils.isNotEmpty(patientWeightList)) { | |
62 | - PatientWeight patientWeight = patientWeightList.get(0); | |
63 | - if (patientWeight != null && com.lyms.platform.common.utils.StringUtils.isNotEmpty(patientWeight.getBmi())) { | |
64 | - Map map = new HashMap(); | |
65 | - puliMap(patients, patientWeight, map); | |
66 | - //列表中冗余上追访管理--孕期检查列表id | |
67 | - TrackDownRecordQuery query = new TrackDownRecordQuery(); | |
68 | - query.setParentId(patients.getId()); | |
69 | - List <TrackDownRecord> trackDownRecords = trackDownRecordService.queryTrackDown(query); | |
70 | - if(CollectionUtils.isNotEmpty(trackDownRecords)){ | |
71 | - TrackDownRecord trackDownRecord = trackDownRecords.get(0); | |
72 | - if (StringUtils.isNotEmpty(trackDownRecord.getId())){ | |
73 | - map.put("trackDownRecId", trackDownRecord.getId()); | |
74 | - } | |
75 | - } | |
76 | - data.add(map); | |
58 | + for (PatientWeight patientWeight : patientWeightList){ | |
59 | + List <Patients> patientsList = mongoTemplate.find(Query.query(Criteria.where("id").is(patientWeight.getPatientId()).and("yn").ne("0")), Patients.class); | |
60 | + if(CollectionUtils.isNotEmpty(patientsList)){ | |
61 | + Patients patients = patientsList.get(0); | |
62 | + Map map = new HashMap(); | |
63 | + puliMap(patients, patientWeight, map); | |
64 | + //列表中冗余上追访管理--孕期检查列表id | |
65 | + TrackDownRecordQuery query = new TrackDownRecordQuery(); | |
66 | + query.setParentId(patients.getId()); | |
67 | + List <TrackDownRecord> trackDownRecords = trackDownRecordService.queryTrackDown(query); | |
68 | + if(CollectionUtils.isNotEmpty(trackDownRecords)){ | |
69 | + TrackDownRecord trackDownRecord = trackDownRecords.get(0); | |
70 | + if (StringUtils.isNotEmpty(trackDownRecord.getId())){ | |
71 | + map.put("trackDownRecId", trackDownRecord.getId()); | |
77 | 72 | } |
78 | - | |
79 | 73 | } |
74 | + data.add(map); | |
80 | 75 | } |
76 | + } | |
81 | 77 | return data; |
82 | 78 | } |
83 | 79 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanWeightWorker2.java
View file @
29c1120
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.biz.service.TrackDownRecordService; | |
6 | +import com.lyms.platform.common.utils.DateUtil; | |
7 | +import com.lyms.platform.common.utils.StringUtils; | |
8 | +import com.lyms.platform.operate.web.facade.PatientFacade; | |
9 | +import com.lyms.platform.pojo.PatientWeight; | |
10 | +import com.lyms.platform.pojo.Patients; | |
11 | +import com.lyms.platform.pojo.TrackDownRecord; | |
12 | +import com.lyms.platform.query.TrackDownRecordQuery; | |
13 | +import org.apache.commons.collections.CollectionUtils; | |
14 | +import org.slf4j.Logger; | |
15 | +import org.slf4j.LoggerFactory; | |
16 | +import org.springframework.data.mongodb.core.MongoTemplate; | |
17 | +import org.springframework.data.mongodb.core.query.Criteria; | |
18 | +import org.springframework.data.mongodb.core.query.Query; | |
19 | + | |
20 | +import java.util.*; | |
21 | +import java.util.concurrent.Callable; | |
22 | + | |
23 | +/** | |
24 | + * 孕期体重异常管理 | |
25 | + * | |
26 | + * @Author: 武涛涛 | |
27 | + * @Date: 2021/1/4 9:28 | |
28 | + */ | |
29 | +public class QuanWeightWorker2 implements Callable<List<Map>> { | |
30 | + | |
31 | + private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class); | |
32 | + | |
33 | + private List<Patients> patientses; | |
34 | + private MongoTemplate mongoTemplate; | |
35 | + private CommonService commonService; | |
36 | + private BasicConfigService basicConfigService; | |
37 | + private TrackDownRecordService trackDownRecordService; | |
38 | + public QuanWeightWorker2(List<Patients> patientses, | |
39 | + MongoTemplate mongoTemplate, | |
40 | + CommonService commonService, | |
41 | + BasicConfigService basicConfigService, | |
42 | + TrackDownRecordService trackDownRecordService | |
43 | + ) { | |
44 | + this.patientses = patientses; | |
45 | + this.mongoTemplate = mongoTemplate; | |
46 | + this.commonService = commonService; | |
47 | + this.basicConfigService = basicConfigService; | |
48 | + this.trackDownRecordService = trackDownRecordService; | |
49 | + } | |
50 | + | |
51 | + @Override | |
52 | + public List<Map> call() throws Exception { | |
53 | + List<Map> data = new ArrayList<>(); | |
54 | + for (Patients patients : patientses) | |
55 | + if (StringUtils.isNotEmpty(patients.getId())) { | |
56 | + List<PatientWeight> patientWeightList = mongoTemplate.find(Query.query(Criteria.where("patientId").is(patients.getId()).and("yn").ne("0")), PatientWeight.class); | |
57 | + if (CollectionUtils.isNotEmpty(patientWeightList)) { | |
58 | + PatientWeight patientWeight = patientWeightList.get(0); | |
59 | + if (patientWeight != null && StringUtils.isNotEmpty(patientWeight.getBmi())) { | |
60 | + Map map = new HashMap(); | |
61 | + puliMap(patients, patientWeight, map); | |
62 | + //列表中冗余上追访管理--孕期检查列表id | |
63 | + TrackDownRecordQuery query = new TrackDownRecordQuery(); | |
64 | + query.setParentId(patients.getId()); | |
65 | + List <TrackDownRecord> trackDownRecords = trackDownRecordService.queryTrackDown(query); | |
66 | + if(CollectionUtils.isNotEmpty(trackDownRecords)){ | |
67 | + TrackDownRecord trackDownRecord = trackDownRecords.get(0); | |
68 | + if (StringUtils.isNotEmpty(trackDownRecord.getId())){ | |
69 | + map.put("trackDownRecId", trackDownRecord.getId()); | |
70 | + } | |
71 | + } | |
72 | + data.add(map); | |
73 | + } | |
74 | + | |
75 | + } | |
76 | + } | |
77 | + return data; | |
78 | + } | |
79 | + | |
80 | + private void puliMap(Patients patients, PatientWeight patientWeight, Map map) { | |
81 | + map.put("username", patients.getUsername()); | |
82 | + map.put("age", patients.getAge()); | |
83 | + map.put("phone", patients.getPhone()); | |
84 | + map.put("currentWeek", patients.getType() == 3 ? "已分娩" : DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); | |
85 | + String risk = getRiskFactor(patients.getRiskFactorId()); | |
86 | + if (org.apache.commons.lang.StringUtils.isEmpty(risk)) { | |
87 | + risk = (org.apache.commons.lang.StringUtils.isEmpty(patients.getoRiskFactor()) ? "" : patients.getoRiskFactor()); | |
88 | + } else { | |
89 | + risk = risk + (org.apache.commons.lang.StringUtils.isEmpty(patients.getoRiskFactor()) ? "" : "," + patients.getoRiskFactor()); | |
90 | + } | |
91 | +// String rFactor = commonService.resloveFactor(JsonUtil.toList(patients.getRiskLevelId(), String.class)); | |
92 | + map.put("riskFactor", risk); | |
93 | + map.put("bmi", patientWeight.getBmi()); | |
94 | + map.put("id", patientWeight.getId()); | |
95 | + map.put("beforeHeight", patientWeight.getBeforeHeight()); | |
96 | + map.put("beforeWeight", patientWeight.getBeforeWeight()); | |
97 | + map.put("dayWeights", patientWeight.getDayWeights()); | |
98 | + if (patientWeight.getDayWeights() != null) { | |
99 | + int i = 1; | |
100 | + for (Map.Entry<String, String> entry : patientWeight.getDayWeights().entrySet()) { | |
101 | + String mapKey = entry.getKey(); | |
102 | + String mapValue = entry.getValue(); | |
103 | +// System.out.println(mapKey + "/" + mapValue); | |
104 | + map.put("dayWeights" + i++, mapKey + "/" + mapValue); | |
105 | + } | |
106 | + | |
107 | + } | |
108 | + | |
109 | + map.put("patientId", patients.getId()); | |
110 | + map.put("pid", patients.getPid()); | |
111 | + map.put("cardNo", patients.getCardNo()); | |
112 | + | |
113 | + | |
114 | + } | |
115 | + | |
116 | + public static List filter(List<Map> level) { | |
117 | + List list = new ArrayList(); | |
118 | + List addEdList = new ArrayList(); | |
119 | + if (CollectionUtils.isNotEmpty(level)) { | |
120 | + for (Map map : level) { | |
121 | + if (!addEdList.contains(map.get("name"))) { | |
122 | + list.add(map); | |
123 | + addEdList.add(map.get("name")); | |
124 | + } | |
125 | + } | |
126 | + } | |
127 | + | |
128 | + return list; | |
129 | + } | |
130 | + | |
131 | + | |
132 | + private String getRiskFactor(List<String> list) { | |
133 | + String riskFactor = ""; | |
134 | + if (list != null && list.size() > 0) { | |
135 | + for (String s : list) { | |
136 | + try { | |
137 | + riskFactor += basicConfigService.getOneBasicConfigById(s).getName(); | |
138 | + riskFactor += ","; | |
139 | + } catch (Exception e) { | |
140 | + riskFactor += ""; | |
141 | + } | |
142 | + } | |
143 | + } | |
144 | + if (riskFactor.length() > 0) { | |
145 | + return riskFactor.substring(0, riskFactor.length() - 1); | |
146 | + } | |
147 | + return riskFactor; | |
148 | + } | |
149 | +} |