Commit 1d38f610633d86dc2ba857f9442f0b336e1e7008
1 parent
222ff4b6f3
Exists in
master
and in
6 other branches
改部分逻辑
Showing 7 changed files with 221 additions and 6 deletions
- platform-common/src/main/java/com/lyms/platform/common/enums/ErrorPatientEnums.java
- platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/AreaCountController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RemoteController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AreaCountFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/RemoteFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodPressureServiceImpl.java
platform-common/src/main/java/com/lyms/platform/common/enums/ErrorPatientEnums.java
View file @
1d38f61
1 | +package com.lyms.platform.common.enums; | |
2 | + | |
3 | +/** | |
4 | + * 健康异常孕妇 | |
5 | + */ | |
6 | +public enum ErrorPatientEnums { | |
7 | + | |
8 | + PATIENT_WEIGHT(1), | |
9 | + TEMP(2), | |
10 | + BLOOD_PRESSURE(3), | |
11 | + BLOOD_SUGAR(4); | |
12 | + | |
13 | + ErrorPatientEnums(Integer id) { | |
14 | + this.id = id; | |
15 | + } | |
16 | + | |
17 | + private Integer id; | |
18 | + public Integer getId() { | |
19 | + return id; | |
20 | + } | |
21 | + | |
22 | + public void setId(Integer id) { | |
23 | + this.id = id; | |
24 | + } | |
25 | + | |
26 | +} |
platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
View file @
1d38f61
... | ... | @@ -1388,6 +1388,17 @@ |
1388 | 1388 | return restList; |
1389 | 1389 | } |
1390 | 1390 | |
1391 | + | |
1392 | + /** | |
1393 | + * 获取昨天五点的时间 | |
1394 | + * @return | |
1395 | + */ | |
1396 | + public static Date getYesterday() { | |
1397 | + Calendar calendar = Calendar.getInstance(); | |
1398 | + calendar.add(Calendar.DAY_OF_MONTH, -1); | |
1399 | + return getYmdDate(calendar.getTime()); | |
1400 | + } | |
1401 | + | |
1391 | 1402 | public static void main(String[] args) { |
1392 | 1403 | /* List<Map<String, Date>> monthBetween = getRange(parseYMD("2017-1-11"), parseYMD("2017-3-11")); |
1393 | 1404 | for (Map<String, Date> map : monthBetween) { |
... | ... | @@ -1397,6 +1408,7 @@ |
1397 | 1408 | }*/ |
1398 | 1409 | |
1399 | 1410 | Date date = parseDate("2017-11-30"); |
1411 | + System.out.println(getYesterday().toLocaleString()); | |
1400 | 1412 | System.out.println("当月第一天: " + getMonthDay(date, 0, 1).toLocaleString()); |
1401 | 1413 | System.out.println("当月最后一天: " + getMonthDay(date, 0, 0).toLocaleString()); |
1402 | 1414 | System.out.println("上月第一天: " + getMonthDay(date, -1, 1).toLocaleString()); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/AreaCountController.java
View file @
1d38f61
... | ... | @@ -24,6 +24,13 @@ |
24 | 24 | @Autowired |
25 | 25 | private AreaCountFacade areaCountFacade; |
26 | 26 | |
27 | + @ResponseBody | |
28 | + @RequestMapping(value = "/area/{id}", method = RequestMethod.GET) | |
29 | + public BaseResponse getAreaName(@PathVariable String id) { | |
30 | + return areaCountFacade.getAreaName(id); | |
31 | + } | |
32 | + | |
33 | + | |
27 | 34 | @RequestMapping(value = "/area/childs", method = RequestMethod.GET) |
28 | 35 | @ResponseBody |
29 | 36 | public BaseResponse getAreaChilds(@RequestParam String provinceName, String cityName, String areaName) { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RemoteController.java
View file @
1d38f61
... | ... | @@ -6,13 +6,12 @@ |
6 | 6 | import com.lyms.platform.common.base.BaseController; |
7 | 7 | import com.lyms.platform.common.base.LoginContext; |
8 | 8 | import com.lyms.platform.common.enums.YnEnums; |
9 | -import com.lyms.platform.common.result.BaseResponse; | |
10 | 9 | import com.lyms.platform.common.utils.JsonUtil; |
11 | 10 | import com.lyms.platform.common.utils.MessageUtil; |
12 | 11 | import com.lyms.platform.common.utils.PropertiesUtils; |
13 | 12 | import com.lyms.platform.common.utils.StringUtils; |
14 | 13 | import com.lyms.platform.operate.web.facade.AutoMatchFacade; |
15 | -import com.lyms.platform.operate.web.facade.PatientFacade; | |
14 | +import com.lyms.platform.operate.web.facade.RemoteFacade; | |
16 | 15 | import com.lyms.platform.pojo.ArchiveData; |
17 | 16 | import com.lyms.platform.pojo.Patients; |
18 | 17 | import com.lyms.platform.query.ArchiveDataQuery; |
... | ... | @@ -21,9 +20,7 @@ |
21 | 20 | import org.apache.commons.httpclient.HttpClient; |
22 | 21 | import org.springframework.beans.factory.annotation.Autowired; |
23 | 22 | import org.springframework.stereotype.Controller; |
24 | -import org.springframework.web.bind.annotation.RequestMapping; | |
25 | -import org.springframework.web.bind.annotation.RequestMethod; | |
26 | -import org.springframework.web.bind.annotation.RequestParam; | |
23 | +import org.springframework.web.bind.annotation.*; | |
27 | 24 | |
28 | 25 | import javax.servlet.http.HttpServletRequest; |
29 | 26 | import javax.servlet.http.HttpServletResponse; |
... | ... | @@ -41,7 +38,6 @@ |
41 | 38 | @Controller |
42 | 39 | public class RemoteController extends BaseController { |
43 | 40 | |
44 | - | |
45 | 41 | @Autowired |
46 | 42 | private PatientsService patientsService; |
47 | 43 | |
48 | 44 | |
... | ... | @@ -51,7 +47,16 @@ |
51 | 47 | @Autowired |
52 | 48 | private AutoMatchFacade autoMatchFacade; |
53 | 49 | |
50 | + @Autowired | |
51 | + private RemoteFacade remoteFacade; | |
52 | + | |
54 | 53 | public static final String center_statistics_url= PropertiesUtils.getPropertyValue("center_statistics_url"); |
54 | + | |
55 | + @ResponseBody | |
56 | + @RequestMapping(value = "/error/fy/list/{operaterId}", method = RequestMethod.GET) | |
57 | + public List<Map<String, Object>> errorYfList(@PathVariable String operaterId) { | |
58 | + return remoteFacade.errorYfList(operaterId); | |
59 | + } | |
55 | 60 | |
56 | 61 | @RequestMapping(value = "/bookArchive",method = RequestMethod.GET) |
57 | 62 | public void queryBookArchive(HttpServletResponse response, String idCard, String hospitalId,String cardNum,String phone) { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AreaCountFacade.java
View file @
1d38f61
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/RemoteFacade.java
View file @
1d38f61
1 | +package com.lyms.platform.operate.web.facade; | |
2 | + | |
3 | +import com.lyms.platform.common.enums.ErrorPatientEnums; | |
4 | +import com.lyms.platform.common.utils.DateUtil; | |
5 | +import com.lyms.platform.operate.web.utils.MathUtil; | |
6 | +import com.lyms.platform.pojo.BloodPressure; | |
7 | +import com.lyms.platform.pojo.PatientWeight; | |
8 | +import com.lyms.platform.pojo.Patients; | |
9 | +import com.lyms.platform.pojo.TempModel; | |
10 | +import org.apache.commons.collections.MapUtils; | |
11 | +import org.apache.commons.lang.StringUtils; | |
12 | +import org.springframework.beans.factory.annotation.Autowired; | |
13 | +import org.springframework.data.mongodb.core.MongoTemplate; | |
14 | +import org.springframework.data.mongodb.core.query.Criteria; | |
15 | +import org.springframework.data.mongodb.core.query.Query; | |
16 | +import org.springframework.stereotype.Component; | |
17 | + | |
18 | +import java.util.*; | |
19 | + | |
20 | +/** | |
21 | + * Created by lt on 2017/12/4 0004 | |
22 | + */ | |
23 | +@Component | |
24 | +public class RemoteFacade { | |
25 | + | |
26 | + @Autowired | |
27 | + private MongoTemplate mongoTemplate; | |
28 | + | |
29 | + public List<Map<String, Object>> errorYfList(String operaterId) { | |
30 | + Date yesterday = DateUtil.getYesterday(); | |
31 | + List<Map<String, Object>> restList = new ArrayList<>(); | |
32 | + | |
33 | + List<PatientWeight> patientWeights = mongoTemplate.find(Query.query(Criteria.where("operaterId").is(operaterId)), PatientWeight.class); | |
34 | + List<BloodPressure> bloodPressures = mongoTemplate.find(Query.query(Criteria.where("operaterId").is(operaterId)), BloodPressure.class); | |
35 | + List<TempModel> tempModels = mongoTemplate.find(Query.query(Criteria.where("operaterId").is(operaterId)), TempModel.class); | |
36 | + | |
37 | + for (PatientWeight patientWeight : patientWeights) { | |
38 | + Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); | |
39 | + String bmi = patientWeight.getBmi(); | |
40 | + Map<Integer, Double> highMap = new LinkedHashMap<>(); | |
41 | + Map<Integer, Double> lowMap = new LinkedHashMap<>(); | |
42 | + setMapInfo(highMap, lowMap, bmi); | |
43 | + Map<String, String> dayWeights = patientWeight.getDayWeights(); | |
44 | + Map<String, Object> temp = new HashMap<>(); | |
45 | + for (Map.Entry<String, String> entry : dayWeights.entrySet()) { | |
46 | + if(DateUtil.parseYMD(entry.getKey()).getTime() >= yesterday.getTime()) { | |
47 | + Integer week = DateUtil.getWeek2(patients.getLastMenses(), DateUtil.parseYMD(entry.getKey())); | |
48 | + Double addWeight = getAddWeight(patientWeight.getBeforeWeight(), entry.getValue()); | |
49 | + Double low = lowMap.get(week); | |
50 | + Double high = highMap.get(week); | |
51 | + if(addWeight < low || addWeight > high) { | |
52 | + temp.put("username", patients.getUsername()); | |
53 | + temp.put("week", DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); | |
54 | + temp.put("parentId", patientWeight.getPatientId()); | |
55 | + temp.put("id", patientWeight.getId()); | |
56 | + temp.put("day", entry.getKey()); | |
57 | + temp.put("desc", addWeight < low ? "增重过少" : "增重过多"); | |
58 | + temp.put("beforeWeight", patientWeight.getBeforeWeight()); | |
59 | + temp.put("nowWeight", patientWeight.getNowWeight()); | |
60 | + temp.put("addWeight", addWeight); | |
61 | + temp.put("ckz", "(" + lowMap.get(0) + "~" + highMap.get(0) + ")"); | |
62 | + temp.put("type", ErrorPatientEnums.PATIENT_WEIGHT); | |
63 | + } | |
64 | + } | |
65 | + } | |
66 | + if(MapUtils.isNotEmpty(temp)) { | |
67 | + restList.add(temp); | |
68 | + } | |
69 | + } | |
70 | + | |
71 | + for (TempModel tempModel : tempModels) { | |
72 | + Map<String, Object> temp = new HashMap<>(); | |
73 | + LinkedHashMap<String, Double> tempList = tempModel.getTempList(); | |
74 | + Patients patients = null; | |
75 | + for (Map.Entry<String, Double> entry : tempList.entrySet()) { | |
76 | + if(DateUtil.parseYMD(entry.getKey()).getTime() >= yesterday.getTime()) { | |
77 | + if(entry.getValue() < 36D || entry.getValue() > 38.5D ) { | |
78 | + /* patients = (patients == null ? mongoTemplate.findById(p, Patients.class) : patients); | |
79 | + temp.put("username", patients.getUsername()); | |
80 | + temp.put("week", DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); | |
81 | + temp.put("parentId", patientWeight.getPatientId()); | |
82 | + temp.put("id", patientWeight.getId()); | |
83 | + temp.put("day", entry.getKey()); | |
84 | + temp.put("desc", addWeight < low ? "增重过少" : "增重过多"); | |
85 | + temp.put("beforeWeight", patientWeight.getBeforeWeight()); | |
86 | + temp.put("nowWeight", patientWeight.getNowWeight()); | |
87 | + temp.put("addWeight", addWeight); | |
88 | + temp.put("ckz", "(" + lowMap.get(0) + "~" + highMap.get(0) + ")"); | |
89 | + temp.put("type", ErrorPatientEnums.PATIENT_WEIGHT);*/ | |
90 | + } | |
91 | + } | |
92 | + } | |
93 | + | |
94 | + } | |
95 | + | |
96 | + return restList; | |
97 | + } | |
98 | + | |
99 | + | |
100 | + /** | |
101 | + * 获取两个体重之间相差的数值 | |
102 | + */ | |
103 | + private Double getAddWeight(String before, String now) { | |
104 | + if(StringUtils.isEmpty(before) || StringUtils.isEmpty(now)) { | |
105 | + return 0D; | |
106 | + } | |
107 | + Double b = Double.parseDouble(before); | |
108 | + Double n = Double.parseDouble(now); | |
109 | + return MathUtil.doubleFormat2(n - b); | |
110 | + } | |
111 | + | |
112 | + private void setMapInfo(Map<Integer, Double> highMap, Map<Integer, Double> lowMap, String bmi) { | |
113 | + double low = 0D; | |
114 | + double low2 = 0D; | |
115 | + double high = 0D; | |
116 | + double high2 = 0D; | |
117 | + Double bmiD = 20D; // 小程序和app可能没有bmi 默认返回标准 | |
118 | + if(StringUtils.isNotEmpty(bmi)) { | |
119 | + bmiD = Double.parseDouble(bmi); | |
120 | + } | |
121 | + if(bmiD <= 18.5) { | |
122 | + low = 1.2; | |
123 | + low2 = 11.9; | |
124 | + high = 3.8; | |
125 | + high2 = 18.1; | |
126 | + } else if(bmiD > 18.5 && bmiD <= 24.9){ | |
127 | + low = 1.4; | |
128 | + low2 = 11.9; | |
129 | + high = 3.2; | |
130 | + high2 = 15.9; | |
131 | + } else if(bmiD > 24.9 && bmiD < 30){ | |
132 | + low = 1.1 ; | |
133 | + low2 = 7.1; | |
134 | + high = 3.1; | |
135 | + high2 = 11.6; | |
136 | + } else if(bmiD >= 30){ | |
137 | + low = 0.8 ; | |
138 | + low2 = 4.9; | |
139 | + high = 2.1; | |
140 | + high2 = 8.9; | |
141 | + } | |
142 | + double avg = low / 13; | |
143 | + for (int i = 0; i <= 13; i++) { | |
144 | + lowMap.put(i, i * avg); | |
145 | + } | |
146 | + double avg2 = (low2 - low) / 27; | |
147 | + for (int i = 1; i <= 27; i++) { | |
148 | + lowMap.put(13 + i, low + i * avg2); | |
149 | + } | |
150 | + double highAvg = high / 13; | |
151 | + for (int i = 0; i <= 13; i++) { | |
152 | + highMap.put(i, i * highAvg); | |
153 | + } | |
154 | + double highAvg2 = (high2 - high) / 27; | |
155 | + for (int i = 1; i <= 27; i++) { | |
156 | + highMap.put(13 + i, high + i * highAvg2); | |
157 | + } | |
158 | + } | |
159 | + | |
160 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodPressureServiceImpl.java
View file @
1d38f61
... | ... | @@ -54,6 +54,7 @@ |
54 | 54 | temp.put("pulse", bloodPressure.getPulse()); |
55 | 55 | temp.put("hospitalId", hospitalId); |
56 | 56 | BloodPressure bp = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(bloodPressure.getParentId()).and("yn").ne(0)), BloodPressure.class); |
57 | + bloodPressure.setModified(new Date()); | |
57 | 58 | if(bp == null) { |
58 | 59 | String parentId = mongoUtil.doHidePatient(bloodPressure.getParentId(), hospitalId); |
59 | 60 | bloodPressure.setParentId(parentId); |