|
|
@@ -189,25 +189,7 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
|
|
|
//先删除当前 文件
|
|
|
Path deleteFile = Paths.get(filePath);
|
|
|
Files.deleteIfExists(deleteFile);
|
|
|
- //重新构建json文件
|
|
|
- Path file = Paths.get(path);
|
|
|
- if (!Files.exists(file)) {
|
|
|
- logger.warn("处理文件失败:文件不存在: {}", path);
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, Object> directoryStructure;
|
|
|
- if(Files.isDirectory(file)) {
|
|
|
- // 如果是目录直接获取目录信息
|
|
|
- directoryStructure = FileExtractUtil.getDirectoryStructure(file);
|
|
|
- } else {
|
|
|
- // 直接获取文件信息
|
|
|
- directoryStructure = FileExtractUtil.getFileStructure(file);
|
|
|
- }
|
|
|
- // 保存附件信息并返回ID
|
|
|
- String id = updateAttachment(nodeAttachmentId,directoryStructure);
|
|
|
- logger.info("成功处理文件并保存附件信息,id: {}, filePath: {}", id, filePath);
|
|
|
- return id;
|
|
|
+ return this.restFileAttachment(path,nodeAttachmentId);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("处理文件并保存附件信息异常,filePath: {}", filePath, e);
|
|
|
return null;
|
|
|
@@ -222,6 +204,12 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
|
|
|
@Override
|
|
|
public String restFileAttachment(String rootPath,String nodeAttachmentId) {
|
|
|
Path file = Paths.get(rootPath);
|
|
|
+ //重新构建json文件
|
|
|
+ if (!Files.exists(file)) {
|
|
|
+ logger.warn("处理文件失败:文件不存在: {}", rootPath);
|
|
|
+ throw new ServiceException("处理文件失败:文件路径不存在:"+rootPath);
|
|
|
+ }
|
|
|
+
|
|
|
Map<String, Object> directoryStructure;
|
|
|
if(Files.isDirectory(file)) {
|
|
|
// 如果是目录直接获取目录信息
|
|
|
@@ -303,23 +291,26 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
|
|
|
public NodeAttachment addDefaultAttachment(String projectId,String nodeId) {
|
|
|
String nodeAttachmentId = null;
|
|
|
String tableName = "";
|
|
|
+ Map<String, Object> directoryStructure = null;
|
|
|
+
|
|
|
//获取当前节点表名
|
|
|
List<ProjectWorkflow> projectWorkflowList = projectWorkflowMapper.selectByNodeId(nodeId,projectId);
|
|
|
if(CollectionUtils.isNotEmpty(projectWorkflowList) && Objects.nonNull(projectWorkflowList.get(0))) {
|
|
|
ProjectWorkflow projectWorkflow = projectWorkflowList.get(0);
|
|
|
tableName = projectWorkflow.getNodeTableName();
|
|
|
+ logger.info("这里获取projectWorkflow表的节点表名:{}",tableName);
|
|
|
+ //获取枚举配置的目录信息
|
|
|
+ Map<String,List<String>> resultMap = this.getCurrentAttachmentName(tableName);
|
|
|
+ String directoryName = resultMap.keySet().stream().findFirst().get();
|
|
|
+ List<String> subDirectoryName = resultMap.values().stream().findFirst().get();
|
|
|
+ String[] subDirectoryNameArr = subDirectoryName.toArray(new String[0]);
|
|
|
+ //这里操作文件系统,并生成json目录结构
|
|
|
+ String path = ServiceFileUtil.createMultipartDirectory(directoryName,subDirectoryNameArr);
|
|
|
+ //重新构建json文件
|
|
|
+ Path file = Paths.get(path);
|
|
|
+ directoryStructure = FileExtractUtil.getDirectoryStructure(file);
|
|
|
+ nodeAttachmentId = this.saveAttachment(directoryStructure,nodeId);
|
|
|
}
|
|
|
- //获取枚举配置的目录信息
|
|
|
- Map<String,List<String>> resultMap = this.getCurrentAttachmentName(tableName);
|
|
|
- String directoryName = resultMap.keySet().stream().findFirst().get();
|
|
|
- List<String> subDirectoryName = resultMap.values().stream().findFirst().get();
|
|
|
- String[] subDirectoryNameArr = subDirectoryName.toArray(new String[0]);
|
|
|
- //这里操作文件系统,并生成json目录结构
|
|
|
- String path = ServiceFileUtil.createMultipartDirectory(directoryName,subDirectoryNameArr);
|
|
|
- //重新构建json文件
|
|
|
- Path file = Paths.get(path);
|
|
|
- Map<String, Object> directoryStructure = FileExtractUtil.getDirectoryStructure(file);
|
|
|
- nodeAttachmentId = this.saveAttachment(directoryStructure,nodeId);
|
|
|
NodeAttachment nodeAttachment = new NodeAttachment();
|
|
|
nodeAttachment.setId(nodeAttachmentId);
|
|
|
nodeAttachment.setNodeId(nodeId); // 不设置nodeId
|