Commit 11c7deb876806a6bc85fbb3cbbbe5bb531e1cbdc

Authored by 648540858
2 parents db6dd3f7 9cd63f01

Merge branch 'wvp-28181-2.0' into main-dev

src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
... ... @@ -163,7 +163,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
163 163 // 查询平台下是否有该通道
164 164 DeviceChannel channel = storager.queryChannelInParentPlatform(requesterId, channelId);
165 165 GbStream gbStream = storager.queryStreamInParentPlatform(requesterId, channelId);
166   - PlatformCatalog catalog = storager.getCatalog(channelId);
  166 + PlatformCatalog catalog = storager.getCatalog(requesterId, channelId);
167 167  
168 168 MediaServerItem mediaServerItem = null;
169 169 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 262 }
263 263  
264 264 private void executeSave(){
  265 + executeSaveForAdd();
265 266 executeSaveForUpdate();
266 267 executeSaveForDelete();
267 268 executeSaveForOnline();
... ...
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
... ... @@ -806,7 +806,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
806 806 if (platformCatalog.getParentId().length() <= 8) {
807 807 platformCatalog.setCivilCode(platformCatalog.getParentId());
808 808 }else {
809   - PlatformCatalog catalog = catalogMapper.select(platformCatalog.getParentId());
  809 + PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platformCatalog.getPlatformId(), platformCatalog.getParentId());
810 810 if (catalog != null) {
811 811 platformCatalog.setCivilCode(catalog.getCivilCode());
812 812 }
... ... @@ -816,7 +816,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
816 816 if (platformCatalog.getParentId().length() <= 8) {
817 817 platformCatalog.setCivilCode(platformCatalog.getParentId());
818 818 }else {
819   - PlatformCatalog catalog = catalogMapper.select(platformCatalog.getParentId());
  819 + PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platformCatalog.getPlatformId(),platformCatalog.getParentId());
820 820 if (catalog == null) {
821 821 logger.warn("[添加目录] 无法获取目录{}的CivilCode和BusinessGroupId", platformCatalog.getPlatformId());
822 822 break;
... ... @@ -845,7 +845,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
845 845 }
846 846  
847 847 private PlatformCatalog getTopCatalog(String id, String platformId) {
848   - PlatformCatalog catalog = catalogMapper.selectParentCatalog(id);
  848 + PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platformId, id);
849 849 if (catalog.getParentId().equals(platformId)) {
850 850 return catalog;
851 851 }else {
... ... @@ -854,27 +854,16 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
854 854 }
855 855  
856 856 @Override
857   - public PlatformCatalog getCatalog(String id) {
858   - return catalogMapper.select(id);
  857 + public PlatformCatalog getCatalog(String platformId, String id) {
  858 + return catalogMapper.selectByPlatFormAndCatalogId(platformId, id);
859 859 }
860 860  
861 861 @Override
862   - public int delCatalog(String id) {
863   - PlatformCatalog platformCatalog = catalogMapper.select(id);
864   - if (platformCatalog.getChildrenCount() > 0) {
865   - List<PlatformCatalog> platformCatalogList = catalogMapper.selectByParentId(platformCatalog.getPlatformId(), platformCatalog.getId());
866   - for (PlatformCatalog catalog : platformCatalogList) {
867   - if (catalog.getChildrenCount() == 0) {
868   - delCatalogExecute(catalog.getId(), catalog.getPlatformId());
869   - }else {
870   - delCatalog(catalog.getId());
871   - }
872   - }
873   - }
874   - return delCatalogExecute(id, platformCatalog.getPlatformId());
  862 + public int delCatalog(String platformId, String id) {
  863 + return delCatalogExecute(id, platformId);
875 864 }
876 865 private int delCatalogExecute(String id, String platformId) {
877   - int delresult = catalogMapper.del(id);
  866 + int delresult = catalogMapper.del(platformId, id);
878 867 DeviceChannel deviceChannelForCatalog = new DeviceChannel();
879 868 if (delresult > 0){
880 869 deviceChannelForCatalog.setChannelId(id);
... ... @@ -891,7 +880,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
891 880 }
892 881 eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
893 882 }
894   - int delStreamresult = platformGbStreamMapper.delByCatalogId(id);
  883 + int delStreamresult = platformGbStreamMapper.delByPlatformAndCatalogId(platformId,id);
895 884 List<PlatformCatalog> platformCatalogs = platformChannelMapper.queryChannelInParentPlatformAndCatalog(platformId, id);
896 885 if (platformCatalogs.size() > 0){
897 886 List<DeviceChannel> deviceChannelList = new ArrayList<>();
... ... @@ -902,7 +891,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
902 891 }
903 892 eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
904 893 }
905   - int delChannelresult = platformChannelMapper.delByCatalogId(id);
  894 + int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id);
906 895 return delresult + delChannelresult + delStreamresult;
907 896 }
908 897  
... ...
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  
... ...