Compare commits

...

2 Commits

Author SHA1 Message Date
wangsiyuan 9462f5caab Update MonitorService.java 2024-04-22 15:35:03 +08:00
wangsiyuan 7020497109 Update HeartBeatService.java 2024-04-22 15:34:59 +08:00
2 changed files with 8 additions and 6 deletions

View File

@ -1,4 +1,4 @@
package com.kimgo.wepush.service;
package com.kimgo.wepush.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@ -102,7 +102,7 @@ public class HeartBeatService {
try {
DeviceInfoDAO deviceInfoDAO = deviceInfoDAOMapper.selectOne(queryWrapper);
if (deviceInfoDAO != null) {
logger.info("Data is queried in the database based on the SN");
//logger.info("Data is queried in the database based on the SN");
return deviceInfoDAO;
}
return null; // 数据不存在
@ -120,7 +120,7 @@ public class HeartBeatService {
* @return DeviceInfoDAO
*/
private DeviceInfoDAO convertToDeviceInfoDAO(DeviceInfo deviceInfo) {
logger.info("start convert to device info dao");
// logger.info("start convert to device info dao");
DeviceInfoDAO deviceInfoDAO = new DeviceInfoDAO();
deviceInfoDAO.setIsMonitored(1);

View File

@ -70,15 +70,15 @@ public class MonitorService {
long timeDifferenceSeconds = timeDifferenceMillis / 1000;
// 如果设备超出设定的超时周期未上线,则认为设备离线,并进行相应处理
if (timeDifferenceSeconds > device.getTimeOutPeriod()) {
logger.info("Device offline. SN: {}, LastOnlineTime: {}, TimeDifference: {}, TimeoutPeriod: {}",
device.getSN(), device.getLastOnlineTime(), timeDifferenceSeconds, device.getTimeOutPeriod());
//logger.info("Device offline. SN: {}, LastOnlineTime: {}, TimeDifference: {}, TimeoutPeriod: {}",
//device.getSN(), 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.");
//logger.info("update the device status to online.");
}
} catch (DatabaseUpdateException dbe) {
// 更新数据库出错时的处理逻辑
@ -138,6 +138,7 @@ public class MonitorService {
/**
*
*
* @param deviceInfoDAO 访
* @return TextCardMessage
*/
@ -177,6 +178,7 @@ public class MonitorService {
/**
*
*
* @param device SN
* @param status
* @throws DatabaseUpdateException