支持国标级联通道查询

结构优化
648540858 2024-01-24 19:11:50 +08:00
parent 3821dba14d
commit 5d973ef246
11 changed files with 366 additions and 21 deletions

View File

@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPush; import com.genersoft.iot.vmp.media.zlm.dto.StreamPush;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxy; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxy;
import com.genersoft.iot.vmp.service.bean.CommonGbChannelType; import com.genersoft.iot.vmp.service.bean.CommonGbChannelType;
import com.genersoft.iot.vmp.service.bean.Group;
import com.genersoft.iot.vmp.service.impl.CommonGbChannelServiceImpl; import com.genersoft.iot.vmp.service.impl.CommonGbChannelServiceImpl;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
@ -325,6 +326,7 @@ public class CommonGbChannel {
@Schema(description = "创建时间") @Schema(description = "创建时间")
private String createTime; private String createTime;
public int getCommonGbId() { public int getCommonGbId() {
return commonGbId; return commonGbId;
} }
@ -794,4 +796,14 @@ public class CommonGbChannel {
public void setCommonGbSVCSpaceSupportMode(Integer commonGbSVCSpaceSupportMode) { public void setCommonGbSVCSpaceSupportMode(Integer commonGbSVCSpaceSupportMode) {
this.commonGbSVCSpaceSupportMode = commonGbSVCSpaceSupportMode; this.commonGbSVCSpaceSupportMode = commonGbSVCSpaceSupportMode;
} }
public static CommonGbChannel getInstance(Group group) {
CommonGbChannel commonGbChannel = new CommonGbChannel();
commonGbChannel.setCommonGbDeviceID(group.getCommonGroupDeviceId());
commonGbChannel.setCommonGbName(group.getCommonGroupName());
commonGbChannel.setCommonGbParental(1);
commonGbChannel.setCommonGbParentID(group.getCommonGroupParentId());
commonGbChannel.setCommonGbBusinessGroupID(group.getCommonGroupTopId());
return commonGbChannel;
}
} }

View File

@ -1,15 +1,14 @@
package com.genersoft.iot.vmp.service; package com.genersoft.iot.vmp.service;
import com.genersoft.iot.vmp.common.CommonGbChannel; import com.genersoft.iot.vmp.common.CommonGbChannel;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.Gb28181CodeType;
import com.genersoft.iot.vmp.service.bean.*; import com.genersoft.iot.vmp.service.bean.*;
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup; import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup;
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToRegion; import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToRegion;
import com.genersoft.iot.vmp.vmanager.channel.bean.ShareCommonChannelListResult;
import com.genersoft.iot.vmp.vmanager.channel.bean.ShareCommonGbChannelParam;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -67,4 +66,10 @@ public interface ICommonGbChannelService {
void offlineForList(List<Integer> onlinePushers); void offlineForList(List<Integer> onlinePushers);
void onlineForList(List<Integer> commonChannelIdList); void onlineForList(List<Integer> commonChannelIdList);
void addShareChannel(ShareCommonGbChannelParam param);
void removeShareChannel(ShareCommonGbChannelParam param);
PageInfo<ShareCommonChannelListResult> getShareChannelList(int platformId, int page, int count, String query, String type, Boolean online);
} }

View File

