优化级联添加通道流程

This commit is contained in:
648540858
2022-02-15 17:41:09 +08:00
parent d4fe0fb325
commit 9442c37ce7
20 changed files with 608 additions and 352 deletions

View File

@@ -17,7 +17,7 @@ public interface IGbStreamService {
* @param count
* @return
*/
PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId);
PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId, String catalogId,String query,Boolean pushing,String mediaServerId);
/**

View File

@@ -52,9 +52,9 @@ public class GbStreamServiceImpl implements IGbStreamService {
private EventPublisher eventPublisher;
@Override
public PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId) {
public PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId, String catalogId, String query, Boolean pushing, String mediaServerId) {
PageHelper.startPage(page, count);
List<GbStream> all = gbStreamMapper.selectAll(platFormId);
List<GbStream> all = gbStreamMapper.selectAll(platFormId, catalogId, query, pushing, mediaServerId);
return new PageInfo<>(all);
}
@@ -70,6 +70,7 @@ public class GbStreamServiceImpl implements IGbStreamService {
boolean result = false;
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
ParentPlatform parentPlatform = platformMapper.getParentPlatByServerGBId(platformId);
if (catalogId == null) catalogId = parentPlatform.getCatalogId();
try {
List<DeviceChannel> deviceChannelList = new ArrayList<>();
for (GbStream gbStream : gbStreams) {

View File

@@ -239,7 +239,7 @@ public interface IVideoManagerStorager {
/**
* 查询通道信息,不区分设备(已关联平台或全部)
*/
PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, Boolean inPlatform);
PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId);
/**
* 查询设备的通道信息

View File

@@ -93,28 +93,31 @@ public interface DeviceChannelMapper {
void startPlay(String deviceId, String channelId, String streamId);
@Select(value = {" <script>" +
"SELECT * FROM ( "+
" SELECT dc.channelId, dc.deviceId, dc.name, de.manufacturer, de.hostAddress, " +
"(SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount, " +
"(SELECT pc.platformId FROM platform_gb_channel pc WHERE pc.deviceId=dc.deviceId AND pc.channelId = dc.channelId AND pc.platformId = #{platformId}) as platformId, " +
"(SELECT pc.catalogId FROM platform_gb_channel pc WHERE pc.deviceId=dc.deviceId AND pc.channelId = dc.channelId AND pc.platformId = #{platformId} ) as catalogId " +
"FROM device_channel dc " +
"LEFT JOIN device de ON dc.deviceId = de.deviceId " +
" WHERE 1=1 " +
" <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
" <if test='online == true' > AND dc.status=1</if> " +
" <if test='online == false' > AND dc.status=0</if> " +
") dcr" +
" WHERE 1=1 " +
" <if test='hasSubChannel!= null and hasSubChannel == true' > AND subCount >0</if> " +
" <if test='hasSubChannel!= null and hasSubChannel == false' > AND subCount=0</if> " +
" <if test='platformId != null and inPlatform == true ' > AND platformId='${platformId}'</if> " +
" <if test='platformId != null and inPlatform == false ' > AND (platformId != '${platformId}' OR platformId is NULL ) </if> " +
" ORDER BY deviceId, channelId ASC" +
" </script>"})
List<ChannelReduce> queryChannelListInAll(String query, Boolean online, Boolean hasSubChannel, String platformId, Boolean inPlatform);
@Select(value = {" <script>" +
"SELECT dc.channelId, "+
"dc.deviceId, " +
"dc.name, " +
"de.manufacturer, " +
"de.hostAddress, " +
"(SELECT count(0) FROM device_channel WHERE parentId = dc.channelId) as subCount, " +
"pgc.platformId as platformId, " +
"pgc.catalogId as catalogId " +
"FROM device_channel dc " +
"LEFT JOIN device de ON dc.deviceId = de.deviceId " +
"LEFT JOIN platform_gb_channel pgc on de.deviceId = pgc.deviceId and pgc.channelId = dc.channelId " +
"LEFT JOIN device_channel dc2 ON dc2.deviceId = de.deviceId AND dc2.parentId = dc.channelId " +
" WHERE 1=1 " +
" <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
" <if test='online == true' > AND dc.status=1</if> " +
" <if test='online == false' > AND dc.status=0</if> " +
" <if test='hasSubChannel!= null and hasSubChannel == true' > AND dc2.channelId is not null</if> " +
" <if test='hasSubChannel!= null and hasSubChannel == false' > AND dc2.channelId is null</if> " +
" <if test='catalogId == null ' > AND pgc.platformId is null AND pgc.catalogId is null</if> " +
" <if test='catalogId != null ' > AND pgc.platformId =#{platformId} AND pgc.catalogId = #{catalogId}</if> " +
" ORDER BY dc.deviceId, dc.channelId ASC" +
" </script>"})
List<ChannelReduce> queryChannelListInAll(String query, Boolean online, Boolean hasSubChannel, String platformId, String catalogId);
@Select("SELECT * FROM device_channel WHERE channelId=#{channelId}")
List<DeviceChannel> queryChannelByChannelId( String channelId);

View File

@@ -37,10 +37,20 @@ public interface GbStreamMapper {
@Delete("DELETE FROM gb_stream WHERE app=#{app} AND stream=#{stream}")
int del(String app, String stream);
@Select("SELECT gs.*, pgs.platformId AS platformId, pgs.catalogId AS catalogId FROM gb_stream gs " +
"LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream AND (pgs.platformId = #{platformId} OR pgs.platformId is null)" +
"order by gs.id asc ")
List<GbStream> selectAll(String platformId);
@Select("<script> "+
"SELECT gs.*, pgs.platformId AS platformId, pgs.catalogId AS catalogId FROM gb_stream gs " +
"LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " +
"WHERE " +
"1=1 " +
" <if test='catalogId != null'> AND pgs.platformId = #{platformId} AND pgs.catalogId = #{catalogId}</if> " +
" <if test='catalogId == null'> AND pgs.platformId is null AND pgs.catalogId is null</if> " +
" <if test='query != null'> AND (gs.app LIKE '%${query}%' OR gs.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%')</if> " +
" <if test='pushing == true' > AND gs.status=1</if>" +
" <if test='pushing == false' > AND gs.status=0</if>" +
" <if test='mediaServerId != null' > AND gs.mediaServerId=#{mediaServerId} </if>" +
" order by gs.id asc " +
"</script>")
List<GbStream> selectAll(String platformId, String catalogId, String query, Boolean pushing, String mediaServerId);
@Select("SELECT * FROM gb_stream WHERE app=#{app} AND stream=#{stream}")
StreamProxyItem selectOne(String app, String stream);

View File

@@ -575,16 +575,16 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
@Override
public PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online,
Boolean channelType, String platformId, Boolean inPlatform) {
Boolean channelType, String platformId, String catalogId) {
PageHelper.startPage(page, count);
List<ChannelReduce> all = deviceChannelMapper.queryChannelListInAll(query, online, channelType, platformId, inPlatform);
List<ChannelReduce> all = deviceChannelMapper.queryChannelListInAll(query, online, channelType, platformId, catalogId);
return new PageInfo<>(all);
}
@Override
public List<ChannelReduce> queryChannelListInParentPlatform(String platformId) {
return deviceChannelMapper.queryChannelListInAll(null, null, null, platformId, true);
return deviceChannelMapper.queryChannelListInAll(null, null, null, platformId, null);
}
@Override

View File

@@ -12,6 +12,7 @@ import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
@Api(tags = "视频流关联到级联平台")
@@ -40,15 +41,33 @@ public class GbStreamController {
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "当前页", required = true , dataTypeClass = Integer.class),
@ApiImplicitParam(name = "count", value = "每页条数", required = true , dataTypeClass = Integer.class),
@ApiImplicitParam(name = "platformId", value = "平台ID", required = true , dataTypeClass = Integer.class),
@ApiImplicitParam(name = "platformId", value = "平台ID", required = true , dataTypeClass = String.class),
@ApiImplicitParam(name = "catalogId", value = "目录ID", required = false , dataTypeClass = String.class),
@ApiImplicitParam(name="query", value = "查询内容", required = false , dataTypeClass = String.class),
@ApiImplicitParam(name="pushing", value = "是否正在推流", required = false , dataTypeClass = Boolean.class),
@ApiImplicitParam(name="mediaServerId", value = "流媒体ID", required = false , dataTypeClass = String.class),
})
@GetMapping(value = "/list")
@ResponseBody
public PageInfo<GbStream> list(@RequestParam(required = true)Integer page,
@RequestParam(required = true)Integer count,
@RequestParam(required = true)String platformId){
@RequestParam(required = true)String platformId,
@RequestParam(required = false)String catalogId,
@RequestParam(required = false)String query,
@RequestParam(required = false)Boolean pushing,
@RequestParam(required = false)String mediaServerId){
if (StringUtils.isEmpty(catalogId)) {
catalogId = null;
}
if (StringUtils.isEmpty(query)) {
query = null;
}
if (StringUtils.isEmpty(mediaServerId)) {
mediaServerId = null;
}
return gbStreamService.getAll(page, count, platformId);
return gbStreamService.getAll(page, count, platformId, catalogId, query, pushing, mediaServerId);
}

View File

@@ -65,6 +65,25 @@ public class PlatformController {
result.put("password", sipConfig.getPassword());
return new ResponseEntity<>(result, HttpStatus.OK);
}
/**
* 获取级联服务器信息
* @return
*/
@ApiOperation("获取国标服务的配置")
@GetMapping("/info/{id}")
public ResponseEntity<WVPResult<ParentPlatform>> getPlatform(@PathVariable String id) {
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(id);
WVPResult<ParentPlatform> wvpResult = new WVPResult<>();
if (parentPlatform != null) {
wvpResult.setCode(0);
wvpResult.setMsg("success");
wvpResult.setData(parentPlatform);
}else {
wvpResult.setCode(-1);
wvpResult.setMsg("未查询到此平台");
}
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
}
/**
* 分页查询级联平台
@@ -282,29 +301,33 @@ public class PlatformController {
@ApiImplicitParam(name = "page", value = "当前页", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "count", value = "每页条数", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "platformId", value = "上级平台ID", dataTypeClass = String.class),
@ApiImplicitParam(name = "catalogId", value = "目录ID", dataTypeClass = String.class),
@ApiImplicitParam(name = "query", value = "查询内容", dataTypeClass = String.class),
@ApiImplicitParam(name = "online", value = "是否在线", dataTypeClass = Boolean.class),
@ApiImplicitParam(name = "choosed", value = "是否已选中", dataTypeClass = Boolean.class),
@ApiImplicitParam(name = "channelType", value = "通道类型", dataTypeClass = Boolean.class),
})
@GetMapping("/channel_list")
@ResponseBody
public PageInfo<ChannelReduce> channelList(int page, int count,
@RequestParam(required = false) String platformId,
@RequestParam(required = false) String catalogId,
@RequestParam(required = false) String query,
@RequestParam(required = false) Boolean online,
@RequestParam(required = false) Boolean choosed,
@RequestParam(required = false) Boolean channelType){
// if (logger.isDebugEnabled()) {
// logger.debug("查询所有所有通道API调用");
// }
PageInfo<ChannelReduce> channelReduces = null;
if (platformId != null ) {
channelReduces = storager.queryAllChannelList(page, count, query, online, channelType, platformId, choosed);
}else {
channelReduces = storager.queryAllChannelList(page, count, query, online, channelType, null, false);
if(StringUtils.isEmpty(platformId)) {
platformId = null;
}
if(StringUtils.isEmpty(query)) {
query = null;
}
if(StringUtils.isEmpty(platformId) || StringUtils.isEmpty(catalogId)) {
catalogId = null;
}
PageInfo<ChannelReduce> channelReduces = storager.queryAllChannelList(page, count, query, online, channelType, platformId, catalogId);
return channelReduces;
}
@@ -371,11 +394,11 @@ public class PlatformController {
}
List<PlatformCatalog> platformCatalogList = storager.getChildrenCatalogByPlatform(platformId, parentId);
// 查询下属的国标通道
List<PlatformCatalog> catalogsForChannel = storager.queryChannelInParentPlatformAndCatalog(platformId, parentId);
// List<PlatformCatalog> catalogsForChannel = storager.queryChannelInParentPlatformAndCatalog(platformId, parentId);
// 查询下属的直播流通道
List<PlatformCatalog> catalogsForStream = storager.queryStreamInParentPlatformAndCatalog(platformId, parentId);
platformCatalogList.addAll(catalogsForChannel);
platformCatalogList.addAll(catalogsForStream);
// List<PlatformCatalog> catalogsForStream = storager.queryStreamInParentPlatformAndCatalog(platformId, parentId);
// platformCatalogList.addAll(catalogsForChannel);
// platformCatalogList.addAll(catalogsForStream);
WVPResult<List<PlatformCatalog>> result = new WVPResult<>();
result.setCode(0);
result.setMsg("success");