|
@ -151,7 +151,11 @@ public class DcDeviceOnlineController extends BaseController { |
|
|
for (String type : types) { |
|
|
for (String type : types) { |
|
|
Map<String, String> map = new HashMap<>(); |
|
|
Map<String, String> map = new HashMap<>(); |
|
|
List<OnlineSum> listOfType = stringListMap.getOrDefault(type, new ArrayList<>()); |
|
|
List<OnlineSum> listOfType = stringListMap.getOrDefault(type, new ArrayList<>()); |
|
|
|
|
|
Map<LocalDate, List<OnlineSum>> localDateListMap = listOfType.stream() |
|
|
|
|
|
.collect(Collectors.groupingBy(onlineSum -> onlineSum.getStatisticalDate().toLocalDate())); |
|
|
|
|
|
/* |
|
|
Map<LocalDate, List<OnlineSum>> localDateListMap = listOfType.stream().collect(Collectors.groupingBy(OnlineSum::getStatisticalDate)); |
|
|
Map<LocalDate, List<OnlineSum>> localDateListMap = listOfType.stream().collect(Collectors.groupingBy(OnlineSum::getStatisticalDate)); |
|
|
|
|
|
*/ |
|
|
for (LocalDate date = start.toLocalDate(); date.isBefore(end.toLocalDate().plusDays(1)); date = date.plusDays(1)) { |
|
|
for (LocalDate date = start.toLocalDate(); date.isBefore(end.toLocalDate().plusDays(1)); date = date.plusDays(1)) { |
|
|
List<OnlineSum> dayList = localDateListMap.getOrDefault(date, new ArrayList<>()); |
|
|
List<OnlineSum> dayList = localDateListMap.getOrDefault(date, new ArrayList<>()); |
|
|
map.put(date.toString(), MathUtil.doubleTwoDecimalStr(dayList.stream().mapToDouble(OnlineSum::getOnlineRate).average().orElse(0.0)) + "%"); |
|
|
map.put(date.toString(), MathUtil.doubleTwoDecimalStr(dayList.stream().mapToDouble(OnlineSum::getOnlineRate).average().orElse(0.0)) + "%"); |
|
@ -191,7 +195,8 @@ public class DcDeviceOnlineController extends BaseController { |
|
|
List<OnlineSum> listOfType = stringListMap.getOrDefault(type, new ArrayList<>()); |
|
|
List<OnlineSum> listOfType = stringListMap.getOrDefault(type, new ArrayList<>()); |
|
|
|
|
|
|
|
|
// 按日期分组
|
|
|
// 按日期分组
|
|
|
Map<LocalDate, List<OnlineSum>> localDateListMap = listOfType.stream().collect(Collectors.groupingBy(OnlineSum::getStatisticalDate)); |
|
|
Map<LocalDate, List<OnlineSum>> localDateListMap = listOfType.stream() .collect(Collectors.groupingBy(onlineSum -> onlineSum.getStatisticalDate().toLocalDate())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 按日期统计
|
|
|
// 按日期统计
|
|
|
for (LocalDate date = start.toLocalDate(); date.isBefore(end.toLocalDate().plusDays(1)); date = date.plusDays(1)) { |
|
|
for (LocalDate date = start.toLocalDate(); date.isBefore(end.toLocalDate().plusDays(1)); date = date.plusDays(1)) { |
|
@ -203,7 +208,7 @@ public class DcDeviceOnlineController extends BaseController { |
|
|
LocalDateTime startHour = LocalDateTime.of(date, LocalTime.of(hour, 0)); |
|
|
LocalDateTime startHour = LocalDateTime.of(date, LocalTime.of(hour, 0)); |
|
|
LocalDateTime endHour = startHour.plusHours(1); |
|
|
LocalDateTime endHour = startHour.plusHours(1); |
|
|
List<OnlineSum> hourList = dayList.stream() |
|
|
List<OnlineSum> hourList = dayList.stream() |
|
|
.filter(os -> os.getStatisticalDate().isAfter(ChronoLocalDate.from(startHour)) && os.getStatisticalDate().isBefore(ChronoLocalDate.from(endHour))) |
|
|
.filter(os -> os.getStatisticalDate().toLocalDate().isAfter(ChronoLocalDate.from(startHour)) && os.getStatisticalDate().toLocalDate().isBefore(ChronoLocalDate.from(endHour))) |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
double averageRate = hourList.stream().mapToDouble(OnlineSum::getOnlineRate).average().orElse(0.0); |
|
|
double averageRate = hourList.stream().mapToDouble(OnlineSum::getOnlineRate).average().orElse(0.0); |
|
|