国标级联通道共享支持按照设备添加共享和移除共享
This commit is contained in:
@@ -30,4 +30,8 @@ public interface IPlatformChannelService {
|
||||
List<CommonGBChannel> queryByPlatform(Platform platform);
|
||||
|
||||
void pushChannel(Integer platformId);
|
||||
|
||||
void addChannelByDevice(Integer platformId, List<Integer> deviceIds);
|
||||
|
||||
void removeChannelByDevice(Integer platformId, List<Integer> deviceIds);
|
||||
}
|
||||
|
||||
@@ -51,6 +51,8 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
private ISIPCommanderForPlatform sipCommanderFroPlatform;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public PageInfo<PlatformChannel> queryChannelList(int page, int count, String query, Boolean online, Integer platformId, Boolean hasShare) {
|
||||
PageHelper.startPage(page, count);
|
||||
@@ -58,48 +60,6 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
return new PageInfo<>(all);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
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<Region> regionListNotShare = getRegionNotShareByChannelList(channelListNotShare, platformId);
|
||||
if (!regionListNotShare.isEmpty()) {
|
||||
int addGroupResult = platformChannelMapper.addPlatformRegion(new ArrayList<>(regionListNotShare), platformId);
|
||||
if (addGroupResult > 0) {
|
||||
for (Region region : regionListNotShare) {
|
||||
// 分组信息排序时需要将顶层排在最后
|
||||
channelListNotShare.add(0, CommonGBChannel.build(region));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 查询通道相关的分组信息是否共享,如果没共享就添加
|
||||
Set<Group> groupListNotShare = getGroupNotShareByChannelList(channelListNotShare, platformId);
|
||||
if (!groupListNotShare.isEmpty()) {
|
||||
int addGroupResult = platformChannelMapper.addPlatformGroup(new ArrayList<>(groupListNotShare), platformId);
|
||||
if (addGroupResult > 0) {
|
||||
for (Group group : groupListNotShare) {
|
||||
// 分组信息排序时需要将顶层排在最后
|
||||
channelListNotShare.add(0, CommonGBChannel.build(group));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 发送消息
|
||||
try {
|
||||
// 发送catalog
|
||||
eventPublisher.catalogEventPublish(platformId, channelListNotShare, CatalogEvent.ADD);
|
||||
} catch (Exception e) {
|
||||
log.warn("[关联全部通道] 发送失败,数量:{}", channelListNotShare.size(), e);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取通道使用的分组中未分享的
|
||||
*/
|
||||
@@ -231,33 +191,46 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
return channelList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int addAllChannel(Integer platformId) {
|
||||
List<CommonGBChannel> channelListNotShare = platformChannelMapper.queryNotShare(platformId, null);
|
||||
Assert.notEmpty(channelListNotShare, "所有通道已共享");
|
||||
return addChannelList(platformId, channelListNotShare);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int addChannels(Integer platformId, List<Integer> channelIds) {
|
||||
List<CommonGBChannel> channelListNotShare = platformChannelMapper.queryNotShare(platformId, channelIds);
|
||||
Assert.notEmpty(channelListNotShare, "通道已共享");
|
||||
int result = platformChannelMapper.addChannels(platformId, channelListNotShare);
|
||||
return addChannelList(platformId, channelListNotShare);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public int addChannelList(Integer platformId, List<CommonGBChannel> channelList) {
|
||||
int result = platformChannelMapper.addChannels(platformId, channelList);
|
||||
if (result > 0) {
|
||||
// 查询通道相关的行政区划信息是否共享,如果没共享就添加
|
||||
Set<Region> regionListNotShare = getRegionNotShareByChannelList(channelListNotShare, platformId);
|
||||
Set<Region> regionListNotShare = getRegionNotShareByChannelList(channelList, platformId);
|
||||
if (!regionListNotShare.isEmpty()) {
|
||||
int addGroupResult = platformChannelMapper.addPlatformRegion(new ArrayList<>(regionListNotShare), platformId);
|
||||
if (addGroupResult > 0) {
|
||||
for (Region region : regionListNotShare) {
|
||||
// 分组信息排序时需要将顶层排在最后
|
||||
channelListNotShare.add(0, CommonGBChannel.build(region));
|
||||
channelList.add(0, CommonGBChannel.build(region));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 查询通道相关的分组信息是否共享,如果没共享就添加
|
||||
Set<Group> groupListNotShare = getGroupNotShareByChannelList(channelListNotShare, platformId);
|
||||
Set<Group> groupListNotShare = getGroupNotShareByChannelList(channelList, platformId);
|
||||
if (!groupListNotShare.isEmpty()) {
|
||||
int addGroupResult = platformChannelMapper.addPlatformGroup(new ArrayList<>(groupListNotShare), platformId);
|
||||
if (addGroupResult > 0) {
|
||||
for (Group group : groupListNotShare) {
|
||||
// 分组信息排序时需要将顶层排在最后
|
||||
channelListNotShare.add(0, CommonGBChannel.build(group));
|
||||
channelList.add(0, CommonGBChannel.build(group));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,9 +238,9 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
// 发送消息
|
||||
try {
|
||||
// 发送catalog
|
||||
eventPublisher.catalogEventPublish(platformId, channelListNotShare, CatalogEvent.ADD);
|
||||
eventPublisher.catalogEventPublish(platformId, channelList, CatalogEvent.ADD);
|
||||
} catch (Exception e) {
|
||||
log.warn("[关联通道] 发送失败,数量:{}", channelListNotShare.size(), e);
|
||||
log.warn("[关联通道] 发送失败,数量:{}", channelList.size(), e);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -309,9 +282,20 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int removeChannels(Integer platformId, List<Integer> channelIds) {
|
||||
List<CommonGBChannel> channelList = platformChannelMapper.queryShare(platformId, channelIds);
|
||||
Assert.notEmpty(channelList, "所选通道未共享");
|
||||
public void addChannelByDevice(Integer platformId, List<Integer> deviceIds) {
|
||||
List<Integer> channelList = commonGBChannelMapper.queryByGbDeviceIdsForIds(deviceIds);
|
||||
addChannels(platformId, channelList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void removeChannelByDevice(Integer platformId, List<Integer> deviceIds) {
|
||||
List<Integer> channelList = commonGBChannelMapper.queryByGbDeviceIdsForIds(deviceIds);
|
||||
removeChannels(platformId, channelList);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public int removeChannelList(Integer platformId, List<CommonGBChannel> channelList) {
|
||||
int result = platformChannelMapper.removeChannelsWithPlatform(platformId, channelList);
|
||||
if (result > 0) {
|
||||
// 查询通道相关的分组信息
|
||||
@@ -342,6 +326,14 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int removeChannels(Integer platformId, List<Integer> channelIds) {
|
||||
List<CommonGBChannel> channelList = platformChannelMapper.queryShare(platformId, channelIds);
|
||||
Assert.notEmpty(channelList, "所选通道未共享");
|
||||
return removeChannelList(platformId, channelList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void removeChannels(List<Integer> ids) {
|
||||
@@ -356,12 +348,12 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void removeChannel(int channelId) {
|
||||
List<Platform> platformList = platformChannelMapper.queryPlatFormListByChannelId(channelId);
|
||||
if (platformList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Platform platform : platformList) {
|
||||
ArrayList<Integer> ids = new ArrayList<>();
|
||||
ids.add(channelId);
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.genersoft.iot.vmp.gb28181.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.genersoft.iot.vmp.common.*;
|
||||
import com.genersoft.iot.vmp.common.InviteInfo;
|
||||
import com.genersoft.iot.vmp.common.*;
|
||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.PlatformChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.PlatformMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
|
||||
@@ -96,6 +97,8 @@ public class PlatformServiceImpl implements IPlatformService {
|
||||
@Autowired
|
||||
private PlatformChannelMapper platformChannelMapper;
|
||||
|
||||
@Autowired
|
||||
private EventPublisher eventPublisher;
|
||||
|
||||
/**
|
||||
* 流离开的处理
|
||||
@@ -147,7 +150,6 @@ public class PlatformServiceImpl implements IPlatformService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Platform queryPlatformByServerGBId(String platformGbId) {
|
||||
return platformMapper.getParentPlatByServerGBId(platformGbId);
|
||||
|
||||
Reference in New Issue
Block a user