Browse Source

格式化设备在线率返回的时间去除中间T

develop
wangsixiang 2 weeks ago
parent
commit
3a19f58a08
  1. 7
      zc-business/src/main/java/com/zc/business/controller/DcDeviceOnlineController.java

7
zc-business/src/main/java/com/zc/business/controller/DcDeviceOnlineController.java

@ -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));
}
@ -584,4 +587,4 @@ public class DcDeviceOnlineController extends BaseController {
}
}
}
}

Loading…
Cancel
Save