Commit 7324b78d84fdd11103bc959218a048beb288decc
1 parent
781c02c89f
Exists in
master
and in
6 other branches
孕期体重异常管理
Showing 4 changed files with 263 additions and 33 deletions
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PuerperaManageController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/RiskPatientsQueryRequest.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanWeightWorker.java
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PuerperaManageController.java
View file @
7324b78
... | ... | @@ -160,20 +160,28 @@ |
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | - * 巨大儿管理 | |
164 | - * | |
163 | + * 孕期体重异常管理 | |
165 | 164 | * @param patientsQueryRequest 全部孕妇管理查询 (因为请求参数一样同用一个对象) |
166 | 165 | * @return 返回结果 |
167 | 166 | */ |
168 | - @RequestMapping(value = "/queryAllMacrosomia", method = RequestMethod.GET) | |
167 | + @RequestMapping(value = "/queryAbnormalWeight", method = RequestMethod.GET) | |
169 | 168 | @ResponseBody |
170 | 169 | @TokenRequired |
171 | - public BaseResponse queryAllMacrosomia(@Valid RiskPatientsQueryRequest patientsQueryRequest, HttpServletRequest request) { | |
170 | + public BaseResponse queryAbnormalWeight(@Valid RiskPatientsQueryRequest patientsQueryRequest, HttpServletRequest request) { | |
172 | 171 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
173 | - | |
174 | - return patientFacade.queryAllMacrosomia(patientsQueryRequest, loginState.getId(), "true"); | |
172 | + return patientFacade.queryAbnormalWeight(patientsQueryRequest, loginState.getId()); | |
175 | 173 | } |
176 | - | |
174 | + /** | |
175 | + * 孕期体重异常管理 导出 | |
176 | + * @Author: 武涛涛 | |
177 | + * @Date: 2021/1/4 14:27 | |
178 | + */ | |
179 | + @RequestMapping(value = "/exportQueryAbnormalWeight", method = RequestMethod.GET) | |
180 | + @TokenRequired | |
181 | + public void exportQueryAbnormalWeight(@Valid RiskPatientsQueryRequest riskPatientsQueryRequest, HttpServletRequest request, HttpServletResponse response) { | |
182 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
183 | + patientFacade.exportQueryAbnormalWeight(riskPatientsQueryRequest, loginState.getId(), response); | |
184 | + } | |
177 | 185 | /** |
178 | 186 | * 双胎全部孕妇管理 |
179 | 187 | * |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
View file @
7324b78
... | ... | @@ -102,6 +102,8 @@ |
102 | 102 | |
103 | 103 | @Autowired |
104 | 104 | private MongoTemplate mongoTemplate; |
105 | + @Autowired | |
106 | + private CommonService commonService; | |
105 | 107 | |
106 | 108 | @Autowired |
107 | 109 | private DischargeAbstractMotherService dischargeAbstractMotherService; |
108 | 110 | |
109 | 111 | |
... | ... | @@ -744,24 +746,12 @@ |
744 | 746 | } |
745 | 747 | |
746 | 748 | /** |
747 | - * 巨大儿管理 | |
748 | - * | |
749 | + * 孕期体重异常管理 | |
749 | 750 | * @param riskPatientsQueryRequest |
750 | 751 | * @return |
751 | 752 | */ |
752 | - public BaseResponse queryAllMacrosomia(RiskPatientsQueryRequest riskPatientsQueryRequest, Integer userId, String needPage) { | |
753 | - /* | |
754 | - 孕期体重异常管理 | |
755 | - 1 数据来全部孕妇管理(本就是人次) | |
756 | - 当前孕周: startDueWeek endDueWeek | |
757 | - 高危等级: rLevel 单个 | |
758 | - 高危因素 rFacotr 多个 | |
753 | + public BaseResponse queryAbnormalWeight(RiskPatientsQueryRequest riskPatientsQueryRequest, Integer userId) { | |
759 | 754 | |
760 | - 2 获取孕期的 lyms_patient_weight 体重数据 | |
761 | - 3 过滤bmi 值 BMI≥25 | |
762 | - 4 获取单条数据,其中单条数据中 dayWeights==测量日期/体重 | |
763 | - */ | |
764 | -// PatientsQuery patientsQuery = complayRequest(riskPatientsQueryRequest, false, 1, userId, needPage,false); | |
765 | 755 | String hospital = autoMatchFacade.getHospitalId(userId); |
766 | 756 | PatientsQuery patientsQuery = new PatientsQuery(); |
767 | 757 | patientsQuery.setYn(YnEnums.YES.getId()); |
768 | 758 | |
769 | 759 | |
770 | 760 | |
771 | 761 | |
772 | 762 | |
773 | 763 | |
774 | 764 | |
... | ... | @@ -772,18 +762,106 @@ |
772 | 762 | patientsQuery.setrFactorList(com.lyms.platform.common.utils.StringUtils.covertToList(riskPatientsQueryRequest.getrFacotr(), String.class)); |
773 | 763 | patientsQuery.setHospitalId(hospital); |
774 | 764 | List <Patients> patientses = patientsService.queryPatientBySort(patientsQuery, riskPatientsQueryRequest.getSort(), riskPatientsQueryRequest.getOrder()); |
765 | + List<Map> data = new ArrayList<>(); | |
766 | + List<String> ids = new ArrayList<>(); | |
775 | 767 | if (CollectionUtils.isNotEmpty(patientses)) { |
768 | + for (Patients patients : patientses) { | |
769 | + if(com.lyms.platform.common.utils.StringUtils.isNotEmpty(patients.getId())){ | |
770 | + List<PatientWeight> patientWeightList = mongoTemplate.find(Query.query(Criteria.where("patientId").is(patients.getId()).and("yn").ne("0")), PatientWeight.class); | |
771 | + if(CollectionUtils.isNotEmpty(patientWeightList)){ | |
772 | + PatientWeight patientWeight = patientWeightList.get(0); | |
773 | + if(patientWeight!=null && com.lyms.platform.common.utils.StringUtils.isNotEmpty(patientWeight.getBmi())){ | |
774 | + double bmid = Double.parseDouble(patientWeight.getBmi()); | |
775 | + if("1".equals(riskPatientsQueryRequest.getBmi())&& (bmid >= 25 && bmid < 28)){ | |
776 | + ids.add(patients.getId()); | |
777 | + }else if("2".equals(riskPatientsQueryRequest.getBmi())&& (bmid >= 28)){ | |
778 | + ids.add(patients.getId()); | |
779 | + }else if(StringUtils.isEmpty(riskPatientsQueryRequest.getBmi()) && bmid > 25){ | |
780 | + ids.add(patients.getId()); | |
781 | + } | |
782 | + } | |
783 | + } | |
776 | 784 | |
777 | - for(Patients p :patientses){ | |
778 | - p.getId(); | |
785 | + } | |
779 | 786 | } |
787 | + //获取bmi大于 25 &筛选bmi条件 | |
788 | + PatientsQuery pq = new PatientsQuery(); | |
789 | + pq.setIds(ids); | |
790 | + pq.setPage(riskPatientsQueryRequest.getPage()); | |
791 | + pq.setLimit(riskPatientsQueryRequest.getLimit()); | |
792 | + List <Patients> ps = patientsService.queryPatientBySort(pq, riskPatientsQueryRequest.getSort(), riskPatientsQueryRequest.getOrder()); | |
793 | + if(CollectionUtils.isNotEmpty(ps)){ | |
794 | + data = convertToQuanWeight(ps); | |
795 | + } | |
796 | + } | |
797 | + return new BaseListResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(data).setPageInfo(patientsQuery.getPageInfo()); | |
798 | + } | |
780 | 799 | |
800 | + public void exportQueryAbnormalWeight(RiskPatientsQueryRequest riskPatientsQueryRequest, Integer id, HttpServletResponse response) { | |
801 | + | |
802 | + try { | |
803 | + BaseListResponse listResponse = (BaseListResponse) queryAbnormalWeight(riskPatientsQueryRequest, id); | |
804 | + | |
805 | + List<Map> list = listResponse.getData(); | |
806 | + List<Map<String, Object>> datas = new ArrayList<>(); | |
807 | + | |
808 | + if (CollectionUtils.isNotEmpty(list)) { | |
809 | + for (Map map : list) { | |
810 | + Map m = new HashMap <>(); | |
811 | + m.put("username", map.get("username")); | |
812 | + m.put("age", map.get("age")); | |
813 | + m.put("phone", map.get("phone")); | |
814 | + m.put("currentWeek", map.get("currentWeek")); | |
815 | + m.put("riskFactor", map.get("riskFactor")); | |
816 | + m.put("bmi", map.get("bmi")); | |
817 | + m.put("beforeHeight", map.get("beforeHeight")); | |
818 | + m.put("beforeWeight", map.get("beforeWeight")); | |
819 | + Map<String, String> dayWeights = (Map<String, String>)map.get("dayWeights"); | |
820 | + List <String> stringList = new ArrayList <>(); | |
821 | + for(Map.Entry<String, String> entry : dayWeights.entrySet()){ | |
822 | + if(StringUtils.isNotEmpty(entry.getKey()) && StringUtils.isNotEmpty(entry.getValue())){ | |
823 | + String mapKey = entry.getKey(); | |
824 | + String mapValue = entry.getValue(); | |
825 | + stringList.add(mapKey + " / " + mapValue); | |
826 | + } | |
827 | + } | |
828 | + for (int i = 0; i <= 20 ; i++) { | |
829 | + if(i >= stringList.size()){ | |
830 | + m.put("dayWeight"+i,""); | |
831 | + }else { | |
832 | + m.put("dayWeight"+i, stringList.get(i)); | |
833 | + } | |
834 | + } | |
835 | + datas.add(m); | |
836 | + } | |
837 | + } | |
838 | + OutputStream out = response.getOutputStream(); | |
839 | + Map<String, String> cnames = new LinkedHashMap<>(); | |
840 | + cnamesMap(cnames); | |
841 | + response.setContentType("application/octet-stream"); | |
842 | + response.setCharacterEncoding("UTF-8"); | |
843 | + response.setHeader("Content-Disposition", "attachment;fileName=" + "孕期体重异常管理.xls"); | |
844 | + ExcelUtil.toExcel(out, datas, cnames); | |
845 | + } catch (Exception e) { | |
846 | + e.printStackTrace(); | |
847 | + ExceptionUtils.catchException(e, "孕期体重异常管理导出异常"); | |
781 | 848 | } |
782 | - List data = new ArrayList<QuanChanResult>(); | |
783 | - data = convertToQuanPatient(patientses, userId, hospital); | |
784 | 849 | |
850 | + } | |
785 | 851 | |
786 | - return new BaseListResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(data).setPageInfo(patientsQuery.getPageInfo()); | |
852 | + | |
853 | + private void cnamesMap(Map<String, String> cnames) { | |
854 | + cnames.put("username", "姓名"); | |
855 | + cnames.put("age", "年龄"); | |
856 | + cnames.put("phone", "手机号"); | |
857 | + cnames.put("currentWeek", "当前孕周"); | |
858 | + cnames.put("riskFactor", "高危因素"); | |
859 | + cnames.put("bmi", "BMI指数"); | |
860 | + cnames.put("beforeHeight", "身高"); | |
861 | + cnames.put("beforeWeight", "孕前体重"); | |
862 | + for (int i = 0; i <= 20 ; i++) { | |
863 | + cnames.put("dayWeight"+i,"测量日期/体重"+i); | |
864 | + } | |
787 | 865 | } |
788 | 866 | |
789 | 867 | /** |
... | ... | @@ -1254,6 +1332,27 @@ |
1254 | 1332 | data.addAll((List) f.get(30, TimeUnit.SECONDS)); |
1255 | 1333 | } catch (Exception e) { |
1256 | 1334 | ExceptionUtils.catchException(e, "convertToQuanPatient get result Future error."); |
1335 | + } | |
1336 | + } | |
1337 | + return data; | |
1338 | + } | |
1339 | + private List<Map> convertToQuanWeight(List<Patients> patientses) { | |
1340 | + List<Map> data = new ArrayList<>(); | |
1341 | + int batchSize = 4; | |
1342 | + int end = 0; | |
1343 | + List<Future> listFuture = new ArrayList<>(); | |
1344 | + for (int i = 0; i < patientses.size(); i += batchSize) { | |
1345 | + end = (end + batchSize); | |
1346 | + if (end > patientses.size()) { | |
1347 | + end = patientses.size(); | |
1348 | + } | |
1349 | + listFuture.add(commonThreadPool.submit(new QuanWeightWorker(patientses.subList(i, end),mongoTemplate,commonService,basicConfigService))); | |
1350 | + } | |
1351 | + for (Future f : listFuture) { | |
1352 | + try { | |
1353 | + data.addAll(( List<Map>) f.get(30, TimeUnit.SECONDS)); | |
1354 | + } catch (Exception e) { | |
1355 | + ExceptionUtils.catchException(e, "convertToQuanWeight get result Future error."); | |
1257 | 1356 | } |
1258 | 1357 | } |
1259 | 1358 | return data; |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/RiskPatientsQueryRequest.java
View file @
7324b78
... | ... | @@ -15,8 +15,8 @@ |
15 | 15 | */ |
16 | 16 | @Form |
17 | 17 | public class RiskPatientsQueryRequest extends BasePageQueryRequest { |
18 | - //巨大儿使用 bim | |
19 | - private String bim; | |
18 | + //巨大儿使用 BMI:⭕ 1 〇25≤BMI<28 、 2 〇BMI≥28 | |
19 | + private String bmi; | |
20 | 20 | |
21 | 21 | //判断定制机构 lp滦平 |
22 | 22 | private String hstart; |
23 | 23 | |
... | ... | @@ -374,12 +374,12 @@ |
374 | 374 | this.liveType = liveType; |
375 | 375 | } |
376 | 376 | |
377 | - public String getBim() { | |
378 | - return bim; | |
377 | + public String getBmi() { | |
378 | + return bmi; | |
379 | 379 | } |
380 | 380 | |
381 | - public void setBim(String bim) { | |
382 | - this.bim = bim; | |
381 | + public void setBmi(String bmi) { | |
382 | + this.bmi = bmi; | |
383 | 383 | } |
384 | 384 | |
385 | 385 | //分娩年龄 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanWeightWorker.java
View file @
7324b78
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.enums.YnEnums; | |
6 | +import com.lyms.platform.common.utils.DateUtil; | |
7 | +import com.lyms.platform.operate.web.facade.PatientFacade; | |
8 | +import com.lyms.platform.pojo.PatientWeight; | |
9 | +import com.lyms.platform.pojo.Patients; | |
10 | +import com.lyms.platform.query.AntExChuQuery; | |
11 | +import com.lyms.platform.query.AntExQuery; | |
12 | +import org.apache.commons.collections.CollectionUtils; | |
13 | +import org.slf4j.Logger; | |
14 | +import org.slf4j.LoggerFactory; | |
15 | +import org.springframework.data.mongodb.core.MongoTemplate; | |
16 | +import org.springframework.data.mongodb.core.query.Criteria; | |
17 | +import org.springframework.data.mongodb.core.query.Query; | |
18 | + | |
19 | +import java.util.*; | |
20 | +import java.util.concurrent.Callable; | |
21 | + | |
22 | +/** | |
23 | + * @Author: 武涛涛 | |
24 | + * @Date: 2021/1/4 9:28 | |
25 | + */ | |
26 | +public class QuanWeightWorker implements Callable<List<Map>> { | |
27 | + | |
28 | + private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class); | |
29 | + | |
30 | + private List<Patients> patientses; | |
31 | + private MongoTemplate mongoTemplate; | |
32 | + private CommonService commonService; | |
33 | + private BasicConfigService basicConfigService; | |
34 | + public QuanWeightWorker(List<Patients> patientses, | |
35 | + MongoTemplate mongoTemplate, | |
36 | + CommonService commonService, | |
37 | + BasicConfigService basicConfigService | |
38 | + ) { | |
39 | + this.patientses = patientses; | |
40 | + this.mongoTemplate = mongoTemplate; | |
41 | + this.commonService = commonService; | |
42 | + this.basicConfigService = basicConfigService; | |
43 | + } | |
44 | + | |
45 | + @Override | |
46 | + public List<Map> call() throws Exception { | |
47 | + List<Map> data = new ArrayList<>(); | |
48 | + AntExQuery antExQuery = new AntExQuery(); | |
49 | + antExQuery.setYn(YnEnums.YES.getId()); | |
50 | + AntExChuQuery antExChuQuery1 = new AntExChuQuery(); | |
51 | + | |
52 | + antExChuQuery1.setYn(YnEnums.YES.getId()); | |
53 | + for (Patients patients : patientses) { | |
54 | + if(com.lyms.platform.common.utils.StringUtils.isNotEmpty(patients.getId())){ | |
55 | + List<PatientWeight> patientWeightList = mongoTemplate.find(Query.query(Criteria.where("patientId").is(patients.getId()).and("yn").ne("0")), PatientWeight.class); | |
56 | + if(CollectionUtils.isNotEmpty(patientWeightList)){ | |
57 | + PatientWeight patientWeight = patientWeightList.get(0); | |
58 | + if(patientWeight!=null && com.lyms.platform.common.utils.StringUtils.isNotEmpty(patientWeight.getBmi())){ | |
59 | + double bmid = Double.parseDouble(patientWeight.getBmi()); | |
60 | + Map map = new HashMap(); | |
61 | + map.put("username", patients.getUsername()); | |
62 | + map.put("age", patients.getAge()); | |
63 | + map.put("phone", patients.getPhone()); | |
64 | + map.put("currentWeek", patients.getType() == 3 ? "已分娩" : DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); | |
65 | + String risk =getRiskFactor(patients.getRiskFactorId()); | |
66 | + if(org.apache.commons.lang.StringUtils.isEmpty(risk)){ | |
67 | + risk=(org.apache.commons.lang.StringUtils.isEmpty(patients.getoRiskFactor())?"":patients.getoRiskFactor()); | |
68 | + }else{ | |
69 | + risk=risk+(org.apache.commons.lang.StringUtils.isEmpty(patients.getoRiskFactor())?"":","+patients.getoRiskFactor()); | |
70 | + } | |
71 | +// String rFactor = commonService.resloveFactor(JsonUtil.toList(patients.getRiskLevelId(), String.class)); | |
72 | + map.put("riskFactor",risk); | |
73 | + map.put("bmi", patientWeight.getBmi()); | |
74 | + map.put("beforeHeight", patientWeight.getBeforeHeight()); | |
75 | + map.put("beforeWeight", patientWeight.getBeforeWeight()); | |
76 | + map.put("dayWeights",patientWeight.getDayWeights()); | |
77 | + | |
78 | + | |
79 | + map.put("patientId", patients.getId()); | |
80 | + map.put("pid", patients.getPid()); | |
81 | + map.put("cardNo", patients.getCardNo()); | |
82 | + data.add(map); | |
83 | + } | |
84 | + | |
85 | + } | |
86 | + } | |
87 | + } | |
88 | + return data; | |
89 | + } | |
90 | + public static List filter(List<java.util.Map> level){ | |
91 | + List list = new ArrayList(); | |
92 | + List addEdList = new ArrayList(); | |
93 | + if(CollectionUtils.isNotEmpty(level)){ | |
94 | + for(java.util.Map map :level){ | |
95 | + if(!addEdList.contains(map.get("name"))){ | |
96 | + list.add(map); | |
97 | + addEdList.add(map.get("name")); | |
98 | + } | |
99 | + } | |
100 | + } | |
101 | + | |
102 | + return list; | |
103 | + } | |
104 | + | |
105 | + | |
106 | + private String getRiskFactor(List<String> list) { | |
107 | + String riskFactor = ""; | |
108 | + if (list != null && list.size() > 0) { | |
109 | + for (String s : list) { | |
110 | + try { | |
111 | + riskFactor += basicConfigService.getOneBasicConfigById(s).getName(); | |
112 | + riskFactor += ","; | |
113 | + } catch (Exception e) { | |
114 | + riskFactor += ""; | |
115 | + } | |
116 | + } | |
117 | + } | |
118 | + if (riskFactor.length() > 0) { | |
119 | + return riskFactor.substring(0, riskFactor.length() - 1); | |
120 | + } | |
121 | + return riskFactor; | |
122 | + } | |
123 | +} |