|
|
@@ -1,10 +1,7 @@
|
|
|
package com.siwei.apply.service.impl;
|
|
|
|
|
|
import com.siwei.apply.common.UnifyAttachmentEnum;
|
|
|
-import com.siwei.apply.domain.NodeAttachment;
|
|
|
-import com.siwei.apply.domain.Project;
|
|
|
-import com.siwei.apply.domain.ProjectAttachmentInfo;
|
|
|
-import com.siwei.apply.domain.ProjectWorkflow;
|
|
|
+import com.siwei.apply.domain.*;
|
|
|
import com.siwei.apply.domain.res.TdgyRes;
|
|
|
import com.siwei.apply.enums.*;
|
|
|
import com.siwei.apply.mapper.NodeAttachmentMapper;
|
|
|
@@ -16,6 +13,7 @@ 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.domain.R;
|
|
|
import com.siwei.common.core.exception.ServiceException;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.io.FilenameUtils;
|
|
|
@@ -29,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.io.IOException;
|
|
|
import java.nio.file.*;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@@ -605,32 +604,39 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
|
|
|
*/
|
|
|
|
|
|
public Boolean modifyAttachmentInfo(String projectId,String nodeId,String rootPath){
|
|
|
- try {
|
|
|
- List<Path> fileList = ServiceFileUtil.getDirectoryFileList(rootPath);
|
|
|
-
|
|
|
-
|
|
|
- if(CollectionUtils.isEmpty(fileList)){
|
|
|
- for(Path path : fileList){
|
|
|
- ProjectAttachmentInfo projectAttachmentInfo = new ProjectAttachmentInfo();
|
|
|
- projectAttachmentInfo.generateId();
|
|
|
- projectAttachmentInfo.setProjectId(projectId);
|
|
|
- projectAttachmentInfo.setNodeId(nodeId);
|
|
|
- projectAttachmentInfo.setFilePath(path.toString());
|
|
|
- String baseName = FilenameUtils.getBaseName(path.getFileName().toString());
|
|
|
- projectAttachmentInfo.setFileName(baseName);
|
|
|
- projectAttachmentInfoMapper.insert(projectAttachmentInfo);
|
|
|
+ //这里使用异步方法
|
|
|
+ CompletableFuture.supplyAsync(()->{
|
|
|
+ try {
|
|
|
+ //先进行删除
|
|
|
+ List<ProjectAttachmentInfo> projectAttachmentInfoList = projectAttachmentInfoMapper.selectByProjectIdNodeId(projectId,nodeId);
|
|
|
+ if(CollectionUtils.isEmpty(projectAttachmentInfoList)){
|
|
|
+ List<String> ids = projectAttachmentInfoList.stream().map(BaseId::getId).collect(Collectors.toList());
|
|
|
+ projectAttachmentInfoMapper.deleteByIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ //再进行更新
|
|
|
+ List<Path> fileList = ServiceFileUtil.getDirectoryFileList(rootPath);
|
|
|
+ if(CollectionUtils.isEmpty(fileList)){
|
|
|
+ for(Path path : fileList){
|
|
|
+ ProjectAttachmentInfo projectAttachmentInfo = new ProjectAttachmentInfo();
|
|
|
+ projectAttachmentInfo.generateId();
|
|
|
+ projectAttachmentInfo.setProjectId(projectId);
|
|
|
+ projectAttachmentInfo.setNodeId(nodeId);
|
|
|
+ projectAttachmentInfo.setFilePath(path.toString());
|
|
|
+ String baseName = FilenameUtils.getBaseName(path.getFileName().toString());
|
|
|
+ projectAttachmentInfo.setFileName(baseName);
|
|
|
+ projectAttachmentInfoMapper.insert(projectAttachmentInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new ServiceException("全文检索附件材料--保存失败");
|
|
|
}
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- throw new ServiceException("全文检索附件材料--保存失败");
|
|
|
- }
|
|
|
+ return null;
|
|
|
+ });
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|