临时提交

pull/1642/head
648540858 2024-08-21 17:40:01 +08:00
parent 88abf36d6f
commit a18fba8495
8 changed files with 239 additions and 80 deletions

View File

@ -188,4 +188,44 @@ public interface GroupMapper {
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbBusinessGroupId}</foreach>" + " <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbBusinessGroupId}</foreach>" +
" </script>") " </script>")
Set<Group> queryBusinessGroupInChannelList(List<CommonGBChannel> channelList); Set<Group> queryBusinessGroupInChannelList(List<CommonGBChannel> channelList);
@Select(" <script>" +
" SELECT " +
" wcg.device_id as gb_device_id," +
" wcg.name as gb_name," +
" wcg.business_group as gb_business_group," +
" 1 as gb_parental," +
" wcg.parent_device_id as gb_parent_id" +
" from wvp_common_group wcg" +
" left join wvp_platform_group wpg on wpg.group_id = wcg.id" +
" where wpg.platform_id = #{platformId} " +
" </script>")
List<CommonGBChannel> queryForPlatform(@Param("platformId") Integer platformId);
@Select(" <script>" +
" SELECT * " +
" from wvp_common_group wcg" +
" left join wvp_platform_group wpg on wpg.group_id = wcg.id and wpg.platform_id = #{platformId}" +
" where wpg.platform_id = null and wcg.device_id in " +
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbParentId}</foreach>" +
" </script>")
Set<Group> queryNotShareForPlatformByChannelList(List<CommonGBChannel> channelList, @Param("platformId") Integer platformId);
@Select(" <script>" +
" SELECT * " +
" from wvp_common_group wcg" +
" left join wvp_platform_group wpg on wpg.group_id = wcg.id and wpg.platform_id = #{platformId}" +
" where wpg.platform_id = null and wcg.id in " +
" <foreach collection='allGroup' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>")
Set<Group> queryNotShareForPlatformByGroupList(Set<Group> allGroup, @Param("platformId") Integer platformId);
@Select(" <script>" +
" SELECT " +
" * " +
" from wvp_common_group " +
" where device_id in " +
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbParentId}</foreach>" +
" </script>")
Set<Group> queryByChannelList(List<CommonGBChannel> channelList);
} }

View File

@ -343,4 +343,22 @@ public interface PlatformChannelMapper {
"</script>") "</script>")
int removeChannels(@Param("platformId") Integer platformId, List<CommonGBChannel> channelList); int removeChannels(@Param("platformId") Integer platformId, List<CommonGBChannel> channelList);
@Insert("<script> "+
"INSERT INTO wvp_platform_group (platform_id, group_id) VALUES" +
"<foreach collection='groupListNotShare' item='item' separator=','>" +
" (#{platformId}, #{item.id} )" +
"</foreach>" +
"</script>")
int addPlatformGroup(List<Group> groupListNotShare, @Param("platformId") Integer platformId);
@Delete("<script> "+
"DELETE from wvp_platform_group WHERE platform_id=#{platformId} AND group_id in" +
"<foreach collection='groupList' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
"</script>")
int removePlatformGroup(List<Group> groupList, @Param("platformId") Integer platformId);
@Delete("<script> "+
"DELETE from wvp_platform_group WHERE platform_id=#{platformId} AND group_id =#{id}" +
"</script>")
void removePlatformGroupById(@Param("id") int id, @Param("platformId") Integer platformId);
} }

View File

