|
|
@ -146,7 +146,7 @@ public class DcDeviceOnlineController extends BaseController { |
|
|
|
Map<String, Map<String, String>> maps = new HashMap<>(); |
|
|
|
LocalDateTime start = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
|
|
|
LocalDateTime end = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
|
|
|
List<OnlineSum> onlineSums = onlineSumService.queryByDeviceTypeAndDate(types, start.toLocalDate(), end.toLocalDate(), direction); |
|
|
|
List<OnlineSum> onlineSums = onlineSumService.queryByDeviceTypeAndDate(types, start, end, direction); |
|
|
|
Map<String, List<OnlineSum>> stringListMap = onlineSums.stream().collect(Collectors.groupingBy(OnlineSum::getDeviceType)); |
|
|
|
for (String type : types) { |
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
@ -183,7 +183,7 @@ public class DcDeviceOnlineController extends BaseController { |
|
|
|
} |
|
|
|
|
|
|
|
// 查询数据
|
|
|
|
List<OnlineSum> onlineSums = onlineSumService.queryByDeviceTypeAndDate(types, start.toLocalDate(), end.toLocalDate(), direction); |
|
|
|
List<OnlineSum> onlineSums = onlineSumService.queryByDeviceTypeAndDate(types, start, end, direction); |
|
|
|
|
|
|
|
// 按设备类型分组
|
|
|
|
Map<String, List<OnlineSum>> stringListMap = onlineSums.stream().collect(Collectors.groupingBy(OnlineSum::getDeviceType)); |
|
|
@ -208,9 +208,9 @@ public class DcDeviceOnlineController extends BaseController { |
|
|
|
LocalDateTime startHour = LocalDateTime.of(date, LocalTime.of(hour, 0)); |
|
|
|
LocalDateTime endHour = startHour.plusHours(1); |
|
|
|
List<OnlineSum> hourList = dayList.stream() |
|
|
|
.filter(os -> os.getStatisticalDate().toLocalDate().isAfter(ChronoLocalDate.from(startHour)) && os.getStatisticalDate().toLocalDate().isBefore(ChronoLocalDate.from(endHour))) |
|
|
|
.filter(os -> os.getStatisticalDate().isAfter(startHour) && |
|
|
|
os.getStatisticalDate().isBefore(endHour)) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
double averageRate = hourList.stream().mapToDouble(OnlineSum::getOnlineRate).average().orElse(0.0); |
|
|
|
hourlyMap.put(startHour.toString(), MathUtil.doubleTwoDecimalStr(averageRate) + "%"); |
|
|
|
} |
|
|
|