Commit 7443f2b123774083af4730fdc733b6ba1ab99f7d

Authored by 648540858
1 parent 7de73ebd

修复目录名称修改,修复多层级目录删除,修复全部移除

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  
... ... @@ -118,4 +119,6 @@ public interface PlatformChannelMapper {
118 119  
119 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 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 16 import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend;
17 17 import com.github.pagehelper.PageHelper;
18 18 import com.github.pagehelper.PageInfo;
  19 +import com.sun.org.apache.xml.internal.resolver.Catalog;
19 20 import org.slf4j.Logger;
20 21 import org.slf4j.LoggerFactory;
21 22 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -73,6 +74,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
73 74 private PlatformChannelMapper platformChannelMapper;
74 75  
75 76 @Autowired
  77 + private PlatformCatalogMapper platformCatalogMapper;
  78 +
  79 + @Autowired
76 80 private StreamProxyMapper streamProxyMapper;
77 81  
78 82 @Autowired
... ... @@ -903,9 +907,43 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
903 907 eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
904 908 }
905 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 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 948 @Override
911 949 public int updateCatalog(PlatformCatalog platformCatalog) {
... ...