Parcourir la source

离线包 下载scene.json优化

dengsixing il y a 10 mois
Parent
commit
35590e6896

+ 42 - 16
src/main/java/com/fdkankan/scene/service/impl/SceneDownloadHandlerServiceImpl.java

@@ -12,11 +12,10 @@ import cn.hutool.extra.spring.SpringUtil;
 import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.fdkankan.common.constant.ErrorCode;
-import com.fdkankan.common.constant.SceneDownloadProgressStatus;
-import com.fdkankan.common.constant.SceneKind;
-import com.fdkankan.common.constant.ServerCode;
+import com.fdkankan.common.constant.*;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.scene.bean.*;
@@ -29,6 +28,8 @@ import com.fdkankan.model.constants.UploadFilePath;
 import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.util.RedisUtil;
 import com.fdkankan.scene.bean.ImageType;
+import com.fdkankan.scene.vo.SceneEditControlsVO;
+import com.fdkankan.scene.vo.SceneViewInfo;
 import com.google.common.collect.Lists;
 import lombok.extern.slf4j.Slf4j;
 import lombok.var;
@@ -228,16 +229,15 @@ public class SceneDownloadHandlerServiceImpl {
                 zipFile.getParentFile().mkdirs();
             }
 
-            String sceneJsonData = ossUtil.getFileContent(bucket,String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json");
-            JSONObject sceneJson = JSONUtil.parseObj(sceneJsonData);
-            String resolution = sceneJson.getStr("sceneResolution");
+            SceneViewInfo sceneViewInfo = this.getSceneJson(num, bucket);
+            String resolution = sceneViewInfo.getSceneResolution();
             //国际版存在已经切好图的情况,下载时不需要再切图,只需要把文件直接下载下来打包就可以了
-            if(SceneKind.FACE.code().equals(sceneJson.getStr("sceneKind"))){
+            if(SceneKind.FACE.code().equals(sceneViewInfo.getSceneKind())){
                 resolution = "notNeadCut";
             }
 
             int imagesVersion = -1;
-            Integer version = sceneJson.getInt("version");
+            Integer version = sceneViewInfo.getVersion();
             if(Objects.nonNull(version)){
                 imagesVersion = version;
             }
@@ -251,7 +251,7 @@ public class SceneDownloadHandlerServiceImpl {
             log.info("打包oss文件耗时, num:{}, time:{}", num, timer.intervalRestart());
 
             //重新写入scene.json(去掉密码访问设置)
-            this.zipSceneJson(num, sceneJson);
+            this.zipSceneJson(num, sceneViewInfo);
 
             //写入启动命令
             this.zipBat(num, "v4", downLoadTaskBean.getLang());
@@ -278,6 +278,34 @@ public class SceneDownloadHandlerServiceImpl {
         }
     }
 
+    private SceneViewInfo getSceneJson(String num, String bucket){
+        String sceneJsonData = redisUtil.get(String.format(RedisKey.SCENE_JSON, num));
+        if(StrUtil.isEmpty(sceneJsonData)){
+            sceneJsonData = ossUtil.getFileContent(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json");
+        }
+        sceneJsonData = sceneJsonData.replace(this.publicUrl, "");
+        SceneViewInfo sceneInfoVO = JSON.parseObject(sceneJsonData, SceneViewInfo.class);
+        sceneInfoVO.setScenePassword(null);
+        if(Objects.isNull(sceneInfoVO.getFloorPlanAngle())){
+            sceneInfoVO.setFloorPlanAngle(0f);
+        }
+        if(Objects.isNull(sceneInfoVO.getFloorPlanCompass())){
+            sceneInfoVO.setFloorPlanCompass(0f);
+        }
+        SceneEditControlsVO controls = sceneInfoVO.getControls();
+        if(Objects.isNull(controls.getShowShare())){
+            controls.setShowShare(CommonStatus.YES.code().intValue());
+        }
+        if(Objects.isNull(controls.getShowCapture())){
+            controls.setShowCapture(CommonStatus.YES.code().intValue());
+        }
+        if(Objects.isNull(controls.getShowBillboardTitle())){
+            controls.setShowBillboardTitle(CommonStatus.YES.code().intValue());
+        }
+
+        return sceneInfoVO;
+    }
+
     public void downloadHandlerV3(DownLoadTaskBean downLoadTaskBean) throws Exception{
 
         String num = downLoadTaskBean.getSceneNum();
@@ -540,14 +568,12 @@ public class SceneDownloadHandlerServiceImpl {
         return map;
     }
 
-    private void zipSceneJson(String num, JSONObject sceneJson) throws Exception{
+    private void zipSceneJson(String num, SceneViewInfo sceneViewInfo) throws Exception{
         //访问密码置0
-        JSONObject controls = sceneJson.getJSONObject("controls");
-        controls.set("showLock", 0);
+        SceneEditControlsVO controls = sceneViewInfo.getControls();
+        controls.setShowLock(CommonStatus.NO.code().intValue());
         String sceneJsonPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json";
-
-        String sceneJsonStr = sceneJson.toString().replace(this.publicUrl, "");
-        FileUtil.writeUtf8String(sceneJsonStr, String.format(this.sourceLocal, num, this.wwwroot + sceneJsonPath));
+        FileUtil.writeUtf8String(JSON.toJSONString(sceneViewInfo, SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.WriteNullNumberAsZero), String.format(this.sourceLocal, num, this.wwwroot + sceneJsonPath));
     }
 
     private void zipGetInfoJson(String num, JSONObject getInfo) throws Exception{

+ 268 - 0
src/main/java/com/fdkankan/scene/vo/SceneViewInfo.java

@@ -0,0 +1,268 @@
+package com.fdkankan.scene.vo;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ * TODO
+ * </p>
+ *
+ * @author dengsixing
+ * @since 2022/1/19
+ **/
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SceneViewInfo implements Serializable {
+
+    private static final long serialVersionUID = 1l;
+
+    /**
+     * 场景码
+     */
+    private String num;
+
+    /**
+     * 地面logo名称
+     */
+    private String floorLogo;
+
+    /**
+     * 地面logo大小
+     */
+    private Integer floorLogoSize;
+
+    /**
+     * 地面logo文件名称
+     */
+    private String floorLogoFile;
+
+    /**
+     * 背景音乐
+     */
+    private String music;
+
+    /**
+     * 背景音乐文件名称
+     */
+    private String musicFile;
+
+    /**
+     * 浏览密码
+     */
+    private String scenePassword;
+
+    /**
+     * 场景标题
+     */
+    private String title;
+
+    /**
+     * 场景描述
+     */
+    private String description;
+
+    private SceneEditControlsVO controls;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+//    /**
+//     * 点位数量
+//     */
+//    private Integer panoCount;
+//
+//    /**
+//     * 球幕视频数量
+//     */
+//    private Integer videoCount;
+
+    /**
+     * 版本
+     */
+    private Integer version;
+
+    /**
+     * 图片版本
+     */
+    private Integer imgVersion;
+
+    /**
+     * 场景关联版本
+     */
+    private Integer linkVersion;
+
+    /**
+     * 是否上传了户型图(0-否,1-是)
+     */
+    private Byte floorPlanUser;
+
+//    private String cadInfo;
+//
+//    private Byte isUploadObj;
+//
+//    private Integer floorEditVer;
+//
+//    private Integer floorPublishVer;
+
+    /**
+     * 初始点信息
+     */
+    private String entry;
+
+    /**
+     * 全景图加载方式,tiles/1k:1k瓦片图,tiles/2:2k瓦片图,tiles/4k:4k瓦片图,pan:全景图 ,local:本地切片,cube:立体图
+     */
+    private String sceneResolution;
+
+    /**
+     * 场景来源,lite:双目lite相机,pro:八目相机,minion:双面转台相机,laser:激光相机,virtual:虚拟场景,sketch:图片建模场景
+     */
+    private String sceneFrom;
+
+    /**
+     * 切图方式(tiles:瓦片图,face:切片图,pan:全景图 ,local:本地切片,cube:立体图)
+     */
+    private String sceneKind;
+
+    /**
+     * 算法模型类型(dam,3dtiles)
+     */
+    private String modelKind;
+
+    /**
+     * 空间视频数据
+     */
+    private String boxVideos;
+    /**
+     * 空间贴图数据
+     */
+    private String boxPhotos;
+
+    /**
+     * 空间模型数据
+     */
+    private String boxModels;
+
+    /**
+     *点位视频
+     */
+    private String videos;
+
+    /**
+     * 是否有热点数据
+     */
+    private Integer tags;
+
+    /**
+     * 加载logo名
+     */
+    private String loadingLogo;
+
+    /**
+     * 加载logo文件名
+     */
+    private String loadingLogoFile;
+
+    /**
+     * 数据同步方式
+     */
+    private String dataSync;
+
+    /**
+     * 户型角度
+     */
+    private Float floorPlanAngle;
+
+    /**
+     * 指南针角度
+     */
+    private Float floorPlanCompass;
+
+    /**
+     * 用户上传自定义平面图
+     */
+    private JSONArray floorPlanUpload;
+
+    /**
+     * 是否保存导览
+     */
+    private Integer tours;
+
+    /**
+     * 是否有马赛克
+     */
+    private Integer mosaic;
+
+    /**
+     * 马赛克列表
+     */
+    private List<JSONObject> mosaicList;
+
+    /**
+     * 水印文件名
+     */
+    private String waterMark;
+
+    /**
+     * 是否有场景关联(0-否,1-是)
+     */
+    private Integer links;
+
+    /**
+     * 是否有滤镜(0-否,1-是)
+     */
+    private Integer filters;
+
+    /**
+     * 是否有监控摄像头数据
+     */
+    private Integer surveillances;
+
+    /**
+     * 场景容量 单位 MB
+     */
+    private Integer space;
+
+    /**
+     * 分享信息
+     */
+    private JSONObject sns;
+
+    /**
+     * 是否有指示牌(0-否,1-是)
+     */
+    private Integer billboards;
+
+    /**
+     * 是否有模型裁剪(0-否,1-是)
+     */
+    private Integer cutModel = 0;
+
+    /**
+     * 启动页配置信息
+     */
+    private JSONObject started;
+
+    /**
+     * 空间绘制
+     */
+    private Integer sceneDraw;
+
+    //动态面板
+    private int dynamicPanel;
+
+
+}