debug 重启设备

This commit is contained in:
磷叶 2025-05-01 08:43:17 +08:00
parent 4852c9322b
commit 09f3d57884

View File

@ -94,12 +94,6 @@ public class IotReceiveServiceImpl implements IotReceiveService {
LocalDateTime at = DateUtils.toLocalDateTime(msg.getAt()); LocalDateTime at = DateUtils.toLocalDateTime(msg.getAt());
DeviceUtil.setIotSysInfo(device, sys, at); 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.setOnlineStatus(DeviceOnlineStatus.ONLINE.getStatus());
device.setLastOnlineTime(at); device.setLastOnlineTime(at);
@ -108,6 +102,12 @@ public class IotReceiveServiceImpl implements IotReceiveService {
log.error("更新设备信息失败: {}", msg.getDevName()); log.error("更新设备信息失败: {}", msg.getDevName());
} }
// 处理设备定位BUG若出现BUG则重启设备
int handle = this.handleDeviceLocationBug(device, at, lastLocationTime, oldLon, oldLat);
if (handle == 1) {
return;
}
// 处理运营区 // 处理运营区
this.handleArea(device); this.handleArea(device);
@ -155,12 +155,12 @@ public class IotReceiveServiceImpl implements IotReceiveService {
if (!isOpen) { if (!isOpen) {
// 若当前数据点的上报时间和设备内上次上报的时间不一样但是定位一样则重启设备 // 若当前数据点的上报时间和设备内上次上报的时间不一样但是定位一样则重启设备
log.info("当前定位:{},{},上次定位:{},{}", log.info("当前定位:{},{},上次定位:{},{}",
device.getLongitude().setScale(8, RoundingMode.HALF_UP), device.getLongitude(),
device.getLatitude().setScale(8, RoundingMode.HALF_UP), device.getLatitude(),
oldLon.setScale(8, RoundingMode.HALF_UP), oldLon,
oldLat.setScale(8, RoundingMode.HALF_UP) 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); 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;