Commit 9cd63f0105ad51fd85310a4702f88067d4ec17c4

Authored by 648540858
1 parent 19533c8f

修复国标级联时添加目录不同平台无法使用同一个目录的问题

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,7 +153,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
153 // 查询平台下是否有该通道 153 // 查询平台下是否有该通道
154 DeviceChannel channel = storager.queryChannelInParentPlatform(requesterId, channelId); 154 DeviceChannel channel = storager.queryChannelInParentPlatform(requesterId, channelId);
155 GbStream gbStream = storager.queryStreamInParentPlatform(requesterId, channelId); 155 GbStream gbStream = storager.queryStreamInParentPlatform(requesterId, channelId);
156 - PlatformCatalog catalog = storager.getCatalog(channelId); 156 + PlatformCatalog catalog = storager.getCatalog(requesterId, channelId);
157 157
158 MediaServerItem mediaServerItem = null; 158 MediaServerItem mediaServerItem = null;
159 StreamPushItem streamPushItem = null; 159 StreamPushItem streamPushItem = null;
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java
@@ -262,6 +262,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent @@ -262,6 +262,7 @@ public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent
262 } 262 }
263 263
264 private void executeSave(){ 264 private void executeSave(){
  265 + executeSaveForAdd();
265 executeSaveForUpdate(); 266 executeSaveForUpdate();
266 executeSaveForDelete(); 267 executeSaveForDelete();
267 executeSaveForOnline(); 268 executeSaveForOnline();
src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
@@ -114,7 +114,7 @@ public class GbStreamServiceImpl implements IGbStreamService { @@ -114,7 +114,7 @@ public class GbStreamServiceImpl implements IGbStreamService {
114 114
115 deviceChannel.setRegisterWay(1); 115 deviceChannel.setRegisterWay(1);
116 116
117 - PlatformCatalog catalog = catalogMapper.select(catalogId); 117 + PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platform.getServerGBId(), catalogId);
118 if (catalog != null) { 118 if (catalog != null) {
119 deviceChannel.setCivilCode(catalog.getCivilCode()); 119 deviceChannel.setCivilCode(catalog.getCivilCode());
120 deviceChannel.setParentId(catalog.getParentId()); 120 deviceChannel.setParentId(catalog.getParentId());
@@ -216,7 +216,7 @@ public class GbStreamServiceImpl implements IGbStreamService { @@ -216,7 +216,7 @@ public class GbStreamServiceImpl implements IGbStreamService {
216 deviceChannel.setStatus(status != null && status); 216 deviceChannel.setStatus(status != null && status);
217 217
218 deviceChannel.setRegisterWay(1); 218 deviceChannel.setRegisterWay(1);
219 - PlatformCatalog catalog = catalogMapper.select(catalogId); 219 + PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platform.getServerGBId(), catalogId);
220 if (catalog != null) { 220 if (catalog != null) {
221 deviceChannel.setCivilCode(catalog.getCivilCode()); 221 deviceChannel.setCivilCode(catalog.getCivilCode());
222 deviceChannel.setParentId(catalog.getParentId()); 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,7 +125,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
125 private List<DeviceChannel> getDeviceChannelListByChannelReduceList(List<ChannelReduce> channelReduces, String catalogId, ParentPlatform platform) { 125 private List<DeviceChannel> getDeviceChannelListByChannelReduceList(List<ChannelReduce> channelReduces, String catalogId, ParentPlatform platform) {
126 List<DeviceChannel> deviceChannelList = new ArrayList<>(); 126 List<DeviceChannel> deviceChannelList = new ArrayList<>();
127 if (channelReduces.size() > 0){ 127 if (channelReduces.size() > 0){
128 - PlatformCatalog catalog = catalogManager.select(catalogId); 128 + PlatformCatalog catalog = catalogManager.selectByPlatFormAndCatalogId(platform.getServerGBId(),catalogId);
129 if (catalog == null || !catalogId.equals(platform.getDeviceGBId())) { 129 if (catalog == null || !catalogId.equals(platform.getDeviceGBId())) {
130 logger.warn("未查询到目录{}的信息", catalogId); 130 logger.warn("未查询到目录{}的信息", catalogId);
131 return null; 131 return null;
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java
@@ -342,9 +342,9 @@ public interface IVideoManagerStorage { @@ -342,9 +342,9 @@ public interface IVideoManagerStorage {
342 342
343 int addCatalog(PlatformCatalog platformCatalog); 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 int updateCatalog(PlatformCatalog platformCatalog); 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,8 +16,8 @@ public interface PlatformCatalogMapper {
16 "(#{id}, #{name}, #{platformId}, #{parentId}, #{civilCode}, #{businessGroupId})") 16 "(#{id}, #{name}, #{platformId}, #{parentId}, #{civilCode}, #{businessGroupId})")
17 int add(PlatformCatalog platformCatalog); 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 @Delete("DELETE from wvp_platform_catalog WHERE platform_id=#{platformId}") 22 @Delete("DELETE from wvp_platform_catalog WHERE platform_id=#{platformId}")
23 int delByPlatformId(String platformId); 23 int delByPlatformId(String platformId);
@@ -28,13 +28,10 @@ public interface PlatformCatalogMapper { @@ -28,13 +28,10 @@ public interface PlatformCatalogMapper {
28 "group by pc.id, pc.name, pc.platform_id, pc.business_group_id, pc.civil_code, pc.parent_id") 28 "group by pc.id, pc.name, pc.platform_id, pc.business_group_id, pc.civil_code, pc.parent_id")
29 List<PlatformCatalog> selectByParentId(String platformId, String parentId); 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 @Update(value = {" <script>" + 31 @Update(value = {" <script>" +
35 "UPDATE wvp_platform_catalog " + 32 "UPDATE wvp_platform_catalog " +
36 "SET name=#{name}" + 33 "SET name=#{name}" +
37 - "WHERE id=#{id}"+ 34 + "WHERE id=#{id} and platform_id=#{platformId}"+
38 "</script>"}) 35 "</script>"})
39 int update(PlatformCatalog platformCatalog); 36 int update(PlatformCatalog platformCatalog);
40 37
@@ -44,11 +41,13 @@ public interface PlatformCatalogMapper { @@ -44,11 +41,13 @@ public interface PlatformCatalogMapper {
44 @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})") 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 PlatformCatalog selectDefaultByPlatFormId(String platformId); 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 @Select("SELECT pc.id as channel_id, pc.name, pc.civil_code, pc.business_group_id,'1' as parental, pc.parent_id " + 44 @Select("SELECT pc.id as channel_id, pc.name, pc.civil_code, pc.business_group_id,'1' as parental, pc.parent_id " +
52 " from wvp_platform_catalog pc WHERE pc.platform_id=#{platformId}") 45 " from wvp_platform_catalog pc WHERE pc.platform_id=#{platformId}")
53 List<DeviceChannel> queryCatalogInPlatform(String platformId); 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,9 +73,9 @@ public interface PlatformChannelMapper {
73 List<Device> queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); 73 List<Device> queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId);
74 74
75 @Delete("<script> "+ 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 "</script>") 77 "</script>")
78 - int delByCatalogId(String id); 78 + int delByCatalogId(String platformId, String id);
79 79
80 @Delete("<script> "+ 80 @Delete("<script> "+
81 "DELETE from wvp_platform_gb_channel WHERE catalog_id=#{parentId} AND platform_id=#{platformId} AND channel_id=#{id}" + 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,8 +50,8 @@ public interface PlatformGbStreamMapper {
50 50
51 @Select("SELECT pgs.*, gs.gb_id from wvp_platform_gb_stream pgs " + 51 @Select("SELECT pgs.*, gs.gb_id from wvp_platform_gb_stream pgs " +
52 "LEFT join wvp_gb_stream gs ON pgs.gb_stream_id = gs.gb_stream_id " + 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 @Select("select gs.* \n" + 56 @Select("select gs.* \n" +
57 "from wvp_gb_stream gs\n" + 57 "from wvp_gb_stream gs\n" +
@@ -67,9 +67,6 @@ public interface PlatformGbStreamMapper { @@ -67,9 +67,6 @@ public interface PlatformGbStreamMapper {
67 "where pgs.platform_id=#{platformId} and pgs.catalog_id=#{catalogId}") 67 "where pgs.platform_id=#{platformId} and pgs.catalog_id=#{catalogId}")
68 List<PlatformCatalog> queryChannelInParentPlatformAndCatalogForCatalog(String platformId, String catalogId); 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 @Select("<script> " + 70 @Select("<script> " +
74 "SELECT " + 71 "SELECT " +
75 "pp.* " + 72 "pp.* " +
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
@@ -813,7 +813,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -813,7 +813,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
813 if (platformCatalog.getParentId().length() <= 8) { 813 if (platformCatalog.getParentId().length() <= 8) {
814 platformCatalog.setCivilCode(platformCatalog.getParentId()); 814 platformCatalog.setCivilCode(platformCatalog.getParentId());
815 }else { 815 }else {
816 - PlatformCatalog catalog = catalogMapper.select(platformCatalog.getParentId()); 816 + PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platformCatalog.getPlatformId(), platformCatalog.getParentId());
817 if (catalog != null) { 817 if (catalog != null) {
818 platformCatalog.setCivilCode(catalog.getCivilCode()); 818 platformCatalog.setCivilCode(catalog.getCivilCode());
819 } 819 }
@@ -823,7 +823,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -823,7 +823,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
823 if (platformCatalog.getParentId().length() <= 8) { 823 if (platformCatalog.getParentId().length() <= 8) {
824 platformCatalog.setCivilCode(platformCatalog.getParentId()); 824 platformCatalog.setCivilCode(platformCatalog.getParentId());
825 }else { 825 }else {
826 - PlatformCatalog catalog = catalogMapper.select(platformCatalog.getParentId()); 826 + PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platformCatalog.getPlatformId(),platformCatalog.getParentId());
827 if (catalog == null) { 827 if (catalog == null) {
828 logger.warn("[添加目录] 无法获取目录{}的CivilCode和BusinessGroupId", platformCatalog.getPlatformId()); 828 logger.warn("[添加目录] 无法获取目录{}的CivilCode和BusinessGroupId", platformCatalog.getPlatformId());
829 break; 829 break;
@@ -852,7 +852,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -852,7 +852,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
852 } 852 }
853 853
854 private PlatformCatalog getTopCatalog(String id, String platformId) { 854 private PlatformCatalog getTopCatalog(String id, String platformId) {
855 - PlatformCatalog catalog = catalogMapper.selectParentCatalog(id); 855 + PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platformId, id);
856 if (catalog.getParentId().equals(platformId)) { 856 if (catalog.getParentId().equals(platformId)) {
857 return catalog; 857 return catalog;
858 }else { 858 }else {
@@ -861,27 +861,16 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -861,27 +861,16 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
861 } 861 }
862 862
863 @Override 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 @Override 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 private int delCatalogExecute(String id, String platformId) { 872 private int delCatalogExecute(String id, String platformId) {
884 - int delresult = catalogMapper.del(id); 873 + int delresult = catalogMapper.del(platformId, id);
885 DeviceChannel deviceChannelForCatalog = new DeviceChannel(); 874 DeviceChannel deviceChannelForCatalog = new DeviceChannel();
886 if (delresult > 0){ 875 if (delresult > 0){
887 deviceChannelForCatalog.setChannelId(id); 876 deviceChannelForCatalog.setChannelId(id);
@@ -898,7 +887,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -898,7 +887,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
898 } 887 }
899 eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); 888 eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
900 } 889 }
901 - int delStreamresult = platformGbStreamMapper.delByCatalogId(id); 890 + int delStreamresult = platformGbStreamMapper.delByPlatformAndCatalogId(platformId,id);
902 List<PlatformCatalog> platformCatalogs = platformChannelMapper.queryChannelInParentPlatformAndCatalog(platformId, id); 891 List<PlatformCatalog> platformCatalogs = platformChannelMapper.queryChannelInParentPlatformAndCatalog(platformId, id);
903 if (platformCatalogs.size() > 0){ 892 if (platformCatalogs.size() > 0){
904 List<DeviceChannel> deviceChannelList = new ArrayList<>(); 893 List<DeviceChannel> deviceChannelList = new ArrayList<>();
@@ -909,7 +898,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -909,7 +898,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
909 } 898 }
910 eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); 899 eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
911 } 900 }
912 - int delChannelresult = platformChannelMapper.delByCatalogId(id); 901 + int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id);
913 return delresult + delChannelresult + delStreamresult; 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,7 +428,7 @@ public class PlatformController {
428 if (logger.isDebugEnabled()) { 428 if (logger.isDebugEnabled()) {
429 logger.debug("添加目录,{}", JSON.toJSONString(platformCatalog)); 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 if (platformCatalogInStore != null) { 433 if (platformCatalogInStore != null) {
434 throw new ControllerException(ErrorCode.ERROR100.getCode(), platformCatalog.getId() + " already exists"); 434 throw new ControllerException(ErrorCode.ERROR100.getCode(), platformCatalog.getId() + " already exists");
@@ -453,7 +453,7 @@ public class PlatformController { @@ -453,7 +453,7 @@ public class PlatformController {
453 if (logger.isDebugEnabled()) { 453 if (logger.isDebugEnabled()) {
454 logger.debug("编辑目录,{}", JSON.toJSONString(platformCatalog)); 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 if (platformCatalogInStore == null) { 458 if (platformCatalogInStore == null) {
459 throw new ControllerException(ErrorCode.ERROR100.getCode(), platformCatalog.getId() + " not exists"); 459 throw new ControllerException(ErrorCode.ERROR100.getCode(), platformCatalog.getId() + " not exists");
@@ -486,7 +486,7 @@ public class PlatformController { @@ -486,7 +486,7 @@ public class PlatformController {
486 throw new ControllerException(ErrorCode.ERROR400); 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 PlatformCatalog parentPlatform = storager.queryDefaultCatalogInPlatform(platformId); 491 PlatformCatalog parentPlatform = storager.queryDefaultCatalogInPlatform(platformId);
492 492