Commit 7443f2b123774083af4730fdc733b6ba1ab99f7d
1 parent
7de73ebd
修复目录名称修改,修复多层级目录删除,修复全部移除
Showing
4 changed files
with
57 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,7 +162,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { | ||
| 162 | return 0; | 162 | return 0; |
| 163 | } | 163 | } |
| 164 | if (ObjectUtils.isEmpty(catalogId)) { | 164 | if (ObjectUtils.isEmpty(catalogId)) { |
| 165 | - catalogId = platform.getDeviceGBId(); | 165 | + catalogId = null; |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | if ((result = platformChannelMapper.delChannelForGBByCatalogId(platformId, catalogId)) > 0) { | 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,8 +31,8 @@ public interface PlatformCatalogMapper { | ||
| 31 | 31 | ||
| 32 | @Update(value = {" <script>" + | 32 | @Update(value = {" <script>" + |
| 33 | "UPDATE wvp_platform_catalog " + | 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 | "</script>"}) | 36 | "</script>"}) |
| 37 | int update(@Param("platformCatalog") PlatformCatalog platformCatalog); | 37 | int update(@Param("platformCatalog") PlatformCatalog platformCatalog); |
| 38 | 38 | ||
| @@ -51,4 +51,16 @@ public interface PlatformCatalogMapper { | @@ -51,4 +51,16 @@ public interface PlatformCatalogMapper { | ||
| 51 | " from wvp_platform_catalog pc " + | 51 | " from wvp_platform_catalog pc " + |
| 52 | " WHERE pc.id=#{id} and pc.platform_id=#{platformId}") | 52 | " WHERE pc.id=#{id} and pc.platform_id=#{platformId}") |
| 53 | PlatformCatalog selectByPlatFormAndCatalogId(@Param("platformId") String platformId, @Param("id") String id); | 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,7 +105,8 @@ public interface PlatformChannelMapper { | ||
| 105 | void delByPlatformId(String serverGBId); | 105 | void delByPlatformId(String serverGBId); |
| 106 | 106 | ||
| 107 | @Delete("<script> " + | 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 | "</script>") | 110 | "</script>") |
| 110 | int delChannelForGBByCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId); | 111 | int delChannelForGBByCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId); |
| 111 | 112 | ||
| @@ -118,4 +119,6 @@ public interface PlatformChannelMapper { | @@ -118,4 +119,6 @@ public interface PlatformChannelMapper { | ||
| 118 | 119 | ||
| 119 | @Select("SELECT pgc.platform_id from wvp_platform_gb_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.channel_id='${channelId}'") | 120 | @Select("SELECT pgc.platform_id from wvp_platform_gb_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.channel_id='${channelId}'") |
| 120 | List<String> queryParentPlatformByChannelId(String channelId); | 121 | List<String> queryParentPlatformByChannelId(String channelId); |
| 122 | + | ||
| 123 | + | ||
| 121 | } | 124 | } |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
| @@ -16,6 +16,7 @@ import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; | @@ -16,6 +16,7 @@ import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; | ||
| 16 | import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; | 16 | import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; |
| 17 | import com.github.pagehelper.PageHelper; | 17 | import com.github.pagehelper.PageHelper; |
| 18 | import com.github.pagehelper.PageInfo; | 18 | import com.github.pagehelper.PageInfo; |
| 19 | +import com.sun.org.apache.xml.internal.resolver.Catalog; | ||
| 19 | import org.slf4j.Logger; | 20 | import org.slf4j.Logger; |
| 20 | import org.slf4j.LoggerFactory; | 21 | import org.slf4j.LoggerFactory; |
| 21 | import org.springframework.beans.factory.annotation.Autowired; | 22 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -73,6 +74,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | @@ -73,6 +74,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | ||
| 73 | private PlatformChannelMapper platformChannelMapper; | 74 | private PlatformChannelMapper platformChannelMapper; |
| 74 | 75 | ||
| 75 | @Autowired | 76 | @Autowired |
| 77 | + private PlatformCatalogMapper platformCatalogMapper; | ||
| 78 | + | ||
| 79 | + @Autowired | ||
| 76 | private StreamProxyMapper streamProxyMapper; | 80 | private StreamProxyMapper streamProxyMapper; |
| 77 | 81 | ||
| 78 | @Autowired | 82 | @Autowired |
| @@ -903,9 +907,43 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | @@ -903,9 +907,43 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { | ||
| 903 | eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); | 907 | eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); |
| 904 | } | 908 | } |
| 905 | int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id); | 909 | int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id); |
| 910 | + // 查看是否存在子目录,如果存在一并删除 | ||
| 911 | + List<String> allChildCatalog = getAllChildCatalog(id, platformId); | ||
| 912 | + if (!allChildCatalog.isEmpty()) { | ||
| 913 | + int limitCount = 50; | ||
| 914 | + if (allChildCatalog.size() > limitCount) { | ||
| 915 | + for (int i = 0; i < allChildCatalog.size(); i += limitCount) { | ||
| 916 | + int toIndex = i + limitCount; | ||
| 917 | + if (i + limitCount > allChildCatalog.size()) { | ||
| 918 | + toIndex = allChildCatalog.size(); | ||
| 919 | + } | ||
| 920 | + delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog.subList(i, toIndex)); | ||
| 921 | + } | ||
| 922 | + }else { | ||
| 923 | + delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog); | ||
| 924 | + } | ||
| 925 | + } | ||
| 906 | return delresult + delChannelresult + delStreamresult; | 926 | return delresult + delChannelresult + delStreamresult; |
| 907 | } | 927 | } |
| 908 | 928 | ||
| 929 | + private List<String> getAllChildCatalog(String id, String platformId) { | ||
| 930 | + List<String> catalogList = platformCatalogMapper.queryCatalogFromParent(id, platformId); | ||
| 931 | + List<String> catalogListChild = new ArrayList<>(); | ||
| 932 | + if (catalogList != null && !catalogList.isEmpty()) { | ||
| 933 | + for (String childId : catalogList) { | ||
| 934 | + List<String> allChildCatalog = getAllChildCatalog(childId, platformId); | ||
| 935 | + if (allChildCatalog != null && !allChildCatalog.isEmpty()) { | ||
| 936 | + catalogListChild.addAll(allChildCatalog); | ||
| 937 | + } | ||
| 938 | + | ||
| 939 | + } | ||
| 940 | + } | ||
| 941 | + if (!catalogListChild.isEmpty()) { | ||
| 942 | + catalogList.addAll(catalogListChild); | ||
| 943 | + } | ||
| 944 | + return catalogList; | ||
| 945 | + } | ||
| 946 | + | ||
| 909 | 947 | ||
| 910 | @Override | 948 | @Override |
| 911 | public int updateCatalog(PlatformCatalog platformCatalog) { | 949 | public int updateCatalog(PlatformCatalog platformCatalog) { |