Commit 7d6aaf3bb0a4bdcc319eaec1840c78ab32cfa81e
1 parent
205f1f1f
修复国标接连选择通道相关的问题
Showing
4 changed files
with
54 additions
and
4 deletions
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java
| ... | ... | @@ -162,7 +162,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { |
| 162 | 162 | return 0; |
| 163 | 163 | } |
| 164 | 164 | if (ObjectUtils.isEmpty(catalogId)) { |
| 165 | - catalogId = platform.getDeviceGBId(); | |
| 165 | + catalogId = null; | |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | if ((result = platformChannelMapper.delChannelForGBByCatalogId(platformId, catalogId)) > 0) { | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java
| ... | ... | @@ -31,8 +31,8 @@ public interface PlatformCatalogMapper { |
| 31 | 31 | |
| 32 | 32 | @Update(value = {" <script>" + |
| 33 | 33 | "UPDATE wvp_platform_catalog " + |
| 34 | - "SET name=#{name}" + | |
| 35 | - "WHERE id=#{id} and platform_id=#{platformId}"+ | |
| 34 | + "SET name=#{platformCatalog.name}" + | |
| 35 | + "WHERE id=#{platformCatalog.id} and platform_id=#{platformCatalog.platformId}"+ | |
| 36 | 36 | "</script>"}) |
| 37 | 37 | int update(@Param("platformCatalog") PlatformCatalog platformCatalog); |
| 38 | 38 | |
| ... | ... | @@ -51,4 +51,16 @@ public interface PlatformCatalogMapper { |
| 51 | 51 | " from wvp_platform_catalog pc " + |
| 52 | 52 | " WHERE pc.id=#{id} and pc.platform_id=#{platformId}") |
| 53 | 53 | PlatformCatalog selectByPlatFormAndCatalogId(@Param("platformId") String platformId, @Param("id") String id); |
| 54 | + | |
| 55 | + | |
| 56 | + @Delete("<script> "+ | |
| 57 | + "DELETE from wvp_platform_catalog where platform_id=#{platformId} and id in " + | |
| 58 | + "<foreach collection='ids' item='item' open='(' separator=',' close=')'>" + | |
| 59 | + "#{item} " + | |
| 60 | + "</foreach>" + | |
| 61 | + "</script>") | |
| 62 | + int deleteAll(String platformId, List<String> ids); | |
| 63 | + | |
| 64 | + @Select("SELECT id from wvp_platform_catalog WHERE platform_id=#{platformId} and parent_id = #{id}") | |
| 65 | + List<String> queryCatalogFromParent(@Param("id") String id, @Param("platformId") String platformId); | |
| 54 | 66 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
| ... | ... | @@ -105,7 +105,8 @@ public interface PlatformChannelMapper { |
| 105 | 105 | void delByPlatformId(String serverGBId); |
| 106 | 106 | |
| 107 | 107 | @Delete("<script> " + |
| 108 | - "DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} and catalog_id=#{catalogId}" + | |
| 108 | + "DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} " + | |
| 109 | + " <if test=\"catalogId != null\" > and catalog_id=#{catalogId}</if>" + | |
| 109 | 110 | "</script>") |
| 110 | 111 | int delChannelForGBByCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId); |
| 111 | 112 | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
| ... | ... | @@ -74,6 +74,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| 74 | 74 | private PlatformChannelMapper platformChannelMapper; |
| 75 | 75 | |
| 76 | 76 | @Autowired |
| 77 | + private PlatformCatalogMapper platformCatalogMapper; | |
| 78 | + | |
| 79 | + @Autowired | |
| 77 | 80 | private StreamProxyMapper streamProxyMapper; |
| 78 | 81 | |
| 79 | 82 | @Autowired |
| ... | ... | @@ -910,9 +913,43 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { |
| 910 | 913 | eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); |
| 911 | 914 | } |
| 912 | 915 | int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id); |
| 916 | + // 查看是否存在子目录,如果存在一并删除 | |
| 917 | + List<String> allChildCatalog = getAllChildCatalog(id, platformId); | |
| 918 | + if (!allChildCatalog.isEmpty()) { | |
| 919 | + int limitCount = 50; | |
| 920 | + if (allChildCatalog.size() > limitCount) { | |
| 921 | + for (int i = 0; i < allChildCatalog.size(); i += limitCount) { | |
| 922 | + int toIndex = i + limitCount; | |
| 923 | + if (i + limitCount > allChildCatalog.size()) { | |
| 924 | + toIndex = allChildCatalog.size(); | |
| 925 | + } | |
| 926 | + delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog.subList(i, toIndex)); | |
| 927 | + } | |
| 928 | + }else { | |
| 929 | + delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog); | |
| 930 | + } | |
| 931 | + } | |
| 913 | 932 | return delresult + delChannelresult + delStreamresult; |
| 914 | 933 | } |
| 915 | 934 | |
| 935 | + private List<String> getAllChildCatalog(String id, String platformId) { | |
| 936 | + List<String> catalogList = platformCatalogMapper.queryCatalogFromParent(id, platformId); | |
| 937 | + List<String> catalogListChild = new ArrayList<>(); | |
| 938 | + if (catalogList != null && !catalogList.isEmpty()) { | |
| 939 | + for (String childId : catalogList) { | |
| 940 | + List<String> allChildCatalog = getAllChildCatalog(childId, platformId); | |
| 941 | + if (allChildCatalog != null && !allChildCatalog.isEmpty()) { | |
| 942 | + catalogListChild.addAll(allChildCatalog); | |
| 943 | + } | |
| 944 | + | |
| 945 | + } | |
| 946 | + } | |
| 947 | + if (!catalogListChild.isEmpty()) { | |
| 948 | + catalogList.addAll(catalogListChild); | |
| 949 | + } | |
| 950 | + return catalogList; | |
| 951 | + } | |
| 952 | + | |
| 916 | 953 | |
| 917 | 954 | @Override |
| 918 | 955 | public int updateCatalog(PlatformCatalog platformCatalog) { | ... | ... |