From 09f3d578849b1e00035c4788c5bd10d00a276bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A3=B7=E5=8F=B6?= <14103883+leaf-phos@user.noreply.gitee.com> Date: Thu, 1 May 2025 08:43:17 +0800 Subject: [PATCH] =?UTF-8?q?debug=20=E9=87=8D=E5=90=AF=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/IotReceiveServiceImpl.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ruoyi-service/src/main/java/com/ruoyi/iot/service/impl/IotReceiveServiceImpl.java b/ruoyi-service/src/main/java/com/ruoyi/iot/service/impl/IotReceiveServiceImpl.java index f63212a..277852e 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/iot/service/impl/IotReceiveServiceImpl.java +++ b/ruoyi-service/src/main/java/com/ruoyi/iot/service/impl/IotReceiveServiceImpl.java @@ -94,12 +94,6 @@ public class IotReceiveServiceImpl implements IotReceiveService { LocalDateTime at = DateUtils.toLocalDateTime(msg.getAt()); DeviceUtil.setIotSysInfo(device, sys, at); - // 处理设备定位BUG,若出现BUG则重启设备 - int handle = this.handleDeviceLocationBug(device, at, lastLocationTime, oldLon, oldLat); - if (handle == 1) { - return; - } - // 更新设备信息 device.setOnlineStatus(DeviceOnlineStatus.ONLINE.getStatus()); device.setLastOnlineTime(at); @@ -108,6 +102,12 @@ public class IotReceiveServiceImpl implements IotReceiveService { log.error("更新设备信息失败: {}", msg.getDevName()); } + // 处理设备定位BUG,若出现BUG则重启设备 + int handle = this.handleDeviceLocationBug(device, at, lastLocationTime, oldLon, oldLat); + if (handle == 1) { + return; + } + // 处理运营区 this.handleArea(device); @@ -155,12 +155,12 @@ public class IotReceiveServiceImpl implements IotReceiveService { if (!isOpen) { // 若当前数据点的上报时间和设备内上次上报的时间不一样,但是定位一样,则重启设备 log.info("当前定位:{},{},上次定位:{},{}", - device.getLongitude().setScale(8, RoundingMode.HALF_UP), - device.getLatitude().setScale(8, RoundingMode.HALF_UP), - oldLon.setScale(8, RoundingMode.HALF_UP), - oldLat.setScale(8, RoundingMode.HALF_UP) + device.getLongitude(), + device.getLatitude(), + oldLon, + oldLat ); - if (at.isAfter(lastLocationTime) && MathUtils.equalsFixed(device.getLongitude(), oldLon, 8) && MathUtils.equalsFixed(device.getLatitude(), oldLat, 8)) { + if (at.isAfter(lastLocationTime) && MathUtils.equals(device.getLongitude(), oldLon) && MathUtils.equals(device.getLatitude(), oldLat)) { String reason = String.format("设备不同时间的两次定位一样,重启设备。新定位:%s,%s,旧定位:%s,%s", device.getLongitude(), device.getLatitude(), oldLon, oldLat); deviceIotService.reboot(device, reason, true); return 1;