| | |
| | | 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.*; |
| | | |
| | |
| | | Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>(); |
| | | if (event.getPlatformId() != null) { |
| | | parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId()); |
| | | if (!parentPlatform.isStatus())return; |
| | | String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + event.getPlatformId(); |
| | | subscribe = redisCatchStorage.getSubscribe(key); |
| | | if (subscribe == null) return; |
| | | }else { |
| | | // 获取所用订阅 |
| | | List<String> platforms = redisCatchStorage.getAllSubscribePlatform(); |
| | |
| | | }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: |
| | |
| | | if (event.getDeviceChannels() != null) { |
| | | deviceChannelList.addAll(event.getDeviceChannels()); |
| | | } |
| | | if (event.getGbStreams().size() > 0){ |
| | | if (event.getGbStreams() != null && event.getGbStreams().length > 0){ |
| | | for (GbStream gbStream : event.getGbStreams()) { |
| | | DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), parentPlatform.getDeviceGBId()); |
| | | deviceChannelList.add(deviceChannelByStream); |
| | |
| | | } |
| | | if (deviceChannelList.size() > 0) { |
| | | logger.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), deviceChannelList.size()); |
| | | sipCommanderFroPlatform.sendNotifyForCatalogAddOrUpdate(event.getType(), parentPlatform, deviceChannelList, subscribe); |
| | | sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), parentPlatform, deviceChannelList, subscribe); |
| | | } |
| | | }else if (parentPlatformMap.keySet().size() > 0) { |
| | | for (String gbId : parentPlatformMap.keySet()) { |
| | | List<ParentPlatform> parentPlatforms = parentPlatformMap.get(gbId); |
| | | if (parentPlatforms != null && parentPlatforms.size() > 0) { |
| | | for (ParentPlatform platform : parentPlatforms) { |
| | | logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId); |
| | | String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + platform.getServerGBId(); |
| | | SubscribeInfo subscribeInfo = redisCatchStorage.getSubscribe(key); |
| | | if (subscribeInfo == null) continue; |
| | | logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId); |
| | | List<DeviceChannel> deviceChannelList = new ArrayList<>(); |
| | | DeviceChannel deviceChannel = new DeviceChannel(); |
| | | deviceChannel.setChannelId(gbId); |
| | |
| | | if (event.getDeviceChannels() != null) { |
| | | deviceChannelList.addAll(event.getDeviceChannels()); |
| | | } |
| | | if (event.getGbStreams().size() > 0){ |
| | | if (event.getGbStreams() != null && event.getGbStreams().length > 0){ |
| | | for (GbStream gbStream : event.getGbStreams()) { |
| | | DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), parentPlatform.getDeviceGBId()); |
| | | deviceChannelList.add(deviceChannelByStream); |
| | |
| | | List<ParentPlatform> parentPlatforms = parentPlatformMap.get(gbId); |
| | | if (parentPlatforms != null && parentPlatforms.size() > 0) { |
| | | for (ParentPlatform platform : parentPlatforms) { |
| | | logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId); |
| | | String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + platform.getServerGBId(); |
| | | SubscribeInfo subscribeInfo = redisCatchStorage.getSubscribe(key); |
| | | if (subscribeInfo == null) continue; |
| | | logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId); |
| | | List<DeviceChannel> deviceChannelList = new ArrayList<>(); |
| | | DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(platform.getServerGBId(), gbId); |
| | | deviceChannelList.add(deviceChannel); |