Commit 89dfd406c8508bc90f0d93b4af54d686333cc115
1 parent
718f849755
Exists in
master
and in
6 other branches
体重管理相关代码
Showing 2 changed files with 24 additions and 4 deletions
platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
View file @
89dfd40
... | ... | @@ -1071,6 +1071,19 @@ |
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | /** |
1074 | + * 把传入的时间 格式化为 只有年月日的时间 | |
1075 | + * @param date | |
1076 | + * @return | |
1077 | + */ | |
1078 | + public static void formatYmd(Date date){ | |
1079 | + try { | |
1080 | + date.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(y_m_d.format(date)).getTime()); | |
1081 | + } catch (Exception e) { | |
1082 | + e.printStackTrace(); | |
1083 | + } | |
1084 | + } | |
1085 | + | |
1086 | + /** | |
1074 | 1087 | * 获取当前时间加上多少周的时间 |
1075 | 1088 | * @param week |
1076 | 1089 | * @return |
1077 | 1090 | |
... | ... | @@ -1159,13 +1172,19 @@ |
1159 | 1172 | |
1160 | 1173 | /** |
1161 | 1174 | * 获取几年之前的日期 |
1175 | + * 主要用于年龄查询 | |
1176 | + * Date start = DateUtil.getBeforeAge(age); | |
1177 | + Date end = DateUtil.getBeforeAge(age + 1); | |
1178 | + pCriteria.and("birth").gte(end).lt(start); | |
1162 | 1179 | * @param age |
1163 | 1180 | * @return |
1164 | 1181 | */ |
1165 | 1182 | public static Date getBeforeAge(Integer age) { |
1166 | 1183 | Calendar c = Calendar.getInstance(); |
1167 | 1184 | c.add(Calendar.YEAR, -age); |
1168 | - return c.getTime(); | |
1185 | + Date time = c.getTime(); | |
1186 | + formatYmd(time); | |
1187 | + return time; | |
1169 | 1188 | } |
1170 | 1189 | |
1171 | 1190 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java
View file @
89dfd40
... | ... | @@ -125,9 +125,9 @@ |
125 | 125 | pCriteria.and("lastMenses").gt(start).lte(end); |
126 | 126 | } |
127 | 127 | if(age != null) { |
128 | - Date start = DateUtil.getBeforeAge(1); | |
129 | - Date end = DateUtil.getBeforeAge(2); | |
130 | - pCriteria.and("birth").lte(start).gt(end); | |
128 | + Date start = DateUtil.getBeforeAge(age); | |
129 | + Date end = DateUtil.getBeforeAge(age + 1); | |
130 | + pCriteria.and("birth").gte(end).lt(start); | |
131 | 131 | } |
132 | 132 | List<Patients> patients = mongoTemplate.find(Query.query(pCriteria), Patients.class); |
133 | 133 | List<String> ids = new ArrayList<>(); |
... | ... | @@ -287,6 +287,7 @@ |
287 | 287 | |
288 | 288 | if(StringUtils.isEmpty(patientWeight.getId()) && patients != null) { |
289 | 289 | patientWeight.setCreated(new Date()); |
290 | + patientWeight.setHospitalId(patients.getHospitalId()); | |
290 | 291 | if(StringUtils.isNotBlank(patientWeight.getPatientId())) { |
291 | 292 | weights.put(DateUtil.getWeek(patients.getLastMenses(), new Date()), nowWeight); |
292 | 293 | patientWeight.setWeights(weights); |