Browse Source

优化级联选择通道逻辑

pull/317/head
648540858 3 years ago
parent
commit
385fdb95f1
  1. 1
      src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
  2. 2
      src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java
  3. 4
      src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
  4. 6
      src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
  5. 4
      src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java
  6. 2
      src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
  7. 4
      src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java
  8. 2
      src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
  9. 9
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java
  10. 1
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
  11. 44
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platformGbStream/PlatformGbStreamController.java

1
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java

@ -59,6 +59,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>();
if (event.getPlatformId() != null) {
parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId());
if (!parentPlatform.isStatus())return;
String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + event.getPlatformId();
subscribe = redisCatchStorage.getSubscribe(key);
}else {

2
src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java

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

4
src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java

@ -51,9 +51,9 @@ public class GbStreamServiceImpl implements IGbStreamService {
private EventPublisher eventPublisher;
@Override
public PageInfo<GbStream> getAll(Integer page, Integer count) {
public PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId) {
PageHelper.startPage(page, count);
List<GbStream> all = gbStreamMapper.selectAll();
List<GbStream> all = gbStreamMapper.selectAll(platFormId);
return new PageInfo<>(all);
}

6
src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java

@ -37,8 +37,10 @@ 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")
List<GbStream> selectAll();
@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 " +
"WHERE pgs.platformId is null OR pgs.platformId = #{platformId}")
List<GbStream> selectAll(String platformId);
@Select("SELECT * FROM gb_stream WHERE app=#{app} AND stream=#{stream}")
StreamProxyItem selectOne(String app, String stream);

4
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java

@ -24,7 +24,9 @@ public interface PlatformCatalogMapper {
@Delete("DELETE FROM platform_catalog WHERE platformId=#{platformId}")
int delByPlatformId(String platformId);
@Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id AND platformId=#{platformId}) as childrenCount FROM platform_catalog pc WHERE parentId=#{parentId} AND platformId=#{platformId}")
@Select("SELECT pc.*, count(pc2.id) as childrenCount FROM platform_catalog pc " +
"left join platform_catalog pc2 on pc.id = pc2.parentId " +
"WHERE pc.parentId=#{parentId} AND pc.platformId=#{platformId} group by pc.id")
List<PlatformCatalog> selectByParentId(String platformId, String parentId);
@Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id) as childrenCount FROM platform_catalog pc WHERE pc.id=#{id}")

2
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java

@ -83,7 +83,7 @@ public interface PlatformChannelMapper {
"left join platform_gb_channel pgc on " +
"pp.serverGBId = pgc.platformId " +
"WHERE " +
"pgc.channelId = #{channelId} " +
"pgc.channelId = #{channelId} pp.status = true " +
"AND pp.serverGBId IN" +
"<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
"</script> ")

4
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java

@ -52,8 +52,8 @@ public interface PlatformGbStreamMapper {
"from gb_stream gs\n" +
" left join platform_gb_stream pgs\n" +
" on gs.app = pgs.app and gs.stream = pgs.stream\n" +
"where pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}")
List<PlatformCatalog> queryChannelInParentPlatformAndCatalogForCatlog(String platformId, String catalogId);
"where and pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}")
List<PlatformCatalog> queryChannelInParentPlatformAndCatalogForCatalog(String platformId, String catalogId);
@Delete("DELETE FROM platform_gb_stream WHERE catalogId=#{id}")
int delByCatalogId(String id);

2
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java

@ -639,7 +639,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
@Override
public List<PlatformCatalog> queryStreamInParentPlatformAndCatalog(String platformId, String catalogId) {
List<PlatformCatalog> catalogs = platformGbStreamMapper.queryChannelInParentPlatformAndCatalogForCatlog(platformId, catalogId);
List<PlatformCatalog> catalogs = platformGbStreamMapper.queryChannelInParentPlatformAndCatalogForCatalog(platformId, catalogId);
return catalogs;
}

9
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java

@ -33,19 +33,22 @@ public class GbStreamController {
* 查询国标通道
* @param page 当前页
* @param count 每页条数
* @param platformId 平台ID
* @return
*/
@ApiOperation("查询国标通道")
@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),
})
@GetMapping(value = "/list")
@ResponseBody
public PageInfo<GbStream> list(@RequestParam(required = false)Integer page,
@RequestParam(required = false)Integer count){
public PageInfo<GbStream> list(@RequestParam(required = true)Integer page,
@RequestParam(required = true)Integer count,
@RequestParam(required = true)String platformId){
return gbStreamService.getAll(page, count);
return gbStreamService.getAll(page, count, platformId);
}

1
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java

@ -307,6 +307,7 @@ public class PlatformController {
List<PlatformCatalog> platformCatalogList = storager.getChildrenCatalogByPlatform(platformId, parentId);
// 查询下属的国标通道
List<PlatformCatalog> catalogsForChannel = storager.queryChannelInParentPlatformAndCatalog(platformId, parentId);
// 查询下属的直播流通道
List<PlatformCatalog> catalogsForStream = storager.queryStreamInParentPlatformAndCatalog(platformId, parentId);
platformCatalogList.addAll(catalogsForChannel);
platformCatalogList.addAll(catalogsForStream);

44
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platformGbStream/PlatformGbStreamController.java

@ -1,44 +0,0 @@
package com.genersoft.iot.vmp.vmanager.gb28181.platformGbStream;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.service.IGbStreamService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@Api(tags = "级联平台关联视频流")
@CrossOrigin
@RestController
@RequestMapping("/api/platform_gb_stream")
public class PlatformGbStreamController {
private final static Logger logger = LoggerFactory.getLogger(PlatformGbStreamController.class);
@Autowired
private IGbStreamService gbStreamService;
@Autowired
private IVideoManagerStorager storager;
@ApiOperation("分页查询级联平台关联的视频流")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "当前页", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "count", value = "每页条数", dataTypeClass = Integer.class),
})
@GetMapping(value = "/list")
@ResponseBody
public PageInfo<GbStream> list(@RequestParam(required = false)Integer page,
@RequestParam(required = false)Integer count){
return gbStreamService.getAll(page, count);
}
}
Loading…
Cancel
Save