lyhzzz пре 4 месеци
родитељ
комит
dcaf7afff2

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

@@ -30,6 +30,7 @@ import org.springframework.stereotype.Service;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 
@@ -229,6 +230,8 @@ public class CaseDownService {
         CaseParam param = new CaseParam();
         param.setCaseId(caseId);
 
+        HashMap<String,String> replaceMap = new HashMap<>();
+
         //设置案件信息
         jsonObject.put(basePath+inquestInfoUrl+caseId, ResultData.ok(caseInquestInfoService.getByCaseId(caseId)));
         jsonObject.put(basePath+caseInfo+caseId, ResultData.ok(caseService.getInfo(caseId)));
@@ -256,16 +259,7 @@ public class CaseDownService {
 
         List<SceneVo> sceneVos = caseService.sceneList(param);
         for (SceneVo sceneData : sceneVos) {
-            if(StringUtils.isNotBlank(sceneData.getCutModelPath())){
-                sceneData.setCutModelPath(sceneData.getCutModelPath().replace("/oss/","/swkk/"+sceneData.getNum()+"/wwwroot/"));
-            }
-            if(StringUtils.isNotBlank(sceneData.getSurveillancePath())){
-                sceneData.setSurveillancePath(sceneData.getSurveillancePath().replace("/oss/","/swkk/"+sceneData.getNum()+"/wwwroot/"));
-            }
-            if(StringUtils.isNotBlank(sceneData.getSceneJsonPath())){
-                sceneData.setSceneJsonPath(sceneData.getSceneJsonPath().replace("/oss/","/swkk/"+sceneData.getNum()+"/wwwroot/"));
-            }
-
+            addReplaceMap(sceneData,replaceMap);
             //下载模型
             if(StringUtils.isNotBlank(sceneData.getModelGlbUrl())){
                 downModel(caseId,sceneData.getModelGlbUrl());
@@ -307,15 +301,6 @@ public class CaseDownService {
             }
             if(sceneData.getModelId() != null){
                 SceneVo info = modelService.getInfo(sceneData.getModelId());
-                if(StringUtils.isNotBlank(info.getCutModelPath())){
-                    info.setCutModelPath(info.getCutModelPath().replace("/oss/","/swkk/"+info.getNum()+"/wwwroot/"));
-                }
-                if(StringUtils.isNotBlank(info.getSurveillancePath())){
-                    info.setSurveillancePath(info.getSurveillancePath().replace("/oss/","/swkk/"+info.getNum()+"/wwwroot/"));
-                }
-                if(StringUtils.isNotBlank(info.getSceneJsonPath())){
-                    info.setSceneJsonPath(info.getSceneJsonPath().replace("/oss/","/swkk/"+info.getNum()+"/wwwroot/"));
-                }
                 jsonObject.put(basePath+model+sceneData.getModelId(), ResultData.ok(info));
             }
         }
@@ -407,12 +392,27 @@ public class CaseDownService {
         jsonObject.put(basePath+caseAnimationUrl+caseId, ResultData.ok(list));
         jsonObject.put(basePath+getMapConfig, ResultData.ok(mapConfigService.list()));
 
-
-        FileUtil.writeString(JSON.toJSONString(jsonObject), FilePath.OFFLINE_PACKAGE_PATH+caseId+"/www/package/"+jsonDataName,"UTF-8");
+        String jsonString = JSON.toJSONString(jsonObject);
+        if(!replaceMap.isEmpty()){
+            for (String key : replaceMap.keySet()) {
+                jsonString = jsonString.replaceAll(key,replaceMap.get(key));
+            }
+        }
+        FileUtil.writeString(jsonString, FilePath.OFFLINE_PACKAGE_PATH+caseId+"/www/package/"+jsonDataName,"UTF-8");
 
     }
 
-
+    private void addReplaceMap(SceneVo sceneData,HashMap<String,String> map) {
+        if(StringUtils.isNotBlank(sceneData.getCutModelPath())){
+            map.put(sceneData.getCutModelPath(),sceneData.getCutModelPath().replace("/oss/","/swkk/"+sceneData.getNum()+"/wwwroot/"));
+        }
+        if(StringUtils.isNotBlank(sceneData.getSurveillancePath())){
+            map.put(sceneData.getSurveillancePath(),sceneData.getSurveillancePath().replace("/oss/","/swkk/"+sceneData.getNum()+"/wwwroot/"));
+        }
+        if(StringUtils.isNotBlank(sceneData.getSceneJsonPath())){
+            map.put(sceneData.getSceneJsonPath(),sceneData.getSceneJsonPath().replace("/oss/","/swkk/"+sceneData.getNum()+"/wwwroot/"));
+        }
+    }
 
 
     //http://127.0.0.1:8080/offline.html?caseId=362&app=1&share=1#/show/summary

+ 3 - 3
src/main/java/com/fdkankan/fusion/response/SceneVo.java

@@ -57,21 +57,21 @@ public class SceneVo extends Model {
 
 
     public String getCutModelPath() {
-        if(StringUtils.isNotBlank(num) && StringUtils.isBlank(cutModelPath)){
+        if(StringUtils.isNotBlank(num) ){
             return "/oss/"+String.format(FilePath.OBJ_OSS_PATH,num)+"/user/cutModel.json";
         }
         return cutModelPath;
     }
 
     public String getSurveillancePath() {
-        if(StringUtils.isNotBlank(num)&& StringUtils.isBlank(surveillancePath)){
+        if(StringUtils.isNotBlank(num)){
             return "/oss/"+String.format(FilePath.OBJ_OSS_PATH,num)+"/user/surveillance.json";
         }
         return surveillancePath;
     }
 
     public String getSceneJsonPath() {
-        if(StringUtils.isNotBlank(num)&& StringUtils.isBlank(sceneJsonPath)){
+        if(StringUtils.isNotBlank(num)){
             return "/oss/"+String.format(FilePath.OBJ_OSS_PATH,num)+"/data/scene.json";
         }
         return sceneJsonPath;