优化国标级联接口

结构优化
648540858 2024-01-23 16:20:36 +08:00
parent 1411de77fe
commit 407828e880
11 changed files with 167 additions and 137 deletions

View File

@ -28,6 +28,43 @@ public class SipConfig {
private boolean alarm;
private String name = "WVP视频平台";
/**
*
*/
private String manufacturer = "WVP视频平台";
/**
*
*/
private String model;
/**
*
*/
private String owner;
/**
*
*/
private String civilCode;
/**
*
*/
private String address;
/**
*
*/
private int registerWay = 1;
/**
*
*/
private int secrecy = 0;
public void setIp(String ip) {
this.ip = ip;
}
@ -107,4 +144,68 @@ public class SipConfig {
public void setShowIp(String showIp) {
this.showIp = showIp;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getManufacturer() {
return manufacturer;
}
public void setManufacturer(String manufacturer) {
this.manufacturer = manufacturer;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getCivilCode() {
return civilCode;
}
public void setCivilCode(String civilCode) {
this.civilCode = civilCode;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public int getRegisterWay() {
return registerWay;
}
public void setRegisterWay(int registerWay) {
this.registerWay = registerWay;
}
public int getSecrecy() {
return secrecy;
}
public void setSecrecy(int secrecy) {
this.secrecy = secrecy;
}
}

View File

@ -129,12 +129,6 @@ public class ParentPlatform {
@Schema(description = "共享的通道数量")
private int channelCount;
/**
* Id,
*/
@Schema(description = "默认目录Id,自动添加的通道多放在这个目录下")
private String catalogId;
/**
*
*/
@ -165,12 +159,6 @@ public class ParentPlatform {
@Schema(description = "目录分组-每次向上级发送通道信息时单个包携带的通道数量取值1,2,4,8")
private int catalogGroup;
/**
*
*/
@Schema(description = "行政区划")
private String administrativeDivision;
/**
*
*/
@ -198,6 +186,9 @@ public class ParentPlatform {
@Schema(description = "是否共享区域")
private boolean shareRegion;
@Schema(description = "推送系统目录")
private boolean systemCatalog;
public Integer getId() {
return id;
}
@ -358,14 +349,6 @@ public class ParentPlatform {
this.channelCount = channelCount;
}
public String getCatalogId() {
return catalogId;
}
public void setCatalogId(String catalogId) {
this.catalogId = catalogId;
}
public boolean isCatalogSubscribe() {
return catalogSubscribe;
}
@ -406,14 +389,6 @@ public class ParentPlatform {
this.catalogGroup = catalogGroup;
}
public String getAdministrativeDivision() {
return administrativeDivision;
}
public void setAdministrativeDivision(String administrativeDivision) {
this.administrativeDivision = administrativeDivision;
}
public String getUpdateTime() {
return updateTime;
}

View File

@ -90,48 +90,48 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
@Override
public void register(ParentPlatform parentPlatform, @Nullable SipTransactionInfo sipTransactionInfo, @Nullable WWWAuthenticateHeader www,
SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean isRegister) throws SipException, InvalidArgumentException, ParseException {
Request request;
Request request;
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
String fromTag = SipUtils.getNewFromTag();
String toTag = null;
if (sipTransactionInfo != null ) {
if (sipTransactionInfo.getCallId() != null) {
callIdHeader.setCallId(sipTransactionInfo.getCallId());
}
if (sipTransactionInfo.getFromTag() != null) {
fromTag = sipTransactionInfo.getFromTag();
}
if (sipTransactionInfo.getToTag() != null) {
toTag = sipTransactionInfo.getToTag();
}
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
String fromTag = SipUtils.getNewFromTag();
String toTag = null;
if (sipTransactionInfo != null ) {
if (sipTransactionInfo.getCallId() != null) {
callIdHeader.setCallId(sipTransactionInfo.getCallId());
}
if (www == null ) {
request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform,
redisCatchStorage.getCSEQ(), fromTag,
toTag, callIdHeader, isRegister? parentPlatform.getExpires() : 0);
// 将 callid 写入缓存, 等注册成功可以更新状态
String callIdFromHeader = callIdHeader.getCallId();
redisCatchStorage.updatePlatformRegisterInfo(callIdFromHeader, PlatformRegisterInfo.getInstance(parentPlatform.getServerGBId(), isRegister));
sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (event)->{
if (event != null) {
logger.info("向上级平台 [ {} ] 注册发生错误: {} ",
parentPlatform.getServerGBId(),
event.msg);
}
redisCatchStorage.delPlatformRegisterInfo(callIdFromHeader);
if (errorEvent != null ) {
errorEvent.response(event);
}
});
}else {
request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, fromTag, toTag, www, callIdHeader, isRegister? parentPlatform.getExpires() : 0);
if (sipTransactionInfo.getFromTag() != null) {
fromTag = sipTransactionInfo.getFromTag();
}
if (sipTransactionInfo.getToTag() != null) {
toTag = sipTransactionInfo.getToTag();
}
}
sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, null, okEvent);
if (www == null ) {
request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform,
redisCatchStorage.getCSEQ(), fromTag,
toTag, callIdHeader, isRegister? parentPlatform.getExpires() : 0);
// 将 callid 写入缓存, 等注册成功可以更新状态
String callIdFromHeader = callIdHeader.getCallId();
redisCatchStorage.updatePlatformRegisterInfo(callIdFromHeader, PlatformRegisterInfo.getInstance(parentPlatform.getServerGBId(), isRegister));
sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (event)->{
if (event != null) {
logger.info("向上级平台 [ {} ] 注册发生错误: {} ",
parentPlatform.getServerGBId(),
event.msg);
}
redisCatchStorage.delPlatformRegisterInfo(callIdFromHeader);
if (errorEvent != null ) {
errorEvent.response(event);
}
});
}else {
request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, fromTag, toTag, www, callIdHeader, isRegister? parentPlatform.getExpires() : 0);
}
sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, null, okEvent);
}
@Override
@ -677,7 +677,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException {
if (parentPlatform == null
|| channelList == null
|| channelList.size() == 0
|| channelList.isEmpty()
|| subscribeInfo == null) {
logger.warn("[缺少必要参数]");
return;

View File

@ -101,7 +101,6 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
deviceChannel.setName(platform.getName());
deviceChannel.setManufacture("wvp-pro");
deviceChannel.setOwner("wvp-pro");
deviceChannel.setCivilCode(platform.getAdministrativeDivision());
deviceChannel.setAddress("wvp-pro");
deviceChannel.setRegisterWay(0);
deviceChannel.setSecrecy("0");

View File

@ -21,7 +21,7 @@ public interface IPlatformService {
* @param count
* @return
*/
PageInfo<ParentPlatform> queryParentPlatformList(int page, int count, String query, Boolean online);
PageInfo<ParentPlatform> queryParentPlatformList(int page, int count, String query, Boolean online, Boolean enable);
/**
*

View File

@ -95,9 +95,9 @@ public class PlatformServiceImpl implements IPlatformService {
}
@Override
public PageInfo<ParentPlatform> queryParentPlatformList(int page, int count, String query, Boolean online) {
public PageInfo<ParentPlatform> queryParentPlatformList(int page, int count, String query, Boolean online, Boolean enable) {
PageHelper.startPage(page, count);
List<ParentPlatform> all = platformMapper.getParentPlatformList(query, online);
List<ParentPlatform> all = platformMapper.getParentPlatformList(query, online, enable);
PageInfo<ParentPlatform> platformPageInfo = new PageInfo<>(all);
int allCount = commonChannelMapper.getAllCount();
platformPageInfo.getList().stream().forEach(parentPlatform -> {
@ -115,11 +115,6 @@ public class PlatformServiceImpl implements IPlatformService {
// 每次发送目录的数量默认为1
parentPlatform.setCatalogGroup(1);
}
if (parentPlatform.getAdministrativeDivision() == null) {
// 行政区划默认去编号的前6位
parentPlatform.setAdministrativeDivision(parentPlatform.getServerGBId().substring(0,6));
}
parentPlatform.setCatalogId(parentPlatform.getDeviceGBId());
int result = platformMapper.addParentPlatform(parentPlatform);
// 添加缓存
ParentPlatformCatch parentPlatformCatch = new ParentPlatformCatch();
@ -171,10 +166,6 @@ public class PlatformServiceImpl implements IPlatformService {
if (parentPlatform.getCatalogGroup() == 0) {
parentPlatform.setCatalogGroup(1);
}
if (parentPlatform.getAdministrativeDivision() == null) {
parentPlatform.setAdministrativeDivision(parentPlatform.getAdministrativeDivision());
}
platformMapper.updateParentPlatform(parentPlatform);
// 更新redis
redisCatchStorage.delPlatformCatchInfo(parentPlatformOld.getServerGBId());
@ -478,7 +469,7 @@ public class PlatformServiceImpl implements IPlatformService {
redisCatchStorage.delPlatformRegister(parentPlatform.getServerGBId());
}
}
return true;
return platformMapper.delParentPlatform(parentPlatform) > 0;
}
@Override

View File

@ -19,11 +19,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,"+
"status,start_offline_push,catalog_id,administrative_division,catalog_group,create_time,update_time) " +
"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}, " +
" #{status}, #{startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime})")
" #{status}, #{startOfflinePush}, #{catalogGroup}, #{createTime}, #{updateTime})")
int addParentPlatform(ParentPlatform parentPlatform);
@Update("UPDATE wvp_platform " +
@ -52,10 +52,8 @@ public interface ParentPlatformMapper {
"status=#{status}, " +
"start_offline_push=#{startOfflinePush}, " +
"catalog_group=#{catalogGroup}, " +
"administrative_division=#{administrativeDivision}, " +
"create_time=#{createTime}, " +
"update_time=#{updateTime}, " +
"catalog_id=#{catalogId} " +
"update_time=#{updateTime} " +
"WHERE id=#{id}")
int updateParentPlatform(ParentPlatform parentPlatform);
@ -67,13 +65,18 @@ public interface ParentPlatformMapper {
"(SELECT count(0) as channel_count FROM wvp_common_channel_platform wccp WHERE wccp.platform_id = pp.id) " +
"FROM wvp_platform pp where 1=1 " +
"<if test='query != null'> " +
"and (pp.name LIKE '%${query}%' OR de.server_gb_id LIKE '%${query}%' OR de.device_gb_id LIKE '%${query}%')" +
"and (pp.name LIKE '%${query}%' OR pp.server_gb_id LIKE '%${query}%' OR pp.device_gb_id LIKE '%${query}%')" +
"</if>" +
"<if test='online != null'> " +
"and status = #{online}" +
"</if>" +
"<if test='enable != null'> " +
"and enable = #{enable}" +
"</if>" +
"</script>")
List<ParentPlatform> getParentPlatformList(@Param("query") String query, @Param("online") Boolean online);
List<ParentPlatform> getParentPlatformList(@Param("query") String query,
@Param("online") Boolean online,
@Param("enable") Boolean enable);
@Select("SELECT * FROM wvp_platform WHERE enable=#{enable} ")
List<ParentPlatform> getEnableParentPlatformList(boolean enable);

View File

@ -84,18 +84,19 @@ public class PlatformController {
* @param count
* @return
*/
@GetMapping("/list/{count}/{page}")
@GetMapping("/list")
@Operation(summary = "分页查询级联平台", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "page", description = "当前页", required = true)
@Parameter(name = "count", description = "每页条数", required = true)
public PageInfo<ParentPlatform> platforms(int page, int count,
@RequestParam(required = false)String query,
@RequestParam(required = false)Boolean online) {
@RequestParam(required = false)Boolean online,
@RequestParam(required = false)Boolean enable) {
if (ObjectUtils.isEmpty(query)) {
query = null;
}
PageInfo<ParentPlatform> parentPlatformPageInfo = platformService.queryParentPlatformList(page, count, query, online);
PageInfo<ParentPlatform> parentPlatformPageInfo = platformService.queryParentPlatformList(page, count, query, online, enable);
if (!parentPlatformPageInfo.getList().isEmpty()) {
for (ParentPlatform platform : parentPlatformPageInfo.getList()) {
platform.setMobilePositionSubscribe(subscribeHolder.getMobilePositionSubscribe(platform.getId()) != null);

View File

@ -164,6 +164,12 @@ alter table wvp_stream_push
alter table wvp_stream_proxy
drop column src_url;
alter table wvp_platform
drop column administrative_division;
alter table wvp_platform
drop column catalog_id;

View File

@ -186,12 +186,10 @@ create table wvp_platform (
keep_timeout character varying(50),
transport character varying(50),
character_set character varying(50),
catalog_id character varying(50),
ptz bool default false,
rtcp bool default false,
status bool default false,
start_offline_push bool default false,
administrative_division character varying(50),
catalog_group integer,
create_time character varying(50),
update_time character varying(50),
@ -200,32 +198,6 @@ create table wvp_platform (
constraint uk_platform_unique_server_gb_id unique (server_gb_id)
);
create table wvp_platform_catalog (
id character varying(50),
platform_id character varying(50),
name character varying(255),
parent_id character varying(50),
civil_code character varying(50),
business_group_id character varying(50),
constraint uk_platform_catalog_id_platform_id unique (id, platform_id)
);
create table wvp_platform_gb_channel (
id serial primary key ,
platform_id character varying(50),
catalog_id character varying(50),
device_channel_id integer,
constraint uk_platform_gb_channel_platform_id_catalog_id_device_channel_id unique (platform_id, catalog_id, device_channel_id)
);
create table wvp_platform_gb_stream (
id serial primary key,
platform_id character varying(50),
catalog_id character varying(50),
gb_stream_id integer,
constraint uk_platform_gb_stream_platform_id_catalog_id_gb_stream_id unique (platform_id, catalog_id, gb_stream_id)
);
create table wvp_stream_proxy (
id serial primary key,
type character varying(50),
@ -303,15 +275,6 @@ create table wvp_user_role (
create_time character varying(50),
update_time character varying(50)
);
create table wvp_resources_tree (
id serial primary key ,
is_catalog bool default true,
device_channel_id integer ,
gb_stream_id integer,
name character varying(255),
parentId integer,
path character varying(255)
);
/*初始数据*/

View File

@ -177,7 +177,6 @@ create table wvp_platform (
rtcp bool default false,
status bool default false,
start_offline_push bool default false,
administrative_division character varying(50),
catalog_group integer,
create_time character varying(50),
update_time character varying(50),
@ -186,14 +185,6 @@ create table wvp_platform (
constraint uk_platform_unique_server_gb_id unique (server_gb_id)
);
create table wvp_platform_gb_channel (
id serial primary key ,
platform_id character varying(50),
catalog_id character varying(50),
device_channel_id integer,
constraint uk_platform_gb_channel_platform_id_catalog_id_device_channel_id unique (platform_id, catalog_id, device_channel_id)
);
create table wvp_stream_proxy (
id serial primary key,
type character varying(50),