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;