更新 MonitorService.java
parent
ae889a2447
commit
8772a041f3
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue