chenendian пре 5 дана
родитељ
комит
394ffd555c

+ 9 - 9
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/zrzysite/impl/ZrzysiteCommonServiceImpl.java

@@ -387,34 +387,34 @@ public class ZrzysiteCommonServiceImpl implements IZrzysiteCommonService {
         }
 
         String fileDownLoadPath = "";
-
         try {
             //这里把文件下载下来,并且构建正确的目录结构
             List<ZrzysiteAttachment> zrzysiteAttachmentList = zrzysiteAttachmentMapper.selectByApplyinstId(sourceId);
             //这里增加一个方法,把文件下载下来
-
+            String unsafeChars = "[<>:\"/\\\\|?*]";
             if (CollectionUtils.isNotEmpty(zrzysiteAttachmentList)) {
                 String[] subDirectoryNameArr = zrzysiteAttachmentList.stream().map(ZrzysiteAttachment::getClmc).distinct().toArray(String[]::new);
                 //先删除相关目录
-                for(String subDirectoryName : subDirectoryNameArr){
-                    ServiceFileUtil.deleteDirectory(subDirectoryName);
-                }
+//                 for(String subDirectoryName : subDirectoryNameArr){
+//                    ServiceFileUtil.deleteDirectory(subDirectoryName);
+//                 }
+                String[] subDirectoryNameNew = Arrays.stream(subDirectoryNameArr)
+                        .map(name -> name.replaceAll(unsafeChars, "_"))
+                        .toArray(String[]::new);
                 //重新创建子目录
-                fileDownLoadPath = ServiceFileUtil.createMultipartDirectory(nodeName,subDirectoryNameArr);
-
+                fileDownLoadPath = ServiceFileUtil.createMultipartDirectory(nodeName,subDirectoryNameNew);
                 for (ZrzysiteAttachment attachment : zrzysiteAttachmentList) {
                     String url = attachment.getAttachment();
                     if(StringUtils.isBlank(url)){ //这里避免空值造成数据无法传输
                         continue;
                     }
                     String directoryName = attachment.getClmc();
+                    directoryName = directoryName.replaceAll(unsafeChars,"_");
                     String fileName = attachment.getFjmc();
-//                    //子目录存在先删除
                     String subDownLoadFilePath = fileDownLoadPath + "/" + directoryName;
                     ServiceFileUtil.downloadFile(url,fileName, subDownLoadFilePath);
                 }
             }
-
             String nodeAttachmentId = nodeAttachmentService.processFileAndSave(fileDownLoadPath, null, null);
             boolean success = nodeAttachmentService.updateNodeId(nodeAttachmentId, nodeId);
             log.info("附件材料下载并关联入库成功:{},环节id:{]-项目id:{}",success,nodeId, projectId);