|
|
@ -238,12 +238,15 @@ public class DcDeviceOnlineController extends BaseController { |
|
|
|
LocalDate startDate = LocalDate.now().minusDays(30); |
|
|
|
LocalDate endDate = LocalDate.now(); |
|
|
|
List<OnlineSum> onlineSums = onlineSumService.queryByDateRangeOfDevice(deviceId, startDate, endDate); |
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|
|
|
if (onlineSums.isEmpty()) { |
|
|
|
return AjaxResult.success(UniversalEnum.NO_DATA_AVAILABLE.getValue()); |
|
|
|
} |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
for (OnlineSum onlineSum : onlineSums) { |
|
|
|
map.put(onlineSum.getStatisticalDate().toString(), onlineSum.getOnlineRate()); |
|
|
|
LocalDateTime dateTime = onlineSum.getStatisticalDate(); |
|
|
|
String formattedDate = dateTime.format(formatter); |
|
|
|
map.put(formattedDate, onlineSum.getOnlineRate()); |
|
|
|
} |
|
|
|
return AjaxResult.success(new TreeMap<>(map)); |
|
|
|
} |
|
|
|