From 02c3fc29d0e65ef25eca7e20175c73dac720b8f4 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Fri, 12 Jul 2024 14:08:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=BE=E5=A4=87=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=BB=9F=E8=AE=A1=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zc/business/controller/DeviceStatus.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java b/zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java index 85e57e8a..48596918 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java +++ b/zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java @@ -61,10 +61,15 @@ public class DeviceStatus { for (DcDevice device : deviceList) { Callable 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());