diff --git a/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java b/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java index 163c4a9..00a395b 100644 --- a/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java +++ b/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java @@ -9,20 +9,20 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class DateUtil { - private static Lock lock = new ReentrantLock(); + private static Lock lock = new ReentrantLock(); public static SimpleDateFormat dd = new SimpleDateFormat("dd"); public static SimpleDateFormat yyyy = new SimpleDateFormat("yyyy"); public static SimpleDateFormat ymd = new SimpleDateFormat("yyyyMMdd"); public static SimpleDateFormat y_m_d = new SimpleDateFormat("yyyy-MM-dd"); public static SimpleDateFormat y_m = new SimpleDateFormat("yyyy年MM月"); - public static SimpleDateFormat y_m_d1= new SimpleDateFormat("yyyy年MM月dd日"); + public static SimpleDateFormat y_m_d1 = new SimpleDateFormat("yyyy年MM月dd日"); public static SimpleDateFormat md = new SimpleDateFormat("MM-dd"); public static SimpleDateFormat m_d = new SimpleDateFormat("MM/dd"); public static SimpleDateFormat y_m_d_h_m_s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static SimpleDateFormat y_m_d_h_m1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - public static String[] parsePatterns = { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", - "yyyy/MM/dd HH:mm" }; + public static String[] parsePatterns = {"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", + "yyyy/MM/dd HH:mm"}; public static SimpleDateFormat y_m_d_h_m = new SimpleDateFormat("yyyyMMddHHmm"); public static SimpleDateFormat yyyyMMddHHmmssSSS = new SimpleDateFormat("yyyyMMddHHmmssSSS"); @@ -67,13 +67,14 @@ public class DateUtil { /** * 获取传入日期 相加xx月后的第xx天 + * * @param date - * @param addMonth 添加的月份数 当前月=0, 下月=1,上月=-1 - * @param day 第一天传1, 第二天传2,....... 最后一天传0 + * @param addMonth 添加的月份数 当前月=0, 下月=1,上月=-1 + * @param day 第一天传1, 第二天传2,....... 最后一天传0 * @return */ public static Date getMonthDay(Date date, Integer addMonth, Integer day) { - if(date != null && addMonth != null && day != null) { + if (date != null && addMonth != null && day != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.MONTH, day == 0 ? addMonth + 1 : addMonth); @@ -89,7 +90,7 @@ public class DateUtil { */ public static Date getQuartDay(Date date, Integer addQuart, Integer day) { Integer quart = getQuart(date); - if(quart != null && addQuart != null && day != null) { + if (quart != null && addQuart != null && day != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.MONTH, day == 0 ? (quart + addQuart) * 3 : (quart - 1 + addQuart) * 3); @@ -103,8 +104,8 @@ public class DateUtil { * 获取半年的时间 */ public static Date getHalfDay(Date date, Integer addHalt, Integer day) { - if(date != null) { - if(getMonth(date) > 6) { + if (date != null) { + if (getMonth(date) > 6) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.MONTH, day == 0 ? 6 + (addHalt + 1) * 6 : 6 + addHalt * 6); @@ -119,7 +120,7 @@ public class DateUtil { * 获取一年的时间 */ public static Date getYear(Date date, Integer addYear, Integer day) { - if(date != null) { + if (date != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.YEAR, addYear); @@ -133,26 +134,27 @@ public class DateUtil { /** * 1月~3月 4~6 7~9 10~11 * 获取当前时间属于哪个季度 + * * @param date * @return */ public static Integer getQuart(Date date) { - if(date != null) { + if (date != null) { Integer month = getMonth(date); - if(month >= 1 && month <= 3) { + if (month >= 1 && month <= 3) { return 1; - } else if(month >= 4 && month <= 6) { + } else if (month >= 4 && month <= 6) { return 2; - } else if(month >= 7 && month <= 9) { + } else if (month >= 7 && month <= 9) { return 3; - } else if(month >= 10 && month <= 12) { + } else if (month >= 10 && month <= 12) { return 4; } } return null; } - public static Date getYmdDate(Date date){ + public static Date getYmdDate(Date date) { try { date.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(y_m_d.format(date)).getTime()); } catch (Exception e) { @@ -169,11 +171,11 @@ public class DateUtil { } public static Integer getAge(Date birth) { - if(null==birth){ + if (null == birth) { return null; } - java.util.Calendar calendar= Calendar.getInstance(); - Date date=new Date(); + java.util.Calendar calendar = Calendar.getInstance(); + Date date = new Date(); calendar.setTime(date); Calendar c1 = Calendar.getInstance(); @@ -185,7 +187,7 @@ public class DateUtil { int mouth1 = c1.get(Calendar.MONTH);//0当前 int mouth2 = c2.get(Calendar.MONTH);//4 - int i=0; + int i = 0; /* if(mouth2-mouth1>=0){ int days1 = c1.get(Calendar.DAY_OF_MONTH);//当前10 int days2 = c2.get(Calendar.DAY_OF_MONTH);//1 @@ -197,16 +199,16 @@ public class DateUtil { i=i-1; }*/ - if(mouth2==mouth1){ + if (mouth2 == mouth1) { int days1 = c1.get(Calendar.DAY_OF_MONTH);//当前10 int days2 = c2.get(Calendar.DAY_OF_MONTH);//1 - if(days1days2){ + if (days1 < days2) { + i = i - 1; + } else if (days1 > days2) { // i=i-1; } - }else if(mouth2>mouth1){ - i=i-1; + } else if (mouth2 > mouth1) { + i = i - 1; } @@ -217,10 +219,11 @@ public class DateUtil { // long m = now.getTime() - birth.getTime(); // Long age = m / 31536000000L; // return age.intValue(); - return (Math.abs(year1 - year2)+i); + return (Math.abs(year1 - year2) + i); } - public static Integer getAge(Date birth,Date fmDate) { - if (birth == null ||null==fmDate) { + + public static Integer getAge(Date birth, Date fmDate) { + if (birth == null || null == fmDate) { return null; } long m = fmDate.getTime() - birth.getTime(); @@ -321,15 +324,14 @@ public class DateUtil { } } - public static Date getYear() - { + public static Date getYear() { lock.lock(); try { String year = yyyy.format(new Date()); return yyyy.parse(year); } catch (Exception e) { return null; - }finally { + } finally { lock.unlock(); } } @@ -407,7 +409,7 @@ public class DateUtil { return y_m_d.parse(s); } catch (Exception e) { return null; - }finally { + } finally { lock.unlock(); } } @@ -423,7 +425,7 @@ public class DateUtil { return ymd.parse(s); } catch (Exception e) { return null; - }finally { + } finally { lock.unlock(); } } @@ -477,7 +479,7 @@ public class DateUtil { return y_m_d.format(d); } catch (Exception e) { return null; - }finally { + } finally { lock.unlock(); } } @@ -658,7 +660,7 @@ public class DateUtil { rightNow.setTime(srcDate); rightNow.add(Calendar.DAY_OF_YEAR, days); return rightNow.getTime(); - }finally { + } finally { lock.unlock(); } } @@ -670,7 +672,7 @@ public class DateUtil { rightNow.setTime(srcDate); rightNow.add(Calendar.MONTH, month); return rightNow.getTime(); - }finally { + } finally { lock.unlock(); } } @@ -682,7 +684,7 @@ public class DateUtil { rightNow.setTime(srcDate); rightNow.add(Calendar.YEAR, year); return rightNow.getTime(); - }finally { + } finally { lock.unlock(); } } @@ -694,13 +696,12 @@ public class DateUtil { rightNow.setTime(srcDate); rightNow.add(Calendar.WEEK_OF_YEAR, weak); return rightNow.getTime(); - }finally { + } finally { lock.unlock(); } } - /** * 获取当天还剩多少秒 * @@ -718,73 +719,67 @@ public class DateUtil { /** * 计算儿童的月龄 + * * @param birth * @param checkDate * @return */ - public static String getBabyMonthAge(Date birth, Date checkDate) - { - if(birth == null){ + public static String getBabyMonthAge(Date birth, Date checkDate) { + if (birth == null) { return ""; } Calendar rightNow = Calendar.getInstance(); rightNow.setTime(checkDate); - rightNow.add(Calendar.MONTH,-1); - if (birth.getTime() > rightNow.getTime().getTime()) - { - int day = daysBetween(birth,checkDate); - return day+"天"; + rightNow.add(Calendar.MONTH, -1); + if (birth.getTime() > rightNow.getTime().getTime()) { + int day = daysBetween(birth, checkDate); + return day + "天"; } Calendar rightNow1 = Calendar.getInstance(); rightNow1.setTime(checkDate); - rightNow1.add(Calendar.YEAR,-1); + rightNow1.add(Calendar.YEAR, -1); - if (birth.getTime() > rightNow1.getTime().getTime()) - { - int month = getMonthSpace(birth,checkDate); + if (birth.getTime() > rightNow1.getTime().getTime()) { + int month = getMonthSpace(birth, checkDate); Calendar yearNow = Calendar.getInstance(); yearNow.setTime(birth); - yearNow.add(Calendar.MONTH,month); + yearNow.add(Calendar.MONTH, month); - int day = daysBetween(yearNow.getTime(),checkDate); + int day = daysBetween(yearNow.getTime(), checkDate); String dstr = ""; - if (day != 0) - { - dstr=day+"天"; + if (day != 0) { + dstr = day + "天"; } String ms = ""; - if (month != 0) - { - ms = month+"月龄"; + if (month != 0) { + ms = month + "月龄"; } - return ms+dstr; + return ms + dstr; } int year = getYearSpace(birth, checkDate); rightNow.setTime(checkDate); - rightNow.add(Calendar.YEAR,year); + rightNow.add(Calendar.YEAR, year); int month = getMonthSpace1(birth, rightNow.getTime()); - return year+"岁"+ (month == 0 ? "" : month+"月龄"); + return year + "岁" + (month == 0 ? "" : month + "月龄"); } - public static int daysBetween(Date smdate,Date bdate) - { - if (smdate == null || bdate == null) - { + public static int daysBetween(Date smdate, Date bdate) { + if (smdate == null || bdate == null) { return -1; } - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { - smdate=sdf.parse(sdf.format(smdate)); - bdate=sdf.parse(sdf.format(bdate)); + smdate = sdf.parse(sdf.format(smdate)); + bdate = sdf.parse(sdf.format(bdate)); Calendar cal = Calendar.getInstance(); cal.setTime(smdate); long time1 = cal.getTimeInMillis(); cal.setTime(bdate); long time2 = cal.getTimeInMillis(); - long between_days=(time2-time1)/(1000*3600*24); + long between_days = (time2 - time1) / (1000 * 3600 * 24); return Integer.parseInt(String.valueOf(between_days)); } catch (ParseException e) { e.printStackTrace(); @@ -805,21 +800,20 @@ public class DateUtil { c2.setTime(date2); result = c2.get(Calendar.MONDAY) - c1.get(Calendar.MONTH); - if (result <= 0) - { + if (result <= 0) { result = 12 - Math.abs(result); } // result = result == 0 ? 1 : Math.abs(result); - if (Integer.parseInt(getDD(date1)) > Integer.parseInt(getDD(date2))) - { - result = result -1; + if (Integer.parseInt(getDD(date1)) > Integer.parseInt(getDD(date2))) { + result = result - 1; } return result; } - public static int countMonths(Date date1,Date date2) throws ParseException{ + + public static int countMonths(Date date1, Date date2) throws ParseException { /* Calendar c1=Calendar.getInstance(); Calendar c2=Calendar.getInstance(); @@ -836,40 +830,38 @@ public class DateUtil { }*/ // return year*12+c2.get(Calendar.MONTH)-c1.get(Calendar.MONTH); - return 0; + return 0; } - public static int getBabyMonthAge1(Date birth, Date checkDate) - { + + public static int getBabyMonthAge1(Date birth, Date checkDate) { Calendar rightNow = Calendar.getInstance(); rightNow.setTime(checkDate); - rightNow.add(Calendar.MONTH,-1); - if (birth.getTime() > rightNow.getTime().getTime()) - { + rightNow.add(Calendar.MONTH, -1); + if (birth.getTime() > rightNow.getTime().getTime()) { return 0; } Calendar rightNow1 = Calendar.getInstance(); rightNow1.setTime(checkDate); - rightNow1.add(Calendar.YEAR,-1); + rightNow1.add(Calendar.YEAR, -1); - if (birth.getTime() > rightNow1.getTime().getTime()) - { + if (birth.getTime() > rightNow1.getTime().getTime()) { - int month = getMonthSpace(birth,checkDate); + int month = getMonthSpace(birth, checkDate); Calendar yearNow = Calendar.getInstance(); yearNow.setTime(birth); - yearNow.add(Calendar.MONTH,month); + yearNow.add(Calendar.MONTH, month); return month; } int year = getYearSpace(birth, checkDate); rightNow.setTime(checkDate); - rightNow.add(Calendar.YEAR,year); + rightNow.add(Calendar.YEAR, year); int month = getMonthSpace1(birth, rightNow.getTime()); - return year*12+month; + return year * 12 + month; } public static int getMonthSpace1(Date date1, Date date2) { @@ -883,14 +875,12 @@ public class DateUtil { c2.setTime(date2); result = c2.get(Calendar.MONDAY) - c1.get(Calendar.MONTH); - if (result < 0) - { + if (result < 0) { result = 12 - Math.abs(result); } - if (Integer.parseInt(getDD(date1)) > Integer.parseInt(getDD(date2))) - { - result = result -1; + if (Integer.parseInt(getDD(date1)) > Integer.parseInt(getDD(date2))) { + result = result - 1; } return result; @@ -898,7 +888,6 @@ public class DateUtil { } - public static int getYearSpace(Date date1, Date date2) { int result = 0; @@ -909,28 +898,32 @@ public class DateUtil { c2.setTime(date2); result = c2.get(Calendar.YEAR) - c1.get(Calendar.YEAR); - if (Integer.parseInt(getMMdd(date1).split("-")[0]) > Integer.parseInt(getMMdd(date2).split("-")[0])) - { - result = result -1; + if (Integer.parseInt(getMMdd(date1).split("-")[0]) > Integer.parseInt(getMMdd(date2).split("-")[0])) { + result = result - 1; } return result == 0 ? 1 : Math.abs(result); } - - - public static int getBabyAgeMonth(Date d1,Date d2){ - int months=0;//相差月份 - int y1=d1.getYear(); - int y2=d2.getYear(); - int dd1=d1.getDate(); //起始日期天 - int dd2=d2.getDate(); //结束日期天 - if(d1.getTime()= 42) { + if (week >= 42) { return "已分娩"; } return "孕" + week + "周" + (day > 0 ? "+" + day + "天" : ""); @@ -1131,12 +1124,13 @@ public class DateUtil { /** * 获取孕周 * 上面写的有bug 有时候会多一周!!! + * * @param start * @param end * @return */ public static Integer getWeek2(Date start, Date end) { - if(start == null || end == null) { + if (start == null || end == null) { return null; } Integer betweenDay = DateUtil.getDays(start, end); @@ -1146,6 +1140,7 @@ public class DateUtil { /** * 获取两个日期相差几个月 + * * @param start * @param end * @return @@ -1159,7 +1154,7 @@ public class DateUtil { c2.setTime(end); result = c2.get(Calendar.MONTH) - c1.get(Calendar.MONTH); result += 12 * (c2.get(Calendar.YEAR) - c1.get(Calendar.YEAR)); - if(c2.get(Calendar.DAY_OF_MONTH) - c1.get(Calendar.DAY_OF_MONTH) < 0 && result > 0) { + if (c2.get(Calendar.DAY_OF_MONTH) - c1.get(Calendar.DAY_OF_MONTH) < 0 && result > 0) { result -= 1; } } catch (Exception e) { @@ -1171,6 +1166,7 @@ public class DateUtil { /** * 获取两个日期直接的天数(只算最后的天数) * 比如 2017-10-10 2017-11-20 返回 10 + * * @param start * @param end * @return @@ -1185,10 +1181,10 @@ public class DateUtil { int endDay = c2.get(Calendar.DAY_OF_MONTH); int startDay = c1.get(Calendar.DAY_OF_MONTH); - if(endDay >= startDay) { + if (endDay >= startDay) { result = endDay - startDay; } else { /** 获取上个月天数 + endDate天数 - startDate天数 */ - c2.add(Calendar.MONTH,-1);/** 得到上个月的月份 */ + c2.add(Calendar.MONTH, -1);/** 得到上个月的月份 */ result = c2.getActualMaximum(Calendar.DAY_OF_MONTH) + endDay - startDay; } @@ -1199,15 +1195,15 @@ public class DateUtil { } - /** * 获取月龄描述信息 优惠券使用时间 - 分娩时间 + * * @param start * @param end * @return */ public static String getMonthDesc(Date start, Date end) { - if(start == null || end == null) { + if (start == null || end == null) { return "0月龄+0天"; } int month = getMonth(start, end); @@ -1217,6 +1213,7 @@ public class DateUtil { /** * 获取传入日期的月份 + * * @param date * @return */ @@ -1228,9 +1225,10 @@ public class DateUtil { /** * 返回当前时间 只包括年月日 + * * @return */ - public static Date getYMDTime(){ + public static Date getYMDTime() { try { Date now = new SimpleDateFormat("yyyy-MM-dd").parse(getymd()); return now; @@ -1242,10 +1240,11 @@ public class DateUtil { /** * 把传入的时间 格式化为 只有年月日的时间 + * * @param date * @return */ - public static void formatYmd(Date date){ + public static void formatYmd(Date date) { try { date.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(y_m_d.format(date)).getTime()); } catch (Exception e) { @@ -1255,6 +1254,7 @@ public class DateUtil { /** * 获取当前时间加上多少周的时间 + * * @param week * @return */ @@ -1274,6 +1274,7 @@ public class DateUtil { /** * 获取当前时间加上xx月后的年月日时间 + * * @param month * @return */ @@ -1291,10 +1292,10 @@ public class DateUtil { /** * 用于月龄查询 - * - * Date start = DateUtil.getBirthStart(endMonth); - * Date end = DateUtil.getBirthEnd(startMonth); - * criteria.and("birth").gte(start).lt(end); + *

+ * Date start = DateUtil.getBirthStart(endMonth); + * Date end = DateUtil.getBirthEnd(startMonth); + * criteria.and("birth").gte(start).lt(end); * * @param end * @return @@ -1302,16 +1303,17 @@ public class DateUtil { public static Date getBirthStart(Integer end) { return getMonth(-end - 1); } + public static Date getBirthEnd(Integer start) { return addDay(getMonth(-start), 1); } /** * 用于孕周查询 - * - * Date start = DateUtil.getBirthStart(endMonth); - * Date end = DateUtil.getBirthEnd(startMonth); - * criteria.and("birth").gte(start).lt(end); + *

+ * Date start = DateUtil.getBirthStart(endMonth); + * Date end = DateUtil.getBirthEnd(startMonth); + * criteria.and("birth").gte(start).lt(end); * * @param end * @return @@ -1319,16 +1321,18 @@ public class DateUtil { public static Date getWeekStart(Integer end) { return getWeek(-end - 1); } + public static Date getWeekEnd(Integer start) { return getWeek(-start); } /** * 获取xx周的日期 + * * @param week * @return */ - public static Date getWeek(Integer week) { + public static Date getWeek(Integer week) { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); calendar.add(Calendar.WEEK_OF_MONTH, week); @@ -1343,9 +1347,10 @@ public class DateUtil { /** * 获取几年之前的日期 * 主要用于年龄查询 - * Date start = DateUtil.getBeforeAge(age); - Date end = DateUtil.getBeforeAge(age + 1); - pCriteria.and("birth").gt(end).lte(start); + * Date start = DateUtil.getBeforeAge(age); + * Date end = DateUtil.getBeforeAge(age + 1); + * pCriteria.and("birth").gt(end).lte(start); + * * @param age * @return */ @@ -1359,12 +1364,12 @@ public class DateUtil { public static List> getRange(Date start, Date end) { List> restList = new ArrayList<>(); - if(start != null && end != null) { + if (start != null && end != null) { List dates = getMonthBetween(start, end); for (int i = 0; i < dates.size(); i++) { Map temp = new HashMap<>(); temp.put("cname", dates.get(i)); - if(i == 0) { + if (i == 0) { temp.put("start", start); temp.put("end", dates.size() > 1 ? addDay(dates.get(1), -1) : end); } else if (i == dates.size() - 1) { @@ -1382,6 +1387,7 @@ public class DateUtil { /** * 把传进来的日期 设置为当天的最后一秒 + * * @param date */ public static Date getDayLastSecond(Date date) { @@ -1405,7 +1411,7 @@ public class DateUtil { Calendar curr = min; while (curr.before(max)) { result.add(curr.getTime()); - curr.add(Calendar.MONTH, 1); + curr.add(Calendar.MONTH, 1); } return result; } @@ -1442,6 +1448,7 @@ public class DateUtil { /** * 获取昨天五点的时间 + * * @return */ public static Date getYesterday() { @@ -1452,10 +1459,10 @@ public class DateUtil { public static void main(String[] args) { - int i = DateUtil.daysBetween(DateUtil.parseYMD("2018-02-20"),new Date()); + int i = DateUtil.daysBetween(DateUtil.parseYMD("2018-02-20"), new Date()); System.out.println(i); - int week = DateUtil.getWeek2(parseYMD("2017-10-12"),new Date()); + int week = DateUtil.getWeek2(parseYMD("2017-10-12"), new Date()); System.out.println(week); // System.out.println(getDayLastSecond(new Date()).toLocaleString()); // List> monthBetween = getRange(parseYMD("2017-1-11"), parseYMD("2017-12-29")); diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java index 2cb2c08..b2fd5bb 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java @@ -38,6 +38,9 @@ public class BabyCheckFacade { @Autowired private BabyBookbuildingService babyBookbuildingService; + @Autowired + private BabyService babyService; + @Autowired private BasicConfigService basicConfigService; @@ -1675,19 +1678,22 @@ public class BabyCheckFacade { Map map = new HashMap<>(); - List weightTitles = new LinkedList<>(); + List weightTitles = new LinkedList<>(); List weightValues = new LinkedList<>(); - List heightTitles = new LinkedList<>(); + List heightTitles = new LinkedList<>(); List heightValues = new LinkedList<>(); - List> tables = new LinkedList<>(); + List> tables = new LinkedList<>(); + + BabyModel babyModel = babyService.getOneBabyById(babyId); BabyCheckModelQuery query = new BabyCheckModelQuery(); query.setYn(YnEnums.YES.getId()); query.setBuildId(babyId); //查询儿童的检查记录 List checkModels = babyCheckService.queryBabyCheckRecord(query, "checkDate,created", Sort.Direction.ASC); + if (CollectionUtils.isNotEmpty(checkModels)) { for (BabyCheckModel checkModel : checkModels) @@ -1696,15 +1702,21 @@ public class BabyCheckFacade { { if (org.apache.commons.lang.StringUtils.isNotEmpty(checkModel.getHeight()) || org.apache.commons.lang.StringUtils.isNotEmpty(checkModel.getWeight())) { - Map heightMap = new HashMap<>(); + int month = DateUtil.getBabyAgeMonth(babyModel.getBirth(),checkModel.getCheckDate()); + Map heightMap = new HashMap<>(); + heightMap.put("time",month); if (org.apache.commons.lang.StringUtils.isNotEmpty(checkModel.getHeight())) { if (org.apache.commons.lang.StringUtils.isNumeric(checkModel.getHeight()) || Pattern.compile("^[-\\+]?[.\\d]*$").matcher(checkModel.getHeight()).matches()) { - heightTitles.add(DateUtil.getyyyy_MM_dd(checkModel.getCheckDate())); - heightValues.add(checkModel.getHeight()); + if(heightTitles.contains(month)){ + int index = heightTitles.indexOf(month); + heightValues.set(index,checkModel.getHeight()); + }else { + heightTitles.add(month); + heightValues.add(checkModel.getHeight()); + } } - heightMap.put("time",DateUtil.getyyyy_MM_dd(checkModel.getCheckDate())); heightMap.put("height", checkModel.getHeight()); } else @@ -1716,17 +1728,21 @@ public class BabyCheckFacade { { if (org.apache.commons.lang.StringUtils.isNumeric(checkModel.getWeight()) || Pattern.compile("^[-\\+]?[.\\d]*$").matcher(checkModel.getWeight()).matches()) { - weightTitles.add(DateUtil.getyyyy_MM_dd(checkModel.getCheckDate())); - weightValues.add(checkModel.getWeight()); + + if(weightTitles.contains(month)){//如果存在月的数据则更新对应索引的值 + int index = weightTitles.indexOf(month); + weightValues.set(index,checkModel.getWeight()); + }else { + weightTitles.add(month); + weightValues.add(checkModel.getWeight()); + } } - heightMap.put("time", DateUtil.getyyyy_MM_dd(checkModel.getCheckDate())); heightMap.put("weight",checkModel.getWeight()); } else { heightMap.put("weight", "--"); } - tables.add(heightMap); } } @@ -1739,7 +1755,9 @@ public class BabyCheckFacade { map.put("heightValues",heightValues); map.put("tables",tables); - + if(babyModel!=null){ + map.put("sex",babyModel.getSex()); + } return new BaseObjectResponse().setData(map).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); } }