@ -14,6 +14,8 @@ import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup; import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup;
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToRegion; import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToRegion;
import com.genersoft.iot.vmp.vmanager.channel.bean.ShareCommonChannelListResult;
import com.genersoft.iot.vmp.vmanager.channel.bean.ShareCommonGbChannelParam;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
@ -87,6 +89,30 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
} }
} }
/**
* catalog
*/
private void sendCatalogEvent(List<CommonGbChannel> channelListForShare, ParentPlatform platform, CatalogEventType catalogEventType) {
// 获取开启了目录订阅且关联了这些通道的
SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(platform.getId());
if (catalogSubscribe == null) {
catalogSubscribe = SipUtils.buildVirtuallyCatalogSubSubscribe(platform);
}
// 获取关联的通道
logger.warn("[发送Catalog事件] 类型: {} 平台:{} 通道个数: {}",
catalogEventType.getVal(), platform.getServerGBId(), channelListForShare.size());
try {
if (catalogEventType.equals(CatalogEventType.ADD) || catalogEventType.equals(CatalogEventType.UPDATE)) {
sipCommanderForPlatform.sendNotifyForCatalogAddOrUpdate(catalogEventType.getVal(), platform, channelListForShare, catalogSubscribe, 0);
}else {
sipCommanderForPlatform.sendNotifyForCatalogOther(catalogEventType.getVal(), platform, channelListForShare, catalogSubscribe, 0);
}
} catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException |
IllegalAccessException e) {
throw new RuntimeException(e);
}
}
private void sendCatalogEvent(CommonGbChannel channel, CatalogEventType catalogEventType) { private void sendCatalogEvent(CommonGbChannel channel, CatalogEventType catalogEventType) {
List<CommonGbChannel> commonGbChannelList = new ArrayList<>(); List<CommonGbChannel> commonGbChannelList = new ArrayList<>();
commonGbChannelList.add(channel); commonGbChannelList.add(channel);
@ -398,4 +424,68 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
commonGbChannelMapper.channelsOnlineFromList(commonGbChannelList); commonGbChannelMapper.channelsOnlineFromList(commonGbChannelList);
sendCatalogEvent(commonGbChannelList, CatalogEventType.ON); sendCatalogEvent(commonGbChannelList, CatalogEventType.ON);
} }
@Override
public void addShareChannel(ShareCommonGbChannelParam param) {
if (param == null || ObjectUtils.isEmpty(param.getPlatformId()) || param.getChannelIdList().isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "参数不全");
}
ParentPlatform platform = platformService.query(param.getPlatformId());
if (platform == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台不存在");
}
if (platform.isShareAllChannel()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台已开启共享所有通道");
}
// 排除参数中已经共享的数据
List<Integer> channelList = commonGbChannelMapper.getShareChannelInList(
param.getPlatformId(), param.getChannelIdList());
if (!channelList.isEmpty()) {
for (Integer id : channelList) {
param.getChannelIdList().remove(id);
}
}
if (param.getChannelIdList().isEmpty()) {
logger.info("[添加共享通道] 移除已经共享的数据后,待加入数据为空");
return;
}
logger.info("[添加共享通道] 平台: {} 共{}个通道", platform.getServerGBId(), param.getChannelIdList().size());
commonGbChannelMapper.addShareChannel(param);
// 发送ADD事件
List<CommonGbChannel> commonGbChannelList = commonGbChannelMapper.queryInIdList(new ArrayList<>(param.getChannelIdList()));
sendCatalogEvent(commonGbChannelList, platform, CatalogEventType.ADD);
}
@Override
public void removeShareChannel(ShareCommonGbChannelParam param) {
if (param == null || ObjectUtils.isEmpty(param.getPlatformId()) || param.getChannelIdList().isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "参数不全");
}
ParentPlatform platform = platformService.query(param.getPlatformId());
if (platform == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台不存在");
}
if (platform.isShareAllChannel()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台已开启共享所有通道");
}
// 获取参数中确实已经共享的数据
List<Integer> channelList = commonGbChannelMapper.getShareChannelInList(
param.getPlatformId(), param.getChannelIdList());
if (channelList.isEmpty()) {
logger.info("[移除共享通道] 参数中确定已经共享的数据为空");
return;
}
param.setChannelIdList(new HashSet<>(channelList));
commonGbChannelMapper.removeShareChannel(param);
// 发送DELETE事件
List<CommonGbChannel> commonGbChannelList = commonGbChannelMapper.queryInIdList(new ArrayList<>(param.getChannelIdList()));
sendCatalogEvent(commonGbChannelList, platform, CatalogEventType.DEL);
}
@Override
public PageInfo<ShareCommonChannelListResult> getShareChannelList(int platformId, int page, int count, String query, String type, Boolean online) {
PageHelper.startPage(page, count);
List<ShareCommonChannelListResult> all = commonGbChannelMapper.getShareChannel(platformId, query, type, online);
return new PageInfo<>(all);
}
} }

