Browse Source

徐总要求增加下载数据库和redis数据,为了支持本地版离线包导入功能

dengsixing 1 year ago
parent
commit
633443bb14

+ 5 - 2
src/main/java/com/fdkankan/download/entity/ScenePlusExt.java

@@ -12,10 +12,10 @@ import lombok.Setter;
 
 /**
  * <p>
- * 
+ *
  * </p>
  *
- * @author 
+ * @author
  * @since 2022-08-17
  */
 @Getter
@@ -130,6 +130,9 @@ public class ScenePlusExt implements Serializable {
     @TableField("videos")
     private String videos;
 
+    @TableField("model_kind")
+    private String modelKind;
+
     /**
      * 计算耗时
      */

+ 122 - 59
src/main/java/com/fdkankan/download/service/impl/SceneDownloadHandlerServiceImpl.java

@@ -1,5 +1,6 @@
 package com.fdkankan.download.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.ConcurrentHashSet;
 import cn.hutool.core.date.DateUtil;
@@ -509,75 +510,137 @@ public class SceneDownloadHandlerServiceImpl {
         try {
             //db t_scene_plus、t_scene_plus_ext、t_scene_edit_info、t_scene_edit_info_ext、t_scene_edit_controls
             ScenePlus scenePlus = scenePlusService.getByNum(num);
-            ScenePlusExt scenePlusExt = scenePlusExtService.getByScenePlusId(scenePlus.getId());
-            SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
-            SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfo.getId());
-            SceneEditControls sceneEditControls = sceneEditControlsService.getBySceneEditId(sceneEditInfo.getId());
             FileUtil.writeUtf8String(JSON.toJSONString(scenePlus), cachePath + "t_scene_plus.txt");
-            FileUtil.writeUtf8String(JSON.toJSONString(scenePlusExt), cachePath + "t_scene_plus_ext.txt");
-            FileUtil.writeUtf8String(JSON.toJSONString(sceneEditInfo), cachePath + "t_scene_edit_info.txt");
-            FileUtil.writeUtf8String(JSON.toJSONString(sceneEditInfoExt), cachePath + "t_scene_edit_info_ext.txt");
-            FileUtil.writeUtf8String(JSON.toJSONString(sceneEditControls), cachePath + "t_scene_edit_controls.txt");
 
-            //redis
-            Map<String, String> hotdataStr = redisUtil.hmget(String.format(RedisKey.SCENE_HOT_DATA, num));
-            if(CollUtil.isNotEmpty(hotdataStr)){
-                Map<String, JSONObject> hotdata = hotdataStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
-                FileUtil.writeUtf8String(JSON.toJSONString(hotdata), cachePath + "hotdata.json");
-            }
-
-            Set<String> hoticons = redisUtil.sGet(String.format(RedisKey.SCENE_HOT_ICONS, num));
-            if(CollUtil.isNotEmpty(hoticons)){
-                FileUtil.writeUtf8String(JSON.toJSONString(hoticons), cachePath + "hoticons.json");
-            }
-
-            Map<String, String> LinkPanStr = redisUtil.hmget(String.format(RedisKey.SCENE_LINKPAN_DATA, num));
-            if(CollUtil.isNotEmpty(LinkPanStr)){
-                Map<String, JSONObject> linkPan = LinkPanStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
-                FileUtil.writeUtf8String(JSON.toJSONString(linkPan), cachePath + "linkPan.json");
-            }
+            ScenePlusExt scenePlusExt = scenePlusExtService.getByScenePlusId(scenePlus.getId());
+            FileUtil.writeUtf8String(JSON.toJSONString(scenePlusExt), cachePath + "t_scene_plus_ext.txt");
 
-            Map<String, String> LinkPanStylesStr = redisUtil.hmget(String.format(RedisKey.SCENE_LINKPAN_STYLES, num));
-            if(CollUtil.isNotEmpty(LinkPanStylesStr)){
-                Map<String, JSONObject> LinkPanStyles = LinkPanStylesStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
-                FileUtil.writeUtf8String(JSON.toJSONString(LinkPanStyles), cachePath + "LinkPanStyles.json");
-            }
+            SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
+            sceneEditInfo.setFloorLogo("0");
+            sceneEditInfo.setFloorLogoSize(null);
+            sceneEditInfo.setFloorLogoFile(null);
+            sceneEditInfo.setMusic(null);
+            sceneEditInfo.setMusicFile(null);
+            sceneEditInfo.setFloorPlanUser((byte)0);
+            sceneEditInfo.setTags((byte)0);
+            sceneEditInfo.setVersion(0);
+            sceneEditInfo.setImgVersion(0);
+            sceneEditInfo.setLinkVersion(0);
+            sceneEditInfo.setIsUploadObj((byte)0);
+            sceneEditInfo.setFloorEditVer(0);
+            sceneEditInfo.setFloorPublishVer(0);
+            sceneEditInfo.setBoxVideos(null);
+            sceneEditInfo.setBoxPhotos(null);
+            sceneEditInfo.setBoxModels(null);
+            sceneEditInfo.setEntry(null);
+            sceneEditInfo.setLoadingLogo(null);
+            sceneEditInfo.setFloorLogoFile(null);
+            sceneEditInfo.setFloorPlanUpload(null);
+            FileUtil.writeUtf8String(JSON.toJSONString(sceneEditInfo), cachePath + "t_scene_edit_info.txt");
 
-            Map<String, String> billboardsStr = redisUtil.hmget(String.format(RedisKey.SCENE_BILLBOARDS, num));
-            if(CollUtil.isNotEmpty(billboardsStr)){
-                Map<String, JSONObject> billboards = billboardsStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
-                FileUtil.writeUtf8String(JSON.toJSONString(billboards), cachePath + "billboards.json");
-            }
+            SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByEditInfoId(sceneEditInfo.getId());
+            sceneEditInfoExt.setFloorPlanAngle(0f);
+            sceneEditInfoExt.setFloorPlanCompass(0f);
+            sceneEditInfoExt.setTours(0);
+            sceneEditInfoExt.setMosaic(null);
+            sceneEditInfoExt.setWaterMark(null);
+            sceneEditInfoExt.setLinks(0);
+            sceneEditInfoExt.setFilters(0);
+            sceneEditInfoExt.setSurveillances(0);
+            sceneEditInfoExt.setShareLogoImg(null);
+            sceneEditInfoExt.setBillboards(0);
+            sceneEditInfoExt.setCutModel(0);
+            sceneEditInfoExt.setSnsInfo(null);
+            sceneEditInfoExt.setStarted(null);
+            sceneEditInfoExt.setSceneDraw(0);
+            FileUtil.writeUtf8String(JSON.toJSONString(sceneEditInfoExt), cachePath + "t_scene_edit_info_ext.txt");
 
-            Map<String, String> billboardsStylesStr = redisUtil.hmget(String.format(RedisKey.SCENE_BILLBOARDS_STYLES, num));
-            if(CollUtil.isNotEmpty(billboardsStylesStr)){
-                Map<String, JSONObject> billboardsStyles = billboardsStylesStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
-                FileUtil.writeUtf8String(JSON.toJSONString(billboardsStyles), cachePath + "billboardsStyles.json");
-            }
+            SceneEditControls sceneEditControls = sceneEditControlsService.getBySceneEditId(sceneEditInfo.getId());
+            sceneEditControls.setShowLock(0);
+            sceneEditControls.setShowScale(0);
+            sceneEditControls.setShowCameraTitle(0);
+            sceneEditControls.setShowLinkTitle(0);
+            sceneEditControls.setShowAllModel(0);
+            FileUtil.writeUtf8String(JSON.toJSONString(sceneEditControls), cachePath + "t_scene_edit_controls.txt");
 
-            Map<String, String> cutModelStr = redisUtil.hmget(String.format(RedisKey.SCENE_CUT_MODEL, num));
-            if(CollUtil.isNotEmpty(cutModelStr)){
-                Map<String, JSONObject> cutModel = cutModelStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
-                FileUtil.writeUtf8String(JSON.toJSONString(cutModel), cachePath + "cutModel.json");
-            }
+            //生成sceneJson
+            SceneViewInfo sceneJson = new SceneViewInfo();
+            BeanUtil.copyProperties(sceneEditInfoExt, sceneJson);
+            BeanUtil.copyProperties(sceneEditInfo, sceneJson);
+            SceneEditControlsVO sceneEditControlsVO = BeanUtil.copyProperties(sceneEditControls, SceneEditControlsVO.class);
+            sceneJson.setControls(sceneEditControlsVO);
+            sceneJson.setNum(num);
+            sceneJson.setCreateTime(scenePlus.getCreateTime());
 
-            Map<String, String> mosaicStr = redisUtil.hmget(String.format(RedisKey.SCENE_MOSAIC_DATA, num));
-            if(CollUtil.isNotEmpty(mosaicStr)){
-                Map<String, JSONObject> mosaic = mosaicStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
-                FileUtil.writeUtf8String(JSON.toJSONString(mosaic), cachePath + "mosaic.json");
+            sceneJson.setSceneResolution(scenePlusExt.getSceneResolution());
+            sceneJson.setSceneFrom(scenePlusExt.getSceneFrom());
+            sceneJson.setSceneKind(scenePlusExt.getSceneKind());
+            if(StrUtil.isNotEmpty(scenePlusExt.getVideos())){
+                sceneJson.setVideos(scenePlusExt.getVideos());
             }
+            sceneJson.setModelKind(scenePlusExt.getModelKind());
+            FileUtil.writeUtf8String(JSON.toJSONString(sceneJson), cachePath + "scene.json");
 
-            List<String> filterStr = redisUtil.lGet(String.format(RedisKey.SCENE_filter_DATA, num), 0, -1);
-            if(CollUtil.isNotEmpty(filterStr)){
-                List<JSONObject> filter = filterStr.stream().map(v -> JSONUtil.parseObj(v)).collect(Collectors.toList());
-                FileUtil.writeUtf8String(JSON.toJSONString(filter), cachePath + "filter.json");
-            }
 
-            Map<String, String> drawStr = redisUtil.hmget(String.format(RedisKey.SCENE_DRAW, num));
-            if(CollUtil.isNotEmpty(drawStr)){
-                Map<String, JSONObject> draw = drawStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
-                FileUtil.writeUtf8String(JSON.toJSONString(draw), cachePath + "draw.json");
-            }
+            //redis
+//            Map<String, String> hotdataStr = redisUtil.hmget(String.format(RedisKey.SCENE_HOT_DATA, num));
+//            if(CollUtil.isNotEmpty(hotdataStr)){
+//                Map<String, JSONObject> hotdata = hotdataStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
+//                FileUtil.writeUtf8String(JSON.toJSONString(hotdata), cachePath + "hotdata.json");
+//            }
+//
+//            Set<String> hoticons = redisUtil.sGet(String.format(RedisKey.SCENE_HOT_ICONS, num));
+//            if(CollUtil.isNotEmpty(hoticons)){
+//                FileUtil.writeUtf8String(JSON.toJSONString(hoticons), cachePath + "hoticons.json");
+//            }
+//
+//            Map<String, String> LinkPanStr = redisUtil.hmget(String.format(RedisKey.SCENE_LINKPAN_DATA, num));
+//            if(CollUtil.isNotEmpty(LinkPanStr)){
+//                Map<String, JSONObject> linkPan = LinkPanStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
+//                FileUtil.writeUtf8String(JSON.toJSONString(linkPan), cachePath + "linkPan.json");
+//            }
+//
+//            Map<String, String> LinkPanStylesStr = redisUtil.hmget(String.format(RedisKey.SCENE_LINKPAN_STYLES, num));
+//            if(CollUtil.isNotEmpty(LinkPanStylesStr)){
+//                Map<String, JSONObject> LinkPanStyles = LinkPanStylesStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
+//                FileUtil.writeUtf8String(JSON.toJSONString(LinkPanStyles), cachePath + "LinkPanStyles.json");
+//            }
+//
+//            Map<String, String> billboardsStr = redisUtil.hmget(String.format(RedisKey.SCENE_BILLBOARDS, num));
+//            if(CollUtil.isNotEmpty(billboardsStr)){
+//                Map<String, JSONObject> billboards = billboardsStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
+//                FileUtil.writeUtf8String(JSON.toJSONString(billboards), cachePath + "billboards.json");
+//            }
+//
+//            Map<String, String> billboardsStylesStr = redisUtil.hmget(String.format(RedisKey.SCENE_BILLBOARDS_STYLES, num));
+//            if(CollUtil.isNotEmpty(billboardsStylesStr)){
+//                Map<String, JSONObject> billboardsStyles = billboardsStylesStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
+//                FileUtil.writeUtf8String(JSON.toJSONString(billboardsStyles), cachePath + "billboardsStyles.json");
+//            }
+//
+//            Map<String, String> cutModelStr = redisUtil.hmget(String.format(RedisKey.SCENE_CUT_MODEL, num));
+//            if(CollUtil.isNotEmpty(cutModelStr)){
+//                Map<String, JSONObject> cutModel = cutModelStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
+//                FileUtil.writeUtf8String(JSON.toJSONString(cutModel), cachePath + "cutModel.json");
+//            }
+//
+//            Map<String, String> mosaicStr = redisUtil.hmget(String.format(RedisKey.SCENE_MOSAIC_DATA, num));
+//            if(CollUtil.isNotEmpty(mosaicStr)){
+//                Map<String, JSONObject> mosaic = mosaicStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
+//                FileUtil.writeUtf8String(JSON.toJSONString(mosaic), cachePath + "mosaic.json");
+//            }
+//
+//            List<String> filterStr = redisUtil.lGet(String.format(RedisKey.SCENE_filter_DATA, num), 0, -1);
+//            if(CollUtil.isNotEmpty(filterStr)){
+//                List<JSONObject> filter = filterStr.stream().map(v -> JSONUtil.parseObj(v)).collect(Collectors.toList());
+//                FileUtil.writeUtf8String(JSON.toJSONString(filter), cachePath + "filter.json");
+//            }
+//
+//            Map<String, String> drawStr = redisUtil.hmget(String.format(RedisKey.SCENE_DRAW, num));
+//            if(CollUtil.isNotEmpty(drawStr)){
+//                Map<String, JSONObject> draw = drawStr.entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey(), entry -> JSONUtil.parseObj(entry.getValue())));
+//                FileUtil.writeUtf8String(JSON.toJSONString(draw), cachePath + "draw.json");
+//            }
 
             //下载计算资源
             if(fYunFileService.fileExist(String.format(UploadFilePath.scene_result_data_path, num) + "data.json")){