From 92669f192f014f0d613bef920f89d5a704e7c927 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 11 Dec 2023 21:18:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/common.sql | 1 + .../iot/vmp/common/CommonGbChannel.java | 14 ++ .../iot/vmp/gb28181/bean/SubscribeHolder.java | 20 +- .../iot/vmp/gb28181/event/EventPublisher.java | 8 +- .../event/subscribe/catalog/CatalogEvent.java | 14 +- .../subscribe/catalog/CatalogEventLister.java | 164 +++++++--------- .../cmd/ISIPCommanderForPlatform.java | 9 +- .../cmd/impl/SIPCommanderFroPlatform.java | 177 ++++++++++++------ .../impl/SubscribeRequestProcessor.java | 20 +- .../vmp/service/IPlatformChannelService.java | 5 + .../iot/vmp/service/IPlatformService.java | 5 + .../impl/CommonGbChannelServiceImpl.java | 7 + .../impl/PlatformChannelServiceImpl.java | 13 +- .../vmp/service/impl/PlatformServiceImpl.java | 22 ++- .../vmp/storager/dao/CommonChannelMapper.java | 11 ++ .../gb28181/platform/PlatformController.java | 4 +- 16 files changed, 284 insertions(+), 210 deletions(-) diff --git a/sql/common.sql b/sql/common.sql index 5e364234..c7bcd34e 100644 --- a/sql/common.sql +++ b/sql/common.sql @@ -34,6 +34,7 @@ CREATE TABLE `wvp_common_channel` `common_gb_business_group_id` varchar(255) DEFAULT NULL, `common_gb_download_speed` varchar(255) DEFAULT NULL, `common_gb_svc_time_support_mode` integer, + `common_gb_svc_space_support_mode` integer, `type` varchar(255) NOT NULL, `update_time` varchar(50) NOT NULL, `create_time` varchar(50) NOT NULL, diff --git a/src/main/java/com/genersoft/iot/vmp/common/CommonGbChannel.java b/src/main/java/com/genersoft/iot/vmp/common/CommonGbChannel.java index b7bed5b8..5529ab5d 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/CommonGbChannel.java +++ b/src/main/java/com/genersoft/iot/vmp/common/CommonGbChannel.java @@ -293,6 +293,12 @@ public class CommonGbChannel { "载则应写为“1/2/4") private String commonGbDownloadSpeed; + /** + * 时域编码能力,取值0:不支持;1:1级增强;2:2级增强;3:3级增强(可选) + */ + @Schema(description = "空域编码能力,取值0:不支持;1:1级增强(1个增强层);2:2级增强(2个增强层);3:3级增强(3个增强层)(可选)") + private Integer SVCSpaceSupportMode; + /** * 时域编码能力,取值0:不支持;1:1级增强;2:2级增强;3:3级增强(可选) */ @@ -755,4 +761,12 @@ public class CommonGbChannel { // } return commonGbChannel; } + + public Integer getSVCSpaceSupportMode() { + return SVCSpaceSupportMode; + } + + public void setSVCSpaceSupportMode(Integer SVCSpaceSupportMode) { + this.SVCSpaceSupportMode = SVCSpaceSupportMode; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java index d932a208..83622a64 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java @@ -26,11 +26,11 @@ public class SubscribeHolder { private final String taskOverduePrefix = "subscribe_overdue_"; - private static ConcurrentHashMap catalogMap = new ConcurrentHashMap<>(); - private static ConcurrentHashMap mobilePositionMap = new ConcurrentHashMap<>(); + private static ConcurrentHashMap catalogMap = new ConcurrentHashMap<>(); + private static ConcurrentHashMap mobilePositionMap = new ConcurrentHashMap<>(); - public void putCatalogSubscribe(String platformId, SubscribeInfo subscribeInfo) { + public void putCatalogSubscribe(Integer platformId, SubscribeInfo subscribeInfo) { catalogMap.put(platformId, subscribeInfo); if (subscribeInfo.getExpires() > 0) { // 添加订阅到期 @@ -41,11 +41,11 @@ public class SubscribeHolder { } } - public SubscribeInfo getCatalogSubscribe(String platformId) { + public SubscribeInfo getCatalogSubscribe(Integer platformId) { return catalogMap.get(platformId); } - public void removeCatalogSubscribe(String platformId) { + public void removeCatalogSubscribe(Integer platformId) { catalogMap.remove(platformId); String taskOverdueKey = taskOverduePrefix + "catalog_" + platformId; @@ -58,7 +58,7 @@ public class SubscribeHolder { dynamicTask.stop(taskOverdueKey); } - public void putMobilePositionSubscribe(String platformId, SubscribeInfo subscribeInfo) { + public void putMobilePositionSubscribe(Integer platformId, SubscribeInfo subscribeInfo) { mobilePositionMap.put(platformId, subscribeInfo); String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "MobilePosition_" + platformId; // 添加任务处理GPS定时推送 @@ -74,11 +74,11 @@ public class SubscribeHolder { } } - public SubscribeInfo getMobilePositionSubscribe(String platformId) { + public SubscribeInfo getMobilePositionSubscribe(Integer platformId) { return mobilePositionMap.get(platformId); } - public void removeMobilePositionSubscribe(String platformId) { + public void removeMobilePositionSubscribe(Integer platformId) { mobilePositionMap.remove(platformId); String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "MobilePosition_" + platformId; // 结束任务处理GPS定时推送 @@ -96,14 +96,14 @@ public class SubscribeHolder { public List getAllCatalogSubscribePlatform() { List platforms = new ArrayList<>(); if(catalogMap.size() > 0) { - for (String key : catalogMap.keySet()) { + for (Integer key : catalogMap.keySet()) { platforms.add(catalogMap.get(key).getId()); } } return platforms; } - public void removeAllSubscribe(String platformId) { + public void removeAllSubscribe(Integer platformId) { removeMobilePositionSubscribe(platformId); removeCatalogSubscribe(platformId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java index 166cbe14..0cdd08e3 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java @@ -53,7 +53,7 @@ public class EventPublisher { } - public void catalogEventPublish(String platformId, CommonGbChannel channel, String type) { + public void catalogEventPublish(Integer platformId, CommonGbChannel channel, String type) { List channelList = new ArrayList<>(); channelList.add(channel); catalogEventPublish(platformId, channelList, type); @@ -73,7 +73,7 @@ public class EventPublisher { * @param channels * @param type */ - public void catalogEventPublish(String platformId, List channels, String type) { + public void catalogEventPublish(Integer platformId, List channels, String type) { CatalogEvent outEvent = new CatalogEvent(this); outEvent.setChannels(channels); outEvent.setType(type); @@ -82,7 +82,7 @@ public class EventPublisher { } - public void catalogEventPublishForStream(String platformId, List gbStreams, String type) { + public void catalogEventPublishForStream(Integer platformId, List gbStreams, String type) { CatalogEvent outEvent = new CatalogEvent(this); outEvent.setGbStreams(gbStreams); outEvent.setType(type); @@ -91,7 +91,7 @@ public class EventPublisher { } - public void catalogEventPublishForStream(String platformId, GbStream gbStream, String type) { + public void catalogEventPublishForStream(Integer platformId, GbStream gbStream, String type) { List gbStreamList = new ArrayList<>(); gbStreamList.add(gbStream); catalogEventPublishForStream(platformId, gbStreamList, type); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java index f08d02aa..3af91c8e 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java @@ -48,9 +48,8 @@ public class CatalogEvent extends ApplicationEvent { public static final String UPDATE = "UPDATE"; private List channels; - private List gbStreams; private String type; - private String platformId; + private Integer platformId; public List getChannels() { return channels; @@ -68,19 +67,12 @@ public class CatalogEvent extends ApplicationEvent { this.type = type; } - public String getPlatformId() { + public Integer getPlatformId() { return platformId; } - public void setPlatformId(String platformId) { + public void setPlatformId(Integer platformId) { this.platformId = platformId; } - public List getGbStreams() { - return gbStreams; - } - - public void setGbStreams(List gbStreams) { - this.gbStreams = gbStreams; - } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java index 4ccc72ba..0370e0e3 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java @@ -1,9 +1,11 @@ package com.genersoft.iot.vmp.gb28181.event.subscribe.catalog; +import com.genersoft.iot.vmp.common.CommonGbChannel; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; -import com.genersoft.iot.vmp.service.IGbStreamService; +import com.genersoft.iot.vmp.service.IPlatformChannelService; +import com.genersoft.iot.vmp.service.IPlatformService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,54 +31,43 @@ public class CatalogEventLister implements ApplicationListener { private final static Logger logger = LoggerFactory.getLogger(CatalogEventLister.class); @Autowired - private IVideoManagerStorage storager; + private IPlatformChannelService platformChannelService; + + @Autowired + private IPlatformService platformService; @Autowired private SIPCommanderFroPlatform sipCommanderFroPlatform; - @Autowired - private IGbStreamService gbStreamService; - @Autowired private SubscribeHolder subscribeHolder; - @Autowired - private UserSetting userSetting; - @Override public void onApplicationEvent(CatalogEvent event) { SubscribeInfo subscribe = null; ParentPlatform parentPlatform = null; - Map> parentPlatformMap = new HashMap<>(); + Map> parentPlatformMap = new HashMap<>(); + if (!ObjectUtils.isEmpty(event.getPlatformId())) { + // 如果事件指定了要通知的上级,那么定向发给这个上级 subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId()); if (subscribe == null) { return; } - parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId()); + parentPlatform = platformService.query(event.getPlatformId()); if (parentPlatform != null && !parentPlatform.isStatus()) { return; } }else { - // 获取所用订阅 + // 如果事件没有要通知的上级,那么需要自己查询到所有要通知的上级进行通知 List platforms = subscribeHolder.getAllCatalogSubscribePlatform(); - if (event.getDeviceChannels() != null) { - if (platforms.size() > 0) { - for (DeviceChannel deviceChannel : event.getDeviceChannels()) { - List parentPlatformsForGB = storager.queryPlatFormListForGBWithGBId(deviceChannel.getChannelId(), platforms); - parentPlatformMap.put(deviceChannel.getChannelId(), parentPlatformsForGB); - } - } - }else if (event.getGbStreams() != null) { - if (platforms.size() > 0) { - for (GbStream gbStream : event.getGbStreams()) { - if (gbStream == null || ObjectUtils.isEmpty(gbStream.getGbId())) { - continue; - } - List parentPlatformsForGB = storager.queryPlatFormListForStreamWithGBId(gbStream.getApp(),gbStream.getStream(), platforms); - parentPlatformMap.put(gbStream.getGbId(), parentPlatformsForGB); + if (event.getChannels() != null) { + if (!platforms.isEmpty()) { + for (CommonGbChannel channel : event.getChannels()) { + List parentPlatformsForGB = platformChannelService.querySharePlatformListByChannelId(channel.getCommonGbId(), platforms); + parentPlatformMap.put(channel, parentPlatformsForGB); } } } @@ -86,55 +77,44 @@ public class CatalogEventLister implements ApplicationListener { case CatalogEvent.OFF: case CatalogEvent.DEL: - if (parentPlatform != null || subscribe != null) { - List deviceChannelList = new ArrayList<>(); - if (event.getDeviceChannels() != null) { - deviceChannelList.addAll(event.getDeviceChannels()); - } - if (event.getGbStreams() != null && !event.getGbStreams().isEmpty()){ - for (GbStream gbStream : event.getGbStreams()) { - if (gbStream != null - && gbStream.getStreamType() != null - && gbStream.getStreamType().equals("push") - && !userSetting.isUsePushingAsStatus()) { - continue; - } - DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), parentPlatform); - deviceChannelList.add(deviceChannelByStream); - } - } - if (deviceChannelList.size() > 0) { - logger.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), deviceChannelList.size()); + if (parentPlatform != null ) { + + if (!event.getChannels().isEmpty()) { + logger.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), event.getChannels().size()); try { - sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), parentPlatform, deviceChannelList, subscribe, null); + sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), parentPlatform, event.getChannels(), subscribe, null); } catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException | IllegalAccessException e) { logger.error("[命令发送失败] 国标级联 Catalog通知: {}", e.getMessage()); } } - }else if (parentPlatformMap.keySet().size() > 0) { - for (String gbId : parentPlatformMap.keySet()) { - List parentPlatforms = parentPlatformMap.get(gbId); + }else if (!parentPlatformMap.keySet().isEmpty()) { + // 事件没有要通知的上级,那么需要通知所有订阅了的上级 + Map> catalogData = new HashMap<>(); + for (CommonGbChannel channel : parentPlatformMap.keySet()) { + List parentPlatforms = parentPlatformMap.get(channel); if (parentPlatforms != null && parentPlatforms.size() > 0) { for (ParentPlatform platform : parentPlatforms) { - SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId()); - if (subscribeInfo == null) { - continue; - } - logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId); - List deviceChannelList = new ArrayList<>(); - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(gbId); - deviceChannelList.add(deviceChannel); - try { - sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), platform, deviceChannelList, subscribeInfo, null); - } catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException | - IllegalAccessException e) { - logger.error("[命令发送失败] 国标级联 Catalog通知: {}", e.getMessage()); + if (!catalogData.containsKey(platform)) { + catalogData.put(platform, new ArrayList<>()); } + catalogData.get(platform).add(channel); } } } + for (ParentPlatform platform : catalogData.keySet()) { + SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getId()); + if (subscribeInfo == null) { + continue; + } + logger.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), platform.getServerGBId(), catalogData.get(platform).size()); + try { + sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), platform, catalogData.get(platform), subscribeInfo, null); + } catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException | + IllegalAccessException e) { + logger.error("[命令发送失败] 国标级联 Catalog通知: {}", e.getMessage()); + } + } } break; case CatalogEvent.VLOST: @@ -144,52 +124,42 @@ public class CatalogEventLister implements ApplicationListener { case CatalogEvent.ADD: case CatalogEvent.UPDATE: if (parentPlatform != null || subscribe != null) { - List deviceChannelList = new ArrayList<>(); - if (event.getDeviceChannels() != null) { - deviceChannelList.addAll(event.getDeviceChannels()); - } - if (event.getGbStreams() != null && event.getGbStreams().size() > 0){ - for (GbStream gbStream : event.getGbStreams()) { - deviceChannelList.add( - gbStreamService.getDeviceChannelListByStreamWithStatus(gbStream, gbStream.getCatalogId(), parentPlatform)); - } - } - if (deviceChannelList.size() > 0) { - logger.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), deviceChannelList.size()); + if (!event.getChannels().isEmpty()) { + logger.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), event.getChannels().size()); try { - sipCommanderFroPlatform.sendNotifyForCatalogAddOrUpdate(event.getType(), parentPlatform, deviceChannelList, subscribe, null); + sipCommanderFroPlatform.sendNotifyForCatalogAddOrUpdate(event.getType(), parentPlatform, event.getChannels(), subscribe, null); } catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException | IllegalAccessException e) { logger.error("[命令发送失败] 国标级联 Catalog通知: {}", e.getMessage()); } } - }else if (parentPlatformMap.keySet().size() > 0) { - for (String gbId : parentPlatformMap.keySet()) { - List parentPlatforms = parentPlatformMap.get(gbId); + }else if (!parentPlatformMap.keySet().isEmpty()) { + // 事件没有要通知的上级,那么需要通知所有订阅了的上级 + Map> catalogData = new HashMap<>(); + for (CommonGbChannel channel : parentPlatformMap.keySet()) { + List parentPlatforms = parentPlatformMap.get(channel); if (parentPlatforms != null && parentPlatforms.size() > 0) { for (ParentPlatform platform : parentPlatforms) { - SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId()); - if (subscribeInfo == null) { - continue; - } - logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId); - List deviceChannelList = new ArrayList<>(); - DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(platform.getServerGBId(), gbId); - deviceChannelList.add(deviceChannel); - GbStream gbStream = storager.queryStreamInParentPlatform(platform.getServerGBId(), gbId); - if(gbStream != null){ - DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStreamWithStatus(gbStream, gbStream.getCatalogId(), platform); - deviceChannelList.add(deviceChannelByStream); - } - try { - sipCommanderFroPlatform.sendNotifyForCatalogAddOrUpdate(event.getType(), platform, deviceChannelList, subscribeInfo, null); - } catch (InvalidArgumentException | ParseException | NoSuchFieldException | - SipException | IllegalAccessException e) { - logger.error("[命令发送失败] 国标级联 Catalog通知: {}", e.getMessage()); + if (!catalogData.containsKey(platform)) { + catalogData.put(platform, new ArrayList<>()); } + catalogData.get(platform).add(channel); } } } + for (ParentPlatform platform : catalogData.keySet()) { + SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getId()); + if (subscribeInfo == null) { + continue; + } + logger.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), platform.getServerGBId(), catalogData.get(platform).size()); + try { + sipCommanderFroPlatform.sendNotifyForCatalogAddOrUpdate(event.getType(), platform, catalogData.get(platform), subscribeInfo, null); + } catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException | + IllegalAccessException e) { + logger.error("[命令发送失败] 国标级联 Catalog通知: {}", e.getMessage()); + } + } } break; default: diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java index a4558c75..544e7deb 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.gb28181.transmit.cmd; +import com.genersoft.iot.vmp.common.CommonGbChannel; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; @@ -89,17 +90,13 @@ public interface ISIPCommanderForPlatform { /** * 回复catalog事件-增加/更新 - * @param parentPlatform - * @param deviceChannels */ - void sendNotifyForCatalogAddOrUpdate(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException; + void sendNotifyForCatalogAddOrUpdate(String type, ParentPlatform parentPlatform, List channels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException; /** * 回复catalog事件-删除 - * @param parentPlatform - * @param deviceChannels */ - void sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException; + void sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List channels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException; /** * 回复recordInfo diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java index 473ca91d..933153f2 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; import com.alibaba.fastjson2.JSON; +import com.genersoft.iot.vmp.common.CommonGbChannel; import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.gb28181.SipLayer; import com.genersoft.iot.vmp.gb28181.bean.*; @@ -556,30 +557,30 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { } @Override - public void sendNotifyForCatalogAddOrUpdate(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException { - if (parentPlatform == null || deviceChannels == null || deviceChannels.size() == 0 || subscribeInfo == null) { + public void sendNotifyForCatalogAddOrUpdate(String type, ParentPlatform parentPlatform, List channelList, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException { + if (parentPlatform == null || channelList == null || channelList.size() == 0 || subscribeInfo == null) { return; } if (index == null) { index = 0; } - if (index >= deviceChannels.size()) { + if (index >= channelList.size()) { return; } - List channels; - if (index + parentPlatform.getCatalogGroup() < deviceChannels.size()) { - channels = deviceChannels.subList(index, index + parentPlatform.getCatalogGroup()); + List subChannels; + if (index + parentPlatform.getCatalogGroup() < channelList.size()) { + subChannels = channelList.subList(index, index + parentPlatform.getCatalogGroup()); }else { - channels = deviceChannels.subList(index, deviceChannels.size()); + subChannels = channelList.subList(index, channelList.size()); } Integer finalIndex = index; - String catalogXmlContent = getCatalogXmlContentForCatalogAddOrUpdate(parentPlatform, channels, - deviceChannels.size(), type, subscribeInfo); + String catalogXmlContent = getCatalogXmlContentForCatalogAddOrUpdate(parentPlatform, subChannels, + channelList.size(), type, subscribeInfo); sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> { logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg); }, (eventResult -> { try { - sendNotifyForCatalogAddOrUpdate(type, parentPlatform, deviceChannels, subscribeInfo, + sendNotifyForCatalogAddOrUpdate(type, parentPlatform, channelList, subscribeInfo, finalIndex + parentPlatform.getCatalogGroup()); } catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException | IllegalAccessException e) { @@ -601,7 +602,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { sipSender.transmitRequest(parentPlatform.getDeviceIp(), notifyRequest); } - private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, List channels, int sumNum, String type, SubscribeInfo subscribeInfo) { + private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, List channels, int sumNum, String type, SubscribeInfo subscribeInfo) { StringBuffer catalogXml = new StringBuffer(600); String characterSet = parentPlatform.getCharacterSet(); @@ -613,40 +614,109 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { .append("1\r\n") .append("\r\n"); if (channels.size() > 0) { - for (DeviceChannel channel : channels) { - if (parentPlatform.getServerGBId().equals(channel.getParentId())) { - channel.setParentId(parentPlatform.getDeviceGBId()); - } + for (CommonGbChannel channel : channels) { catalogXml.append("\r\n"); // 行政区划分组只需要这两项就可以 - catalogXml.append("" + channel.getChannelId() + "\r\n"); - catalogXml.append("" + channel.getName() + "\r\n"); - if (channel.getParentId() != null) { + catalogXml.append("" + channel.getCommonGbDeviceID() + "\r\n"); + catalogXml.append("" + channel.getCommonGbName() + "\r\n"); + if (!ObjectUtils.isEmpty(channel.getCommonGbManufacturer())) { + catalogXml.append("" + channel.getCommonGbManufacturer() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbModel())) { + catalogXml.append("" + channel.getCommonGbModel() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbOwner())) { + catalogXml.append(" " + channel.getCommonGbOwner()+ "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbCivilCode())) { + catalogXml.append(" " + channel.getCommonGbCivilCode()+ "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbBlock())) { + catalogXml.append("" + channel.getCommonGbBlock() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbAddress())) { + catalogXml.append("
" + channel.getCommonGbAddress()+ "
\r\n"); + } + catalogXml.append("" + channel.getCommonGbParental() + "\r\n"); + if (!ObjectUtils.isEmpty(channel.getCommonGbParentID())) { // 业务分组加上这一项即可,提高兼容性, - catalogXml.append("" + channel.getParentId() + "\r\n"); + catalogXml.append("" + channel.getCommonGbParentID() + "\r\n"); } - if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) { - // 虚拟组织增加BusinessGroupID字段 - catalogXml.append("" + channel.getParentId() + "\r\n"); + if (!ObjectUtils.isEmpty(channel.getCommonGbSafetyWay())) { + catalogXml.append("" + channel.getCommonGbSafetyWay() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbRegisterWay())) { + catalogXml.append("" + channel.getCommonGbRegisterWay() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbCertNum())) { + catalogXml.append("" + channel.getCommonGbCertNum() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbCertifiable())) { + catalogXml.append("" + channel.getCommonGbCertifiable() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbErrCode())) { + catalogXml.append("" + channel.getCommonGbErrCode() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbEndTime())) { + catalogXml.append("" + channel.getCommonGbEndTime() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbSecrecy())) { + catalogXml.append("" + channel.getCommonGbSecrecy() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbIPAddress())) { + catalogXml.append("" + channel.getCommonGbIPAddress() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbPort())) { + catalogXml.append("" + channel.getCommonGbPort() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbPassword())) { + catalogXml.append("" + channel.getCommonGbPassword() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbStatus())) { + catalogXml.append("" + (channel.getCommonGbStatus() ? "ON" : "OFF") + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbLongitude())) { + catalogXml.append("" + channel.getCommonGbLongitude() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbLatitude())) { + catalogXml.append("" + channel.getCommonGbLatitude() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbPtzType())) { + catalogXml.append("" + channel.getCommonGbPtzType() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbPositionType())) { + catalogXml.append("" + channel.getCommonGbPositionType() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbRoomType())) { + catalogXml.append("" + channel.getCommonGbRoomType() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbUseType())) { + catalogXml.append("" + channel.getCommonGbUseType() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbSupplyLightType())) { + catalogXml.append("" + channel.getCommonGbSupplyLightType() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbDirectionType())) { + catalogXml.append("" + channel.getCommonGbDirectionType() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbResolution())) { + catalogXml.append("" + channel.getCommonGbResolution() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbBusinessGroupID())) { + catalogXml.append("" + channel.getCommonGbBusinessGroupID() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbDownloadSpeed())) { + catalogXml.append("" + channel.getCommonGbDownloadSpeed() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getSVCSpaceSupportMode())) { + catalogXml.append("" + channel.getSVCSpaceSupportMode() + "\r\n"); + } + if (!ObjectUtils.isEmpty(channel.getCommonGbSVCTimeSupportMode())) { + catalogXml.append("" + channel.getCommonGbSVCTimeSupportMode() + "\r\n"); } - catalogXml.append("" + channel.getParental() + "\r\n"); - if (channel.getParental() == 0) { - // 通道项 - catalogXml.append("" + channel.getManufacture() + "\r\n") - .append("" + channel.getSecrecy() + "\r\n") - .append("" + channel.getRegisterWay() + "\r\n") - .append("" + (channel.isStatus() ? "ON" : "OFF") + "\r\n"); - - if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性 - catalogXml.append("" + channel.getModel() + "\r\n") - .append(" " + channel.getOwner()+ "\r\n") - .append("" + channel.getCivilCode() + "\r\n") - .append("
" + channel.getAddress() + "
\r\n"); - } - if (!"presence".equals(subscribeInfo.getEventType())) { - catalogXml.append("" + type + "\r\n"); - } + if (!"presence".equals(subscribeInfo.getEventType())) { + catalogXml.append("" + type + "\r\n"); } catalogXml.append("
\r\n"); } @@ -657,11 +727,11 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { } @Override - public void sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List deviceChannels, + public void sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List channelList, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException { if (parentPlatform == null - || deviceChannels == null - || deviceChannels.size() == 0 + || channelList == null + || channelList.size() == 0 || subscribeInfo == null) { logger.warn("[缺少必要参数]"); return; @@ -670,22 +740,22 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { if (index == null) { index = 0; } - if (index >= deviceChannels.size()) { + if (index >= channelList.size()) { return; } - List channels; - if (index + parentPlatform.getCatalogGroup() < deviceChannels.size()) { - channels = deviceChannels.subList(index, index + parentPlatform.getCatalogGroup()); + List subChannels; + if (index + parentPlatform.getCatalogGroup() < channelList.size()) { + subChannels = channelList.subList(index, index + parentPlatform.getCatalogGroup()); }else { - channels = deviceChannels.subList(index, deviceChannels.size()); + subChannels = channelList.subList(index, channelList.size()); } Integer finalIndex = index; - String catalogXmlContent = getCatalogXmlContentForCatalogOther(parentPlatform, channels, type); + String catalogXmlContent = getCatalogXmlContentForCatalogOther(parentPlatform, subChannels, type); sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> { logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg); }, eventResult -> { try { - sendNotifyForCatalogOther(type, parentPlatform, deviceChannels, subscribeInfo, + sendNotifyForCatalogOther(type, parentPlatform, channelList, subscribeInfo, finalIndex + parentPlatform.getCatalogGroup()); } catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException | IllegalAccessException e) { @@ -694,7 +764,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { }); } - private String getCatalogXmlContentForCatalogOther(ParentPlatform parentPlatform, List channels, String type) { + private String getCatalogXmlContentForCatalogOther(ParentPlatform parentPlatform, List channels, String type) { String characterSet = parentPlatform.getCharacterSet(); StringBuffer catalogXml = new StringBuffer(600); @@ -706,12 +776,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { .append("1\r\n") .append("\r\n"); if (channels.size() > 0) { - for (DeviceChannel channel : channels) { - if (parentPlatform.getServerGBId().equals(channel.getParentId())) { - channel.setParentId(parentPlatform.getDeviceGBId()); - } + for (CommonGbChannel channel : channels) { catalogXml.append("\r\n") - .append("" + channel.getChannelId() + "\r\n") + .append("" + channel.getCommonGbDeviceID() + "\r\n") .append("" + type + "\r\n") .append("\r\n"); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java index 8aa3b0df..7dffdc0d 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java @@ -138,13 +138,12 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme } try { - ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId); - SIPResponse response = responseXmlAck(request, resultXml.toString(), parentPlatform, subscribeInfo.getExpires()); + SIPResponse response = responseXmlAck(request, resultXml.toString(), platform, subscribeInfo.getExpires()); if (subscribeInfo.getExpires() == 0) { - subscribeHolder.removeMobilePositionSubscribe(platformId); + subscribeHolder.removeMobilePositionSubscribe(platform.getId()); }else { subscribeInfo.setResponse(response); - subscribeHolder.putMobilePositionSubscribe(platformId, subscribeInfo); + subscribeHolder.putMobilePositionSubscribe(platform.getId(), subscribeInfo); } } catch (SipException | InvalidArgumentException | ParseException e) { @@ -180,23 +179,22 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme .append("\r\n"); if (subscribeInfo.getExpires() > 0) { - subscribeHolder.putCatalogSubscribe(platformId, subscribeInfo); + subscribeHolder.putCatalogSubscribe(platform.getId(), subscribeInfo); }else if (subscribeInfo.getExpires() == 0) { - subscribeHolder.removeCatalogSubscribe(platformId); + subscribeHolder.removeCatalogSubscribe(platform.getId()); } try { - ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId); - SIPResponse response = responseXmlAck(request, resultXml.toString(), parentPlatform, subscribeInfo.getExpires()); + SIPResponse response = responseXmlAck(request, resultXml.toString(), platform, subscribeInfo.getExpires()); if (subscribeInfo.getExpires() == 0) { - subscribeHolder.removeCatalogSubscribe(platformId); + subscribeHolder.removeCatalogSubscribe(platform.getId()); }else { subscribeInfo.setResponse(response); - subscribeHolder.putCatalogSubscribe(platformId, subscribeInfo); + subscribeHolder.putCatalogSubscribe(platform.getId(), subscribeInfo); } } catch (SipException | InvalidArgumentException | ParseException e) { logger.error("未处理的异常 ", e); } - if (subscribeHolder.getCatalogSubscribe(platformId) == null && platform.isAutoPushChannel()) { + if (subscribeHolder.getCatalogSubscribe(platform.getId()) == null && platform.isAutoPushChannel()) { platformService.addSimulatedSubscribeInfo(platform); } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java b/src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java index 84f922ab..df95f1df 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java @@ -21,4 +21,9 @@ public interface IPlatformChannelService { * 移除共享通道 */ int removeChannelForGB(ParentPlatform platform, List commonGbChannelIds); + + /** + * 在一个给定的范围内查出分享了这个通道的上级平台 + */ + List querySharePlatformListByChannelId(int commonGbId, List platforms); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IPlatformService.java b/src/main/java/com/genersoft/iot/vmp/service/IPlatformService.java index bdc25c8f..dcfd2913 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/IPlatformService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IPlatformService.java @@ -62,4 +62,9 @@ public interface IPlatformService { * 移除上级平台 */ boolean delete(String serverGBId); + + /** + * 根据ID查询上级平台 + */ + ParentPlatform query(Integer platformId); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java index a4002869..20402993 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java @@ -768,6 +768,13 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService { @Override public void deleteById(int commonGbChannelId) { + commonGbChannelMapper.delete(commonGbChannelId); + // TODO 向国标级联发送catalog + } + @Override + public void deleteByIdList(List commonChannelIdList) { + commonGbChannelMapper.deleteByIdList(commonChannelIdList); + // TODO 向国标级联发送catalog } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java index af7b6ea7..1e60c42f 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java @@ -78,11 +78,11 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { allCount = platformChannelMapper.addChannels(platform.getId(), commonGbChannelIdsForSave); logger.info("[关联通道]国标通道 平台:{}, 关联通道数:{}", platform.getServerGBId(), commonGbChannelIdsForSave.size()); } - SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(platform.getServerGBId()); + SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(platform.getId()); if (catalogSubscribe != null) { List channelList = commonGbChannelMapper.queryInIdList(commonGbChannelIdsForSave); if (channelList != null) { - eventPublisher.catalogEventPublish(platform.getServerGBId(), channelList, CatalogEvent.ADD); + eventPublisher.catalogEventPublish(platform.getId(), channelList, CatalogEvent.ADD); } } return allCount; @@ -109,13 +109,18 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { allCount = platformChannelMapper.removeChannels(platform.getId(), commonGbChannelIds); logger.info("[关联通道]国标通道 平台:{}, 取消关联通道数:{}", platform.getServerGBId(), commonGbChannelIds.size()); } - SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(platform.getServerGBId()); + SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(platform.getId()); if (catalogSubscribe != null) { List channelList = commonGbChannelMapper.queryInIdList(commonGbChannelIds); if (channelList != null) { - eventPublisher.catalogEventPublish(platform.getServerGBId(), channelList, CatalogEvent.DEL); + eventPublisher.catalogEventPublish(platform.getId(), channelList, CatalogEvent.DEL); } } return allCount; } + + @Override + public List querySharePlatformListByChannelId(int commonGbId, List platforms) { + return platformChannelMapper.querySharePlatformListByChannelId(); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java index 2a1e1993..9e86a499 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java @@ -74,9 +74,6 @@ public class PlatformServiceImpl implements IPlatformService { @Autowired private SubscribeHolder subscribeHolder; - @Autowired - private GbStreamMapper gbStreamMapper; - @Autowired private UserSetting userSetting; @@ -259,13 +256,13 @@ public class PlatformServiceImpl implements IPlatformService { (parentPlatform.getKeepTimeout())*1000); } if (parentPlatform.isAutoPushChannel()) { - if (subscribeHolder.getCatalogSubscribe(parentPlatform.getServerGBId()) == null) { + if (subscribeHolder.getCatalogSubscribe(parentPlatform.getId()) == null) { addSimulatedSubscribeInfo(parentPlatform); } }else { - SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(parentPlatform.getServerGBId()); + SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(parentPlatform.getId()); if (catalogSubscribe != null && catalogSubscribe.getExpires() == -1) { - subscribeHolder.removeCatalogSubscribe(parentPlatform.getServerGBId()); + subscribeHolder.removeCatalogSubscribe(parentPlatform.getId()); } } } @@ -282,7 +279,7 @@ public class PlatformServiceImpl implements IPlatformService { subscribeInfo.setSimulatedCallId(UUID.randomUUID().toString().replace("-", "") + "@" + parentPlatform.getServerIP()); subscribeInfo.setSimulatedFromTag(UUID.randomUUID().toString().replace("-", "")); subscribeInfo.setSimulatedToTag(UUID.randomUUID().toString().replace("-", "")); - subscribeHolder.putCatalogSubscribe(parentPlatform.getServerGBId(), subscribeInfo); + subscribeHolder.putCatalogSubscribe(parentPlatform.getId(), subscribeInfo); } private void registerTask(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo){ @@ -339,7 +336,7 @@ public class PlatformServiceImpl implements IPlatformService { } // 停止目录订阅回复 logger.info("[平台离线] {}, 停止订阅回复", parentPlatform.getServerGBId()); - subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); + subscribeHolder.removeAllSubscribe(parentPlatform.getId()); // 发起定时自动重新注册 if (!stopRegister) { // 设置为60秒自动尝试重新注册 @@ -393,7 +390,7 @@ public class PlatformServiceImpl implements IPlatformService { if (platform == null) { return; } - SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()); + SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getId()); if (subscribe != null) { // TODO 暂时只处理视频流的回复,后续增加对国标设备的支持 @@ -450,7 +447,7 @@ public class PlatformServiceImpl implements IPlatformService { dynamicTask.stop(keepaliveTaskKey); } // 删除缓存的订阅信息 - subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); + subscribeHolder.removeAllSubscribe(parentPlatform.getId()); // 发送注销的请求 if (parentPlatformCatch != null && parentPlatformCatch.getSipTransactionInfo() != null) { @@ -468,4 +465,9 @@ public class PlatformServiceImpl implements IPlatformService { } return true; } + + @Override + public ParentPlatform query(Integer platformId) { + return platformMapper.getParentPlatById(platformId); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonChannelMapper.java index 8ad1a48f..1f712d31 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonChannelMapper.java @@ -589,4 +589,15 @@ public interface CommonChannelMapper { " #{item}" + "") List getChannelIdsByIds(@Param("channelIds") List channelIds); + + @Delete("") + void delete(@Param("commonGbChannelId") int commonGbChannelId); + + @Delete("") + void deleteByIdList(List commonChannelIdList); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java index d347f125..5aff760d 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java @@ -106,8 +106,8 @@ public class PlatformController { PageInfo parentPlatformPageInfo = platformService.queryParentPlatformList(page, count); if (parentPlatformPageInfo.getList().size() > 0) { for (ParentPlatform platform : parentPlatformPageInfo.getList()) { - platform.setMobilePositionSubscribe(subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()) != null); - platform.setCatalogSubscribe(subscribeHolder.getCatalogSubscribe(platform.getServerGBId()) != null); + platform.setMobilePositionSubscribe(subscribeHolder.getMobilePositionSubscribe(platform.getId()) != null); + platform.setCatalogSubscribe(subscribeHolder.getCatalogSubscribe(platform.getId()) != null); } } return parentPlatformPageInfo;