From 8e111b70d3bb05d791e180a2c5d5b6b765215773 Mon Sep 17 00:00:00 2001 From: lilin Date: Mon, 26 May 2025 16:25:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=AB=E6=8F=8F=E7=BB=93=E6=9E=84=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../specialDocument/mapper/FilesMapper.java | 3 +++ .../service/impl/NodesServiceImpl.java | 17 ++++++----------- .../mapper/specialDocument/FilesMapper.xml | 11 +++++++++++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/java/src/main/java/com/yfd/platform/modules/specialDocument/mapper/FilesMapper.java b/java/src/main/java/com/yfd/platform/modules/specialDocument/mapper/FilesMapper.java index f9581de..40f9727 100644 --- a/java/src/main/java/com/yfd/platform/modules/specialDocument/mapper/FilesMapper.java +++ b/java/src/main/java/com/yfd/platform/modules/specialDocument/mapper/FilesMapper.java @@ -2,6 +2,7 @@ package com.yfd.platform.modules.specialDocument.mapper; import com.yfd.platform.modules.specialDocument.domain.Files; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -16,4 +17,6 @@ import java.util.List; public interface FilesMapper extends BaseMapper { int batchInsertFiles(List filesList); + + int updateNodeIdByPathHierarchy(@Param("id") String id); } diff --git a/java/src/main/java/com/yfd/platform/modules/specialDocument/service/impl/NodesServiceImpl.java b/java/src/main/java/com/yfd/platform/modules/specialDocument/service/impl/NodesServiceImpl.java index 7108836..e19311f 100644 --- a/java/src/main/java/com/yfd/platform/modules/specialDocument/service/impl/NodesServiceImpl.java +++ b/java/src/main/java/com/yfd/platform/modules/specialDocument/service/impl/NodesServiceImpl.java @@ -701,7 +701,7 @@ public class NodesServiceImpl extends ServiceImpl implements //通过hutool获取路径下面的文件和文件夹// 递归获取所有内容(包含文件和目录,需自定义过滤) - String path = storageSourceConfig.getValue() + absolutePath; + String path = storageSourceConfig.getValue() + "/"+ absolutePath; long startHutoolFileListData = System.currentTimeMillis(); List allContents = FileUtil.loopFiles(path, file -> true); LOGGER.info("[allContents] 耗时 {} ms | 数据量: {} 条", @@ -841,19 +841,14 @@ public class NodesServiceImpl extends ServiceImpl implements } - //firstLayerData(fileItemList, id); + + //修改文件表中的nodeId + long costTimeFiles = System.currentTimeMillis(); + int affectedLevelFilesRows = filesMapper.updateNodeIdByPathHierarchy(id); + LOGGER.info("文件表中的节点ID更新完成,影响 {} 行,总耗时 {} 毫秒", affectedLevelFilesRows, costTimeFiles); return "扫描完成"; } -// //获取数据库父节点为0的文件夹数据 通过所属项目ID和父节点查询 -// List nodesList = nodesMapper.selectList(new LambdaQueryWrapper().eq(Nodes::getParentId, "00").eq(Nodes::getProjectId, id)); -// -// // 步骤 1:提取现有的 nodeName -// Set existingNodeNames = nodesList.stream().map(Nodes::getNodeName).collect(Collectors.toSet()); -// -// // 步骤 2:筛选新增数据 找到需要新增到数据库的文件夹 -// List fileItemNewList = fileItemList.stream().filter(fileItem -> !existingNodeNames.contains(fileItem.getName())).collect(Collectors.toList()); - /** * 确保路径格式为以 "/" 开头和结尾(例如 "/data/test/") diff --git a/java/src/main/resources/mapper/specialDocument/FilesMapper.xml b/java/src/main/resources/mapper/specialDocument/FilesMapper.xml index 78ee80f..eff9cf7 100644 --- a/java/src/main/resources/mapper/specialDocument/FilesMapper.xml +++ b/java/src/main/resources/mapper/specialDocument/FilesMapper.xml @@ -14,4 +14,15 @@ + + UPDATE sd_files a + LEFT JOIN sd_nodes b + ON b.project_id = a.project_id + AND a.file_path = CONCAT( b.custom3, b.node_name, '/' ) + SET a.node_id = b.id + WHERE + b.id IS NOT NULL + AND a.project_id = #{id} + +