@ -15,11 +15,11 @@ public interface PlatformMapper {
@Insert("INSERT INTO wvp_platform (enable, name, server_gb_id, server_gb_domain, server_ip, server_port,device_gb_id,device_ip,"+ @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,status,catalog_group, update_time," + " device_port,username,password,expires,keep_timeout,transport,character_set,ptz,rtcp,status,catalog_group, update_time," +
" create_time, as_message_channel, send_stream_ip, auto_push_channel, catalog_with_platform,catalog_with_group,catalog_with_region, "+ " create_time, as_message_channel, send_stream_ip, auto_push_channel, catalog_with_platform, custom_group, custom_civil_code, "+
" civil_code,manufacturer,model,address,register_way,secrecy) " + " civil_code,manufacturer,model,address,register_way,secrecy) " +
" VALUES (#{enable}, #{name}, #{serverGBId}, #{serverGBDomain}, #{serverIp}, #{serverPort}, #{deviceGBId}, #{deviceIp}, " + " VALUES (#{enable}, #{name}, #{serverGBId}, #{serverGBDomain}, #{serverIp}, #{serverPort}, #{deviceGBId}, #{deviceIp}, " +
" #{devicePort}, #{username}, #{password}, #{expires}, #{keepTimeout}, #{transport}, #{characterSet}, #{ptz}, #{rtcp}, #{status}, #{catalogGroup},#{updateTime}," + " #{devicePort}, #{username}, #{password}, #{expires}, #{keepTimeout}, #{transport}, #{characterSet}, #{ptz}, #{rtcp}, #{status}, #{catalogGroup},#{updateTime}," +
" #{createTime}, #{asMessageChannel}, #{sendStreamIp}, #{autoPushChannel}, #{catalogWithPlatform}, #{catalogWithGroup},#{catalogWithRegion}, " + " #{createTime}, #{asMessageChannel}, #{sendStreamIp}, #{autoPushChannel}, #{catalogWithPlatform}, #{customGroup},#{customCivilCode}, " +
" #{civilCode}, #{manufacturer}, #{model}, #{address}, #{registerWay}, #{secrecy})") " #{civilCode}, #{manufacturer}, #{model}, #{address}, #{registerWay}, #{secrecy})")
int add(Platform parentPlatform); int add(Platform parentPlatform);
@ -48,8 +48,8 @@ public interface PlatformMapper {
" send_stream_ip=#{sendStreamIp}, " + " send_stream_ip=#{sendStreamIp}, " +
" auto_push_channel=#{autoPushChannel}, " + " auto_push_channel=#{autoPushChannel}, " +
" catalog_with_platform=#{catalogWithPlatform}, " + " catalog_with_platform=#{catalogWithPlatform}, " +
" catalog_with_group=#{catalogWithGroup}, " + " custom_group=#{customGroup}, " +
" catalog_with_region=#{catalogWithRegion}, " + " custom_civil_code=#{customCivilCode}, " +
" civil_code=#{civilCode}, " + " civil_code=#{civilCode}, " +
" manufacturer=#{manufacturer}, " + " manufacturer=#{manufacturer}, " +
" model=#{model}, " + " model=#{model}, " +

View File

@ -116,4 +116,15 @@ public interface RegionMapper {
" <foreach collection='regionChannelList' item='item' open='(' separator=',' close=')' > #{item.parentDeviceId}</foreach>" + " <foreach collection='regionChannelList' item='item' open='(' separator=',' close=')' > #{item.parentDeviceId}</foreach>" +
" </script>") " </script>")
Set<Region> queryParentInChannelList(Set<Region> regionChannelList); Set<Region> queryParentInChannelList(Set<Region> regionChannelList);
@Select(" <script>" +
" SELECT " +
" wcr.device_id as gb_device_id," +
" wcr.name as gb_name" +
" from wvp_common_region wcr" +
" left join wvp_platform_region wpr on wcr.id = wpr.region_id" +
" where wpr.platform_id = #{platformId} " +
" </script>")
List<CommonGBChannel> queryByPlatform(@Param("platformId") Integer platformId);
} }

View File

