Browse Source

修改重算逻辑

tianboguang 2 năm trước cách đây
mục cha
commit
adc8c9b36f

+ 58 - 6
src/main/java/com/fdkankan/contro/controller/SceneFileController.java

@@ -1,17 +1,24 @@
 package com.fdkankan.contro.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.contro.service.ISceneFileBuildService;
 import com.fdkankan.contro.vo.ResponseSceneFile;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.web.response.ResultData;
 import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 场景文件上传模块
@@ -24,6 +31,10 @@ public class SceneFileController{
     @Autowired
     private ISceneFileBuildService sceneFileBuildService;
 
+    @Autowired
+    private FYunFileServiceInterface fYunFileService;
+
+
     /**
      * 场景文件上传之前先获取fileId
      * @param params
@@ -58,7 +69,48 @@ public class SceneFileController{
     }
 
     @GetMapping("rebuildScene")
-    public ResultData rebuildScene(@RequestParam(value = "num") String num,@RequestParam(value = "force",defaultValue = "true") Boolean force ,@RequestParam(value = "deleteExtras",defaultValue = "true") Boolean deleteExtras) throws IOException {
+    public ResultData rebuildScene(@RequestParam(value = "num") String num,@RequestParam(value = "force",defaultValue = "false") Boolean force ,@RequestParam(value = "deleteExtras",defaultValue = "true") Boolean deleteExtras) throws IOException {
         return sceneFileBuildService.rebuildScene(num,force,deleteExtras);
     }
+
+
+    /**
+     * 国际八目相机调用
+     * @param params
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("getS3UploadUrl")
+    public ResultData getS3UploadUrl(String params) throws Exception {
+        log.info("getS3UploadUrl 参数:{}",params);
+        if (StringUtils.isEmpty(params)) {
+            throw new BusinessException(ErrorCode.PARAM_ERROR,"params为空。");
+        }
+        JSONObject jsonObject = JSON.parseObject(params);
+        if(jsonObject == null){
+            throw new BusinessException(ErrorCode.PARAM_ERROR,"params为空。");
+        }
+        JSONArray files = jsonObject.getJSONArray("Files");
+        if(files == null){
+            throw new BusinessException(ErrorCode.PARAM_ERROR,"params为空。");
+        }
+        List<String> urls = new ArrayList<>();
+        for(int i = 0, len = files.size(); i < len; i++){
+            urls.add(files.getJSONObject(i).getString("filename"));
+        }
+        Map<String, String> uploadS3Url = getUploadS3Url(urls);
+        return ResultData.ok(uploadS3Url);
+    }
+
+    private Map<String, String> getUploadS3Url(List<String> urls) {
+        if(urls == null || urls.size() <= 0){
+            return null;
+        }
+        Map<String, String> map = new HashMap();
+        for(String path : urls){
+            map.put(path, fYunFileService.getPresignedUrl(path).toString());
+        }
+        return map;
+    }
+
 }

+ 5 - 0
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -117,6 +117,11 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
     public void buildScenePre(BuildSceneCallMessage message) {
         boolean success = false;
         try {
+            //重新计算时需要删除文件夹,否知使用缓存
+            if(new File(message.getPath() + File.separator + "results").exists()){
+                FileUtils.deleteDirectory(message.getPath() + File.separator + "results");
+            }
+
             //根据相机类型,组装资源路径
             //下载资源到本地
             this.downLoadSource(message, message.getPath());

+ 0 - 4
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -563,7 +563,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             log.error("该相机详情不存在:" + cameraName);
             throw new BusinessException(CameraConstant.FAILURE_6003);
         }
-        log.info("相机详情:{}",JSONObject.toJSONString(cameraDetail));
         // 判断是否是正顺的场景,如果是正顺的场景,则发送到原来的系统进行计算
         if (!ObjectUtils.isEmpty(cameraDetail.getCompanyId())) {
             Company company = companyService.getById(cameraDetail.getCompanyId());
@@ -1046,9 +1045,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         String buildType = scenePlusExt.getBuildType();
         Integer sceneScheme = scenePlusExt.getSceneScheme();
 
-        //重新计算时需要删除文件夹,否知使用缓存
-        FileUtils.delAllFile(path + File.separator + "results");
-
         String dataFdageOssPath = ConstantFilePath.OSS_PREFIX+ path.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
                 .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "") + "/data.fdage";