lyhzzz пре 2 недеља
родитељ
комит
f077fed19a

+ 2 - 2
src/main/java/com/fdkankan/fusion/controller/CaseFilesController.java

@@ -80,7 +80,7 @@ public class CaseFilesController extends BaseController{
         caseFilesService.save(caseFiles);
         String url = null;
         try {
-            url = uploadService.uploadFile(file, false, String.format(FilePath.File_OSS_PATH,environment,caseFiles.getFilesId() + "/"));
+            url = uploadService.uploadFile(file, true, String.format(FilePath.File_OSS_PATH,environment,caseFiles.getFilesId() + "/"));
         }catch (Exception e){
             caseFilesService.removeById(caseFiles.getFilesId());
             throw e;
@@ -194,7 +194,7 @@ public class CaseFilesController extends BaseController{
         caseFiles.setImgType(imgType);
         caseFiles.setContent(content);
         caseFilesService.saveOrUpdate(caseFiles);
-        String url = uploadService.uploadFile(file, false, String.format(FilePath.File_OSS_PATH,environment,caseFiles.getFilesId() + "/"));
+        String url = uploadService.uploadFile(file, true, String.format(FilePath.File_OSS_PATH,environment,caseFiles.getFilesId() + "/"));
         caseFiles.setFilesUrl(url);
         caseFilesService.saveOrUpdate(caseFiles);
         return ResultData.ok(caseFiles);

+ 17 - 17
src/main/java/com/fdkankan/fusion/down/CaseDownService.java

@@ -194,7 +194,8 @@ public class CaseDownService {
 
         List<CaseFiles> files = caseFilesService.allList(caseId, 6);
         for (CaseFiles file : files) {
-            downResource(file.getFilesUrl(),casePath);
+            //downResource(file.getFilesUrl(),casePath);
+            downCaseFiles(file,casePath);
         }
         jsonObject.put(basePath+String.format(caseFileOtherUrl,caseId), ResultData.ok(files));
 
@@ -412,23 +413,22 @@ public class CaseDownService {
         ShellUtil.yunDownload(url,desPath);
     }
 
-
-    public void downWordByTemplate(Integer caseId,XWPFTemplate template,String name){
-        // 指定输出文件的路径
-        String outputPath = String.format(FilePath.OFFLINE_RESOURCE_PACKAGE_PATH,caseId) + name;
-        File file = new File(outputPath);
-        if(!file.getParentFile().exists()){
-            file.getParentFile().mkdirs();
+    public void downCaseFiles(CaseFiles caseFiles,String path){
+        if(StringUtils.isBlank(caseFiles.getFilesUrl()) ){
+            return;
         }
-        try {
-            FileOutputStream out = new FileOutputStream(outputPath);
-            template.write(out);
-            out.close();
-            log.info("文档已成功写入到: " + outputPath);
-        } catch (Exception e) {
-           log.info("写出文档失败:{},{}",caseId,name,e);
+        String url = caseFiles.getFilesUrl().replace(queryPath, "");
+        String desPath = path + "/" + url;
+        log.info("downResource:{}",url);
+        if(!desPath.contains(".")){
+            ShellUtil.yunDownload(url, new File(desPath).getParentFile().getPath());
+            return;
+        }
+        String filePath = String.format(FilePath.File_OSS_PATH, environment, caseFiles.getFilesId() + "/");
+        if(url.contains(filePath)){
+            ShellUtil.yunDownload(filePath, path +"/" + filePath);
+            return;
         }
+        ShellUtil.yunDownload(url,desPath);
     }
-
-
 }