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) {
Callable<Void> task = () -> {
if (Objects.equals(device.getDeviceType(), UniversalEnum.EIGHT.getValue()) || Objects.equals(device.getDeviceType(), UniversalEnum.FIFTEEN.getValue())) {
AjaxResult deviceByIotDeviceId = deviceService.getDeviceByIotDeviceId(device.getIotDeviceId());
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());
String iotDeviceId = device.getIotDeviceId();
AjaxResult deviceByIotDeviceId = deviceService.getDeviceByIotDeviceId(iotDeviceId);
if (Objects.equals(String.valueOf(deviceByIotDeviceId.get("code")), UniversalEnum.TWO_HUNDRED.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 {
extracted(statusService, device, false, UniversalEnum.ONE_HUNDRED_PERCENT.getValue());
}
@ -104,6 +109,7 @@ public class DeviceStatus {
status.setStartTime(startTime);
statusService.delStatusByTime(status);
}
private void extracted(StatusService statusService, DcDevice device, boolean reachable, String packetLossRate) {
Status status = new Status();
status.setDeviceNo(device.getStakeMark());

Loading…
Cancel
Save