浏览代码

修改上传文件逻辑

tianboguang 2 年之前
父节点
当前提交
2e9995aa23
共有 1 个文件被更改,包括 9 次插入1 次删除
  1. 9 1
      src/main/java/com/fdkankan/contro/controller/SceneFileController.java

+ 9 - 1
src/main/java/com/fdkankan/contro/controller/SceneFileController.java

@@ -18,6 +18,7 @@ import com.fdkankan.web.response.ResultData;
 import lombok.extern.log4j.Log4j2;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
 import java.io.File;
@@ -48,6 +49,9 @@ public class SceneFileController{
     @Autowired
     private IScenePlusService scenePlusService;
 
+    @Value("${nas.dir.base:/mnt}")
+    private String nasBasePath;
+
 
     @GetMapping("rebuildScene")
     public ResultData rebuildScene(@RequestParam(value = "num") String num,@RequestParam(value = "force",defaultValue = "false") Boolean force ,@RequestParam(value = "deleteExtras",defaultValue = "true") Boolean deleteExtras) throws IOException {
@@ -59,12 +63,16 @@ public class SceneFileController{
     public ResultData sendCallAlgorithm(@RequestBody Map<String,String> params) throws Exception {
         log.info("sendCallAlgorithm 参数为:{}",JSONObject.toJSONString(params));
         String filePath = params.get("filePath");
+        String filePathParam = filePath;
         if(ObjectUtils.isEmpty(filePath)){
             throw new BusinessException(ErrorCode.PARAM_ERROR,"filePath为空。");
         }
         if(!filePath.endsWith(File.separator)){
             filePath = filePath.concat(File.separator);
         }
+        filePath = nasBasePath.concat(filePath);
+
+        log.info("filePath:{}", filePath);
         // 读取本地文件并校验文件
         // 读取config.json
         if(!new File(filePath+"config.json").exists()){
@@ -91,7 +99,7 @@ public class SceneFileController{
         ZipUtil.unzip(filePath.concat(zipFileName),filePath);
 
         // 上传oaas
-        fYunFileService.uploadFileByCommand(filePath.concat(folderName), ConstantFilePath.OSS_PREFIX.concat(subFolder));
+        fYunFileService.uploadFileByCommand(filePathParam.concat(folderName), ConstantFilePath.OSS_PREFIX.concat(subFolder));
 
         // 通知计算
         return sceneFileBuildService.copyDataAndBuild(null,dataSource ,"V4");