diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java index e04fdb37..689208f3 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java @@ -444,4 +444,12 @@ public class ParentPlatform { public void setShareRegion(boolean shareRegion) { this.shareRegion = shareRegion; } + + public boolean isSystemCatalog() { + return systemCatalog; + } + + public void setSystemCatalog(boolean systemCatalog) { + this.systemCatalog = systemCatalog; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java index f4b086de..04149b06 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java @@ -67,8 +67,13 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent String channelId = XmlUtil.getText(rootElement, "DeviceID"); // 远程启动功能 if (!ObjectUtils.isEmpty(XmlUtil.getText(rootElement, "TeleBoot"))) { - // TODO 拒绝远程启动命令 logger.warn("[国标级联]收到平台的远程启动命令, 不处理"); + try { + responseAck(request, Response.OK); + } catch (SipException | InvalidArgumentException | ParseException e) { + logger.error("[命令发送失败] 错误信息: {}", e.getMessage()); + } + return; } DeviceControlType deviceControlType = DeviceControlType.typeOf(rootElement); logger.info("[接受deviceControl命令] 命令: {}", deviceControlType); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java index 44d53b64..8c13bbdd 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java @@ -1,18 +1,13 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd; import com.genersoft.iot.vmp.common.CommonGbChannel; -import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; import com.genersoft.iot.vmp.service.IPlatformChannelService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; import org.dom4j.Element; import org.slf4j.Logger; @@ -27,7 +22,6 @@ import javax.sip.SipException; import javax.sip.header.FromHeader; import javax.sip.message.Response; import java.text.ParseException; -import java.util.ArrayList; import java.util.List; @Component @@ -39,21 +33,12 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem @Autowired private QueryMessageHandler queryMessageHandler; - @Autowired - private IVideoManagerStorage storager; - @Autowired private ISIPCommanderForPlatform cmderFroPlatform; @Autowired private IPlatformChannelService platformChannelService; - @Autowired - private EventPublisher publisher; - - @Autowired - private IVideoManagerStorage storage; - @Override public void afterPropertiesSet() throws Exception { queryMessageHandler.addHandler(cmdType, this); @@ -78,7 +63,6 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem String sn = snElement.getText(); // 准备回复通道信息 List commonGbChannelList = platformChannelService.queryChannelList(parentPlatform); - try { if (!commonGbChannelList.isEmpty()) { cmderFroPlatform.catalogQuery(commonGbChannelList, parentPlatform, sn, fromHeader.getTag()); @@ -89,22 +73,5 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem } catch (SipException | InvalidArgumentException | ParseException e) { logger.error("[命令发送失败] 国标级联 目录查询回复: {}", e.getMessage()); } - - - - } - - private DeviceChannel getChannelForPlatform(ParentPlatform platform) { - DeviceChannel deviceChannel = new DeviceChannel(); - - deviceChannel.setChannelId(platform.getDeviceGBId()); - deviceChannel.setName(platform.getName()); - deviceChannel.setManufacture("wvp-pro"); - deviceChannel.setOwner("wvp-pro"); - deviceChannel.setAddress("wvp-pro"); - deviceChannel.setRegisterWay(0); - deviceChannel.setSecrecy("0"); - - return deviceChannel; } } 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 1b3bfad2..0693279c 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 @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.service.impl; import com.genersoft.iot.vmp.common.BatchLimit; import com.genersoft.iot.vmp.common.CommonGbChannel; +import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.baomidou.dynamic.datasource.annotation.DS; import com.genersoft.iot.vmp.gb28181.bean.*; @@ -55,6 +56,9 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { @Autowired EventPublisher eventPublisher; + @Autowired + private SipConfig sipConfig; + @Override @Transactional public int addChannelForGB(ParentPlatform platform, List commonGbChannelIds) { @@ -137,6 +141,9 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { @Override public List queryChannelList(ParentPlatform platform) { List result = new ArrayList<>(); + if (platform.isSystemCatalog()) { + result.add(0, getChannelForPlatform(platform)); + } if (platform.isShareAllChannel()) { // 获取所有地区 List allRegionList = regionMapper.queryAllForCommonChannel(); @@ -181,6 +188,22 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { return result; } + private CommonGbChannel getChannelForPlatform(ParentPlatform platform) { + CommonGbChannel channel = new CommonGbChannel(); + + channel.setCommonGbDeviceID(platform.getDeviceGBId()); + channel.setCommonGbName(platform.getName()); + channel.setCommonGbManufacturer(sipConfig.getManufacturer()); + channel.setCommonGbModel(sipConfig.getModel()); + channel.setCommonGbOwner(sipConfig.getOwner()); + channel.setCommonGbCivilCode(sipConfig.getCivilCode()); + channel.setCommonGbAddress(sipConfig.getAddress()); + channel.setCommonGbRegisterWay(1); + channel.setCommonGbSecrecy(0); + + return channel; + } + private Map getAllDependenceGroup(List commonGbChannelList) { Map result = new HashMap<>(); // 查询这些ID对应的分组信息 diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java index 94fe9db8..57138099 100755 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java @@ -18,11 +18,11 @@ public interface ParentPlatformMapper { @Insert("INSERT INTO wvp_platform (enable, name, server_gb_id, server_gb_domain, server_ip, server_port,device_gb_id,device_ip,"+ "device_port,username,password,expires,keep_timeout,transport,character_set,ptz,rtcp,as_message_channel,auto_push_channel," + - "share_all_channel,share_group,share_region,"+ + "share_all_channel,share_group,share_region,system_catalog,"+ "status,start_offline_push,catalog_group,create_time,update_time) " + " VALUES (#{enable}, #{name}, #{serverGBId}, #{serverGBDomain}, #{serverIP}, #{serverPort}, #{deviceGBId}, #{deviceIp}, " + " #{devicePort}, #{username}, #{password}, #{expires}, #{keepTimeout}, #{transport}, #{characterSet}, #{ptz}, " + - " #{rtcp}, #{asMessageChannel}, #{autoPushChannel}, #{shareAllChannel}, #{shareGroup}, #{shareRegion}, " + + " #{rtcp}, #{asMessageChannel}, #{autoPushChannel}, #{shareAllChannel}, #{shareGroup}, #{shareRegion, #{systemCatalog}, " + " #{status}, #{startOfflinePush}, #{catalogGroup}, #{createTime}, #{updateTime})") int addParentPlatform(ParentPlatform parentPlatform); @@ -49,6 +49,7 @@ public interface ParentPlatformMapper { "share_all_channel=#{shareAllChannel}, " + "share_group=#{shareGroup}, " + "share_region=#{shareRegion}, " + + "system_catalog=#{systemCatalog}, " + "status=#{status}, " + "start_offline_push=#{startOfflinePush}, " + "catalog_group=#{catalogGroup}, " + diff --git a/数据库/结构优化/common.sql b/数据库/结构优化/common.sql index 2ae8eddf..4e92fe61 100644 --- a/数据库/结构优化/common.sql +++ b/数据库/结构优化/common.sql @@ -163,6 +163,9 @@ alter table wvp_platform alter table wvp_platform drop column catalog_id; +alter table wvp_platform + add column system_catalog bool default false; + diff --git a/数据库/结构优化/初始化-mysql.sql b/数据库/结构优化/初始化-mysql.sql index 2705b970..5a7bfc3a 100644 --- a/数据库/结构优化/初始化-mysql.sql +++ b/数据库/结构优化/初始化-mysql.sql @@ -195,6 +195,7 @@ create table wvp_platform ( update_time character varying(50), as_message_channel bool default false, auto_push_channel bool default false, + system_catalog bool default false, constraint uk_platform_unique_server_gb_id unique (server_gb_id) ); diff --git a/数据库/结构优化/初始化-postgresql-kingbase.sql b/数据库/结构优化/初始化-postgresql-kingbase.sql index 830f759f..acbb7cef 100644 --- a/数据库/结构优化/初始化-postgresql-kingbase.sql +++ b/数据库/结构优化/初始化-postgresql-kingbase.sql @@ -182,6 +182,7 @@ create table wvp_platform ( update_time character varying(50), as_message_channel bool default false, auto_push_channel bool default false, + system_catalog bool default false, constraint uk_platform_unique_server_gb_id unique (server_gb_id) );