处理服务重启或设备重新上线时的订阅,优化通道导入重复的处理
This commit is contained in:
@@ -35,6 +35,9 @@ public class OnlineEventListener implements ApplicationListener<OnlineEvent> {
|
||||
|
||||
@Autowired
|
||||
private IVideoManagerStorager storager;
|
||||
|
||||
@Autowired
|
||||
private IDeviceService deviceService;
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redis;
|
||||
@@ -57,6 +60,7 @@ public class OnlineEventListener implements ApplicationListener<OnlineEvent> {
|
||||
logger.debug("设备上线事件触发,deviceId:" + event.getDevice().getDeviceId() + ",from:" + event.getFrom());
|
||||
}
|
||||
Device device = event.getDevice();
|
||||
if (device == null) return;
|
||||
String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + event.getDevice().getDeviceId();
|
||||
|
||||
switch (event.getFrom()) {
|
||||
@@ -84,15 +88,18 @@ public class OnlineEventListener implements ApplicationListener<OnlineEvent> {
|
||||
}
|
||||
|
||||
device.setOnline(1);
|
||||
Device deviceInstore = storager.queryVideoDevice(device.getDeviceId());
|
||||
if (deviceInstore != null && deviceInstore.getOnline() == 0) {
|
||||
Device deviceInStore = storager.queryVideoDevice(device.getDeviceId());
|
||||
if (deviceInStore != null && deviceInStore.getOnline() == 0) {
|
||||
List<DeviceChannel> deviceChannelList = storager.queryOnlineChannelsByDeviceId(device.getDeviceId());
|
||||
eventPublisher.catalogEventPublish(null, deviceChannelList, CatalogEvent.ON);
|
||||
}
|
||||
// 处理上线监听
|
||||
storager.updateDevice(device);
|
||||
|
||||
// TODO 上线添加订阅
|
||||
// 上线添加订阅
|
||||
if (device.getSubscribeCycleForCatalog() > 0) {
|
||||
deviceService.addCatalogSubscribe(device);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -76,12 +77,12 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
|
||||
}else if (event.getGbStreams() != null) {
|
||||
if (platforms.size() > 0) {
|
||||
for (GbStream gbStream : event.getGbStreams()) {
|
||||
if (gbStream == null || StringUtils.isEmpty(gbStream.getGbId())) continue;
|
||||
List<ParentPlatform> parentPlatformsForGB = storager.queryPlatFormListForStreamWithGBId(gbStream.getApp(),gbStream.getStream(), platforms);
|
||||
parentPlatformMap.put(gbStream.getGbId(), parentPlatformsForGB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
switch (event.getType()) {
|
||||
case CatalogEvent.ON:
|
||||
|
||||
Reference in New Issue
Block a user