Browse Source

优化设备状态统计逻辑

develop
zhaoxianglong 9 months ago
parent
commit
02c3fc29d0
  1. 14
      zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java

14
zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java

@ -61,10 +61,15 @@ public class DeviceStatus {
for (DcDevice device : deviceList) { for (DcDevice device : deviceList) {
Callable<Void> task = () -> { Callable<Void> task = () -> {
if (Objects.equals(device.getDeviceType(), UniversalEnum.EIGHT.getValue()) || Objects.equals(device.getDeviceType(), UniversalEnum.FIFTEEN.getValue())) { if (Objects.equals(device.getDeviceType(), UniversalEnum.EIGHT.getValue()) || Objects.equals(device.getDeviceType(), UniversalEnum.FIFTEEN.getValue())) {
AjaxResult deviceByIotDeviceId = deviceService.getDeviceByIotDeviceId(device.getIotDeviceId()); String iotDeviceId = device.getIotDeviceId();
String deviceState = ((JSONObject) JSON.toJSON(deviceByIotDeviceId.get("data"))).getString("deviceState"); AjaxResult deviceByIotDeviceId = deviceService.getDeviceByIotDeviceId(iotDeviceId);
if (Objects.equals(deviceState, UniversalEnum.ON_LINE.getValue())) { if (Objects.equals(String.valueOf(deviceByIotDeviceId.get("code")), UniversalEnum.TWO_HUNDRED.getValue())) {
extracted(statusService, device, true, UniversalEnum.ZERO_PERCENT.getValue()); String deviceState = ((JSONObject) JSON.toJSON(deviceByIotDeviceId.get("data"))).getString("deviceState");
if (Objects.equals(deviceState, UniversalEnum.ON_LINE.getValue())) {
extracted(statusService, device, true, UniversalEnum.ZERO_PERCENT.getValue());
} else {
extracted(statusService, device, false, UniversalEnum.ONE_HUNDRED_PERCENT.getValue());
}
} else { } else {
extracted(statusService, device, false, UniversalEnum.ONE_HUNDRED_PERCENT.getValue()); extracted(statusService, device, false, UniversalEnum.ONE_HUNDRED_PERCENT.getValue());
} }
@ -104,6 +109,7 @@ public class DeviceStatus {
status.setStartTime(startTime); status.setStartTime(startTime);
statusService.delStatusByTime(status); statusService.delStatusByTime(status);
} }
private void extracted(StatusService statusService, DcDevice device, boolean reachable, String packetLossRate) { private void extracted(StatusService statusService, DcDevice device, boolean reachable, String packetLossRate) {
Status status = new Status(); Status status = new Status();
status.setDeviceNo(device.getStakeMark()); status.setDeviceNo(device.getStakeMark());

Loading…
Cancel
Save