Commit 9cd63f0105ad51fd85310a4702f88067d4ec17c4
1 parent
19533c8f
修复国标级联时添加目录不同平台无法使用同一个目录的问题
Showing
10 changed files
with
33 additions
and
47 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
| ... | ... | @@ -153,7 +153,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements |
| 153 | 153 | // 查询平台下是否有该通道 |
| 154 | 154 | DeviceChannel channel = storager.queryChannelInParentPlatform(requesterId, channelId); |
| 155 | 155 | GbStream gbStream = storager.queryStreamInParentPlatform(requesterId, channelId); |
| 156 | - PlatformCatalog catalog = storager.getCatalog(channelId); | |
| 156 | + PlatformCatalog catalog = storager.getCatalog(requesterId, channelId); | |
| 157 | 157 | |
| 158 | 158 | MediaServerItem mediaServerItem = null; |
| 159 | 159 | StreamPushItem streamPushItem = null; | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java
src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
| ... | ... | @@ -114,7 +114,7 @@ public class GbStreamServiceImpl implements IGbStreamService { |
| 114 | 114 | |
| 115 | 115 | deviceChannel.setRegisterWay(1); |
| 116 | 116 | |
| 117 | - PlatformCatalog catalog = catalogMapper.select(catalogId); | |
| 117 | + PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platform.getServerGBId(), catalogId); | |
| 118 | 118 | if (catalog != null) { |
| 119 | 119 | deviceChannel.setCivilCode(catalog.getCivilCode()); |
| 120 | 120 | deviceChannel.setParentId(catalog.getParentId()); |
| ... | ... | @@ -216,7 +216,7 @@ public class GbStreamServiceImpl implements IGbStreamService { |
| 216 | 216 | deviceChannel.setStatus(status != null && status); |
| 217 | 217 | |
| 218 | 218 | deviceChannel.setRegisterWay(1); |
| 219 | - PlatformCatalog catalog = catalogMapper.select(catalogId); | |
| 219 | + PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platform.getServerGBId(), catalogId); | |
| 220 | 220 | if (catalog != null) { |
| 221 | 221 | deviceChannel.setCivilCode(catalog.getCivilCode()); |
| 222 | 222 | deviceChannel.setParentId(catalog.getParentId()); | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java
| ... | ... | @@ -125,7 +125,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { |
| 125 | 125 | private List<DeviceChannel> getDeviceChannelListByChannelReduceList(List<ChannelReduce> channelReduces, String catalogId, ParentPlatform platform) { |
| 126 | 126 | List<DeviceChannel> deviceChannelList = new ArrayList<>(); |
| 127 | 127 | if (channelReduces.size() > 0){ |
| 128 | - PlatformCatalog catalog = catalogManager.select(catalogId); | |
| 128 | + PlatformCatalog catalog = catalogManager.selectByPlatFormAndCatalogId(platform.getServerGBId(),catalogId); | |
| 129 | 129 | if (catalog == null || !catalogId.equals(platform.getDeviceGBId())) { |
| 130 | 130 | logger.warn("未查询到目录{}的信息", catalogId); |
| 131 | 131 | return null; | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java
| ... | ... | @@ -342,9 +342,9 @@ public interface IVideoManagerStorage { |
| 342 | 342 | |
| 343 | 343 | int addCatalog(PlatformCatalog platformCatalog); |
| 344 | 344 | |
| 345 | - PlatformCatalog getCatalog(String id); | |
| 345 | + PlatformCatalog getCatalog(String platformId, String id); | |
| 346 | 346 | |
| 347 | - int delCatalog(String id); | |
| 347 | + int delCatalog(String platformId, String id); | |
| 348 | 348 | |
| 349 | 349 | int updateCatalog(PlatformCatalog platformCatalog); |
| 350 | 350 | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java
| ... | ... | @@ -16,8 +16,8 @@ public interface PlatformCatalogMapper { |
| 16 | 16 | "(#{id}, #{name}, #{platformId}, #{parentId}, #{civilCode}, #{businessGroupId})") |
| 17 | 17 | int add(PlatformCatalog platformCatalog); |
| 18 | 18 | |
| 19 | - @Delete("DELETE from wvp_platform_catalog WHERE id=#{id}") | |
| 20 | - int del(String id); | |
| 19 | + @Delete("DELETE from wvp_platform_catalog WHERE platform_id=#{platformId} and id=#{id}") | |
| 20 | + int del(String platformId, String id); | |
| 21 | 21 | |
| 22 | 22 | @Delete("DELETE from wvp_platform_catalog WHERE platform_id=#{platformId}") |
| 23 | 23 | int delByPlatformId(String platformId); |
| ... | ... | @@ -28,13 +28,10 @@ public interface PlatformCatalogMapper { |
| 28 | 28 | "group by pc.id, pc.name, pc.platform_id, pc.business_group_id, pc.civil_code, pc.parent_id") |
| 29 | 29 | List<PlatformCatalog> selectByParentId(String platformId, String parentId); |
| 30 | 30 | |
| 31 | - @Select("SELECT *, (SELECT COUNT(1) from wvp_platform_catalog where parent_id = pc.id) as children_count from wvp_platform_catalog pc WHERE pc.id=#{id}") | |
| 32 | - PlatformCatalog select(String id); | |
| 33 | - | |
| 34 | 31 | @Update(value = {" <script>" + |
| 35 | 32 | "UPDATE wvp_platform_catalog " + |
| 36 | 33 | "SET name=#{name}" + |
| 37 | - "WHERE id=#{id}"+ | |
| 34 | + "WHERE id=#{id} and platform_id=#{platformId}"+ | |
| 38 | 35 | "</script>"}) |
| 39 | 36 | int update(PlatformCatalog platformCatalog); |
| 40 | 37 | |
| ... | ... | @@ -44,11 +41,13 @@ public interface PlatformCatalogMapper { |
| 44 | 41 | @Select("SELECT pc.* FROM wvp_platform_catalog pc WHERE pc.id = (SELECT pp.catalog_id from wvp_platform pp WHERE pp.server_gb_id=#{platformId})") |
| 45 | 42 | PlatformCatalog selectDefaultByPlatFormId(String platformId); |
| 46 | 43 | |
| 47 | - | |
| 48 | - @Select("SELECT pc.* FROM wvp_platform_catalog pc WHERE pc.id = #{id}") | |
| 49 | - PlatformCatalog selectParentCatalog(String id); | |
| 50 | - | |
| 51 | 44 | @Select("SELECT pc.id as channel_id, pc.name, pc.civil_code, pc.business_group_id,'1' as parental, pc.parent_id " + |
| 52 | 45 | " from wvp_platform_catalog pc WHERE pc.platform_id=#{platformId}") |
| 53 | 46 | List<DeviceChannel> queryCatalogInPlatform(String platformId); |
| 47 | + | |
| 48 | + @Select("SELECT *, " + | |
| 49 | + "(SELECT COUNT(1) from wvp_platform_catalog where parent_id = pc.id) as children_count " + | |
| 50 | + " from wvp_platform_catalog pc " + | |
| 51 | + " WHERE pc.id=#{id} and pc.platform_id=#{platformId}") | |
| 52 | + PlatformCatalog selectByPlatFormAndCatalogId(String platformId, String id); | |
| 54 | 53 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
| ... | ... | @@ -73,9 +73,9 @@ public interface PlatformChannelMapper { |
| 73 | 73 | List<Device> queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); |
| 74 | 74 | |
| 75 | 75 | @Delete("<script> "+ |
| 76 | - "DELETE from wvp_platform_gb_channel WHERE catalog_id=#{id}" + | |
| 76 | + "DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} and catalog_id=#{id}" + | |
| 77 | 77 | "</script>") |
| 78 | - int delByCatalogId(String id); | |
| 78 | + int delByCatalogId(String platformId, String id); | |
| 79 | 79 | |
| 80 | 80 | @Delete("<script> "+ |
| 81 | 81 | "DELETE from wvp_platform_gb_channel WHERE catalog_id=#{parentId} AND platform_id=#{platformId} AND channel_id=#{id}" + | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java
| ... | ... | @@ -50,8 +50,8 @@ public interface PlatformGbStreamMapper { |
| 50 | 50 | |
| 51 | 51 | @Select("SELECT pgs.*, gs.gb_id from wvp_platform_gb_stream pgs " + |
| 52 | 52 | "LEFT join wvp_gb_stream gs ON pgs.gb_stream_id = gs.gb_stream_id " + |
| 53 | - "WHERE gs.app=#{app} AND gs.stream=#{stream} AND pgs.platform_id=#{serverGBId}") | |
| 54 | - StreamProxyItem selectOne(String app, String stream, String serverGBId); | |
| 53 | + "WHERE gs.app=#{app} AND gs.stream=#{stream} AND pgs.platform_id=#{platformId}") | |
| 54 | + StreamProxyItem selectOne(String app, String stream, String platformId); | |
| 55 | 55 | |
| 56 | 56 | @Select("select gs.* \n" + |
| 57 | 57 | "from wvp_gb_stream gs\n" + |
| ... | ... | @@ -67,9 +67,6 @@ public interface PlatformGbStreamMapper { |
| 67 | 67 | "where pgs.platform_id=#{platformId} and pgs.catalog_id=#{catalogId}") |
| 68 | 68 | List<PlatformCatalog> queryChannelInParentPlatformAndCatalogForCatalog(String platformId, String catalogId); |
| 69 | 69 | |
| 70 | - @Delete("DELETE from wvp_platform_gb_stream WHERE catalog_id=#{id}") | |
| 71 | - int delByCatalogId(String id); | |
| 72 | - | |
| 73 | 70 | @Select("<script> " + |
| 74 | 71 | "SELECT " + |
| 75 | 72 | "pp.* " + | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
| ... | ... | @@ -813,7 +813,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| 813 | 813 | if (platformCatalog.getParentId().length() <= 8) { |
| 814 | 814 | platformCatalog.setCivilCode(platformCatalog.getParentId()); |
| 815 | 815 | }else { |
| 816 | - PlatformCatalog catalog = catalogMapper.select(platformCatalog.getParentId()); | |
| 816 | + PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platformCatalog.getPlatformId(), platformCatalog.getParentId()); | |
| 817 | 817 | if (catalog != null) { |
| 818 | 818 | platformCatalog.setCivilCode(catalog.getCivilCode()); |
| 819 | 819 | } |
| ... | ... | @@ -823,7 +823,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| 823 | 823 | if (platformCatalog.getParentId().length() <= 8) { |
| 824 | 824 | platformCatalog.setCivilCode(platformCatalog.getParentId()); |
| 825 | 825 | }else { |
| 826 | - PlatformCatalog catalog = catalogMapper.select(platformCatalog.getParentId()); | |
| 826 | + PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platformCatalog.getPlatformId(),platformCatalog.getParentId()); | |
| 827 | 827 | if (catalog == null) { |
| 828 | 828 | logger.warn("[添加目录] 无法获取目录{}的CivilCode和BusinessGroupId", platformCatalog.getPlatformId()); |
| 829 | 829 | break; |
| ... | ... | @@ -852,7 +852,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | private PlatformCatalog getTopCatalog(String id, String platformId) { |
| 855 | - PlatformCatalog catalog = catalogMapper.selectParentCatalog(id); | |
| 855 | + PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platformId, id); | |
| 856 | 856 | if (catalog.getParentId().equals(platformId)) { |
| 857 | 857 | return catalog; |
| 858 | 858 | }else { |
| ... | ... | @@ -861,27 +861,16 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | @Override |
| 864 | - public PlatformCatalog getCatalog(String id) { | |
| 865 | - return catalogMapper.select(id); | |
| 864 | + public PlatformCatalog getCatalog(String platformId, String id) { | |
| 865 | + return catalogMapper.selectByPlatFormAndCatalogId(platformId, id); | |
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | @Override |
| 869 | - public int delCatalog(String id) { | |
| 870 | - PlatformCatalog platformCatalog = catalogMapper.select(id); | |
| 871 | - if (platformCatalog.getChildrenCount() > 0) { | |
| 872 | - List<PlatformCatalog> platformCatalogList = catalogMapper.selectByParentId(platformCatalog.getPlatformId(), platformCatalog.getId()); | |
| 873 | - for (PlatformCatalog catalog : platformCatalogList) { | |
| 874 | - if (catalog.getChildrenCount() == 0) { | |
| 875 | - delCatalogExecute(catalog.getId(), catalog.getPlatformId()); | |
| 876 | - }else { | |
| 877 | - delCatalog(catalog.getId()); | |
| 878 | - } | |
| 879 | - } | |
| 880 | - } | |
| 881 | - return delCatalogExecute(id, platformCatalog.getPlatformId()); | |
| 869 | + public int delCatalog(String platformId, String id) { | |
| 870 | + return delCatalogExecute(id, platformId); | |
| 882 | 871 | } |
| 883 | 872 | private int delCatalogExecute(String id, String platformId) { |
| 884 | - int delresult = catalogMapper.del(id); | |
| 873 | + int delresult = catalogMapper.del(platformId, id); | |
| 885 | 874 | DeviceChannel deviceChannelForCatalog = new DeviceChannel(); |
| 886 | 875 | if (delresult > 0){ |
| 887 | 876 | deviceChannelForCatalog.setChannelId(id); |
| ... | ... | @@ -898,7 +887,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| 898 | 887 | } |
| 899 | 888 | eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); |
| 900 | 889 | } |
| 901 | - int delStreamresult = platformGbStreamMapper.delByCatalogId(id); | |
| 890 | + int delStreamresult = platformGbStreamMapper.delByPlatformAndCatalogId(platformId,id); | |
| 902 | 891 | List<PlatformCatalog> platformCatalogs = platformChannelMapper.queryChannelInParentPlatformAndCatalog(platformId, id); |
| 903 | 892 | if (platformCatalogs.size() > 0){ |
| 904 | 893 | List<DeviceChannel> deviceChannelList = new ArrayList<>(); |
| ... | ... | @@ -909,7 +898,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| 909 | 898 | } |
| 910 | 899 | eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); |
| 911 | 900 | } |
| 912 | - int delChannelresult = platformChannelMapper.delByCatalogId(id); | |
| 901 | + int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id); | |
| 913 | 902 | return delresult + delChannelresult + delStreamresult; |
| 914 | 903 | } |
| 915 | 904 | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
| ... | ... | @@ -428,7 +428,7 @@ public class PlatformController { |
| 428 | 428 | if (logger.isDebugEnabled()) { |
| 429 | 429 | logger.debug("添加目录,{}", JSON.toJSONString(platformCatalog)); |
| 430 | 430 | } |
| 431 | - PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId()); | |
| 431 | + PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getPlatformId(), platformCatalog.getId()); | |
| 432 | 432 | |
| 433 | 433 | if (platformCatalogInStore != null) { |
| 434 | 434 | throw new ControllerException(ErrorCode.ERROR100.getCode(), platformCatalog.getId() + " already exists"); |
| ... | ... | @@ -453,7 +453,7 @@ public class PlatformController { |
| 453 | 453 | if (logger.isDebugEnabled()) { |
| 454 | 454 | logger.debug("编辑目录,{}", JSON.toJSONString(platformCatalog)); |
| 455 | 455 | } |
| 456 | - PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId()); | |
| 456 | + PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getPlatformId(), platformCatalog.getId()); | |
| 457 | 457 | |
| 458 | 458 | if (platformCatalogInStore == null) { |
| 459 | 459 | throw new ControllerException(ErrorCode.ERROR100.getCode(), platformCatalog.getId() + " not exists"); |
| ... | ... | @@ -486,7 +486,7 @@ public class PlatformController { |
| 486 | 486 | throw new ControllerException(ErrorCode.ERROR400); |
| 487 | 487 | } |
| 488 | 488 | |
| 489 | - int delResult = storager.delCatalog(id); | |
| 489 | + int delResult = storager.delCatalog(platformId, id); | |
| 490 | 490 | // 如果删除的是默认目录则根目录设置为默认目录 |
| 491 | 491 | PlatformCatalog parentPlatform = storager.queryDefaultCatalogInPlatform(platformId); |
| 492 | 492 | ... | ... |