648540858
2023-10-11 7443f2b123774083af4730fdc733b6ba1ab99f7d
修复目录名称修改,修复多层级目录删除,修复全部移除
4个文件已修改
61 ■■■■■ 已修改文件
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java
@@ -162,7 +162,7 @@
            return 0;
        }
        if (ObjectUtils.isEmpty(catalogId)) {
           catalogId = platform.getDeviceGBId();
           catalogId = null;
        }
        if ((result = platformChannelMapper.delChannelForGBByCatalogId(platformId, catalogId)) > 0) {
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java
@@ -31,8 +31,8 @@
    @Update(value = {" <script>" +
            "UPDATE wvp_platform_catalog " +
            "SET name=#{name}" +
            "WHERE id=#{id} and platform_id=#{platformId}"+
            "SET name=#{platformCatalog.name}" +
            "WHERE id=#{platformCatalog.id} and platform_id=#{platformCatalog.platformId}"+
            "</script>"})
    int update(@Param("platformCatalog") PlatformCatalog platformCatalog);
@@ -51,4 +51,16 @@
            " from wvp_platform_catalog pc " +
            " WHERE pc.id=#{id} and pc.platform_id=#{platformId}")
    PlatformCatalog selectByPlatFormAndCatalogId(@Param("platformId") String platformId, @Param("id") String id);
    @Delete("<script> "+
            "DELETE from wvp_platform_catalog where platform_id=#{platformId} and id in " +
            "<foreach collection='ids' item='item' open='(' separator=',' close=')'>" +
            "#{item} " +
            "</foreach>" +
            "</script>")
    int deleteAll(String platformId, List<String> ids);
    @Select("SELECT id from wvp_platform_catalog WHERE platform_id=#{platformId} and parent_id = #{id}")
    List<String> queryCatalogFromParent(@Param("id") String id, @Param("platformId") String platformId);
}
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
@@ -105,7 +105,8 @@
    void delByPlatformId(String serverGBId);
    @Delete("<script> " +
            "DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} and catalog_id=#{catalogId}"  +
            "DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} " +
            " <if test=\"catalogId != null\" >  and catalog_id=#{catalogId}</if>" +
            "</script>")
    int delChannelForGBByCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
@@ -118,4 +119,6 @@
    @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}'")
    List<String> queryParentPlatformByChannelId(String channelId);
}
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
@@ -16,6 +16,7 @@
import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sun.org.apache.xml.internal.resolver.Catalog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -71,6 +72,9 @@
    @Autowired
    private PlatformChannelMapper platformChannelMapper;
    @Autowired
    private PlatformCatalogMapper platformCatalogMapper;
    @Autowired
    private StreamProxyMapper streamProxyMapper;
@@ -903,9 +907,43 @@
            eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
        }
        int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id);
        // 查看是否存在子目录,如果存在一并删除
        List<String> allChildCatalog = getAllChildCatalog(id, platformId);
        if (!allChildCatalog.isEmpty()) {
            int limitCount = 50;
            if (allChildCatalog.size() > limitCount) {
                for (int i = 0; i < allChildCatalog.size(); i += limitCount) {
                    int toIndex = i + limitCount;
                    if (i + limitCount > allChildCatalog.size()) {
                        toIndex = allChildCatalog.size();
                    }
                    delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog.subList(i, toIndex));
                }
            }else {
                delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog);
            }
        }
        return delresult + delChannelresult + delStreamresult;
    }
    private List<String> getAllChildCatalog(String id, String platformId) {
        List<String> catalogList = platformCatalogMapper.queryCatalogFromParent(id, platformId);
        List<String> catalogListChild = new ArrayList<>();
        if (catalogList != null && !catalogList.isEmpty()) {
            for (String childId : catalogList) {
                List<String> allChildCatalog = getAllChildCatalog(childId, platformId);
                if (allChildCatalog != null && !allChildCatalog.isEmpty()) {
                    catalogListChild.addAll(allChildCatalog);
                }
            }
        }
        if (!catalogListChild.isEmpty()) {
            catalogList.addAll(catalogListChild);
        }
        return catalogList;
    }
    @Override
    public int updateCatalog(PlatformCatalog platformCatalog) {