debug 重启设备

This commit is contained in:
磷叶 2025-05-01 08:37:08 +08:00
parent 0186d3a3ea
commit 4852c9322b

View File

@ -86,6 +86,7 @@ public class IotReceiveServiceImpl implements IotReceiveService {
} }
BigDecimal oldLon = device.getLongitude(); BigDecimal oldLon = device.getLongitude();
BigDecimal oldLat = device.getLatitude(); BigDecimal oldLat = device.getLatitude();
LocalDateTime lastLocationTime = device.getLastLocationTime();
// 转为设备信息 // 转为设备信息
log.info("收到sys数据{}", msg.getValue()); log.info("收到sys数据{}", msg.getValue());
@ -94,7 +95,7 @@ public class IotReceiveServiceImpl implements IotReceiveService {
DeviceUtil.setIotSysInfo(device, sys, at); DeviceUtil.setIotSysInfo(device, sys, at);
// 处理设备定位BUG若出现BUG则重启设备 // 处理设备定位BUG若出现BUG则重启设备
int handle = this.handleDeviceLocationBug(device, at, oldLon, oldLat); int handle = this.handleDeviceLocationBug(device, at, lastLocationTime, oldLon, oldLat);
if (handle == 1) { if (handle == 1) {
return; return;
} }
@ -135,8 +136,8 @@ public class IotReceiveServiceImpl implements IotReceiveService {
* 处理设备定位BUG * 处理设备定位BUG
* @param device * @param device
*/ */
private int handleDeviceLocationBug(DeviceVO device, LocalDateTime at, BigDecimal oldLon, BigDecimal oldLat) { private int handleDeviceLocationBug(DeviceVO device, LocalDateTime at, LocalDateTime lastLocationTime, BigDecimal oldLon, BigDecimal oldLat) {
if (device == null || StringUtils.isBlank(device.getMac()) || device.getLastLocationTime() == null || at == null) { if (device == null || StringUtils.isBlank(device.getMac()) || lastLocationTime == null || at == null) {
return 0; return 0;
} }
// 相差一分钟以上的消息不做处理 // 相差一分钟以上的消息不做处理
@ -159,7 +160,7 @@ public class IotReceiveServiceImpl implements IotReceiveService {
oldLon.setScale(8, RoundingMode.HALF_UP), oldLon.setScale(8, RoundingMode.HALF_UP),
oldLat.setScale(8, RoundingMode.HALF_UP) oldLat.setScale(8, RoundingMode.HALF_UP)
); );
if (at.isAfter(device.getLastLocationTime()) && MathUtils.equalsFixed(device.getLongitude(), oldLon, 8) && MathUtils.equalsFixed(device.getLatitude(), oldLat, 8)) { if (at.isAfter(lastLocationTime) && MathUtils.equalsFixed(device.getLongitude(), oldLon, 8) && MathUtils.equalsFixed(device.getLatitude(), oldLat, 8)) {
String reason = String.format("设备不同时间的两次定位一样,重启设备。新定位:%s,%s旧定位%s,%s", device.getLongitude(), device.getLatitude(), oldLon, oldLat); String reason = String.format("设备不同时间的两次定位一样,重启设备。新定位:%s,%s旧定位%s,%s", device.getLongitude(), device.getLatitude(), oldLon, oldLat);
deviceIotService.reboot(device, reason, true); deviceIotService.reboot(device, reason, true);
return 1; return 1;