diff --git a/src/main/java/com/kimgo/wepush/service/MonitorService.java b/src/main/java/com/kimgo/wepush/service/MonitorService.java index 89a6cb6..1a0ff70 100644 --- a/src/main/java/com/kimgo/wepush/service/MonitorService.java +++ b/src/main/java/com/kimgo/wepush/service/MonitorService.java @@ -44,11 +44,17 @@ public class MonitorService { continue; } long currentTimeMillis = System.currentTimeMillis(); - if (currentTimeMillis - device.getLastOnlineTime() > device.getTimeOutPeriod()) { + long timeDifferenceMillis = currentTimeMillis - device.getLastOnlineTime(); + long timeDifferenceSeconds = timeDifferenceMillis / 1000; + if (timeDifferenceSeconds > device.getTimeOutPeriod()) { + logger.info("currentTimeMillis: {},device LastOnlineTime: {},时间差: {},设备超时时间: {}",currentTimeMillis, + device.getLastOnlineTime(),timeDifferenceSeconds,device.getTimeOutPeriod()); updateStatus(device, 0); // 设备离线 + logger.info("Update the device status to offline."); sendNotification(device); } else { updateStatus(device, 1); // 设备在线 + logger.info("update the device status to online."); } } catch (Exception e) { logger.error("Error processing device with SN " + device.getSN(), e);