Commit e861e0365443d5b18d6c87f7e99f9eeea14fe4e9
1 parent
5bc3a44af9
Exists in
master
and in
6 other branches
update
Showing 2 changed files with 53 additions and 1 deletions
platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
View file @
e861e03
... | ... | @@ -229,6 +229,57 @@ |
229 | 229 | // return age.intValue(); |
230 | 230 | return (Math.abs(year1 - year2) + i); |
231 | 231 | } |
232 | + public static Integer getAge2(Date birth,Date date) { | |
233 | + if (null == birth || date==null) { | |
234 | + return null; | |
235 | + } | |
236 | + java.util.Calendar calendar = Calendar.getInstance(); | |
237 | +// Date date = new Date(); | |
238 | + calendar.setTime(date); | |
239 | + | |
240 | + Calendar c1 = Calendar.getInstance(); | |
241 | + Calendar c2 = Calendar.getInstance(); | |
242 | + c1.setTime(date); | |
243 | + c2.setTime(birth); | |
244 | + int year1 = c1.get(Calendar.YEAR); | |
245 | + int year2 = c2.get(Calendar.YEAR); | |
246 | + | |
247 | + int mouth1 = c1.get(Calendar.MONTH);//0当前 | |
248 | + int mouth2 = c2.get(Calendar.MONTH);//4 | |
249 | + int i = 0; | |
250 | + /* if(mouth2-mouth1>=0){ | |
251 | + int days1 = c1.get(Calendar.DAY_OF_MONTH);//当前10 | |
252 | + int days2 = c2.get(Calendar.DAY_OF_MONTH);//1 | |
253 | + if(days1<days2){ | |
254 | + i=i-1; | |
255 | + }else if(days1>days2){ | |
256 | + } | |
257 | + }else if(mouth1-mouth2<0){ | |
258 | + i=i-1; | |
259 | + }*/ | |
260 | + | |
261 | + if (mouth2 == mouth1) { | |
262 | + int days1 = c1.get(Calendar.DAY_OF_MONTH);//当前10 | |
263 | + int days2 = c2.get(Calendar.DAY_OF_MONTH);//1 | |
264 | + if (days1 < days2) { | |
265 | + i = i - 1; | |
266 | + } else if (days1 > days2) { | |
267 | +// i=i-1; | |
268 | + } | |
269 | + } else if (mouth2 > mouth1) { | |
270 | + i = i - 1; | |
271 | + } | |
272 | + | |
273 | + | |
274 | +// if (birth == null) { | |
275 | +// return null; | |
276 | +// } | |
277 | +// Date now = new Date(); | |
278 | +// long m = now.getTime() - birth.getTime(); | |
279 | +// Long age = m / 31536000000L; | |
280 | +// return age.intValue(); | |
281 | + return (Math.abs(year1 - year2) + i); | |
282 | + } | |
232 | 283 | |
233 | 284 | public static Integer getAge(Date birth, Date fmDate) { |
234 | 285 | if (birth == null || null == fmDate) { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ViewFacade.java
View file @
e861e03
... | ... | @@ -3499,7 +3499,7 @@ |
3499 | 3499 | map.put("fmAddr", data.getFmAddr()); |
3500 | 3500 | map.put("username", patients.getUsername()); |
3501 | 3501 | map.put("birth", DateUtil.getyyyy_MM_dd(patients.getBirth())); |
3502 | - map.put("age", UnitUtils.unitSplice(DateUtil.getAge(patients.getBirth()), UnitConstants.SUI)); | |
3502 | +// map.put("age", UnitUtils.unitSplice(DateUtil.getAge(patients.getBirth()), UnitConstants.SUI)); | |
3503 | 3503 | map.put("phone", patients.getPhone()); |
3504 | 3504 | map.put("fmWeek", checkWeek(patients)); |
3505 | 3505 | map.put("dueDate", DateUtil.getyyyy_MM_dd(patients.getDueDate())); |
... | ... | @@ -3991,6 +3991,7 @@ |
3991 | 3991 | } |
3992 | 3992 | babyMap.put("babyId", temp.getId()); |
3993 | 3993 | babyMap.put("dueTime", temp.getDueTime()); |
3994 | + map.put("age", UnitUtils.unitSplice(DateUtil.getAge2(patients.getBirth(),DateUtil.parseYMDHMS(temp.getDueTime())), UnitConstants.SUI)); | |
3994 | 3995 | babyMap.put("pregnancyOut", temp.getPregnancyOut() == null ? "" : RenShenJieJuEnums.getTitle(temp.getPregnancyOut())); |
3995 | 3996 | babyMap.put("deformity", temp.getDeformity() == null ? "" : temp.getDeformity() == 1 ? "是" : "否"); |
3996 | 3997 | babyMap.put("babyGender", temp.getBabyGender() == null ? "" : SexEnum.getTextById( |