|
@@ -155,6 +155,19 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
sync(device);
|
|
sync(device);
|
|
|
// TODO 如果设备下的通道级联到了其他平台,那么需要发送事件或者notify给上级平台
|
|
// TODO 如果设备下的通道级联到了其他平台,那么需要发送事件或者notify给上级平台
|
|
|
}
|
|
}
|
|
|
|
|
+ // 上线添加订阅
|
|
|
|
|
+ if (device.getSubscribeCycleForCatalog() > 0) {
|
|
|
|
|
+ // 查询在线设备那些开启了订阅,为设备开启定时的目录订阅
|
|
|
|
|
+ addCatalogSubscribe(device);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (device.getSubscribeCycleForMobilePosition() > 0) {
|
|
|
|
|
+ addMobilePositionSubscribe(device);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (userSetting.getDeviceStatusNotify()) {
|
|
|
|
|
+ // 发送redis消息
|
|
|
|
|
+ redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), null, true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}else {
|
|
}else {
|
|
|
if (deviceChannelMapper.queryAllChannels(device.getDeviceId()).size() == 0) {
|
|
if (deviceChannelMapper.queryAllChannels(device.getDeviceId()).size() == 0) {
|
|
|
logger.info("[设备上线]: {},通道数为0,查询通道信息", device.getDeviceId());
|
|
logger.info("[设备上线]: {},通道数为0,查询通道信息", device.getDeviceId());
|
|
@@ -167,22 +180,10 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 上线添加订阅
|
|
|
|
|
- if (device.getSubscribeCycleForCatalog() > 0) {
|
|
|
|
|
- // 查询在线设备那些开启了订阅,为设备开启定时的目录订阅
|
|
|
|
|
- addCatalogSubscribe(device);
|
|
|
|
|
- }
|
|
|
|
|
- if (device.getSubscribeCycleForMobilePosition() > 0) {
|
|
|
|
|
- addMobilePositionSubscribe(device);
|
|
|
|
|
- }
|
|
|
|
|
// 刷新过期任务
|
|
// 刷新过期任务
|
|
|
String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + device.getDeviceId();
|
|
String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + device.getDeviceId();
|
|
|
// 如果第一次注册那么必须在60 * 3时间内收到一个心跳,否则设备离线
|
|
// 如果第一次注册那么必须在60 * 3时间内收到一个心跳,否则设备离线
|
|
|
dynamicTask.startDelay(registerExpireTaskKey, ()-> offline(device.getDeviceId(), "首次注册后未能收到心跳"), device.getKeepaliveIntervalTime() * 1000 * 3);
|
|
dynamicTask.startDelay(registerExpireTaskKey, ()-> offline(device.getDeviceId(), "首次注册后未能收到心跳"), device.getKeepaliveIntervalTime() * 1000 * 3);
|
|
|
- if (userSetting.getDeviceStatusNotify()) {
|
|
|
|
|
- // 发送redis消息
|
|
|
|
|
- redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), null, true);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
//
|
|
//
|
|
|
// try {
|
|
// try {
|
|
@@ -206,6 +207,13 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
}
|
|
}
|
|
|
String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + deviceId;
|
|
String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + deviceId;
|
|
|
dynamicTask.stop(registerExpireTaskKey);
|
|
dynamicTask.stop(registerExpireTaskKey);
|
|
|
|
|
+ if (device.isOnLine()) {
|
|
|
|
|
+ if (userSetting.getDeviceStatusNotify()) {
|
|
|
|
|
+ // 发送redis消息
|
|
|
|
|
+ redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), null, false);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
device.setOnLine(false);
|
|
device.setOnLine(false);
|
|
|
redisCatchStorage.updateDevice(device);
|
|
redisCatchStorage.updateDevice(device);
|
|
|
deviceMapper.update(device);
|
|
deviceMapper.update(device);
|
|
@@ -223,11 +231,6 @@ public class DeviceServiceImpl implements IDeviceService {
|
|
|
// 移除订阅
|
|
// 移除订阅
|
|
|
removeCatalogSubscribe(device);
|
|
removeCatalogSubscribe(device);
|
|
|
removeMobilePositionSubscribe(device);
|
|
removeMobilePositionSubscribe(device);
|
|
|
- if (userSetting.getDeviceStatusNotify()) {
|
|
|
|
|
- // 发送redis消息
|
|
|
|
|
- redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), null, false);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|