Переглянути джерело

Merge branch 'feature-算法指定切图方式-下载改造-20220629' into test

dengsixing 3 роки тому
батько
коміт
5c49d978e0

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

@@ -11,6 +11,7 @@ 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.SceneKind;
 import com.fdkankan.common.constant.SceneResolution;
 import com.fdkankan.common.constant.ServerCode;
 import com.fdkankan.common.constant.UploadFilePath;
@@ -184,9 +185,13 @@ public class SceneDownloadHandlerServiceImpl {
             if(StrUtil.isNotEmpty(sceneForm) && SceneFrom.PRO.code().equals(sceneForm)){
                 resolution = "2k";
             }
-            //国际版存在已经切好图的情况,下载时不需要再切图,只需要把文件直接下载下来打包就可以了
-            String sceneResolution = sceneJson.getStr("sceneResolution");
-            if(SceneResolution.TILES.code().equals(sceneResolution)){
+            //如果是已经切好图的场景,不需要再切图了
+//            String sceneResolution = sceneJson.getStr("sceneResolution");
+//            if(SceneResolution.TILES.code().equals(sceneResolution)){
+//                resolution = "notNeadCut";
+//            }
+            String sceneKind = sceneJson.getStr("sceneKind");
+            if(StrUtil.isNotEmpty(sceneKind) && SceneKind.FACE.code().equals(sceneKind)){
                 resolution = "notNeadCut";
             }
 

+ 5 - 0
4dkankan-center-scene/src/main/java/com/fdkankan/scene/bean/SceneJsonBean.java

@@ -104,6 +104,11 @@ public class SceneJsonBean {
     private String sceneFrom;
 
     /**
+     * 切图方式(tiles:瓦片图,face:切片图,pan:全景图 ,local:本地切片,cube:立体图)
+     */
+    private String sceneKind;
+
+    /**
      * 空间视频数据
      */
     private String boxVideos;

+ 7 - 1
4dkankan-center-scene/src/main/java/com/fdkankan/scene/entity/ScenePlusExt.java

@@ -107,7 +107,7 @@ public class ScenePlusExt implements Serializable {
     private String buildType;
 
     /**
-     * 全景图加载方式,tiles/1k:1k瓦片图,tiles/2:2k瓦片图,tiles/4k:4k瓦片图,pan:全景图 ,local:本地切片,cube:立体图
+     * 分辨率(2k,4k)
      */
     @TableField("scene_resolution")
     private String sceneResolution;
@@ -119,6 +119,12 @@ public class ScenePlusExt implements Serializable {
     private String sceneFrom;
 
     /**
+     * 切图方式(tiles:瓦片图,face:切片图,pan:全景图 ,local:本地切片,cube:立体图)
+     */
+    @TableField("scene_kind")
+    private String sceneKind;
+
+    /**
      * 计算耗时
      */
     @TableField("compute_time")

+ 7 - 1
4dkankan-center-scene/src/main/java/com/fdkankan/scene/entity/SceneProExt.java

@@ -92,7 +92,7 @@ public class SceneProExt implements Serializable {
     private Integer sceneSource;
 
     /**
-     * 全景图加载方式,tiles/1k:1k瓦片图,tiles/2:2k瓦片图,tiles/4k:4k瓦片图,pan:全景图 ,local:本地切片,cube:立体图
+     * 分辨率(2k,4k)
      */
     @TableField("scene_resolution")
     private String sceneResolution;
@@ -104,6 +104,12 @@ public class SceneProExt implements Serializable {
     private String sceneFrom;
 
     /**
+     * 切图方式(tiles:瓦片图,face:切片图,pan:全景图 ,local:本地切片,cube:立体图)
+     */
+    @TableField("scene_kind")
+    private String sceneKind;
+
+    /**
      * 大场景序号(随心装场景码)
      */
     @TableField("vrnum")

+ 2 - 1
4dkankan-center-scene/src/main/java/com/fdkankan/scene/mapper/ISceneUpgradeMapper.java

@@ -5,6 +5,7 @@ import com.fdkankan.scene.entity.Folder;
 import com.fdkankan.scene.vo.FolderVO;
 import java.util.List;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -19,7 +20,7 @@ public interface ISceneUpgradeMapper extends BaseMapper {
 
     public void transferScenePro(Long sceneProId);
 
-    public void transferSceneProExt(Long sceneProId);
+    public void transferSceneProExt(@Param("sceneProId") Long sceneProId, @Param("sceneKind") String sceneKind);
 
     public void transferScenePlus(Long sceneProId);
 

+ 98 - 92
4dkankan-center-scene/src/main/java/com/fdkankan/scene/schedule/ScheduleJob.java

@@ -1,93 +1,99 @@
-package com.fdkankan.scene.schedule;
-
-import com.fdkankan.rabbitmq.util.RabbitMqProducer;
-import com.fdkankan.redis.util.RedisLockUtil;
-import com.fdkankan.scene.service.IScene3dNumService;
-import com.fdkankan.scene.service.ISceneService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-@Slf4j
-@Component
-public class ScheduleJob {
-
-    @Value("${environment}")
-    private String environment;
-    @Value("${queue.modeling.modeling-call}")
-    private String queueModelingCall;
-    @Value("${scaling.mq.threshold.modeling-call}")
-    private String modelingCallMqThreshold;
-
-    @Autowired
-    ISceneService sceneService;
-    @Autowired
-    private IScene3dNumService scene3dNumService;
-    @Autowired
-    private RedisLockUtil redisLockUtil;
-    @Autowired
-    RabbitMqProducer rabbitMqProducer;
-
-//    /**
-//     * 更新浏览量
-//     */
-//    @Scheduled(cron = "0 0/10 * * * ? ")
-//    public void updateViewCount() {
-//        if("hq".equals(environment)){
-//            return;
-//        }
-//        log.info("执行定时任务开始:更新浏览量");
-//        try {
-//            //更新浏览量
-//            sceneService.updatePv();
-//        } catch (Exception e) {
-//            log.error("更新浏览量定时任务出错:", e);
-//        }
-//        log.info("执行定时任务结束:更新浏览量");
-//    }
+//package com.fdkankan.scene.schedule;
 //
-//    /**
-//     * <p>
-//            定时生成场景码
-//            查询码池中未使用场景码数量,如果小于阈值,执行批量生成
-//     * </p>
-//     * @author dengsixing
-//     * @date 2022/3/26
-//     **/
-//    @Scheduled(cron = "0 0/1 * * * ? ")
-//    public void generateSceneCode(){
-//        log.info("执行定时任务开始:批量生成场景码");
-//        scene3dNumService.batchCreateSceneNum();
-//        log.info("执行定时任务结束:批量生成场景码");
-//    }
-
-//    /**
-//     * 开启场景计算弹性伸缩
-//     */
-//    @Scheduled(cron = "0 0/5 8-21 * * ? ")
-//    public void startupModelingServer() {
-//        if("hq".equals(environment)){
-//            return;
-//        }
-//        boolean lock = redisLockUtil.lock(
-//            RedisLockKey.LOCK_STARTUP_MODELING_SERVER, RedisKey.EXPIRE_TIME_5_MINUTE);
-//        if(!lock){
-//            return;
-//        }
-//        try {
-//            //当mq排队数大于指定数量时使用弹性升缩
-//            int mqNum = rabbitMqProducer.getMessageCount(queueModelingCall);
-//            log.info("每5分钟查询一次排队队列,mqNum:" + mqNum);
-//            if(mqNum - Integer.parseInt(modelingCallMqThreshold) > 0){
-//                String responce = rubberSheetingUtil.createEcs();
-//                log.info("开启弹性伸缩:{}", responce);
-//            }
-//        } catch (Exception e) {
-//            log.error(e.getMessage());
-//        }finally {
-//            redisLockUtil.unlockLua(RedisLockKey.LOCK_STARTUP_MODELING_SERVER);
-//        }
-//    }
-
-}
+//import com.fdkankan.common.util.RubberSheetingUtil;
+//import com.fdkankan.rabbitmq.util.RabbitMqProducer;
+//import com.fdkankan.redis.constant.RedisKey;
+//import com.fdkankan.redis.constant.RedisLockKey;
+//import com.fdkankan.redis.util.RedisLockUtil;
+//import com.fdkankan.scene.service.IScene3dNumService;
+//import com.fdkankan.scene.service.ISceneService;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.scheduling.annotation.Scheduled;
+//import org.springframework.stereotype.Component;
+//
+//@Slf4j
+//@Component
+//public class ScheduleJob {
+//
+//    @Value("${environment}")
+//    private String environment;
+//    @Value("${queue.modeling.modeling-call}")
+//    private String queueModelingCall;
+//    @Value("${scaling.mq.threshold.modeling-call}")
+//    private String modelingCallMqThreshold;
+//
+//    @Autowired
+//    ISceneService sceneService;
+//    @Autowired
+//    private IScene3dNumService scene3dNumService;
+//    @Autowired
+//    private RedisLockUtil redisLockUtil;
+//    @Autowired
+//    RubberSheetingUtil rubberSheetingUtil;
+//    @Autowired
+//    RabbitMqProducer rabbitMqProducer;
+//
+////    /**
+////     * 更新浏览量
+////     */
+////    @Scheduled(cron = "0 0/10 * * * ? ")
+////    public void updateViewCount() {
+////        if("hq".equals(environment)){
+////            return;
+////        }
+////        log.info("执行定时任务开始:更新浏览量");
+////        try {
+////            //更新浏览量
+////            sceneService.updatePv();
+////        } catch (Exception e) {
+////            log.error("更新浏览量定时任务出错:", e);
+////        }
+////        log.info("执行定时任务结束:更新浏览量");
+////    }
+////
+////    /**
+////     * <p>
+////            定时生成场景码
+////            查询码池中未使用场景码数量,如果小于阈值,执行批量生成
+////     * </p>
+////     * @author dengsixing
+////     * @date 2022/3/26
+////     **/
+////    @Scheduled(cron = "0 0/1 * * * ? ")
+////    public void generateSceneCode(){
+////        log.info("执行定时任务开始:批量生成场景码");
+////        scene3dNumService.batchCreateSceneNum();
+////        log.info("执行定时任务结束:批量生成场景码");
+////    }
+//
+////    /**
+////     * 开启场景计算弹性伸缩
+////     */
+////    @Scheduled(cron = "0 0/5 8-21 * * ? ")
+////    public void startupModelingServer() {
+////        if("hq".equals(environment)){
+////            return;
+////        }
+////        boolean lock = redisLockUtil.lock(
+////            RedisLockKey.LOCK_STARTUP_MODELING_SERVER, RedisKey.EXPIRE_TIME_5_MINUTE);
+////        if(!lock){
+////            return;
+////        }
+////        try {
+////            //当mq排队数大于指定数量时使用弹性升缩
+////            int mqNum = rabbitMqProducer.getMessageCount(queueModelingCall);
+////            log.info("每5分钟查询一次排队队列,mqNum:" + mqNum);
+////            if(mqNum - Integer.parseInt(modelingCallMqThreshold) > 0){
+////                String responce = rubberSheetingUtil.createEcs();
+////                log.info("开启弹性伸缩:{}", responce);
+////            }
+////        } catch (Exception e) {
+////            log.error(e.getMessage());
+////        }finally {
+////            redisLockUtil.unlockLua(RedisLockKey.LOCK_STARTUP_MODELING_SERVER);
+////        }
+////    }
+//
+//}

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

@@ -249,6 +249,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
 
         sceneJson.setSceneResolution(scenePlusExt.getSceneResolution());
         sceneJson.setSceneFrom(scenePlusExt.getSceneFrom());
+        sceneJson.setSceneKind(scenePlusExt.getSceneKind());
         if(StrUtil.isNotEmpty(scenePlusExt.getVideos())){
             sceneJson.setVideos(scenePlusExt.getVideos());
         }
@@ -461,6 +462,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
 
         sceneInfoVO.setSceneResolution(scenePlusExt.getSceneResolution());
         sceneInfoVO.setSceneFrom(scenePlusExt.getSceneFrom());
+        sceneInfoVO.setSceneKind(scenePlusExt.getSceneKind());
         sceneInfoVO.setVideos(scenePlusExt.getVideos());
 
         // TODO: 2022/4/24 v3版本停机要切换---------------------------start
@@ -961,16 +963,21 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
 
             JSONObject dataJson = JSONObject.parseObject(data);
             dataJson.put("extras", floorplanJson);
+            dataJson.put("split_type", "SPLIT_V8");
             //V5表示不需要生成high,low文件
-            dataJson.put("skybox_type", "SKYBOX_V6");
+            String skyboxType = "SKYBOX_V6";
             if(scenePlusExt.getSceneScheme() == 11){
-                dataJson.put("skybox_type", "SKYBOX_V7");
+                skyboxType = "SKYBOX_V7";
             }
-            dataJson.put("split_type", "SPLIT_V8");
             //sceneScheme为3切成瓦片图
             if(scenePlusExt.getSceneScheme() == 3){
-                dataJson.put("skybox_type", "SKYBOX_V4");
+                if("4k".equals(scenePlusExt.getSceneResolution())){
+                    skyboxType = "SKYBOX_V14";
+                }else{
+                    skyboxType = "SKYBOX_V13";
+                }
             }
+            dataJson.put("skybox_type", skyboxType);
             FileUtils.writeFile(target + File.separator+"data.json", new String(dataJson.toString().getBytes(), "UTF-8"));
         }
         if(new File(target + File.separator + "capture").exists()){
@@ -1710,17 +1717,21 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
             JSONObject dataJson = JSONObject.parseObject(data);
             dataJson.put("extras", floorplanJson);
             dataJson.put("split_type", "SPLIT_V8");//替换全景图算法
-            //V5表示不需要生成high,low文件
-            dataJson.put("skybox_type", "SKYBOX_V6");//默认4k minion
+
+            String skyboxType = "SKYBOX_V6";//默认4k minion
             if(SceneFrom.PRO.code().equals(scenePlusExt.getSceneFrom())){
-                dataJson.put("skybox_type", "SKYBOX_V7");//pro 2k
+                skyboxType = "SKYBOX_V7";
                 type = "2k";
             }
-            // TODO: 2022/6/21 这里暂时不清楚含义,可能是国际版需要,先注释---start
-//            if(scenePlusExt.getSceneScheme() == 3){
-//                dataJson.put("skybox_type", "SKYBOX_V4");
-//            }
-            // TODO: 2022/6/21 这里暂时不清楚含义,可能是国际版需要,先注释---end
+            if(scenePlusExt.getSceneScheme() == 3){
+                if("4k".equals(scenePlusExt.getSceneResolution())){
+                    skyboxType = "SKYBOX_V14";
+                }else{
+                    skyboxType = "SKYBOX_V13";
+                }
+            }
+            dataJson.put("skybox_type", skyboxType);
+
             cn.hutool.core.io.FileUtil.writeString(dataJson.toString(),
                 target + File.separator+"data.json", StandardCharsets.UTF_8);
         }

+ 3 - 9
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneUpgradeToV4Service.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.fdkankan.common.constant.ConstantFilePath;
 import com.fdkankan.common.constant.ErrorCode;
+import com.fdkankan.common.constant.SceneKind;
 import com.fdkankan.common.constant.SceneResolution;
 import com.fdkankan.common.response.ResultData;
 import com.fdkankan.fyun.oss.UploadToOssUtil;
@@ -145,15 +146,8 @@ public class SceneUpgradeToV4Service implements ISceneUpgradeToV4Service {
             sceneUpgradeMapper.deleteScenePro(sceneProV3.getId());
             sceneUpgradeMapper.transferScenePro(sceneProV3.getId());
             sceneUpgradeMapper.deleteSceneProExt(sceneProV3.getId());
-            sceneUpgradeMapper.transferSceneProExt(sceneProV3.getId());
-
-            //国际版需要兼容切片图
-            ScenePro scenePro = sceneProService.getById(sceneProV3.getId());
-            SceneProExt sceneProExt = sceneProExtService.findBySceneProId(scenePro.getId());
-            if(scenePro.getSceneScheme() == 3){
-                sceneProExt.setSceneResolution(SceneResolution.TILES.code());
-                sceneProExtService.updateById(sceneProExt);
-            }
+            sceneUpgradeMapper.transferSceneProExt(sceneProV3.getId(),
+                sceneProV3.getSceneScheme() == 3 ? SceneKind.FACE.code():SceneKind.TILES.code());
 
             String thumb = null;
             if(param.isReUpgrade()){

+ 5 - 0
4dkankan-center-scene/src/main/java/com/fdkankan/scene/vo/SceneInfoVO.java

@@ -119,6 +119,11 @@ public class SceneInfoVO {
     private String sceneFrom;
 
     /**
+     * 切图方式(tiles:瓦片图,face:切片图,pan:全景图 ,local:本地切片,cube:立体图)
+     */
+    private String sceneKind;
+
+    /**
      * 空间视频数据
      */
     private String boxVideos;

+ 9 - 8
4dkankan-center-scene/src/main/resources/mapper/scene/SceneUpgradeMapper.xml

@@ -11,16 +11,16 @@
     FROM `t_scene_pro_v3` t WHERE t.id = #{sceneProId}
   </insert>
 
-  <insert id="transferSceneProExt" parameterType="java.lang.Long">
+  <insert id="transferSceneProExt">
     INSERT INTO t_scene_pro_ext(scene_pro_id, data_source, phone_id, recommend, files_name, `algorithm`, ecs,
-    `space`, firmware_version,compute_time,scene_source,vrnum,scene_resolution ,scene_from,`unicode`,view_count,shoot_count,create_time,update_time,tb_status)
+    `space`, firmware_version,compute_time,scene_source,vrnum,scene_resolution ,scene_from, scene_kind,`unicode`,view_count,shoot_count,create_time,update_time,tb_status)
     SELECT t.`id`, t.`data_source`, t.`phone_id`, t.`recommend`, t.`files_name`, t.`algorithm`, t.`ecs`,
     t.`space`, t.`firmware_version`, t.`compute_time`, t.`scene_source`, t.`vrnum`,
     CASE
-      WHEN t.scene_source = 1 THEN 'tiles/2k'
-      WHEN t.scene_source = 2 THEN 'tiles/1k'
-      WHEN t.scene_source = 3 THEN 'tiles/4k'
-      WHEN t.scene_source = 4 THEN 'tiles/4k'
+      WHEN t.scene_source = 1 THEN '2k'
+      WHEN t.scene_source = 2 THEN '1k'
+      WHEN t.scene_source = 3 THEN '4k'
+      WHEN t.scene_source = 4 THEN '4k'
       ELSE NULL
      END AS scene_resolution,
     CASE
@@ -30,6 +30,7 @@
       WHEN t.scene_source = 4 THEN 'laser'
       ELSE NULL
      END AS scene_from,
+    #{sceneKind} scene_kind,
     t.`unicode`, t.`view_count`, t.`shoot_count`, t.`create_time`, t.`update_time`,
     case when t.rec_status = 'A' then 0 else 1 end as tb_status
     FROM `t_scene_pro_v3` t WHERE t.id = #{sceneProId}
@@ -48,10 +49,10 @@
   <insert id="transferScenePlusExt" parameterType="java.lang.Long">
     INSERT INTO t_scene_plus_ext(plus_id, data_source, web_site,thumb,scene_scheme,SPACE,ecs,
     shoot_count,view_count,gps,ALGORITHM,firmware_version,build_type,create_time,update_time,tb_status,
-    scene_resolution, scene_from, videos)
+    scene_resolution, scene_from, scene_kind, videos)
     SELECT pro.id, ext.`data_source`, pro.`web_site`, pro.`thumb`, pro.`scene_scheme`, ext.`space`, ext.`ecs`,
     ext.`shoot_count`, ext.`view_count`, pro.`gps`, ext.`algorithm`, ext.`firmware_version`, pro.`build_type`, pro.`create_time`, pro.`update_time`, pro.`tb_status`,
-    ext.scene_resolution, ext.scene_from, pro.videos
+    ext.scene_resolution, ext.scene_from, scene_kind, pro.videos
     FROM t_scene_pro pro
     LEFT JOIN t_scene_pro_ext ext ON pro.id = ext.scene_pro_id
     WHERE pro.id = #{sceneProId}