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 | 59 | Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>(); |
| 60 | 60 | if (event.getPlatformId() != null) { |
| 61 | 61 | parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId()); |
| 62 | + if (!parentPlatform.isStatus())return; | |
| 62 | 63 | String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + event.getPlatformId(); |
| 63 | 64 | subscribe = redisCatchStorage.getSubscribe(key); |
| 64 | 65 | }else { | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java
src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
| ... | ... | @@ -51,9 +51,9 @@ public class GbStreamServiceImpl implements IGbStreamService { |
| 51 | 51 | private EventPublisher eventPublisher; |
| 52 | 52 | |
| 53 | 53 | @Override |
| 54 | - public PageInfo<GbStream> getAll(Integer page, Integer count) { | |
| 54 | + public PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId) { | |
| 55 | 55 | PageHelper.startPage(page, count); |
| 56 | - List<GbStream> all = gbStreamMapper.selectAll(); | |
| 56 | + List<GbStream> all = gbStreamMapper.selectAll(platFormId); | |
| 57 | 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 | 37 | @Delete("DELETE FROM gb_stream WHERE app=#{app} AND stream=#{stream}") |
| 38 | 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 | 45 | @Select("SELECT * FROM gb_stream WHERE app=#{app} AND stream=#{stream}") |
| 44 | 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 | 24 | @Delete("DELETE FROM platform_catalog WHERE platformId=#{platformId}") |
| 25 | 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 | 30 | List<PlatformCatalog> selectByParentId(String platformId, String parentId); |
| 29 | 31 | |
| 30 | 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 | 83 | "left join platform_gb_channel pgc on " + |
| 84 | 84 | "pp.serverGBId = pgc.platformId " + |
| 85 | 85 | "WHERE " + |
| 86 | - "pgc.channelId = #{channelId} " + | |
| 86 | + "pgc.channelId = #{channelId} pp.status = true " + | |
| 87 | 87 | "AND pp.serverGBId IN" + |
| 88 | 88 | "<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" + |
| 89 | 89 | "</script> ") | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java
| ... | ... | @@ -52,8 +52,8 @@ public interface PlatformGbStreamMapper { |
| 52 | 52 | "from gb_stream gs\n" + |
| 53 | 53 | " left join platform_gb_stream pgs\n" + |
| 54 | 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 | 58 | @Delete("DELETE FROM platform_gb_stream WHERE catalogId=#{id}") |
| 59 | 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 | 639 | |
| 640 | 640 | @Override |
| 641 | 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 | 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 | 33 | * 查询国标通道 |
| 34 | 34 | * @param page 当前页 |
| 35 | 35 | * @param count 每页条数 |
| 36 | + * @param platformId 平台ID | |
| 36 | 37 | * @return |
| 37 | 38 | */ |
| 38 | 39 | @ApiOperation("查询国标通道") |
| 39 | 40 | @ApiImplicitParams({ |
| 40 | 41 | @ApiImplicitParam(name = "page", value = "当前页", required = true , dataTypeClass = Integer.class), |
| 41 | 42 | @ApiImplicitParam(name = "count", value = "每页条数", required = true , dataTypeClass = Integer.class), |
| 43 | + @ApiImplicitParam(name = "platformId", value = "平台ID", required = true , dataTypeClass = Integer.class), | |
| 42 | 44 | }) |
| 43 | 45 | @GetMapping(value = "/list") |
| 44 | 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 | 307 | List<PlatformCatalog> platformCatalogList = storager.getChildrenCatalogByPlatform(platformId, parentId); |
| 308 | 308 | // 查询下属的国标通道 |
| 309 | 309 | List<PlatformCatalog> catalogsForChannel = storager.queryChannelInParentPlatformAndCatalog(platformId, parentId); |
| 310 | + // 查询下属的直播流通道 | |
| 310 | 311 | List<PlatformCatalog> catalogsForStream = storager.queryStreamInParentPlatformAndCatalog(platformId, parentId); |
| 311 | 312 | platformCatalogList.addAll(catalogsForChannel); |
| 312 | 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 | -} |