临时提交
parent
88abf36d6f
commit
a18fba8495
|
@ -188,4 +188,44 @@ public interface GroupMapper {
|
|||
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbBusinessGroupId}</foreach>" +
|
||||
" </script>")
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -343,4 +343,22 @@ public interface PlatformChannelMapper {
|
|||
"</script>")
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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,"+
|
||||
" 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) " +
|
||||
" VALUES (#{enable}, #{name}, #{serverGBId}, #{serverGBDomain}, #{serverIp}, #{serverPort}, #{deviceGBId}, #{deviceIp}, " +
|
||||
" #{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})")
|
||||
int add(Platform parentPlatform);
|
||||
|
||||
|
@ -48,8 +48,8 @@ public interface PlatformMapper {
|
|||
" send_stream_ip=#{sendStreamIp}, " +
|
||||
" auto_push_channel=#{autoPushChannel}, " +
|
||||
" catalog_with_platform=#{catalogWithPlatform}, " +
|
||||
" catalog_with_group=#{catalogWithGroup}, " +
|
||||
" catalog_with_region=#{catalogWithRegion}, " +
|
||||
" custom_group=#{customGroup}, " +
|
||||
" custom_civil_code=#{customCivilCode}, " +
|
||||
" civil_code=#{civilCode}, " +
|
||||
" manufacturer=#{manufacturer}, " +
|
||||
" model=#{model}, " +
|
||||
|
|
|
@ -116,4 +116,15 @@ public interface RegionMapper {
|
|||
" <foreach collection='regionChannelList' item='item' open='(' separator=',' close=')' > #{item.parentDeviceId}</foreach>" +
|
||||
" </script>")
|
||||
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);
|
||||
|
||||
}
|
||||
|
|
|
@ -322,37 +322,22 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
|||
CommonGBChannel channel = CommonGBChannel.build(platform);
|
||||
channelList.add(channel);
|
||||
}
|
||||
|
||||
// 是否包含行政区划信息
|
||||
// 关联的行政区划信息
|
||||
if (platform.getCatalogWithRegion()) {
|
||||
Set<Region> regionChannelList = regionMapper.queryInChannelList(commonGBChannelList);
|
||||
// 查询关联平台的行政区划信息
|
||||
List<CommonGBChannel> regionChannelList = regionMapper.queryByPlatform(platform.getId());
|
||||
if (!regionChannelList.isEmpty()) {
|
||||
// 获取这些节点的所有父节点, 使用set滤重
|
||||
Set<Region> allRegion = getAllRegion(regionChannelList);
|
||||
allRegion.addAll(regionChannelList);
|
||||
for (Region region : allRegion) {
|
||||
channelList.add(CommonGBChannel.build(region));
|
||||
channelList.addAll(regionChannelList);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 是否包含分组信息
|
||||
if (platform.getCatalogWithGroup()) {
|
||||
// 虚拟组织
|
||||
Set<Group> groupChannelList = groupMapper.queryInChannelList(commonGBChannelList);
|
||||
// 业务分组
|
||||
Set<Group> businessGroupChannelList = groupMapper.queryBusinessGroupInChannelList(commonGBChannelList);
|
||||
// 关联的分组信息
|
||||
List<CommonGBChannel> groupChannelList = groupMapper.queryForPlatform(platform.getId());
|
||||
if (!groupChannelList.isEmpty()) {
|
||||
// 获取这些节点的所有父节点
|
||||
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(groupChannelList);
|
||||
}
|
||||
}
|
||||
|
||||
channelList.addAll(commonGBChannelList);
|
||||
return channelList;
|
||||
}
|
||||
|
@ -370,18 +355,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
|||
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
|
||||
|
|
|
@ -2,7 +2,10 @@ package com.genersoft.iot.vmp.gb28181.service.impl;
|
|||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
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.dao.CommonGBChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.GroupMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
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.util.Assert;
|
||||
|
||||
import java.beans.Transient;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author lin
|
||||
|
@ -28,7 +35,13 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||
private PlatformChannelMapper platformChannelMapper;
|
||||
|
||||
@Autowired
|
||||
EventPublisher eventPublisher;
|
||||
private EventPublisher eventPublisher;
|
||||
|
||||
@Autowired
|
||||
private GroupMapper groupMapper;
|
||||
|
||||
@Autowired
|
||||
private CommonGBChannelMapper commonGBChannelMapper;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -39,11 +52,21 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transient
|
||||
public int addAllChannel(Integer platformId) {
|
||||
List<CommonGBChannel> channelListNotShare = platformChannelMapper.queryNotShare(platformId, null);
|
||||
Assert.notEmpty(channelListNotShare, "所有通道已共享");
|
||||
int result = platformChannelMapper.addChannels(platformId, channelListNotShare);
|
||||
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 {
|
||||
// 发送catalog
|
||||
|
@ -55,12 +78,76 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||
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
|
||||
@Transient
|
||||
public int addChannels(Integer platformId, List<Integer> channelIds) {
|
||||
List<CommonGBChannel> channelListNotShare = platformChannelMapper.queryNotShare(platformId, channelIds);
|
||||
Assert.notEmpty(channelListNotShare, "通道已共享");
|
||||
int result = platformChannelMapper.addChannels(platformId, channelListNotShare);
|
||||
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 {
|
||||
// 发送catalog
|
||||
|
@ -78,6 +165,12 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||
Assert.notEmpty(channelListNotShare, "未共享任何通道");
|
||||
int result = platformChannelMapper.removeChannels(platformId, channelListNotShare);
|
||||
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 {
|
||||
// 发送catalog
|
||||
|
@ -95,6 +188,15 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||
Assert.notEmpty(channelList, "所选通道未共享");
|
||||
int result = platformChannelMapper.removeChannels(platformId, channelList);
|
||||
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 {
|
||||
// 发送catalog
|
||||
|
|
|
@ -125,8 +125,6 @@
|
|||
<el-checkbox label="消息通道" v-model="value.asMessageChannel"></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.catalogWithGroup"></el-checkbox>
|
||||
<el-checkbox label="推送行政区划" v-model="value.catalogWithRegion"></el-checkbox>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ create table wvp_platform
|
|||
);
|
||||
|
||||
|
||||
create table wvp_platform_gb_channel
|
||||
create table wvp_platform_channel
|
||||
(
|
||||
id serial primary key,
|
||||
platform_id integer,
|
||||
|
@ -325,6 +325,22 @@ create table wvp_platform_gb_channel
|
|||
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
|
||||
(
|
||||
id serial primary key,
|
||||
|
|
Loading…
Reference in New Issue