Commit d2c7da3b0c6bec87be2c20cb5e00c16bba7e46b5
1 parent
ff68f37af4
Exists in
master
and in
6 other branches
全部孕妇管理增加按照排序
Showing 1 changed file with 160 additions and 0 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/TempFacade.java
View file @
d2c7da3
1 | +package com.lyms.platform.operate.web.facade; | |
2 | + | |
3 | +import com.lyms.platform.biz.service.PatientsService; | |
4 | +import com.lyms.platform.biz.service.TempService; | |
5 | +import com.lyms.platform.common.base.ContextHolder; | |
6 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
7 | +import com.lyms.platform.common.enums.YnEnums; | |
8 | +import com.lyms.platform.common.result.BaseListResponse; | |
9 | +import com.lyms.platform.common.result.BaseResponse; | |
10 | +import com.lyms.platform.common.utils.Assert; | |
11 | +import com.lyms.platform.common.utils.DateUtil; | |
12 | +import com.lyms.platform.operate.web.request.TempAddRequest; | |
13 | +import com.lyms.platform.operate.web.request.TempQueryRequest; | |
14 | +import com.lyms.platform.operate.web.utils.MongoUtil; | |
15 | +import com.lyms.platform.pojo.Patients; | |
16 | +import com.lyms.platform.pojo.TempModel; | |
17 | +import com.lyms.platform.query.PatientsQuery; | |
18 | +import com.lyms.platform.query.TempQuery; | |
19 | +import org.apache.commons.collections.CollectionUtils; | |
20 | +import org.apache.commons.lang.StringUtils; | |
21 | +import org.apache.commons.lang.math.NumberUtils; | |
22 | +import org.slf4j.Logger; | |
23 | +import org.slf4j.LoggerFactory; | |
24 | +import org.springframework.beans.factory.annotation.Autowired; | |
25 | +import org.springframework.stereotype.Component; | |
26 | + | |
27 | +import java.util.*; | |
28 | + | |
29 | + | |
30 | +/** | |
31 | + * 体温门面操作类 | |
32 | + * <p/> | |
33 | + * 详细描述 | |
34 | + * <p/> | |
35 | + * 示例代码 | |
36 | + * <pre> | |
37 | + * </pre/> | |
38 | + * | |
39 | + * @author JIAZHI.JIANG | |
40 | + * @version BME V100R001 2017-11-28 15:36 | |
41 | + * @since BME V100R001C40B104 | |
42 | + */ | |
43 | +@Component | |
44 | +public class TempFacade { | |
45 | + | |
46 | + //日志调测器 | |
47 | + private static final Logger logger = LoggerFactory.getLogger(TempFacade.class); | |
48 | + | |
49 | + @Autowired | |
50 | + private TempService tempService; | |
51 | + @Autowired | |
52 | + private AutoMatchFacade autoMatchFacade; | |
53 | + @Autowired | |
54 | + private PatientsService patientsService; | |
55 | + @Autowired | |
56 | + private MongoUtil mongoUtil; | |
57 | + | |
58 | + public BaseResponse addOrUpdateOneTemp(TempAddRequest addRequest,Integer userId) { | |
59 | + Assert.notNull(addRequest, "请求为空."); | |
60 | + String hospital =autoMatchFacade.getHospitalId(userId); | |
61 | + String parentId=mongoUtil.doHidePatient(addRequest.getParentId(), hospital); | |
62 | + addRequest.setParentId(parentId); | |
63 | + TempQuery tempQuery = new TempQuery(); | |
64 | + tempQuery.setYn(YnEnums.YES.getId()); | |
65 | + tempQuery.setParentId(addRequest.getParentId()); | |
66 | + | |
67 | + ArrayList list = new ArrayList(); | |
68 | + list.add(hospital); | |
69 | + tempQuery.setHospitalList(list); | |
70 | + TempModel tempModel = addRequest.convertToDataModel(); | |
71 | + | |
72 | + tempModel.setOperator(userId+""); | |
73 | + tempModel.sethId(hospital); | |
74 | + | |
75 | + List<TempModel> temp = tempService.queryTemp(tempQuery); | |
76 | + if (CollectionUtils.isNotEmpty(temp)) { | |
77 | + LinkedHashMap<String,Double> data =temp.get(0).getTempList(); | |
78 | + if(null==data){ | |
79 | + data =new LinkedHashMap<String,Double>(); | |
80 | + } | |
81 | + data.put(DateUtil.getYyyyMmDd(new Date()),Double.valueOf(addRequest.getTemp())); | |
82 | + temp.get(0).setTempList(data); | |
83 | + tempService.update(temp.get(0), temp.get(0).getId()); | |
84 | + } else { | |
85 | + LinkedHashMap<String,Double> data =new LinkedHashMap<>(); | |
86 | + data.put(DateUtil.getYyyyMmDd(new Date()),Double.valueOf(addRequest.getTemp())); | |
87 | + tempModel.setTempList(data); | |
88 | + tempService.addOneTemp(tempModel); | |
89 | + } | |
90 | + return new BaseResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS); | |
91 | + } | |
92 | + | |
93 | + public BaseResponse findTempDataList(TempQueryRequest queryRequest,Integer userId) { | |
94 | + | |
95 | + String hospital = autoMatchFacade.getHospitalId(userId); | |
96 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
97 | + patientsQuery.setCardNo(queryRequest.getCardNo()); | |
98 | + patientsQuery.setVcCardNo(queryRequest.getVcCardNo()); | |
99 | + patientsQuery.setHospitalId(hospital); | |
100 | + patientsQuery.setLastMensesStart(queryRequest.capEnd()); | |
101 | + patientsQuery.setLastMensesEnd(queryRequest.capStart()); | |
102 | + | |
103 | + Date currentDate = DateUtil.formatDate(new Date()); | |
104 | + if (null != queryRequest.getStartAge()) { | |
105 | + Date date = DateUtil.addYear(currentDate, -queryRequest.getStartAge()); | |
106 | + patientsQuery.setBirthEnd(date); | |
107 | + } | |
108 | + if (null != queryRequest.getEndAge()) { | |
109 | + Date date = DateUtil.addYear(currentDate, -queryRequest.getEndAge()); | |
110 | + date = DateUtil.addYear(date, -1); | |
111 | + | |
112 | + patientsQuery.setBirthStart(DateUtil.addDay(date, 1)); | |
113 | + } | |
114 | + | |
115 | + List<Patients> patientses = patientsService.queryPatient(patientsQuery); | |
116 | + if (CollectionUtils.isEmpty(patientses)) { | |
117 | + return new BaseListResponse().setData(new ArrayList()).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); | |
118 | + } | |
119 | + List<String> pids= new ArrayList<>(); | |
120 | + for(Patients patients:patientses){ | |
121 | + if(StringUtils.isNotEmpty(patients.getPid())){ | |
122 | + pids.add(patients.getPid()); | |
123 | + } | |
124 | + } | |
125 | + | |
126 | + TempQuery tempQuery = new TempQuery(); | |
127 | + tempQuery.setYn(YnEnums.YES.getId()); | |
128 | + tempQuery.setpIds(pids); | |
129 | + tempQuery.setPage(queryRequest.getPage()); | |
130 | + tempQuery.setLimit(queryRequest.getLimit()); | |
131 | + tempQuery.setNeed("1"); | |
132 | + | |
133 | + ArrayList list = new ArrayList(); | |
134 | + list.add(hospital); | |
135 | + tempQuery.setHospitalList(list); | |
136 | + | |
137 | + List<TempModel> temp = tempService.queryTemp(tempQuery); | |
138 | + List dataList =new ArrayList(); | |
139 | + if(CollectionUtils.isNotEmpty(temp)){ | |
140 | + for(TempModel tmp:temp){ | |
141 | + if(StringUtils.isNotEmpty(tmp.getParentId())){ | |
142 | + Patients patients =patientsService.findOnePatientById(tmp.getParentId()); | |
143 | + if(patients != null) { | |
144 | + Map<String, Object> data = new LinkedHashMap<>(); | |
145 | + data.put("id", tmp.getId()); | |
146 | + data.put("username", patients.getUsername()); | |
147 | + data.put("age", DateUtil.getAge(patients.getBirth())); | |
148 | + data.put("week", DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); | |
149 | + data.put("temp", tmp.getTempList()); | |
150 | + data.put("patientId", patients.getId()); | |
151 | + data.put("vcCardNo", patients.getVcCardNo()); | |
152 | + data.put("cardNo", patients.getCardNo()); | |
153 | + dataList.add(data); | |
154 | + } | |
155 | + } | |
156 | + } | |
157 | + } | |
158 | + return new BaseListResponse().setData(dataList).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); | |
159 | + } | |
160 | +} |