|
|
@@ -8,6 +8,7 @@ import com.siwei.apply.mapper.NodeAttachmentMapper;
|
|
|
import com.siwei.apply.mapper.ProjectAttachmentInfoMapper;
|
|
|
import com.siwei.apply.mapper.ProjectMapper;
|
|
|
import com.siwei.apply.mapper.ProjectWorkflowMapper;
|
|
|
+import com.siwei.apply.service.LandOneCodeService;
|
|
|
import com.siwei.apply.service.NodeAttachmentService;
|
|
|
import com.siwei.apply.service.TdgyService;
|
|
|
import com.siwei.apply.utils.FileExtractUtil;
|
|
|
@@ -54,6 +55,9 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
|
|
|
@Autowired
|
|
|
private ProjectAttachmentInfoMapper projectAttachmentInfoMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private LandOneCodeService landOneCodeService;
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -188,12 +192,15 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public String deleteFileAndSave(String path,String nodeAttachmentId,String filePath) {
|
|
|
+ public String deleteFileAndSave(String nodeId,String path,String nodeAttachmentId,String filePath) {
|
|
|
try {
|
|
|
//先删除当前 文件
|
|
|
Path deleteFile = Paths.get(filePath);
|
|
|
Files.deleteIfExists(deleteFile);
|
|
|
- return this.restFileAttachment(path,nodeAttachmentId);
|
|
|
+ nodeAttachmentId = this.restFileAttachment(path,nodeAttachmentId);
|
|
|
+ //更新关于附件相关信息
|
|
|
+ this.modifyAttachmentInfo("",nodeId,nodeAttachmentId);
|
|
|
+ return nodeAttachmentId;
|
|
|
} catch (Exception e) {
|
|
|
logger.error("处理文件并保存附件信息异常,filePath: {}", filePath, e);
|
|
|
return null;
|
|
|
@@ -612,24 +619,40 @@ public class NodeAttachmentImpl implements NodeAttachmentService {
|
|
|
* 3.找出要删除的
|
|
|
* 3.再次更新
|
|
|
*
|
|
|
- *
|
|
|
* 更新附件信息关联全文检索
|
|
|
- * @param projectId
|
|
|
- * @param nodeId
|
|
|
- * @param rootPath
|
|
|
+ * @param paramProjectId
|
|
|
+ * @param paramnodeId
|
|
|
+ * @param nodeAttachmentId
|
|
|
* @return
|
|
|
*/
|
|
|
- public Boolean modifyAttachmentInfo(String projectId,String nodeId,String rootPath){
|
|
|
+ @Override
|
|
|
+ public Boolean modifyAttachmentInfo(String paramProjectId,String paramnodeId,String nodeAttachmentId){
|
|
|
+ if(StringUtils.isBlank(nodeAttachmentId)){
|
|
|
+ throw new ServiceException("附件id不能为空!");
|
|
|
+ }
|
|
|
//这里使用异步方法
|
|
|
CompletableFuture.supplyAsync(()->{
|
|
|
try {
|
|
|
+ logger.info("一部方法开始执行,projectId: {},nodeId: {},nodeAttachmentId: {}", paramProjectId,paramnodeId,nodeAttachmentId);
|
|
|
+ String projectId = paramProjectId;
|
|
|
+ String nodeId = paramnodeId;
|
|
|
+ NodeAttachment nodeAttachment = this.getById(nodeAttachmentId);
|
|
|
+ if(StringUtils.isBlank(nodeId)){
|
|
|
+ nodeId = nodeAttachment.getNodeId();
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(projectId)){
|
|
|
+ //这里根据id,查询项目id
|
|
|
+ ProjectWorkflow projectWorkflow = landOneCodeService.getProjectWorkflowByNodeId(nodeId);
|
|
|
+ projectId = projectWorkflow.getProjectId();
|
|
|
+ }
|
|
|
+ String rootPath = String.valueOf(nodeAttachment.getAttachment().get("path"));
|
|
|
+ logger.info("全文检索根目录路径,rootPath: {}", rootPath);
|
|
|
//先进行删除
|
|
|
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)){
|