添加设备离线原因

This commit is contained in:
648540858
2023-03-08 16:57:07 +08:00
parent b16923d175
commit ec90519c90
7 changed files with 9 additions and 15 deletions

View File

@@ -24,7 +24,7 @@ public interface IDeviceService {
* 设备下线
* @param deviceId 设备编号
*/
void offline(String deviceId);
void offline(String deviceId, String reason);
/**
* 添加目录订阅

View File

@@ -156,12 +156,12 @@ public class DeviceServiceImpl implements IDeviceService {
// 刷新过期任务
String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + device.getDeviceId();
// 如果第一次注册那么必须在60 * 3时间内收到一个心跳否则设备离线
dynamicTask.startDelay(registerExpireTaskKey, ()-> offline(device.getDeviceId()), device.getKeepaliveIntervalTime() * 1000 * 3);
dynamicTask.startDelay(registerExpireTaskKey, ()-> offline(device.getDeviceId(), "首次注册后未能收到心跳"), device.getKeepaliveIntervalTime() * 1000 * 3);
}
@Override
public void offline(String deviceId) {
logger.error("[设备离线] device{}", deviceId);
public void offline(String deviceId, String reason) {
logger.error("[设备离线]{}, device{}", reason, deviceId);
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device == null) {
return;