Bladeren bron

修改生成obj场景状态未修改的逻辑

tianboguang 2 jaren geleden
bovenliggende
commit
82d1b90318

+ 22 - 3
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -126,11 +126,25 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
             //下载资源到本地
             this.downLoadSource(message, message.getPath());
 
+            JSONObject fdageJson = JSONObject.parseObject(FileUtils.readFile(message.getPath().concat("/capture/data.fdage")));
+
+            boolean rewrite = false;
             if (!ObjectUtils.isEmpty(modelType)) {
                 // 修改dataFdage文件
-                JSONObject fdageJson = JSONObject.parseObject(FileUtils.readFile(message.getPath().concat("/capture/data.fdage")));
                 fdageJson.put("modelType", modelType);
+                rewrite = true;
+            }
+
+            // 兼容旧的数据,防止OnlyExportMeshObj标志未删除掉
+            if (fdageJson.containsKey("OnlyExportMeshObj")) {
+                // 写入data.fdage 防止重算
+                fdageJson.remove("OnlyExportMeshObj");
+                rewrite = true;
+            }
+            if (rewrite) {
                 FileUtils.writeFile(message.getPath().concat("/capture/data.fdage"), fdageJson.toJSONString());
+                String ossPath = getOssPath(message.getPath());
+                fYunFileService.uploadFile(message.getPath().concat("/capture/data.fdage"), ossPath + "data.fdage");
             }
 
             message.getBuildContext().put("cameraType",message.getCameraType());
@@ -159,14 +173,19 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
         }
     }
 
-    @Override
-    public void downLoadSource(BuildSceneCallMessage buildSceneMqMessage,String path){
+    private String getOssPath(String path) {
         String ossPath = ConstantFilePath.OSS_PREFIX
                 + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
                 .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
         if (!ossPath.endsWith("/")) {
             ossPath = ossPath.concat("/");
         }
+        return ossPath;
+    }
+
+    @Override
+    public void downLoadSource(BuildSceneCallMessage buildSceneMqMessage,String path){
+        String ossPath = getOssPath(path);
         fYunFileService.downloadFileByCommand(path + File.separator + "capture", ossPath);
     }
 

+ 22 - 4
src/main/java/com/fdkankan/contro/mq/service/impl/BuildV3SceneServiceImpl.java

@@ -105,12 +105,25 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
             //根据相机类型,组装资源路径
             //下载资源到本地
             this.downLoadSource(message, message.getPath());
-
+            JSONObject fdageJson = JSONObject.parseObject(FileUtils.readFile(message.getPath().concat("/capture/data.fdage")));
+            boolean rewrite = false;
             if (!ObjectUtils.isEmpty(modelSceneKind)) {
                 // 修改dataFdage文件
-                JSONObject fdageJson = JSONObject.parseObject(FileUtils.readFile(message.getPath().concat("/capture/data.fdage")));
                 fdageJson.put("modelType", modelSceneKind);
+                rewrite = true;
+            }
+
+            // 兼容旧的数据,防止OnlyExportMeshObj标志未删除掉
+            if (fdageJson.containsKey("OnlyExportMeshObj")) {
+                // 写入data.fdage 防止重算
+                fdageJson.remove("OnlyExportMeshObj");
+                rewrite = true;
+            }
+
+            if (rewrite) {
                 FileUtils.writeFile(message.getPath().concat("/capture/data.fdage"), fdageJson.toJSONString());
+                String ossPath = getOssPath(message.getPath());
+                fYunFileService.uploadFile(message.getPath().concat("/capture/data.fdage"), ossPath + "data.fdage");
             }
 
             message.getBuildContext().put("cameraType",message.getCameraType());
@@ -135,14 +148,19 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
         }
     }
 
-    @Override
-    public void downLoadSource(BuildSceneCallMessage buildSceneMqMessage,String path){
+    private String getOssPath(String path) {
         String ossPath = ConstantFilePath.OSS_PREFIX
                 + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
                 .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
         if (!ossPath.endsWith("/")) {
             ossPath = ossPath.concat("/");
         }
+        return ossPath;
+    }
+
+    @Override
+    public void downLoadSource(BuildSceneCallMessage buildSceneMqMessage,String path){
+        String ossPath = getOssPath(path);
         fYunFileService.downloadFileByCommand(path + File.separator + "capture", ossPath);
     }