瀏覽代碼

Merge branch 'feature-v4.0.2-20220621' into release

dengsixing 3 年之前
父節點
當前提交
ce19f29ba3

+ 45 - 13
4dkankan-center-scene-download/src/main/java/com/fdkankan/download/service/impl/SceneDownloadHandlerServiceImpl.java

@@ -6,9 +6,12 @@ import cn.hutool.core.exceptions.ExceptionUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
 import com.fdkankan.common.bean.DownLoadProgressBean;
 import com.fdkankan.common.bean.DownLoadTaskBean;
 import com.fdkankan.common.constant.SceneDownloadProgressStatus;
+import com.fdkankan.common.constant.SceneFrom;
+import com.fdkankan.common.constant.SceneResolution;
 import com.fdkankan.common.constant.ServerCode;
 import com.fdkankan.common.constant.UploadFilePath;
 import com.fdkankan.common.response.ResultData;
@@ -96,6 +99,9 @@ public class SceneDownloadHandlerServiceImpl {
     @Value("${zip.nThreads}")
     private int zipNthreads;
 
+    @Value("${oss.bucket:4dkankan}")
+    private String bucket;
+
     @Value("${upload.type:oss}")
     private String uploadType;
     @Value("${download.config.resource-url}")
@@ -170,19 +176,28 @@ public class SceneDownloadHandlerServiceImpl {
             }
             ZipOutputStream out = new ZipOutputStream(zipFile);
 
-            JSONObject getInfoJson = this.zipGetInfoJson(out, this.wwwroot, num);
-            String resolution = "2k";
-            if(getInfoJson.getInt("sceneSource") != null &&
-                (getInfoJson.getInt("sceneSource") == 3 || getInfoJson.getInt("sceneSource") == 4)){
-                resolution = "4k";
+//            JSONObject getInfoJson = this.zipGetInfoJson(out, this.wwwroot, num);
+            String sceneJsonData = uploadToOssUtil.getObjectContent(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json");
+            JSONObject sceneJson = JSONUtil.parseObj(sceneJsonData);
+            String resolution = "4k";
+            String sceneForm = sceneJson.getStr("sceneFrom");
+            if(StrUtil.isNotEmpty(sceneForm) && SceneFrom.PRO.code().equals(sceneForm)){
+                resolution = "2k";
+            }
+            //国际版存在已经切好图的情况,下载时不需要再切图,只需要把文件直接下载下来打包就可以了
+            String sceneResolution = sceneJson.getStr("sceneResolution");
+            if(SceneResolution.TILES.code().equals(sceneResolution)){
+                resolution = "notNeadCut";
             }
+
             int imagesVersion = -1;
             // TODO: 2022/3/29  V4版本目前没有imagesVersion字段,暂时用version字段替代
 //            if(getInfoJson.getInt("imagesVersion") != null){
 //                imagesVersion = getInfoJson.getInt("imagesVersion");
 //            }
-            if(getInfoJson.getInt("version") != null){
-                imagesVersion = getInfoJson.getInt("version");
+            Integer version = sceneJson.getInt("version");
+            if(Objects.nonNull(version)){
+                imagesVersion = version;
             }
 
 
@@ -198,6 +213,8 @@ public class SceneDownloadHandlerServiceImpl {
             long end2 = Calendar.getInstance().getTimeInMillis();
             log.info("打包oss文件耗时, num:{}, time:{}", num, end2 - end1);
 
+            //重新写入scene.json(去掉密码访问设置)
+            this.zipSceneJson(out, this.wwwroot, num, sceneJson);
 
             //写入启动命令
             this.zipBat(out, num);
@@ -272,14 +289,16 @@ public class SceneDownloadHandlerServiceImpl {
             return;
 
         //切图
-        if((filePath.contains(imageNumPath + "panorama/") && filePath.contains("tiles/" + resolution))
-            || filePath.contains(imageNumPath + "tiles/" + resolution + "/")) {
-            this.processImage(filePath, out, resolution, imagesVersion, cacheKeys);
-            return;
+        if(!"notNeadCut".equals(resolution)){
+            if((filePath.contains(imageNumPath + "panorama/") && filePath.contains("tiles/" + resolution))
+                || filePath.contains(imageNumPath + "tiles/" + resolution + "/")) {
+                this.processImage(filePath, out, resolution, imagesVersion, cacheKeys);
+                return;
+            }
         }
 
         //其他文件打包
-        this.ProcessFiles(filePath, out, this.wwwroot, cacheKeys);
+        this.ProcessFiles(num, filePath, out, this.wwwroot, cacheKeys);
     }
 
     private void zipLocalFiles(ZipOutputStream out, List<String> v3localFilePaths, String v3localPath, String num, AtomicInteger count, int total) throws Exception{
@@ -361,6 +380,16 @@ public class SceneDownloadHandlerServiceImpl {
         return getInfoJson;
     }
 
+    private void zipSceneJson(ZipOutputStream out, String root, String num, JSONObject sceneJson) throws Exception{
+
+        //访问密码置0
+        JSONObject controls = sceneJson.getJSONObject("controls");
+        controls.set("showLock", 0);
+
+        String sceneJsonPath = root + String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json";
+        this.zipBytes(out, sceneJsonPath, sceneJson.toString().getBytes());
+    }
+
     private void processImage(String key, ZipOutputStream out, String resolution, int imagesVersion, Set<String> imgKeys) throws Exception{
 
         String fileName = key.substring(key.lastIndexOf("/")+1, key.indexOf("."));
@@ -424,10 +453,13 @@ public class SceneDownloadHandlerServiceImpl {
 
     }
 
-    public void ProcessFiles(String key, ZipOutputStream out, String prefix, Set<String> cacheKeys) throws Exception{
+    public void ProcessFiles(String num, String key, ZipOutputStream out, String prefix, Set<String> cacheKeys) throws Exception{
         if(cacheKeys.contains(key)){
             return;
         }
+        if(key.equals(String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json")){
+            return;
+        }
         cacheKeys.add(key);
         String url = this.resourceUrl + key + "?t=" + Calendar.getInstance().getTimeInMillis();
         if(key.contains("hot.json") || key.contains("link-scene.json")){

+ 2 - 0
4dkankan-center-scene/src/main/java/com/fdkankan/scene/bean/RequestSceneProV4.java

@@ -29,5 +29,7 @@ public class RequestSceneProV4 {
 
     private String sceneName;
 
+    private String sceneDec;
+
 
 }

+ 6 - 1
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneEditInfoServiceImpl.java

@@ -312,7 +312,12 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         // todo 调用v3接口同步场景缩略图url---------------------------------start
         String url = fkankanMiniHost + URL_UPGRADE_TO_V4_RESULT_SYNC;
         fdkankanMiniClient.upgradeToV4ResultSync(url,
-            RequestSceneProV4.builder().id(scenePlus.getId()).thumb(scenePlusExt.getThumb()).sceneName(sceneEditInfo.getTitle()).build(),
+            RequestSceneProV4.builder()
+                .id(scenePlus.getId())
+                .thumb(scenePlusExt.getThumb())
+                .sceneName(sceneEditInfo.getTitle())
+                .sceneDec(sceneEditInfo.getDescription())
+                .build(),
             new FdkkMiniReqSuccessCallback(), new FdkkMiniReqErrorCallback()
         );
         // todo 调用v3接口同步场景缩略图url---------------------------------end