View File

@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.gb28181.bean.*;
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;
import com.genersoft.iot.vmp.service.IPlatformChannelService; import com.genersoft.iot.vmp.service.IPlatformChannelService;
import com.genersoft.iot.vmp.service.bean.Group;
import com.genersoft.iot.vmp.storager.dao.*; import com.genersoft.iot.vmp.storager.dao.*;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -18,8 +19,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.*;
import java.util.List;
/** /**
* @author lin * @author lin
@ -36,6 +36,12 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
@Autowired @Autowired
private CommonChannelMapper commonGbChannelMapper; private CommonChannelMapper commonGbChannelMapper;
@Autowired
private RegionMapper regionMapper;
@Autowired
private GroupMapper groupMapper;
@Autowired @Autowired
TransactionDefinition transactionDefinition; TransactionDefinition transactionDefinition;
@ -131,26 +137,72 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
public List<CommonGbChannel> queryChannelList(ParentPlatform platform) { public List<CommonGbChannel> queryChannelList(ParentPlatform platform) {
List<CommonGbChannel> result = new ArrayList<>(); List<CommonGbChannel> result = new ArrayList<>();
if (platform.isShareAllChannel()) { if (platform.isShareAllChannel()) {
// 获取所有地区
List<CommonGbChannel> allRegionList = regionMapper.queryAllForCommonChannel();
if (!allRegionList.isEmpty()) {
result.addAll(allRegionList);
}
// 获取所有分组
List<CommonGbChannel> allGroupList = groupMapper.queryAllForCommonChannelByDeviceIdSet(null);
if (!allGroupList.isEmpty()) {
result.addAll(allGroupList);
}
// 获取所有通道 // 获取所有通道
List<CommonGbChannel> allChannelList = commonGbChannelMapper.getAll(); List<CommonGbChannel> allChannelList = commonGbChannelMapper.getAll();
if (!allChannelList.isEmpty()) { if (!allChannelList.isEmpty()) {
result.addAll(allChannelList); result.addAll(allChannelList);
// 获取所有分组
// 获取所有地区
} }
}else { }else {
List<CommonGbChannel> channelList = commonGbChannelMapper.getShareChannelInPLatform(platform.getId());
if (channelList.isEmpty()) {
return result;
}
// 查询所有关联了的国标通道 // 查询所有关联了的国标通道
if (platform.isShareGroup()) { if (platform.isShareGroup()) {
// 获取相关分组 Map<String, Group> allDependenceGroupMap = getAllDependenceGroup(channelList);
if (!allDependenceGroupMap.isEmpty()) {
for (Group group : allDependenceGroupMap.values()) {
result.add(CommonGbChannel.getInstance(group));
}
}
} }
if (platform.isShareRegion()) { if (platform.isShareRegion()) {
} }
result.addAll(channelList);
} }
return result; return result;
} }
private Map<String, Group> getAllDependenceGroup(List<CommonGbChannel> commonGbChannelList) {
Map<String, Group> result = new HashMap<>();
// 查询这些ID对应的分组信息
List<Group> groupList = groupMapper.queryAllByDeviceIds(commonGbChannelList);
// 查询这些分组信息有可能涉及到的全部分组信息
Map<String, Group> allGroupMap = groupMapper.queryAllByTopId(groupList);
for (Group group : groupList) {
result.put(group.getCommonGroupDeviceId(), group);
List<Group> allParentGroup = new ArrayList<>();
getAllParentGroup(group, allGroupMap, allParentGroup);
if (!allParentGroup.isEmpty()) {
for (Group parentGroup : allParentGroup) {
result.put(parentGroup.getCommonGroupDeviceId(), parentGroup);
}
}
}
return result;
}
private void getAllParentGroup(Group group, Map<String, Group> allGroupMap, List<Group> resultGroupList) {
if (Objects.equals(group.getCommonGroupDeviceId(), group.getCommonGroupTopId())) {
return;
}
Group parentGroup = allGroupMap.get(group.getCommonGroupDeviceId());
resultGroupList.add(parentGroup);
getAllParentGroup(parentGroup, allGroupMap, resultGroupList);
}
@Override @Override
public CommonGbChannel queryChannelByPlatformIdAndChannelDeviceId(Integer platformId, String channelId) { public CommonGbChannel queryChannelByPlatformIdAndChannelDeviceId(Integer platformId, String channelId) {
return platformChannelMapper.queryChannelByPlatformIdAndChannelDeviceId(platformId, channelId); return platformChannelMapper.queryChannelByPlatformIdAndChannelDeviceId(platformId, channelId);

View File

@ -6,11 +6,14 @@ import com.genersoft.iot.vmp.service.bean.Group;
import com.genersoft.iot.vmp.service.bean.Region; import com.genersoft.iot.vmp.service.bean.Region;
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup; import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup;
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToRegion; import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToRegion;
import com.genersoft.iot.vmp.vmanager.channel.bean.ShareCommonChannelListResult;
import com.genersoft.iot.vmp.vmanager.channel.bean.ShareCommonGbChannelParam;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
@Mapper @Mapper
@Repository @Repository
@ -665,4 +668,55 @@ public interface CommonChannelMapper {
"</script>") "</script>")
int getAllCount(); int getAllCount();
@Select("<script> "+
" SELECT common_gb_id " +
" FROM wvp_common_channel wcc" +
" left join wvp_common_channel_platform wccp " +
" on wcc.common_gb_id = wccp.common_gb_channel_id " +
" where wcc.common_gb_id in " +
"<foreach collection='channelIdList' item='item' open='(' separator=',' close=')' >#{item}</foreach>" +
" and wccp.platform_id = #{platformId}" +
"</script>")
List<Integer> getShareChannelInList(@Param("platformId") Integer platformId, @Param("channelIdList") Set<Integer> channelIdList);
@Insert(value = "<script>" +
"insert into wvp_common_channel_platform ( " +
"platform_id, " +
"common_gb_channel_id " +
") values " +
"<foreach collection='channelIdList' index='index' item='item' separator=','> " +
"( " +
"#{platformId}, " +
"#{item} " +
")" +
"</foreach>" +
"</script>")
void addShareChannel(ShareCommonGbChannelParam param);
@Delete("<script> "+
" delete from wvp_common_channel_platform where platform_id=#{platformId} and common_gb_channel_id in " +
"<foreach collection='channelIdList' item='item' open='(' separator=',' close=')' >#{item}</foreach>" +
"</script>")
void removeShareChannel(ShareCommonGbChannelParam param);
@Select("<script>" +
" select wcc.*, wccp.platform_id " +
" from wvp_common_channel wcc " +
" left join wvp_common_channel_platform wccp on wcc.common_gb_id = wccp.common_gb_channel_id " +
" where (wccp.platform_id = #{platformId} || wccp.platform_id is null) " +
"<if test='query != null'> and ( wcc.common_gb_device_id LIKE concat('%',#{query},'%') or wcc.common_gb_name LIKE concat('%',#{query},'%') ) </if>" +
"<if test='type != null'> and wcc.type = #{type} </if>" +
"<if test='online != null'> and wcc.common_gb_status = #{online} </if>" +
"</script>" )
List<ShareCommonChannelListResult> getShareChannel(@Param("platformId") int platformId, @Param("query") String query,
@Param("type") String type, @Param("online") Boolean online);
@Select("<script>" +
" select wcc.* " +
" from wvp_common_channel wcc " +
" left join wvp_common_channel_platform wccp on wcc.common_gb_id = wccp.common_gb_channel_id " +
" where wccp.platform_id = #{id}" +
"</script>" )
List<CommonGbChannel> getShareChannelInPLatform(@Param("id") Integer id);
} }

View File

@ -1,11 +1,13 @@
package com.genersoft.iot.vmp.storager.dao; package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.common.CommonGbChannel;
import com.genersoft.iot.vmp.service.bean.Group; import com.genersoft.iot.vmp.service.bean.Group;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
@Mapper @Mapper
@Repository @Repository
@ -168,4 +170,43 @@ public interface GroupMapper {
@Select("select * from wvp_common_group") @Select("select * from wvp_common_group")
Map<String, Group> queryAllForMap(); Map<String, Group> queryAllForMap();
@Select("<script>" +
" select " +
" common_group_id as common_gb_id" +
" common_group_device_id as common_gb_device_id" +
" common_group_name as common_gb_name" +
" 1 as common_gb_parental" +
" common_group_parent_id as common_gb_parent_id" +
" common_group_top_id as common_gb_business_group_id" +
" from wvp_common_group" +
" where 1=1" +
"<if test='groupDeviceIdSet != null'> " +
" and common_group_device_id in " +
"<foreach collection='groupDeviceIdSet' item='item' open='(' separator=',' close=')' >#{item}</foreach>" +
"</if>" +
"</script>")
List<CommonGbChannel> queryAllForCommonChannelByDeviceIdSet(Set<String> groupDeviceIdSet);
@Select("<script>" +
" select * " +
" from wvp_common_group" +
" where 1=1" +
"<if test='groupDeviceIdSet != null'> " +
" and common_group_device_id in " +
"<foreach collection='commonGbChannelList' item='item' open='(' separator=',' close=')' >#{item.commonGbBusinessGroupID}</foreach>" +
"</if>" +
"</script>")
List<Group> queryAllByDeviceIds(List<CommonGbChannel> commonGbChannelList);
@Select("<script>" +
" select * " +
" from wvp_common_group" +
" where 1=1" +
"<if test='groupList != null'> " +
" and common_group_top_id in " +
"<foreach collection='groupList' item='item' open='(' separator=',' close=')' >#{item.commonGroupTopId}</foreach>" +
"</if>" +
"</script>")
Map<String, Group> queryAllByTopId(List<Group> groupList);
} }

View File

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.storager.dao; package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.common.CommonGbChannel;
import com.genersoft.iot.vmp.service.bean.Region; import com.genersoft.iot.vmp.service.bean.Region;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
@ -124,4 +125,13 @@ public interface RegionMapper {
@MapKey("commonRegionDeviceId") @MapKey("commonRegionDeviceId")
@Select("select * from wvp_common_region") @Select("select * from wvp_common_region")
Map<String, Region> getAllForMap(); Map<String, Region> getAllForMap();
@Select("select " +
"common_region_id as common_gb_id, " +
"common_region_device_id as common_gb_device_id, " +
"common_region_name as common_gb_name, " +
"from wvp_common_region")
List<CommonGbChannel> queryAllForCommonChannel();
} }

View File

@ -2,13 +2,17 @@ package com.genersoft.iot.vmp.vmanager.channel;
import com.genersoft.iot.vmp.common.CommonGbChannel; import com.genersoft.iot.vmp.common.CommonGbChannel;
import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.service.ICommonGbChannelService; import com.genersoft.iot.vmp.service.ICommonGbChannelService;
import com.genersoft.iot.vmp.service.bean.*; import com.genersoft.iot.vmp.service.bean.*;
import com.genersoft.iot.vmp.vmanager.bean.*; import com.genersoft.iot.vmp.vmanager.bean.*;
import com.genersoft.iot.vmp.vmanager.channel.bean.ShareCommonChannelListResult;
import com.genersoft.iot.vmp.vmanager.channel.bean.ShareCommonGbChannelParam;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -40,7 +44,7 @@ public class CommonChannelController {
private UserSetting userSetting; private UserSetting userSetting;
@Operation(summary = "更新通道信息") @Operation(summary = "更新通道信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "CommonGbChannel", description = "commonGbChannel", required = true) @Parameter(name = "CommonGbChannel", description = "commonGbChannel", required = true)
@ResponseBody @ResponseBody
@PostMapping("/update") @PostMapping("/update")
@ -52,7 +56,7 @@ public class CommonChannelController {
/** /**
* TODO controller * TODO controller
*/ */
@Operation(summary = "获取行业编码列表") @Operation(summary = "获取行业编码列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
@ResponseBody @ResponseBody
@GetMapping("/industry/list") @GetMapping("/industry/list")
public List<IndustryCodeType> getIndustryCodeList(){ public List<IndustryCodeType> getIndustryCodeList(){
@ -62,7 +66,7 @@ public class CommonChannelController {
/** /**
* TODO controller * TODO controller
*/ */
@Operation(summary = "获取编码列表") @Operation(summary = "获取编码列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
@ResponseBody @ResponseBody
@GetMapping("/type/list") @GetMapping("/type/list")
public List<DeviceType> getDeviceTypeList(){ public List<DeviceType> getDeviceTypeList(){
@ -72,14 +76,14 @@ public class CommonChannelController {
/** /**
* TODO controller * TODO controller
*/ */
@Operation(summary = "获取编码列表") @Operation(summary = "获取编码列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
@ResponseBody @ResponseBody
@GetMapping("/network/identification/list") @GetMapping("/network/identification/list")
public List<NetworkIdentificationType> getNetworkIdentificationTypeList(){ public List<NetworkIdentificationType> getNetworkIdentificationTypeList(){
return commonGbChannelService.getNetworkIdentificationTypeList(); return commonGbChannelService.getNetworkIdentificationTypeList();
} }
@Operation(summary = "查询分组或区域下的通道") @Operation(summary = "查询分组或区域下的通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "groupDeviceId", description = "分组的编号", required = false) @Parameter(name = "groupDeviceId", description = "分组的编号", required = false)
@Parameter(name = "regionDeviceId", description = "区域的编号", required = false) @Parameter(name = "regionDeviceId", description = "区域的编号", required = false)
@Parameter(name = "query", description = "要搜索的内容", required = false) @Parameter(name = "query", description = "要搜索的内容", required = false)
@ -123,7 +127,7 @@ public class CommonChannelController {
inGroup, inRegion, type, ptzType, online); inGroup, inRegion, type, ptzType, online);
} }
@Operation(summary = "为区域添加分组") @Operation(summary = "为区域添加分组", security = @SecurityRequirement(name = JwtUtils.HEADER))
@ResponseBody @ResponseBody
@PostMapping("/region/update") @PostMapping("/region/update")
public void updateChannelToRegion(@RequestBody UpdateCommonChannelToRegion params){ public void updateChannelToRegion(@RequestBody UpdateCommonChannelToRegion params){
@ -132,7 +136,7 @@ public class CommonChannelController {
commonGbChannelService.updateChannelToRegion(params); commonGbChannelService.updateChannelToRegion(params);
} }
@Operation(summary = "从区域中移除通道") @Operation(summary = "从区域中移除通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
@ResponseBody @ResponseBody
@PostMapping("/region/remove") @PostMapping("/region/remove")
public void removeFromRegion(@RequestBody UpdateCommonChannelToRegion params){ public void removeFromRegion(@RequestBody UpdateCommonChannelToRegion params){
@ -140,7 +144,7 @@ public class CommonChannelController {
commonGbChannelService.removeFromRegion(params); commonGbChannelService.removeFromRegion(params);
} }
@Operation(summary = "为通道添加分组") @Operation(summary = "为通道添加分组", security = @SecurityRequirement(name = JwtUtils.HEADER))
@ResponseBody @ResponseBody
@PostMapping("/group/update") @PostMapping("/group/update")
public void updateChannelToGroup(@RequestBody UpdateCommonChannelToGroup params){ public void updateChannelToGroup(@RequestBody UpdateCommonChannelToGroup params){
@ -149,7 +153,7 @@ public class CommonChannelController {
commonGbChannelService.updateChannelToGroup(params); commonGbChannelService.updateChannelToGroup(params);
} }
@Operation(summary = "从分组中移除通道") @Operation(summary = "从分组中移除通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
@ResponseBody @ResponseBody
@PostMapping("/group/remove") @PostMapping("/group/remove")
public void removeFromGroup(@RequestBody UpdateCommonChannelToGroup params){ public void removeFromGroup(@RequestBody UpdateCommonChannelToGroup params){
@ -158,7 +162,7 @@ public class CommonChannelController {
} }
@Operation(summary = "播放通道") @Operation(summary = "播放通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelDeviceId", description = "通道国标编号", required = true) @Parameter(name = "channelDeviceId", description = "通道国标编号", required = true)
@ResponseBody @ResponseBody
@GetMapping("/play") @GetMapping("/play")
@ -213,7 +217,7 @@ public class CommonChannelController {
} }
@Operation(summary = "停止播放通道") @Operation(summary = "停止播放通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelDeviceId", description = "通道国标编号", required = true) @Parameter(name = "channelDeviceId", description = "通道国标编号", required = true)
@GetMapping("/stopPlay") @GetMapping("/stopPlay")
public void playStop(String channelDeviceId) { public void playStop(String channelDeviceId) {
@ -246,8 +250,36 @@ public class CommonChannelController {
} }
// 将通道共享到上级平台 // 将通道共享到上级平台
@Operation(summary = "添加通道共享", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "param", description = "共享通道参数", required = true)
@PostMapping("/share/add")
public void addShareChannel(@RequestBody ShareCommonGbChannelParam param) {
commonGbChannelService.addShareChannel(param);
}
// 从上级平台共享中移除通道 // 从上级平台共享中移除通道
@Operation(summary = "移除通道共享", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "param", description = "共享通道参数", required = true)
@DeleteMapping("/share/remove")
public void removeShareChannel(@RequestBody ShareCommonGbChannelParam param) {
commonGbChannelService.removeShareChannel(param);
}
@Operation(summary = "通道共享列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "platformId", description = "平台Id", required = true)
@GetMapping("/share/list")
public PageInfo<ShareCommonChannelListResult> getShareChannel(@RequestParam(required = true) Integer platformId,
@RequestParam(required = true) Integer page,
@RequestParam(required = true) Integer count,
@RequestParam(required = false) String query,
@RequestParam(required = false) String type,
@RequestParam(required = false) Boolean online) {
if (ObjectUtils.isEmpty(query)) {
query = null;
}
if (ObjectUtils.isEmpty(type)) {
type = null;
}
return commonGbChannelService.getShareChannelList(platformId, page, count, query, type, online);
}
} }

View File

@ -0,0 +1,16 @@
package com.genersoft.iot.vmp.vmanager.channel.bean;
import com.genersoft.iot.vmp.common.CommonGbChannel;
public class ShareCommonChannelListResult extends CommonGbChannel {
private int platformId;
public int getPlatformId() {
return platformId;
}
public void setPlatformId(int platformId) {
this.platformId = platformId;
}
}

View File

@ -0,0 +1,33 @@
package com.genersoft.iot.vmp.vmanager.channel.bean;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import java.util.Set;
@Schema(description = "共享通道参数")
public class ShareCommonGbChannelParam {
@Schema(description = "通道ID列表")
private Set<Integer> channelIdList;
@Schema(description = "平台ID")
private Integer platformId;
public Set<Integer> getChannelIdList() {
return channelIdList;
}
public void setChannelIdList(Set<Integer> channelIdList) {
this.channelIdList = channelIdList;
}
public Integer getPlatformId() {
return platformId;
}
public void setPlatformId(Integer platformId) {
this.platformId = platformId;
}
}