This commit is contained in:
磷叶 2025-04-29 15:18:24 +08:00
parent d38aba8df3
commit 6f3bb42742
3 changed files with 8 additions and 2 deletions

View File

@ -65,6 +65,7 @@ public class ReceiveController {
ObjBody obj = IotUtil.resolveBody(body, false);
if (obj != null){
Object msg = obj.getMsg();
log.info("收到receive数据{}", msg);
// 接收到msg
if (msg instanceof String) {
iotReceiveService.handleReceive(JSON.parseObject((String) msg, ReceiveMsg.class));

View File

@ -152,7 +152,12 @@ public class IotReceiveServiceImpl implements IotReceiveService {
// 需要在设备未启动的时候做否则可能有安全问题
if (!isOpen) {
// 若当前数据点的上报时间和设备内上次上报的时间不一样但是定位一样则重启设备
log.info("当前定位:{},{},上次定位:{},{}", sys.getLon().setScale(8), sys.getLat().setScale(8), device.getLongitude().setScale(8), device.getLatitude().setScale(8));
log.info("当前定位:{},{},上次定位:{},{}",
sys.getLon().setScale(8, BigDecimal.ROUND_HALF_UP),
sys.getLat().setScale(8, BigDecimal.ROUND_HALF_UP),
device.getLongitude().setScale(8, BigDecimal.ROUND_HALF_UP),
device.getLatitude().setScale(8, BigDecimal.ROUND_HALF_UP)
);
if (at.isAfter(device.getLastLocationTime()) && MathUtils.equalsFixed(device.getLongitude(), sys.getLon(), 8) && MathUtils.equalsFixed(device.getLatitude(), sys.getLat(), 8)) {
String reason = String.format("设备不同时间的两次定位一样,重启设备。新定位:%s,%s旧定位%s,%s", sys.getLon(), sys.getLat(), device.getLongitude(), device.getLatitude());
deviceIotService.reboot(device, reason, true);

View File

@ -32,7 +32,7 @@ public class DeviceTask {
/**
* 将过久未上报数据的设备设置为离线
*/
public void monitorOffline(long seconds) {
public void monitorOffline(Integer seconds) {
// 条件在线且最后上报时间小于当前时间 - seconds秒
DeviceQuery query = new DeviceQuery();
query.setOnlineStatus(DeviceOnlineStatus.ONLINE.getStatus());