@ -322,37 +322,22 @@ public class GbChannelServiceImpl implements IGbChannelService {
CommonGBChannel channel = CommonGBChannel.build(platform); CommonGBChannel channel = CommonGBChannel.build(platform);
channelList.add(channel); channelList.add(channel);
} }
// 关联的行政区划信息
// 是否包含行政区划信息
if (platform.getCatalogWithRegion()) { if (platform.getCatalogWithRegion()) {
Set<Region> regionChannelList = regionMapper.queryInChannelList(commonGBChannelList); // 查询关联平台的行政区划信息
List<CommonGBChannel> regionChannelList = regionMapper.queryByPlatform(platform.getId());
if (!regionChannelList.isEmpty()) { if (!regionChannelList.isEmpty()) {
// 获取这些节点的所有父节点, 使用set滤重 channelList.addAll(regionChannelList);
Set<Region> allRegion = getAllRegion(regionChannelList);
allRegion.addAll(regionChannelList);
for (Region region : allRegion) {
channelList.add(CommonGBChannel.build(region));
}
} }
} }
// 是否包含分组信息
if (platform.getCatalogWithGroup()) { if (platform.getCatalogWithGroup()) {
// 虚拟组织 // 关联的分组信息
Set<Group> groupChannelList = groupMapper.queryInChannelList(commonGBChannelList); List<CommonGBChannel> groupChannelList = groupMapper.queryForPlatform(platform.getId());
// 业务分组
Set<Group> businessGroupChannelList = groupMapper.queryBusinessGroupInChannelList(commonGBChannelList);
if (!groupChannelList.isEmpty()) { if (!groupChannelList.isEmpty()) {
// 获取这些节点的所有父节点 channelList.addAll(groupChannelList);
Set<Group> allGroup = getAllGroup(groupChannelList);
allGroup.addAll(groupChannelList);
if (!businessGroupChannelList.isEmpty()) {
allGroup.addAll(businessGroupChannelList);
}
for (Group group : allGroup) {
channelList.add(CommonGBChannel.build(group));
}
} }
} }
channelList.addAll(commonGBChannelList); channelList.addAll(commonGBChannelList);
return channelList; return channelList;
} }
@ -370,18 +355,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
return channelList; return channelList;
} }
private Set<Group> getAllGroup(Set<Group> regionChannelList ) {
if (regionChannelList.isEmpty()) {
return new HashSet<>();
}
Set<Group> channelList = groupMapper.queryParentInChannelList(regionChannelList);
if (channelList.isEmpty()) {
return channelList;
}
Set<Group> allParentRegion = getAllGroup(channelList);
channelList.addAll(allParentRegion);
return channelList;
}
@Override @Override

View File

