|
|
@@ -4,6 +4,7 @@ import com.siwei.apply.common.UnifyAttachmentEnum;
|
|
|
import com.siwei.apply.domain.NodeAttachment;
|
|
|
import com.siwei.apply.domain.Project;
|
|
|
import com.siwei.apply.domain.ProjectWorkflow;
|
|
|
+import com.siwei.apply.domain.Workflow;
|
|
|
import com.siwei.apply.domain.res.TdgyRes;
|
|
|
import com.siwei.apply.enums.*;
|
|
|
import com.siwei.apply.mapper.NodeAttachmentMapper;
|
|
|
@@ -12,6 +13,7 @@ import com.siwei.apply.mapper.ProjectWorkflowMapper;
|
|
|
import com.siwei.apply.service.NodeAttachmentService;
|
|
|
import com.siwei.apply.service.TdgyService;
|
|
|
import com.siwei.apply.utils.FileExtractUtil;
|
|
|
+import com.siwei.apply.utils.ServiceFileUtil;
|
|
|
import com.siwei.apply.utils.ServiceUtil;
|
|
|
import com.siwei.common.core.exception.ServiceException;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
@@ -25,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.nio.file.*;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -165,7 +168,7 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
|
|
|
directoryStructure = FileExtractUtil.getFileStructure(file);
|
|
|
}
|
|
|
// 保存附件信息并返回ID
|
|
|
- String id = saveAttachment(directoryStructure);
|
|
|
+ String id = saveAttachment(directoryStructure,null);
|
|
|
logger.info("成功处理文件并保存附件信息,id: {}, filePath: {}", id, filePath);
|
|
|
return id;
|
|
|
|
|
|
@@ -267,15 +270,52 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化附件信息进行保存
|
|
|
+ * @param nodeId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String addDefaultAttachment(String projectId,String nodeId) {
|
|
|
+ String nodeAttachmentId = null;
|
|
|
+ String tableName = "";
|
|
|
+ //获取当前节点表名
|
|
|
+ List<ProjectWorkflow> projectWorkflowList = projectWorkflowMapper.selectByNodeId(nodeId,projectId);
|
|
|
+ if(CollectionUtils.isNotEmpty(projectWorkflowList) && Objects.nonNull(projectWorkflowList.get(0))) {
|
|
|
+ ProjectWorkflow projectWorkflow = projectWorkflowList.get(0);
|
|
|
+ tableName = projectWorkflow.getNodeTableName();
|
|
|
+ }
|
|
|
+ //获取枚举配置的目录信息
|
|
|
+ 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);
|
|
|
+ return nodeAttachmentId;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 保存附件信息
|
|
|
*/
|
|
|
- private String saveAttachment(Map<String, Object> directoryStructure) {
|
|
|
+ private String saveAttachment(Map<String, Object> directoryStructure,String nodeId) {
|
|
|
// 创建新记录
|
|
|
NodeAttachment nodeAttachment = new NodeAttachment();
|
|
|
nodeAttachment.generateId();
|
|
|
- nodeAttachment.setNodeId(null); // 不设置nodeId
|
|
|
+ nodeAttachment.setNodeId(nodeId); // 不设置nodeId
|
|
|
nodeAttachment.setAttachment(directoryStructure);
|
|
|
nodeAttachmentMapper.insert(nodeAttachment);
|
|
|
return nodeAttachment.getId();
|
|
|
@@ -460,6 +500,51 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据表名获取内容
|
|
|
+ * @param tableName
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String,List<String>> getCurrentAttachmentName(String tableName) {
|
|
|
+ Map<String,List<String>> retMap = new LinkedHashMap<>();
|
|
|
+ String parentName = "";
|
|
|
+ List<String> nameList = null;
|
|
|
+ if(AloneWorkFlowEnum.NODE_0.getTableName().equalsIgnoreCase(tableName)){
|
|
|
+ parentName = YdysyxzAttachmentNameEnum.NAME_1.getParentName();
|
|
|
+ YdysyxzAttachmentNameEnum[] enumValues = YdysyxzAttachmentNameEnum.values();
|
|
|
+ nameList = Arrays.stream(enumValues).map(YdysyxzAttachmentNameEnum::getName).collect(Collectors.toList());
|
|
|
+ }else if(AloneWorkFlowEnum.NODE_1.getTableName().equalsIgnoreCase(tableName)){
|
|
|
+ parentName = YdbpAttachmentNameEnum.NAME_1.getParentName();
|
|
|
+ YdbpAttachmentNameEnum[] enumValues = YdbpAttachmentNameEnum.values();
|
|
|
+ nameList = Arrays.stream(enumValues).map(YdbpAttachmentNameEnum::getName).collect(Collectors.toList());
|
|
|
+ }else if(AloneWorkFlowEnum.NODE_2.getTableName().equalsIgnoreCase(tableName)){
|
|
|
+ parentName = TdgyAttachmentNameEnum.NAME_1.getParentName();
|
|
|
+ TdgyAttachmentNameEnum[] enumValues = TdgyAttachmentNameEnum.values();
|
|
|
+ nameList = Arrays.stream(enumValues).map(TdgyAttachmentNameEnum::getName).collect(Collectors.toList());
|
|
|
+ }else if(AloneWorkFlowEnum.NODE_3.getTableName().equalsIgnoreCase(tableName)){
|
|
|
+ parentName = GyjsydscdjAttachmentNameEnum.NAME_1.getParentName();
|
|
|
+ GyjsydscdjAttachmentNameEnum[] enumValues = GyjsydscdjAttachmentNameEnum.values();
|
|
|
+ nameList = Arrays.stream(enumValues).map(GyjsydscdjAttachmentNameEnum::getName).collect(Collectors.toList());
|
|
|
+ } else if(AloneWorkFlowEnum.NODE_4.getTableName().equalsIgnoreCase(tableName)){
|
|
|
+ parentName = JsydghxkAttachmentNameEnum.NAME_1.getParentName();
|
|
|
+ JsydghxkAttachmentNameEnum[] enumValues = JsydghxkAttachmentNameEnum.values();
|
|
|
+ nameList = Arrays.stream(enumValues).map(JsydghxkAttachmentNameEnum::getName).collect(Collectors.toList());
|
|
|
+ }else if(AloneWorkFlowEnum.NODE_5.getTableName().equalsIgnoreCase(tableName)){
|
|
|
+ parentName = JsgcghxkAttachmentNameEnum.NAME_1.getParentName();
|
|
|
+ JsgcghxkAttachmentNameEnum[] enumValues = JsgcghxkAttachmentNameEnum.values();
|
|
|
+ nameList = Arrays.stream(enumValues).map(JsgcghxkAttachmentNameEnum::getName).collect(Collectors.toList());
|
|
|
+ }else if(AloneWorkFlowEnum.NODE_6.getTableName().equalsIgnoreCase(tableName)){
|
|
|
+ parentName = TdhyhsAttachmentNameEnum.NAME_1.getParentName();
|
|
|
+ TdhyhsAttachmentNameEnum[] enumValues = TdhyhsAttachmentNameEnum.values();
|
|
|
+ nameList = Arrays.stream(enumValues).map(TdhyhsAttachmentNameEnum::getName).collect(Collectors.toList());
|
|
|
+ }else if(AloneWorkFlowEnum.NODE_7.getTableName().equalsIgnoreCase(tableName)){
|
|
|
+ parentName = GyjsydjfwscdjAttachmentNameEnum.NAME_1.getParentName();
|
|
|
+ GyjsydjfwscdjAttachmentNameEnum[] enumValues = GyjsydjfwscdjAttachmentNameEnum.values();
|
|
|
+ nameList = Arrays.stream(enumValues).map(GyjsydjfwscdjAttachmentNameEnum::getName).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ retMap.put(parentName,nameList);
|
|
|
+ return retMap;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|