wangliang 4 жил өмнө
parent
commit
002d5bb50f

+ 5 - 8
themis-backend/src/main/java/com/qmth/themis/backend/api/SysController.java

@@ -196,14 +196,11 @@ public class SysController {
         String filePath = (String) jsonObject.get("path");
         String url = null;
         if (oss) {
-            if (Objects.nonNull(filePath)) {
-                String[] strs = filePath.split("/");
-                Integer fileId = UploadFileEnum.convertToId(strs[0]);
-                if (fileId == 3) {
-                    url = ossUtil.getPrivateUrl(filePath);
-                } else {
-                    url = dictionaryConfig.aliYunOssDomain().getPublicUrl() + File.separator + filePath;
-                }
+            Integer uploadType = (Integer) jsonObject.get("uploadType");
+            if (uploadType == UploadFileEnum.file.ordinal()) {
+                url = ossUtil.getPrivateUrl(filePath);
+            } else {
+                url = dictionaryConfig.aliYunOssDomain().getPublicUrl() + File.separator + filePath;
             }
         } else {
             url = "http://" + dictionaryConfig.sysDomain().getFileHost() + File.separator + filePath;

+ 3 - 1
themis-business/src/main/java/com/qmth/themis/business/templete/TaskExportCommon.java

@@ -7,6 +7,7 @@ import com.qmth.themis.business.constant.SpringContextHolder;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.entity.TBTaskHistory;
 import com.qmth.themis.business.enums.TaskStatusEnum;
+import com.qmth.themis.business.enums.UploadFileEnum;
 import com.qmth.themis.business.service.TBAttachmentService;
 import com.qmth.themis.business.service.TBTaskHistoryService;
 import com.qmth.themis.business.util.OssUtil;
@@ -160,6 +161,7 @@ public class TaskExportCommon {
                 json.put("path", file.getPath());
             }
             json.put("type", this.type);
+            json.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.file.name());
             this.tbTaskHistory.setReportFilePath(json.toJSONString());
             if (Objects.nonNull(excelFile)) {
                 JSONObject excelJson = new JSONObject();
@@ -168,8 +170,8 @@ public class TaskExportCommon {
                 } else {
                     excelJson.put("path", excelFile.getPath());
                 }
-
                 excelJson.put("type", this.type);
+                excelJson.put(SystemConstant.UPLOAD_TYPE, UploadFileEnum.file.name());
                 this.tbTaskHistory.setResultFilePath(excelJson.toJSONString());
             }
             if (Objects.equals(this.type, SystemConstant.OSS)) {

+ 1 - 0
themis-business/src/main/java/com/qmth/themis/business/templete/TaskImportCommon.java

@@ -138,6 +138,7 @@ public class TaskImportCommon {
             JSONObject json = new JSONObject();
             json.put("path", file.getPath());
             json.put("type", this.type);
+            json.put(SystemConstant.UPLOAD_TYPE, this.uploadType);
             this.tbTaskHistory.setReportFilePath(json.toJSONString());
             if (Objects.equals(this.type, SystemConstant.OSS)) {
                 this.ossUtil.upload(false, file.getPath(), txtStr);