@ -2,7 +2,10 @@ package com.genersoft.iot.vmp.gb28181.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Group;
import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel; import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel;
import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.GroupMapper;
import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper; import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
@ -14,7 +17,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import java.beans.Transient;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* @author lin * @author lin
@ -28,7 +35,13 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
private PlatformChannelMapper platformChannelMapper; private PlatformChannelMapper platformChannelMapper;
@Autowired @Autowired
EventPublisher eventPublisher; private EventPublisher eventPublisher;
@Autowired
private GroupMapper groupMapper;
@Autowired
private CommonGBChannelMapper commonGBChannelMapper;
@Override @Override
@ -39,11 +52,21 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
} }
@Override @Override
@Transient
public int addAllChannel(Integer platformId) { public int addAllChannel(Integer platformId) {
List<CommonGBChannel> channelListNotShare = platformChannelMapper.queryNotShare(platformId, null); List<CommonGBChannel> channelListNotShare = platformChannelMapper.queryNotShare(platformId, null);
Assert.notEmpty(channelListNotShare, "所有通道已共享"); Assert.notEmpty(channelListNotShare, "所有通道已共享");
int result = platformChannelMapper.addChannels(platformId, channelListNotShare); int result = platformChannelMapper.addChannels(platformId, channelListNotShare);
if (result > 0) { if (result > 0) {
// 查询通道相关的分组信息是否共享,如果没共享就添加
Set<Group> groupListNotShare = getGroupNotShareByChannelList(channelListNotShare, platformId);
int addGroupResult = platformChannelMapper.addPlatformGroup(new ArrayList<>(groupListNotShare), platformId);
if (addGroupResult > 0) {
for (Group group : groupListNotShare) {
// 分组信息排序时需要将顶层排在最后
channelListNotShare.add(0, CommonGBChannel.build(group));
}
}
// 发送消息 // 发送消息
try { try {
// 发送catalog // 发送catalog
@ -55,12 +78,76 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
return result; return result;
} }
/**
* 使
*/
private Set<Group> getGroupNotShareByChannelList(List<CommonGBChannel> channelList, Integer platformId) {
// 获取分组中未分享的节点
Set<Group> groupList = groupMapper.queryNotShareForPlatformByChannelList(channelList, platformId);
// 获取这些节点的所有父节点
if (groupList.isEmpty()) {
return new HashSet<>();
}
Set<Group> allGroup = getAllGroup(groupList);
// 获取全部节点中未分享的
return groupMapper.queryNotShareForPlatformByGroupList(allGroup, platformId);
}
/**
*
*/
private Set<Group> deleteEmptyGroup(Set<Group> groupSet, Integer platformId) {
for (Group group : groupSet) {
// 获取分组子节点
List<Group> children = platformChannelMapper.getShareChildrenGroup(group.getDeviceId(), platformId);
if (!children.isEmpty()) {
groupSet.remove(group);
continue;
}
// 获取分组关联的通道
List<CommonGBChannel> channelList = platformChannelMapper.queryShareChannelByParentId(group.getDeviceId(), platformId);
if (!channelList.isEmpty()) {
groupSet.remove(group);
continue;
}
platformChannelMapper.removePlatformGroupById(group.getId(), platformId);
}
if (!groupSet.isEmpty()) {
}
}
private Set<Group> getAllGroup(Set<Group> groupList ) {
if (groupList.isEmpty()) {
return new HashSet<>();
}
Set<Group> channelList = groupMapper.queryParentInChannelList(groupList);
if (channelList.isEmpty()) {
return channelList;
}
Set<Group> allParentRegion = getAllGroup(channelList);
channelList.addAll(allParentRegion);
return channelList;
}
@Override @Override
@Transient
public int addChannels(Integer platformId, List<Integer> channelIds) { public int addChannels(Integer platformId, List<Integer> channelIds) {
List<CommonGBChannel> channelListNotShare = platformChannelMapper.queryNotShare(platformId, channelIds); List<CommonGBChannel> channelListNotShare = platformChannelMapper.queryNotShare(platformId, channelIds);
Assert.notEmpty(channelListNotShare, "通道已共享"); Assert.notEmpty(channelListNotShare, "通道已共享");
int result = platformChannelMapper.addChannels(platformId, channelListNotShare); int result = platformChannelMapper.addChannels(platformId, channelListNotShare);
if (result > 0) { if (result > 0) {
// 查询通道相关的分组信息是否共享,如果没共享就添加
Set<Group> groupListNotShare = getGroupNotShareByChannelList(channelListNotShare, platformId);
int addGroupResult = platformChannelMapper.addPlatformGroup(new ArrayList<>(groupListNotShare), platformId);
if (addGroupResult > 0) {
for (Group group : groupListNotShare) {
// 分组信息排序时需要将顶层排在最后
channelListNotShare.add(0, CommonGBChannel.build(group));
}
}
// 发送消息 // 发送消息
try { try {
// 发送catalog // 发送catalog
@ -78,6 +165,12 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
Assert.notEmpty(channelListNotShare, "未共享任何通道"); Assert.notEmpty(channelListNotShare, "未共享任何通道");
int result = platformChannelMapper.removeChannels(platformId, channelListNotShare); int result = platformChannelMapper.removeChannels(platformId, channelListNotShare);
if (result > 0) { if (result > 0) {
// 查询通道相关的分组信息是否共享,如果没共享就添加
Set<Group> groupSet = groupMapper.queryByChannelList(channelListNotShare);
Set<Group> deleteGroup = deleteEmptyGroup(groupSet, platformId);
if (!deleteGroup.isEmpty()) {
channelListNotShare.add(0, CommonGBChannel.build(group));
}
// 发送消息 // 发送消息
try { try {
// 发送catalog // 发送catalog
@ -95,6 +188,15 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
Assert.notEmpty(channelList, "所选通道未共享"); Assert.notEmpty(channelList, "所选通道未共享");
int result = platformChannelMapper.removeChannels(platformId, channelList); int result = platformChannelMapper.removeChannels(platformId, channelList);
if (result > 0) { if (result > 0) {
// 查询通道相关的分组信息是否共享,如果没共享就添加
List<Group> groupListShareEmptyChannel = getGroupShareEmptyChannel(channelList, platformId);
int addGroupResult = platformChannelMapper.removePlatformGroup(groupListShareEmptyChannel, platformId);
if (addGroupResult > 0) {
for (Group group : groupListShareEmptyChannel) {
// 分组信息排序时需要将顶层排在最后
channelList.add(0, CommonGBChannel.build(group));
}
}
// 发送消息 // 发送消息
try { try {
// 发送catalog // 发送catalog

View File

@ -125,8 +125,6 @@
<el-checkbox label="消息通道" v-model="value.asMessageChannel"></el-checkbox> <el-checkbox label="消息通道" v-model="value.asMessageChannel"></el-checkbox>
<el-checkbox label="主动推送通道" v-model="value.autoPushChannel"></el-checkbox> <el-checkbox label="主动推送通道" v-model="value.autoPushChannel"></el-checkbox>
<el-checkbox label="推送平台信息" v-model="value.catalogWithPlatform"></el-checkbox> <el-checkbox label="推送平台信息" v-model="value.catalogWithPlatform"></el-checkbox>
<el-checkbox label="推送分组信息" v-model="value.catalogWithGroup"></el-checkbox>
<el-checkbox label="推送行政区划" v-model="value.catalogWithRegion"></el-checkbox>
</div> </div>

View File

@ -282,49 +282,65 @@ create table wvp_platform
); );
create table wvp_platform_gb_channel create table wvp_platform_channel
( (
id serial primary key, id serial primary key,
platform_id integer, platform_id integer,
device_channel_id integer, device_channel_id integer,
device_id character varying(50), device_id character varying(50),
name character varying(255), name character varying(255),
manufacturer character varying(50), manufacturer character varying(50),
model character varying(50), model character varying(50),
owner character varying(50), owner character varying(50),
civil_code character varying(50), civil_code character varying(50),
block character varying(50), block character varying(50),
address character varying(50), address character varying(50),
parental integer, parental integer,
parent_id character varying(50), parent_id character varying(50),
safety_way integer, safety_way integer,
register_way integer, register_way integer,
cert_num character varying(50), cert_num character varying(50),
certifiable integer, certifiable integer,
err_code integer, err_code integer,
end_time character varying(50), end_time character varying(50),
secrecy integer, secrecy integer,
ip_address character varying(50), ip_address character varying(50),
port integer, port integer,
password character varying(255), password character varying(255),
status character varying(50), status character varying(50),
longitude double precision, longitude double precision,
latitude double precision, latitude double precision,
ptz_type integer, ptz_type integer,
position_type integer, position_type integer,
room_type integer, room_type integer,
use_type integer, use_type integer,
supply_light_type integer, supply_light_type integer,
direction_type integer, direction_type integer,
resolution character varying(255), resolution character varying(255),
business_group_id character varying(255), business_group_id character varying(255),
download_speed character varying(255), download_speed character varying(255),
svc_space_support_mod integer, svc_space_support_mod integer,
svc_time_support_mode integer, svc_time_support_mode integer,
constraint uk_platform_gb_channel_platform_id_catalog_id_device_channel_id unique (platform_id, device_channel_id), constraint uk_platform_gb_channel_platform_id_catalog_id_device_channel_id unique (platform_id, device_channel_id),
constraint uk_platform_gb_channel_device_id unique (device_id) constraint uk_platform_gb_channel_device_id unique (device_id)
); );
create table wvp_platform_group
(
id serial primary key,
platform_id integer,
group_id integer,
constraint uk_wvp_platform_group_id_catalog_platform_id_group_id unique (platform_id, group_id)
);
create table wvp_platform_region
(
id serial primary key,
platform_id integer,
region_id integer,
constraint uk_wvp_platform_group_id_catalog_platform_id_group_id unique (platform_id, region_id)
);
create table wvp_stream_proxy create table wvp_stream_proxy
( (
id serial primary key, id serial primary key,