Commit 385fdb95f18c1f0b4e38f8a6e481176ac31ee987
1 parent
b90969f1
优化级联选择通道逻辑
Showing
11 changed files
with
22 additions
and
57 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
| @@ -59,6 +59,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { | @@ -59,6 +59,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { | ||
| 59 | Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>(); | 59 | Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>(); |
| 60 | if (event.getPlatformId() != null) { | 60 | if (event.getPlatformId() != null) { |
| 61 | parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId()); | 61 | parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId()); |
| 62 | + if (!parentPlatform.isStatus())return; | ||
| 62 | String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + event.getPlatformId(); | 63 | String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + event.getPlatformId(); |
| 63 | subscribe = redisCatchStorage.getSubscribe(key); | 64 | subscribe = redisCatchStorage.getSubscribe(key); |
| 64 | }else { | 65 | }else { |
src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java
| @@ -17,7 +17,7 @@ public interface IGbStreamService { | @@ -17,7 +17,7 @@ public interface IGbStreamService { | ||
| 17 | * @param count | 17 | * @param count |
| 18 | * @return | 18 | * @return |
| 19 | */ | 19 | */ |
| 20 | - PageInfo<GbStream> getAll(Integer page, Integer count); | 20 | + PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId); |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | /** | 23 | /** |
src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
| @@ -51,9 +51,9 @@ public class GbStreamServiceImpl implements IGbStreamService { | @@ -51,9 +51,9 @@ public class GbStreamServiceImpl implements IGbStreamService { | ||
| 51 | private EventPublisher eventPublisher; | 51 | private EventPublisher eventPublisher; |
| 52 | 52 | ||
| 53 | @Override | 53 | @Override |
| 54 | - public PageInfo<GbStream> getAll(Integer page, Integer count) { | 54 | + public PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId) { |
| 55 | PageHelper.startPage(page, count); | 55 | PageHelper.startPage(page, count); |
| 56 | - List<GbStream> all = gbStreamMapper.selectAll(); | 56 | + List<GbStream> all = gbStreamMapper.selectAll(platFormId); |
| 57 | return new PageInfo<>(all); | 57 | return new PageInfo<>(all); |
| 58 | } | 58 | } |
| 59 | 59 |
src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
| @@ -37,8 +37,10 @@ public interface GbStreamMapper { | @@ -37,8 +37,10 @@ public interface GbStreamMapper { | ||
| 37 | @Delete("DELETE FROM gb_stream WHERE app=#{app} AND stream=#{stream}") | 37 | @Delete("DELETE FROM gb_stream WHERE app=#{app} AND stream=#{stream}") |
| 38 | int del(String app, String stream); | 38 | int del(String app, String stream); |
| 39 | 39 | ||
| 40 | - @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") | ||
| 41 | - List<GbStream> selectAll(); | 40 | + @Select("SELECT gs.*, pgs.platformId AS platformId, pgs.catalogId AS catalogId FROM gb_stream gs " + |
| 41 | + "LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " + | ||
| 42 | + "WHERE pgs.platformId is null OR pgs.platformId = #{platformId}") | ||
| 43 | + List<GbStream> selectAll(String platformId); | ||
| 42 | 44 | ||
| 43 | @Select("SELECT * FROM gb_stream WHERE app=#{app} AND stream=#{stream}") | 45 | @Select("SELECT * FROM gb_stream WHERE app=#{app} AND stream=#{stream}") |
| 44 | StreamProxyItem selectOne(String app, String stream); | 46 | StreamProxyItem selectOne(String app, String stream); |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java
| @@ -24,7 +24,9 @@ public interface PlatformCatalogMapper { | @@ -24,7 +24,9 @@ public interface PlatformCatalogMapper { | ||
| 24 | @Delete("DELETE FROM platform_catalog WHERE platformId=#{platformId}") | 24 | @Delete("DELETE FROM platform_catalog WHERE platformId=#{platformId}") |
| 25 | int delByPlatformId(String platformId); | 25 | int delByPlatformId(String platformId); |
| 26 | 26 | ||
| 27 | - @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}") | 27 | + @Select("SELECT pc.*, count(pc2.id) as childrenCount FROM platform_catalog pc " + |
| 28 | + "left join platform_catalog pc2 on pc.id = pc2.parentId " + | ||
| 29 | + "WHERE pc.parentId=#{parentId} AND pc.platformId=#{platformId} group by pc.id") | ||
| 28 | List<PlatformCatalog> selectByParentId(String platformId, String parentId); | 30 | List<PlatformCatalog> selectByParentId(String platformId, String parentId); |
| 29 | 31 | ||
| 30 | @Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id) as childrenCount FROM platform_catalog pc WHERE pc.id=#{id}") | 32 | @Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id) as childrenCount FROM platform_catalog pc WHERE pc.id=#{id}") |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
| @@ -83,7 +83,7 @@ public interface PlatformChannelMapper { | @@ -83,7 +83,7 @@ public interface PlatformChannelMapper { | ||
| 83 | "left join platform_gb_channel pgc on " + | 83 | "left join platform_gb_channel pgc on " + |
| 84 | "pp.serverGBId = pgc.platformId " + | 84 | "pp.serverGBId = pgc.platformId " + |
| 85 | "WHERE " + | 85 | "WHERE " + |
| 86 | - "pgc.channelId = #{channelId} " + | 86 | + "pgc.channelId = #{channelId} pp.status = true " + |
| 87 | "AND pp.serverGBId IN" + | 87 | "AND pp.serverGBId IN" + |
| 88 | "<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" + | 88 | "<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" + |
| 89 | "</script> ") | 89 | "</script> ") |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java
| @@ -52,8 +52,8 @@ public interface PlatformGbStreamMapper { | @@ -52,8 +52,8 @@ public interface PlatformGbStreamMapper { | ||
| 52 | "from gb_stream gs\n" + | 52 | "from gb_stream gs\n" + |
| 53 | " left join platform_gb_stream pgs\n" + | 53 | " left join platform_gb_stream pgs\n" + |
| 54 | " on gs.app = pgs.app and gs.stream = pgs.stream\n" + | 54 | " on gs.app = pgs.app and gs.stream = pgs.stream\n" + |
| 55 | - "where pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}") | ||
| 56 | - List<PlatformCatalog> queryChannelInParentPlatformAndCatalogForCatlog(String platformId, String catalogId); | 55 | + "where and pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}") |
| 56 | + List<PlatformCatalog> queryChannelInParentPlatformAndCatalogForCatalog(String platformId, String catalogId); | ||
| 57 | 57 | ||
| 58 | @Delete("DELETE FROM platform_gb_stream WHERE catalogId=#{id}") | 58 | @Delete("DELETE FROM platform_gb_stream WHERE catalogId=#{id}") |
| 59 | int delByCatalogId(String id); | 59 | int delByCatalogId(String id); |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
| @@ -639,7 +639,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { | @@ -639,7 +639,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { | ||
| 639 | 639 | ||
| 640 | @Override | 640 | @Override |
| 641 | public List<PlatformCatalog> queryStreamInParentPlatformAndCatalog(String platformId, String catalogId) { | 641 | public List<PlatformCatalog> queryStreamInParentPlatformAndCatalog(String platformId, String catalogId) { |
| 642 | - List<PlatformCatalog> catalogs = platformGbStreamMapper.queryChannelInParentPlatformAndCatalogForCatlog(platformId, catalogId); | 642 | + List<PlatformCatalog> catalogs = platformGbStreamMapper.queryChannelInParentPlatformAndCatalogForCatalog(platformId, catalogId); |
| 643 | return catalogs; | 643 | return catalogs; |
| 644 | } | 644 | } |
| 645 | 645 |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java
| @@ -33,19 +33,22 @@ public class GbStreamController { | @@ -33,19 +33,22 @@ public class GbStreamController { | ||
| 33 | * 查询国标通道 | 33 | * 查询国标通道 |
| 34 | * @param page 当前页 | 34 | * @param page 当前页 |
| 35 | * @param count 每页条数 | 35 | * @param count 每页条数 |
| 36 | + * @param platformId 平台ID | ||
| 36 | * @return | 37 | * @return |
| 37 | */ | 38 | */ |
| 38 | @ApiOperation("查询国标通道") | 39 | @ApiOperation("查询国标通道") |
| 39 | @ApiImplicitParams({ | 40 | @ApiImplicitParams({ |
| 40 | @ApiImplicitParam(name = "page", value = "当前页", required = true , dataTypeClass = Integer.class), | 41 | @ApiImplicitParam(name = "page", value = "当前页", required = true , dataTypeClass = Integer.class), |
| 41 | @ApiImplicitParam(name = "count", value = "每页条数", required = true , dataTypeClass = Integer.class), | 42 | @ApiImplicitParam(name = "count", value = "每页条数", required = true , dataTypeClass = Integer.class), |
| 43 | + @ApiImplicitParam(name = "platformId", value = "平台ID", required = true , dataTypeClass = Integer.class), | ||
| 42 | }) | 44 | }) |
| 43 | @GetMapping(value = "/list") | 45 | @GetMapping(value = "/list") |
| 44 | @ResponseBody | 46 | @ResponseBody |
| 45 | - public PageInfo<GbStream> list(@RequestParam(required = false)Integer page, | ||
| 46 | - @RequestParam(required = false)Integer count){ | 47 | + public PageInfo<GbStream> list(@RequestParam(required = true)Integer page, |
| 48 | + @RequestParam(required = true)Integer count, | ||
| 49 | + @RequestParam(required = true)String platformId){ | ||
| 47 | 50 | ||
| 48 | - return gbStreamService.getAll(page, count); | 51 | + return gbStreamService.getAll(page, count, platformId); |
| 49 | } | 52 | } |
| 50 | 53 | ||
| 51 | 54 |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
| @@ -307,6 +307,7 @@ public class PlatformController { | @@ -307,6 +307,7 @@ public class PlatformController { | ||
| 307 | List<PlatformCatalog> platformCatalogList = storager.getChildrenCatalogByPlatform(platformId, parentId); | 307 | List<PlatformCatalog> platformCatalogList = storager.getChildrenCatalogByPlatform(platformId, parentId); |
| 308 | // 查询下属的国标通道 | 308 | // 查询下属的国标通道 |
| 309 | List<PlatformCatalog> catalogsForChannel = storager.queryChannelInParentPlatformAndCatalog(platformId, parentId); | 309 | List<PlatformCatalog> catalogsForChannel = storager.queryChannelInParentPlatformAndCatalog(platformId, parentId); |
| 310 | + // 查询下属的直播流通道 | ||
| 310 | List<PlatformCatalog> catalogsForStream = storager.queryStreamInParentPlatformAndCatalog(platformId, parentId); | 311 | List<PlatformCatalog> catalogsForStream = storager.queryStreamInParentPlatformAndCatalog(platformId, parentId); |
| 311 | platformCatalogList.addAll(catalogsForChannel); | 312 | platformCatalogList.addAll(catalogsForChannel); |
| 312 | platformCatalogList.addAll(catalogsForStream); | 313 | platformCatalogList.addAll(catalogsForStream); |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platformGbStream/PlatformGbStreamController.java deleted
100644 → 0
| 1 | -package com.genersoft.iot.vmp.vmanager.gb28181.platformGbStream; | ||
| 2 | - | ||
| 3 | -import com.genersoft.iot.vmp.gb28181.bean.GbStream; | ||
| 4 | -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; | ||
| 5 | -import com.genersoft.iot.vmp.service.IGbStreamService; | ||
| 6 | -import com.github.pagehelper.PageInfo; | ||
| 7 | -import io.swagger.annotations.Api; | ||
| 8 | -import io.swagger.annotations.ApiImplicitParam; | ||
| 9 | -import io.swagger.annotations.ApiImplicitParams; | ||
| 10 | -import io.swagger.annotations.ApiOperation; | ||
| 11 | -import org.slf4j.Logger; | ||
| 12 | -import org.slf4j.LoggerFactory; | ||
| 13 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 14 | -import org.springframework.web.bind.annotation.*; | ||
| 15 | - | ||
| 16 | -@Api(tags = "级联平台关联视频流") | ||
| 17 | -@CrossOrigin | ||
| 18 | -@RestController | ||
| 19 | -@RequestMapping("/api/platform_gb_stream") | ||
| 20 | -public class PlatformGbStreamController { | ||
| 21 | - | ||
| 22 | - private final static Logger logger = LoggerFactory.getLogger(PlatformGbStreamController.class); | ||
| 23 | - | ||
| 24 | - @Autowired | ||
| 25 | - private IGbStreamService gbStreamService; | ||
| 26 | - | ||
| 27 | - @Autowired | ||
| 28 | - private IVideoManagerStorager storager; | ||
| 29 | - | ||
| 30 | - @ApiOperation("分页查询级联平台关联的视频流") | ||
| 31 | - @ApiImplicitParams({ | ||
| 32 | - @ApiImplicitParam(name = "page", value = "当前页", dataTypeClass = Integer.class), | ||
| 33 | - @ApiImplicitParam(name = "count", value = "每页条数", dataTypeClass = Integer.class), | ||
| 34 | - }) | ||
| 35 | - @GetMapping(value = "/list") | ||
| 36 | - @ResponseBody | ||
| 37 | - public PageInfo<GbStream> list(@RequestParam(required = false)Integer page, | ||
| 38 | - @RequestParam(required = false)Integer count){ | ||
| 39 | - | ||
| 40 | - return gbStreamService.getAll(page, count); | ||
| 41 | - } | ||
| 42 | - | ||
| 43 | - | ||
| 44 | -} |