1.构造连续日期
//2.构造连续的日期,对应图表的x轴 Map<String, Object> collect = null; if (StringUtils.equals(vo.getType(), "1")) { //构造连续的日列表 collect = new TreeMap<>(DateUtil.findDates(vo.getStartDate(), vo.getEndDate(), new SimpleDateFormat(format)) .stream() .collect(Collectors.toMap(Function.identity(), s -> 0))); } else if (StringUtils.equals(vo.getType(), "2")) { //构造连续的周列表 WeekFields weekFields = WeekFields.of(Locale.getDefault()); int start = LocalDate.parse(vo.getStartDate()).get(weekFields.weekOfWeekBasedYear()); int end = LocalDate.parse(vo.getEndDate()).get(weekFields.weekOfWeekBasedYear()); collect = new TreeMap<>(IntStream.rangeClosed(start, end) .mapToObj(s -> String.format("%02d", s)) .collect(Collectors.toMap(Function.identity(), s -> 0))); } else if (StringUtils.equals(vo.getType(), "3")) { //构造连续的月列表 int start = LocalDate.parse(vo.getStartDate()).getMonthValue(); int end = LocalDate.parse(vo.getEndDate()).getMonthValue(); collect = new TreeMap<>(IntStream.rangeClosed(start, end) .mapToObj(s -> String.format("%02d", s)) .collect(Collectors.toMap(Function.identity(), s -> 0))); }