临时提交

结构优化
648540858 2023-12-11 21:18:53 +08:00
parent b7af59b2ce
commit 92669f192f
16 changed files with 284 additions and 210 deletions

View File

@ -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,

View File

@ -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;
}
}

View File

@ -26,11 +26,11 @@ public class SubscribeHolder {
private final String taskOverduePrefix = "subscribe_overdue_";
private static ConcurrentHashMap<String, SubscribeInfo> catalogMap = new ConcurrentHashMap<>();
private static ConcurrentHashMap<String, SubscribeInfo> mobilePositionMap = new ConcurrentHashMap<>();
private static ConcurrentHashMap<Integer, SubscribeInfo> catalogMap = new ConcurrentHashMap<>();
private static ConcurrentHashMap<Integer, SubscribeInfo> 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<String> getAllCatalogSubscribePlatform() {
List<String> 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);
}

View File

@ -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<CommonGbChannel> 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<CommonGbChannel> channels, String type) {
public void catalogEventPublish(Integer platformId, List<CommonGbChannel> 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<GbStream> gbStreams, String type) {
public void catalogEventPublishForStream(Integer platformId, List<GbStream> 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<GbStream> gbStreamList = new ArrayList<>();
gbStreamList.add(gbStream);
catalogEventPublishForStream(platformId, gbStreamList, type);

View File

@ -48,9 +48,8 @@ public class CatalogEvent extends ApplicationEvent {
public static final String UPDATE = "UPDATE";
private List<CommonGbChannel> channels;
private List<GbStream> gbStreams;
private String type;
private String platformId;
private Integer platformId;
public List<CommonGbChannel> 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<GbStream> getGbStreams() {
return gbStreams;
}
public void setGbStreams(List<GbStream> gbStreams) {
this.gbStreams = gbStreams;
}
}

View File

@ -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<CatalogEvent> {
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<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>();
Map<CommonGbChannel, List<ParentPlatform>> 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<String> platforms = subscribeHolder.getAllCatalogSubscribePlatform();
if (event.getDeviceChannels() != null) {
if (platforms.size() > 0) {
for (DeviceChannel deviceChannel : event.getDeviceChannels()) {
List<ParentPlatform> 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<ParentPlatform> 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<ParentPlatform> parentPlatformsForGB = platformChannelService.querySharePlatformListByChannelId(channel.getCommonGbId(), platforms);
parentPlatformMap.put(channel, parentPlatformsForGB);
}
}
}
@ -86,55 +77,44 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
case CatalogEvent.OFF:
case CatalogEvent.DEL:
if (parentPlatform != null || subscribe != null) {
List<DeviceChannel> 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<ParentPlatform> parentPlatforms = parentPlatformMap.get(gbId);
}else if (!parentPlatformMap.keySet().isEmpty()) {
// 事件没有要通知的上级,那么需要通知所有订阅了的上级
Map<ParentPlatform, List<CommonGbChannel>> catalogData = new HashMap<>();
for (CommonGbChannel channel : parentPlatformMap.keySet()) {
List<ParentPlatform> 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<DeviceChannel> 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<CatalogEvent> {
case CatalogEvent.ADD:
case CatalogEvent.UPDATE:
if (parentPlatform != null || subscribe != null) {
List<DeviceChannel> 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<ParentPlatform> parentPlatforms = parentPlatformMap.get(gbId);
}else if (!parentPlatformMap.keySet().isEmpty()) {
// 事件没有要通知的上级,那么需要通知所有订阅了的上级
Map<ParentPlatform, List<CommonGbChannel>> catalogData = new HashMap<>();
for (CommonGbChannel channel : parentPlatformMap.keySet()) {
List<ParentPlatform> 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<DeviceChannel> 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:

View File

@ -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<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException;
void sendNotifyForCatalogAddOrUpdate(String type, ParentPlatform parentPlatform, List<CommonGbChannel> channels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException;
/**
* catalog-
* @param parentPlatform
* @param deviceChannels
*/
void sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException;
void sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<CommonGbChannel> channels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException;
/**
* recordInfo

View File

@ -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<DeviceChannel> 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<CommonGbChannel> 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<DeviceChannel> channels;
if (index + parentPlatform.getCatalogGroup() < deviceChannels.size()) {
channels = deviceChannels.subList(index, index + parentPlatform.getCatalogGroup());
List<CommonGbChannel> 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<DeviceChannel> channels, int sumNum, String type, SubscribeInfo subscribeInfo) {
private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, List<CommonGbChannel> 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("<SumNum>1</SumNum>\r\n")
.append("<DeviceList Num=\"" + channels.size() + "\">\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("<Item>\r\n");
// 行政区划分组只需要这两项就可以
catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");
catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n");
if (channel.getParentId() != null) {
catalogXml.append("<DeviceID>" + channel.getCommonGbDeviceID() + "</DeviceID>\r\n");
catalogXml.append("<Name>" + channel.getCommonGbName() + "</Name>\r\n");
if (!ObjectUtils.isEmpty(channel.getCommonGbManufacturer())) {
catalogXml.append("<Manufacturer>" + channel.getCommonGbManufacturer() + "</Manufacturer>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbModel())) {
catalogXml.append("<Model>" + channel.getCommonGbModel() + "</Model>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbOwner())) {
catalogXml.append("<Owner> " + channel.getCommonGbOwner()+ "</Owner>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbCivilCode())) {
catalogXml.append("<CivilCode> " + channel.getCommonGbCivilCode()+ "</CivilCode>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbBlock())) {
catalogXml.append("<Block>" + channel.getCommonGbBlock() + "</Block>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbAddress())) {
catalogXml.append("<Address> " + channel.getCommonGbAddress()+ "</Address>\r\n");
}
catalogXml.append("<Parental>" + channel.getCommonGbParental() + "</Parental>\r\n");
if (!ObjectUtils.isEmpty(channel.getCommonGbParentID())) {
// 业务分组加上这一项即可,提高兼容性,
catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n");
catalogXml.append("<ParentID>" + channel.getCommonGbParentID() + "</ParentID>\r\n");
}
if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) {
// 虚拟组织增加BusinessGroupID字段
catalogXml.append("<BusinessGroupID>" + channel.getParentId() + "</BusinessGroupID>\r\n");
if (!ObjectUtils.isEmpty(channel.getCommonGbSafetyWay())) {
catalogXml.append("<SafetyWay>" + channel.getCommonGbSafetyWay() + "</SafetyWay>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbRegisterWay())) {
catalogXml.append("<RegisterWay>" + channel.getCommonGbRegisterWay() + "</RegisterWay>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbCertNum())) {
catalogXml.append("<CertNum>" + channel.getCommonGbCertNum() + "</CertNum>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbCertifiable())) {
catalogXml.append("<Certifiable>" + channel.getCommonGbCertifiable() + "</Certifiable>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbErrCode())) {
catalogXml.append("<ErrCode>" + channel.getCommonGbErrCode() + "</ErrCode>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbEndTime())) {
catalogXml.append("<EndTime>" + channel.getCommonGbEndTime() + "</EndTime>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbSecrecy())) {
catalogXml.append("<Secrecy>" + channel.getCommonGbSecrecy() + "</Secrecy>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbIPAddress())) {
catalogXml.append("<IPAddress>" + channel.getCommonGbIPAddress() + "</IPAddress>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbPort())) {
catalogXml.append("<Port>" + channel.getCommonGbPort() + "</Port>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbPassword())) {
catalogXml.append("<Password>" + channel.getCommonGbPassword() + "</Password>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbStatus())) {
catalogXml.append("<Status>" + (channel.getCommonGbStatus() ? "ON" : "OFF") + "</Status>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbLongitude())) {
catalogXml.append("<Longitude>" + channel.getCommonGbLongitude() + "</Longitude>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbLatitude())) {
catalogXml.append("<Latitude>" + channel.getCommonGbLatitude() + "</Latitude>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbPtzType())) {
catalogXml.append("<PTZType>" + channel.getCommonGbPtzType() + "</PTZType>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbPositionType())) {
catalogXml.append("<PositionType>" + channel.getCommonGbPositionType() + "</PositionType>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbRoomType())) {
catalogXml.append("<RoomType>" + channel.getCommonGbRoomType() + "</RoomType>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbUseType())) {
catalogXml.append("<UseType>" + channel.getCommonGbUseType() + "</UseType>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbSupplyLightType())) {
catalogXml.append("<SupplyLightType>" + channel.getCommonGbSupplyLightType() + "</SupplyLightType>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbDirectionType())) {
catalogXml.append("<DirectionType>" + channel.getCommonGbDirectionType() + "</DirectionType>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbResolution())) {
catalogXml.append("<Resolution>" + channel.getCommonGbResolution() + "</Resolution>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbBusinessGroupID())) {
catalogXml.append("<BusinessGroupID>" + channel.getCommonGbBusinessGroupID() + "</BusinessGroupID>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbDownloadSpeed())) {
catalogXml.append("<DownloadSpeed>" + channel.getCommonGbDownloadSpeed() + "</DownloadSpeed>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getSVCSpaceSupportMode())) {
catalogXml.append("<SVCSpaceSupportMode>" + channel.getSVCSpaceSupportMode() + "</SVCSpaceSupportMode>\r\n");
}
if (!ObjectUtils.isEmpty(channel.getCommonGbSVCTimeSupportMode())) {
catalogXml.append("<SVCTimeSupportMode>" + channel.getCommonGbSVCTimeSupportMode() + "</SVCTimeSupportMode>\r\n");
}
catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
if (channel.getParental() == 0) {
// 通道项
catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n")
.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n")
.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n")
.append("<Status>" + (channel.isStatus() ? "ON" : "OFF") + "</Status>\r\n");
if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性
catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n")
.append("<Owner> " + channel.getOwner()+ "</Owner>\r\n")
.append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n")
.append("<Address>" + channel.getAddress() + "</Address>\r\n");
}
if (!"presence".equals(subscribeInfo.getEventType())) {
catalogXml.append("<Event>" + type + "</Event>\r\n");
}
if (!"presence".equals(subscribeInfo.getEventType())) {
catalogXml.append("<Event>" + type + "</Event>\r\n");
}
catalogXml.append("</Item>\r\n");
}
@ -657,11 +727,11 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
}
@Override
public void sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels,
public void sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<CommonGbChannel> 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<DeviceChannel> channels;
if (index + parentPlatform.getCatalogGroup() < deviceChannels.size()) {
channels = deviceChannels.subList(index, index + parentPlatform.getCatalogGroup());
List<CommonGbChannel> 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<DeviceChannel> channels, String type) {
private String getCatalogXmlContentForCatalogOther(ParentPlatform parentPlatform, List<CommonGbChannel> channels, String type) {
String characterSet = parentPlatform.getCharacterSet();
StringBuffer catalogXml = new StringBuffer(600);
@ -706,12 +776,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
.append("<SumNum>1</SumNum>\r\n")
.append("<DeviceList Num=\" " + channels.size() + " \">\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("<Item>\r\n")
.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n")
.append("<DeviceID>" + channel.getCommonGbDeviceID() + "</DeviceID>\r\n")
.append("<Event>" + type + "</Event>\r\n")
.append("</Item>\r\n");
}

View File

@ -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("</Response>\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);
}
}

View File

@ -21,4 +21,9 @@ public interface IPlatformChannelService {
*
*/
int removeChannelForGB(ParentPlatform platform, List<Integer> commonGbChannelIds);
/**
*
*/
List<ParentPlatform> querySharePlatformListByChannelId(int commonGbId, List<String> platforms);
}

View File

@ -62,4 +62,9 @@ public interface IPlatformService {
*
*/
boolean delete(String serverGBId);
/**
* ID
*/
ParentPlatform query(Integer platformId);
}

View File

@ -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<Integer> commonChannelIdList) {
commonGbChannelMapper.deleteByIdList(commonChannelIdList);
// TODO 向国标级联发送catalog
}
}

View File

@ -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<CommonGbChannel> 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<CommonGbChannel> 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<ParentPlatform> querySharePlatformListByChannelId(int commonGbId, List<String> platforms) {
return platformChannelMapper.querySharePlatformListByChannelId();
}
}

View File

@ -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);
}
}

View File

@ -589,4 +589,15 @@ public interface CommonChannelMapper {
"<foreach collection='channelIds' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
"</script>")
List<Integer> getChannelIdsByIds(@Param("channelIds") List<Integer> channelIds);
@Delete("<script> "+
"delete from wvp_common_channel WHERE common_gb_id = #{commonGbChannelId}" +
"</script>")
void delete(@Param("commonGbChannelId") int commonGbChannelId);
@Delete("<script> "+
"delete from wvp_common_channel WHERE common_gb_id in" +
"<foreach collection='commonChannelIdList' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
"</script>")
void deleteByIdList(List<Integer> commonChannelIdList);
}

View File

@ -106,8 +106,8 @@ public class PlatformController {
PageInfo<ParentPlatform> 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;