扫描结构更改提交
This commit is contained in:
parent
776209bdd0
commit
8e111b70d3
@ -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<Files> {
|
||||
|
||||
int batchInsertFiles(List<Files> filesList);
|
||||
|
||||
int updateNodeIdByPathHierarchy(@Param("id") String id);
|
||||
}
|
||||
|
@ -701,7 +701,7 @@ public class NodesServiceImpl extends ServiceImpl<NodesMapper, Nodes> implements
|
||||
|
||||
|
||||
//通过hutool获取路径下面的文件和文件夹// 递归获取所有内容(包含文件和目录,需自定义过滤)
|
||||
String path = storageSourceConfig.getValue() + absolutePath;
|
||||
String path = storageSourceConfig.getValue() + "/"+ absolutePath;
|
||||
long startHutoolFileListData = System.currentTimeMillis();
|
||||
List<File> allContents = FileUtil.loopFiles(path, file -> true);
|
||||
LOGGER.info("[allContents] 耗时 {} ms | 数据量: {} 条",
|
||||
@ -841,19 +841,14 @@ public class NodesServiceImpl extends ServiceImpl<NodesMapper, Nodes> implements
|
||||
}
|
||||
|
||||
|
||||
//firstLayerData(fileItemList, id);
|
||||
|
||||
//修改文件表中的nodeId
|
||||
long costTimeFiles = System.currentTimeMillis();
|
||||
int affectedLevelFilesRows = filesMapper.updateNodeIdByPathHierarchy(id);
|
||||
LOGGER.info("文件表中的节点ID更新完成,影响 {} 行,总耗时 {} 毫秒", affectedLevelFilesRows, costTimeFiles);
|
||||
|
||||
return "扫描完成";
|
||||
}
|
||||
// //获取数据库父节点为0的文件夹数据 通过所属项目ID和父节点查询
|
||||
// List<Nodes> nodesList = nodesMapper.selectList(new LambdaQueryWrapper<Nodes>().eq(Nodes::getParentId, "00").eq(Nodes::getProjectId, id));
|
||||
//
|
||||
// // 步骤 1:提取现有的 nodeName
|
||||
// Set<String> existingNodeNames = nodesList.stream().map(Nodes::getNodeName).collect(Collectors.toSet());
|
||||
//
|
||||
// // 步骤 2:筛选新增数据 找到需要新增到数据库的文件夹
|
||||
// List<FileItemResult> fileItemNewList = fileItemList.stream().filter(fileItem -> !existingNodeNames.contains(fileItem.getName())).collect(Collectors.toList());
|
||||
|
||||
|
||||
/**
|
||||
* 确保路径格式为以 "/" 开头和结尾(例如 "/data/test/")
|
||||
|
@ -14,4 +14,15 @@
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateNodeIdByPathHierarchy">
|
||||
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}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user