Explorar o código

v3场景下载

dengsixing %!s(int64=2) %!d(string=hai) anos
pai
achega
9a87f28021

+ 23 - 4
src/main/java/com/fdkankan/download/bean/CurrentDownloadNumUtil.java

@@ -17,19 +17,38 @@ public class CurrentDownloadNumUtil {
      */
     private static ConcurrentHashSet<String> downLoadingNumSet = new ConcurrentHashSet<>();
 
-    public static void addSceneNum(String num){
+    /**
+     * 正在下载的v3场景码
+     */
+    private static ConcurrentHashSet<String> downLoadingV3NumSet = new ConcurrentHashSet<>();
+
+    public static void addSceneNum(String num, String version){
+        if("v3".equals(version)){
+            downLoadingV3NumSet.add(num);
+            return;
+        }
         downLoadingNumSet.add(num);
     }
 
-    public static boolean containSceneNum(String num){
+    public static boolean containSceneNum(String num, String version){
+        if("v3".equals(version)){
+            return downLoadingV3NumSet.contains(num);
+        }
         return downLoadingNumSet.contains(num);
     }
 
-    public static void removeSceneNum(String num){
+    public static void removeSceneNum(String num, String version){
+        if("v3".equals(version)){
+            downLoadingV3NumSet.remove(num);
+            return;
+        }
         downLoadingNumSet.remove(num);
     }
 
-    public static int cntDownloadingLocal(){
+    public static int cntDownloadingLocal(String version){
+        if("v3".equals(version)){
+            return downLoadingV3NumSet.size();
+        }
         return downLoadingNumSet.size();
     }
 

+ 21 - 0
src/main/java/com/fdkankan/download/controller/SceneProController.java

@@ -0,0 +1,21 @@
+package com.fdkankan.download.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * pro场景表 前端控制器
+ * </p>
+ *
+ * @author 
+ * @since 2022-10-17
+ */
+@RestController
+@RequestMapping("/download/scenePro")
+public class SceneProController {
+
+}
+

+ 237 - 0
src/main/java/com/fdkankan/download/entity/ScenePro.java

@@ -0,0 +1,237 @@
+package com.fdkankan.download.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * pro场景表
+ * </p>
+ *
+ * @author 
+ * @since 2022-10-17
+ */
+@Getter
+@Setter
+@TableName("t_scene_pro")
+public class ScenePro implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 场景名称
+     */
+    @TableField("scene_name")
+    private String sceneName;
+
+    /**
+     * 场景描述
+     */
+    @TableField("scene_dec")
+    private String sceneDec;
+
+    /**
+     * 场景的链接地址
+     */
+    @TableField("web_site")
+    private String webSite;
+
+    /**
+     * 场景缩略图
+     */
+    @TableField("thumb")
+    private String thumb;
+
+    /**
+     * 创建时间
+     */
+    @TableField("create_time")
+    private Date createTime;
+
+    /**
+     * 0表示未建好,1表示建好,-1表示出错,-2表示不要在官网上显示
+     */
+    @TableField("status")
+    private Integer status;
+
+    /**
+     * 原始的大场景数据(七牛)
+     */
+    @TableField("data_source")
+    private String dataSource;
+
+    /**
+     * 用户表t_user的id
+     */
+    @TableField("user_id")
+    private Long userId;
+
+    /**
+     * 0表示未付款,1表示付款了,-1表示欠费,-2表示容量不足
+     */
+    @TableField("pay_status")
+    private Integer payStatus;
+
+    /**
+     * 相机主表t_camera的id
+     */
+    @TableField("camera_id")
+    private Long cameraId;
+
+    /**
+     * 手机id
+     */
+    @TableField("phone_id")
+    private String phoneId;
+
+    /**
+     * 场景logo
+     */
+    @TableField("scene_logo")
+    private String sceneLogo;
+
+    /**
+     * 大场景序号
+     */
+    @TableField("num")
+    private String num;
+
+    /**
+     * 0表示其他,1表示文博,2表示地产,3表示电商,4表示餐饮,5表示家居,99一件换装虚拟房源
+     */
+    @TableField("scene_type")
+    private Integer sceneType;
+
+    /**
+     * 1表示推荐,0表示正常
+     */
+    @TableField("recommend")
+    private Integer recommend;
+
+    /**
+     * 浏览次数
+     */
+    @TableField("view_count")
+    private Integer viewCount;
+
+    /**
+     * 拍摄数量 ps:点位数量
+     */
+    @TableField("shoot_count")
+    private Integer shootCount;
+
+    /**
+     * 所有资源文件名
+     */
+    @TableField("files_name")
+    private String filesName;
+
+    /**
+     * 点位视频
+     */
+    @TableField("videos")
+    private String videos;
+
+    /**
+     * 要gps定位
+     */
+    @TableField("gps")
+    private String gps;
+
+    /**
+     * 方案:1是双目,2是转台,3是六目,4是八目,10获取4k图,11获取2k,12获取1k
+     */
+    @TableField("scene_scheme")
+    private Integer sceneScheme;
+
+    /**
+     * 记录的状态,A: 生效,I: 禁用
+     */
+    @TableField("rec_status")
+    @TableLogic(value = "A", delval = "I")
+    private String recStatus;
+
+    /**
+     * 更新时间
+     */
+    @TableField("update_time")
+    private Date updateTime;
+
+    /**
+     * 算法类型
+     */
+    @TableField("algorithm")
+    private String algorithm;
+
+    /**
+     * 服务器的服务商
+     */
+    @TableField("ecs")
+    private String ecs;
+
+    /**
+     * 使用容量
+     */
+    @TableField("space")
+    private Long space;
+
+    /**
+     * 固件版本
+     */
+    @TableField("firmware_version")
+    private String firmwareVersion;
+
+    /**
+     * 调用V2还是V3的算法
+     */
+    @TableField("build_type")
+    private String buildType;
+
+    /**
+     * 计算时间(秒为单位)
+     */
+    @TableField("compute_time")
+    private Long computeTime;
+
+    /**
+     * 场景来源,相机拍摄10以内表示,1表示八目,2双目,3转台,4 激光  其他来源10以上,11:一键换装,12:123看房,13文通虚拟场景,14上传的matterport场景
+     */
+    @TableField("scene_source")
+    private Integer sceneSource;
+
+    /**
+     * 大场景序号(随心装场景码)
+     */
+    @TableField("vrnum")
+    private String vrnum;
+
+    @TableField("unicode")
+    private String unicode;
+
+    @TableField("mosaics")
+    private String mosaics;
+
+    /**
+     * 是否已升级v4(0-否,1-是)
+     */
+    @TableField("is_upgrade")
+    private Integer isUpgrade;
+
+    /**
+     * 是否是obj场景
+     */
+    @TableField("is_obj")
+    private Integer isObj;
+
+
+}

+ 4 - 4
src/main/java/com/fdkankan/download/generate/AutoGenerate.java

@@ -16,8 +16,8 @@ public class AutoGenerate {
 
         String path =System.getProperty("user.dir") + ".";
 
-        generate(path,"test", getTables(new String[]{
-                "t_scene_plus","t_scene_plus_ext"
+        generate(path,"download", getTables(new String[]{
+                "t_scene_pro"
         }));
 
     }
@@ -28,8 +28,8 @@ public class AutoGenerate {
 
 
     public static void  generate(String path,String moduleName,  List<String> tables){
-        FastAutoGenerator.create("jdbc:mysql://120.24.144.164:3306/4dkankan_v4",
-            "root","4Dage@4Dage#@168")
+        FastAutoGenerator.create("jdbc:mysql://rm-wz90w10465iiwwv098o.mysql.rds.aliyuncs.com/4dkankan_v4",
+            "root","D2719bd0cae1a005")
                 .globalConfig(builder -> {
                     builder.author("")               //作者
                             .outputDir(path+"\\src\\main\\java")    //输出路径(写到java目录)

+ 18 - 0
src/main/java/com/fdkankan/download/mapper/ISceneProMapper.java

@@ -0,0 +1,18 @@
+package com.fdkankan.download.mapper;
+
+import com.fdkankan.download.entity.ScenePro;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ * pro场景表 Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2022-10-17
+ */
+@Mapper
+public interface ISceneProMapper extends BaseMapper<ScenePro> {
+
+}

+ 6 - 1
src/main/java/com/fdkankan/download/schedule/ScheduleJob.java

@@ -16,8 +16,13 @@ public class ScheduleJob {
     @Autowired
     ISceneDownLoadService sceneDownLoadService;
 
+//    @Scheduled(cron = "0/5 * * * * ? ")
+//    public void job4SceneDownload() throws Exception {
+//        sceneDownLoadService.process();
+//    }
+
     @Scheduled(cron = "0/5 * * * * ? ")
-    public void job4SceneDownload() throws Exception {
+    public void job4SceneV3Download() throws Exception {
         sceneDownLoadService.process();
     }
 

+ 2 - 0
src/main/java/com/fdkankan/download/service/ISceneDownLoadService.java

@@ -12,4 +12,6 @@ public interface ISceneDownLoadService {
 
     void process() throws Exception;
 
+    void processV3() throws Exception;
+
 }

+ 18 - 0
src/main/java/com/fdkankan/download/service/ISceneProService.java

@@ -0,0 +1,18 @@
+package com.fdkankan.download.service;
+
+import com.fdkankan.download.entity.ScenePro;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * pro场景表 服务类
+ * </p>
+ *
+ * @author 
+ * @since 2022-10-17
+ */
+public interface ISceneProService extends IService<ScenePro> {
+
+    ScenePro getByNum(String num);
+
+}

+ 33 - 7
src/main/java/com/fdkankan/download/service/impl/SceneDownLoadServiceImpl.java

@@ -39,14 +39,14 @@ public class SceneDownLoadServiceImpl implements ISceneDownLoadService {
     public void process() throws Exception {
 
         //统计本节点正在下载任务数量
-        int downloadIngCnt = CurrentDownloadNumUtil.cntDownloadingLocal();
+        int downloadIngCnt = CurrentDownloadNumUtil.cntDownloadingLocal("v4");
         //如果正在下载的场景大于最大线程数,不往下执行
         if(downloadIngCnt >= downloadThreadMax){
             return;
         }
 
         for(int i = 0; i < downloadThreadMax - downloadIngCnt; i++){
-            DownLoadTaskBean downLoadTaskBean = this.getTaskSceneNum();
+            DownLoadTaskBean downLoadTaskBean = this.getTaskSceneNum("v4");
             //获取任务队列中队头场景码,如果是空,标识没有场景要下载,则退出程序
             if(Objects.isNull(downLoadTaskBean)){
                 continue;
@@ -56,9 +56,35 @@ public class SceneDownLoadServiceImpl implements ISceneDownLoadService {
 
     }
 
-    private DownLoadTaskBean getTaskSceneNum() throws Exception{
+    @Override
+    public void processV3() throws Exception {
+
+        //统计本节点正在下载任务数量
+        int downloadIngCnt = CurrentDownloadNumUtil.cntDownloadingLocal("v3");
+        //如果正在下载的场景大于最大线程数,不往下执行
+        if(downloadIngCnt >= downloadThreadMax){
+            return;
+        }
+
+        for(int i = 0; i < downloadThreadMax - downloadIngCnt; i++){
+            DownLoadTaskBean downLoadTaskBean = this.getTaskSceneNum("v3");
+            //获取任务队列中队头场景码,如果是空,标识没有场景要下载,则退出程序
+            if(Objects.isNull(downLoadTaskBean)){
+                continue;
+            }
+            handlerService.download(downLoadTaskBean);
+        }
+
+    }
+
+    private DownLoadTaskBean getTaskSceneNum(String version) throws Exception{
         //redis待下载任务出队
-        String downloadTask = redisUtil.lLeftPop(RedisKey.SCENE_DOWNLOADS_TASK_V4);
+        String taskkey = RedisKey.SCENE_DOWNLOADS_TASK_V4;
+        if("v3".equals(version)){
+//            taskkey = RedisKey.DOWNLOAD_TASK;
+            taskkey = "downloads:task:v3";
+        }
+        String downloadTask = redisUtil.lLeftPop(taskkey);
         if(StrUtil.isEmpty(downloadTask)){
             return null;
         }
@@ -68,13 +94,13 @@ public class SceneDownLoadServiceImpl implements ISceneDownLoadService {
         }
         //如果场景正在下载中,就直接丢弃
         String num = downLoadTaskBean.getNum();
-        if(CurrentDownloadNumUtil.containSceneNum(num)){
+        if(CurrentDownloadNumUtil.containSceneNum(num, version)){
             return null;
         }
         //本地缓存入队
-        CurrentDownloadNumUtil.addSceneNum(num);
+        CurrentDownloadNumUtil.addSceneNum(num, version);
         //正在下载任务入队
-        redisUtil.lLeftPush(RedisKey.SCENE_DOWNLOAD_ING, num);
+        redisUtil.lLeftPush(RedisKey.SCENE_V3_DOWNLOAD_ING, num);
         return downLoadTaskBean;
     }
 

+ 220 - 22
src/main/java/com/fdkankan/download/service/impl/SceneDownloadHandlerServiceImpl.java

@@ -2,14 +2,19 @@ package com.fdkankan.download.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.ConcurrentHashSet;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.date.TimeInterval;
 import cn.hutool.core.exceptions.ExceptionUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
 import com.fdkankan.common.constant.ErrorCode;
 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.exception.BusinessException;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.download.bean.CurrentDownloadNumUtil;
@@ -19,13 +24,16 @@ import com.fdkankan.download.bean.ImageType;
 import com.fdkankan.download.bean.ImageTypeDetail;
 import com.fdkankan.download.entity.ScenePlus;
 import com.fdkankan.download.entity.ScenePlusExt;
+import com.fdkankan.download.entity.ScenePro;
 import com.fdkankan.download.service.IScenePlusExtService;
 import com.fdkankan.download.service.IScenePlusService;
+import com.fdkankan.download.service.ISceneProService;
 import com.fdkankan.fyun.constant.FYunTypeEnum;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.model.constants.UploadFilePath;
 import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.util.RedisUtil;
+import com.fdkankan.web.response.ResultData;
 import com.google.common.collect.Lists;
 import java.io.File;
 import java.io.FileInputStream;
@@ -75,6 +83,10 @@ public class SceneDownloadHandlerServiceImpl {
         UploadFilePath.USER_VIEW_PATH,
     };
 
+    private static final String[] prefixArr4v3 = new String[]{
+        "data/data%s/", "images/images%s/", "voice/voice%s/", "video/video%s/"
+    };
+
     private static final List<ImageType> imageTypes = Lists.newArrayList();
     static{
         imageTypes.add(ImageType.builder().name("2k_face").size("2048").ranges(new String[]{"0", "511", "1023", "1535"}).build());
@@ -82,8 +94,12 @@ public class SceneDownloadHandlerServiceImpl {
         imageTypes.add(ImageType.builder().name("512_face").size("512").ranges(new String[]{"0"}).build());
     }
 
+    @Value("url.v3.getInfo")
+    private String v3GetInfoUrl;
     @Value("${path.v4school}")
     private String v4localPath;
+    @Value("${path.v3school}")
+    private String v3localPath;
     @Value("${path.zip-local}")
     private String zipLocalFormat;
     @Value("${path.zip-oss}")
@@ -94,7 +110,7 @@ public class SceneDownloadHandlerServiceImpl {
     private int zipNthreads;
     @Value("${oss.bucket:4dkankan}")
     private String bucket;
-    @Value("${upload.type:oss}")
+    @Value("${fyun.type}")
     private String uploadType;
     @Value("${download.config.resource-url}")
     private String resourceUrl;
@@ -104,6 +120,8 @@ public class SceneDownloadHandlerServiceImpl {
     private String exeName;
     @Value("${download.config.exe-content}")
     private String exeContent;
+    @Value("${download.config.exe-content-v3}")
+    private String exeContentV3;
 
     @Autowired
     private RedisUtil redisUtil;
@@ -113,6 +131,8 @@ public class SceneDownloadHandlerServiceImpl {
     private IScenePlusService scenePlusService;
     @Autowired
     private IScenePlusExtService scenePlusExtService;
+    @Autowired
+    private ISceneProService sceneProService;
 
     @Async("sceneDownLoadExecutror")
     public void download(DownLoadTaskBean downLoadTaskBean){
@@ -139,7 +159,39 @@ public class SceneDownloadHandlerServiceImpl {
         }finally {
             if(StrUtil.isNotEmpty(num)){
                 //本地正在下载任务出队
-                CurrentDownloadNumUtil.removeSceneNum(num);
+                CurrentDownloadNumUtil.removeSceneNum(num, "v4");
+                //删除正在下载任务
+                redisUtil.lRemove(RedisKey.SCENE_DOWNLOAD_ING, 1, num);
+            }
+        }
+    }
+
+    @Async("sceneDownLoadExecutror")
+    public void downloadV3(DownLoadTaskBean downLoadTaskBean){
+        //场景码
+        String num = null;
+
+        try {
+            num = downLoadTaskBean.getNum();
+
+            log.info("v3场景下载开始 - num[{}] - threadName[{}]", num, Thread.currentThread().getName());
+
+            long startTime = Calendar.getInstance().getTimeInMillis();
+
+            //执行场景下载逻辑
+            this.downloadHandlerV3(downLoadTaskBean);
+
+            //耗时
+            long consumeTime = Calendar.getInstance().getTimeInMillis() - startTime;
+
+            log.info("v3场景下载结束 - num[{}] - threadName[{}] - consumeTime[{}]", num, Thread.currentThread().getName(), consumeTime);
+
+        }catch (Exception e){
+            log.error(ExceptionUtil.stacktraceToString(e));
+        }finally {
+            if(StrUtil.isNotEmpty(num)){
+                //本地正在下载任务出队
+                CurrentDownloadNumUtil.removeSceneNum(num, "v3");
                 //删除正在下载任务
                 redisUtil.lRemove(RedisKey.SCENE_DOWNLOAD_ING, 1, num);
             }
@@ -164,10 +216,10 @@ public class SceneDownloadHandlerServiceImpl {
 
             Map<String, List<String>> allFiles = this.getAllFiles(num, v4localPath, bucket);
             List<String> ossFilePaths = allFiles.get("ossFilePaths");
-            List<String> v3localFilePaths = allFiles.get("v3localFilePaths");
+            List<String> v4localFilePaths = allFiles.get("v3localFilePaths");
 
             //key总个数
-            int total = ossFilePaths.size() + v3localFilePaths.size();
+            int total = ossFilePaths.size() + v4localFilePaths.size();
             AtomicInteger count = new AtomicInteger(0);
             //定义压缩包
             zipPath = String.format(this.zipLocalFormat, num);
@@ -200,12 +252,12 @@ public class SceneDownloadHandlerServiceImpl {
             long start = Calendar.getInstance().getTimeInMillis();
 
             //固定文件写入
-            this.zipLocalFiles(out, v3localFilePaths, v4localPath, num, count, total);
+            this.zipLocalFiles(out, v4localFilePaths, v4localPath, num, count, total, "v4");
             long end1 = Calendar.getInstance().getTimeInMillis();
             log.info("打包固定文件耗时, num:{}, time:{}", num, end1 - start);
 
             //oss文件写入
-            this.zipOssFiles(out, ossFilePaths, num, count, total, resolution, imagesVersion, cacheKeys);
+            this.zipOssFiles(out, ossFilePaths, num, count, total, resolution, imagesVersion, cacheKeys, "v4");
             long end2 = Calendar.getInstance().getTimeInMillis();
             log.info("打包oss文件耗时, num:{}, time:{}", num, end2 - end1);
 
@@ -213,7 +265,86 @@ public class SceneDownloadHandlerServiceImpl {
             this.zipSceneJson(out, this.wwwroot, num, sceneJson);
 
             //写入启动命令
-            this.zipBat(out, num);
+            this.zipBat(out, num, "v4");
+
+            out.close();
+
+            //上传压缩包
+            String uploadPath = String.format(this.zipOssFormat, num);
+            fYunFileService.uploadFileByCommand(bucket, zipPath, uploadPath);
+
+            //更新进度100
+            String url = this.publicUrl + uploadPath + "?t=" + Calendar.getInstance().getTimeInMillis();
+            this.updateProgress(null, num, SceneDownloadProgressStatus.DOWNLOAD_SUCCESS.code(), url, "v4");
+
+
+        }catch (Exception e){
+            //更新进度为下载失败
+            this.updateProgress( null, num, SceneDownloadProgressStatus.DOWNLOAD_FAILED.code(), null, "v4");
+            throw e;
+        }finally {
+            if(StrUtil.isNotBlank(zipPath)){
+                //删除本地zip包
+                FileUtils.deleteFile(zipPath);
+            }
+        }
+    }
+
+    public void downloadHandlerV3(DownLoadTaskBean downLoadTaskBean) throws Exception{
+
+        String num = downLoadTaskBean.getNum();
+        //zip包路径
+        String zipPath = null;
+
+        try {
+
+            TimeInterval timer = DateUtil.timer();
+
+            ScenePro scenePro = sceneProService.getByNum(num);
+            if(Objects.isNull(scenePro))
+                throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
+
+            Set<String> cacheKeys = new ConcurrentHashSet<>();
+
+            Map<String, List<String>> allFiles = this.getAllFilesV3(num, v3localPath, bucket);
+            List<String> ossFilePaths = allFiles.get("ossFilePaths");
+            List<String> v3localFilePaths = allFiles.get("v3localFilePaths");
+
+            //key总个数
+            int total = ossFilePaths.size() + v3localFilePaths.size();
+            AtomicInteger count = new AtomicInteger(0);
+            //定义压缩包
+            zipPath = String.format(this.zipLocalFormat, num);
+            File zipFile = new File(zipPath);
+            if(!zipFile.getParentFile().exists()){
+                zipFile.getParentFile().mkdirs();
+            }
+            ZipOutputStream out = new ZipOutputStream(zipFile);
+
+            int imagesVersion =0;
+            String resolution = "2k";
+            JSONObject getInfoJson = this.getInfo(num);
+            imagesVersion = getInfoJson.getInt("imagesVersion");
+            // 转台、激光显示4k图片
+            if(getInfoJson.getInt("sceneSource") == 3 || getInfoJson.getInt("sceneSource") == 4){
+                resolution = "4k";
+            }
+
+            //固定文件写入
+            timer.intervalRestart();
+            this.zipLocalFiles(out, v3localFilePaths, v3localPath, num, count, total, "v3");
+            log.info("打包固定文件耗时, num:{}, time:{}", num, timer.intervalRestart());
+
+            //oss文件写入
+            this.zipOssFiles(out, ossFilePaths, num, count, total, resolution, imagesVersion, cacheKeys, "v3");
+            long end2 = Calendar.getInstance().getTimeInMillis();
+            log.info("打包oss文件耗时, num:{}, time:{}", num, timer.intervalRestart());
+
+            //重新写入scene.json(去掉密码访问设置)
+            this.zipGetInfoJson(out, this.wwwroot, num, getInfoJson);
+
+            //写入启动命令
+            this.zipBat(out, num, "v3");
 
             out.close();
 
@@ -223,12 +354,12 @@ public class SceneDownloadHandlerServiceImpl {
 
             //更新进度100
             String url = this.publicUrl + uploadPath + "?t=" + Calendar.getInstance().getTimeInMillis();
-            this.updateProgress(null, num, SceneDownloadProgressStatus.DOWNLOAD_SUCCESS.code(), url);
+            this.updateProgress(null, num, SceneDownloadProgressStatus.DOWNLOAD_SUCCESS.code(), url, "v3");
 
 
         }catch (Exception e){
             //更新进度为下载失败
-            this.updateProgress( null, num, SceneDownloadProgressStatus.DOWNLOAD_FAILED.code(), null);
+            this.updateProgress( null, num, SceneDownloadProgressStatus.DOWNLOAD_FAILED.code(), null, "v3");
             throw e;
         }finally {
             if(StrUtil.isNotBlank(zipPath)){
@@ -238,20 +369,43 @@ public class SceneDownloadHandlerServiceImpl {
         }
     }
 
+    private JSONObject getInfo(String num){
+        String url = String.format(v3GetInfoUrl, num);
+        String getInfoResult = HttpUtil.get(url);
+        JSONObject jsonObject = JSONUtil.parseObj(getInfoResult);
+        if(Objects.isNull(jsonObject)
+            || !ServerCode.SUCCESS.code().equals(jsonObject.getInt("code"))
+            || Objects.isNull(jsonObject.getJSONObject("data"))){
+            throw new RuntimeException("获取getInfo信息失败,url=" + url);
+        }
+        JSONObject data = jsonObject.getJSONObject("data");
+        if (data.getInt("sceneSource") != 2)
+        {
+            data.set("sceneScheme", 3);
+        }
+        data.set("needKey", 0);
+        data.set("sceneKey", "");
+        return data;
+    }
+
     private void zipOssFiles(ZipOutputStream out, List<String> ossFilePaths, String num, AtomicInteger count,
-        int total, String resolution, int imagesVersion, Set<String> cacheKeys) throws Exception{
+        int total, String resolution, int imagesVersion, Set<String> cacheKeys, String version) throws Exception{
         if(CollUtil.isEmpty(ossFilePaths)){
             return;
         }
         String imageNumPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
+        if("v3".equals(version)){
+            imageNumPath = String.format("images/images%s/", num);
+        }
         ExecutorService executorService = Executors.newFixedThreadPool(this.zipNthreads);
         List<Future> futureList = new ArrayList<>();
         for (String filePath : ossFilePaths) {
+            String finalImageNumPath = imageNumPath;
             Callable<Boolean> call = new Callable() {
                 @Override
                 public Boolean call() throws Exception {
                     zipOssFilesHandler(out, num, count, total, resolution,
-                        imagesVersion, cacheKeys,filePath, imageNumPath);
+                        imagesVersion, cacheKeys,filePath, finalImageNumPath, version);
                     return true;
                 }
             };
@@ -275,11 +429,11 @@ public class SceneDownloadHandlerServiceImpl {
     private void zipOssFilesHandler(ZipOutputStream out, String num,
         AtomicInteger count, int total, String resolution,
         int imagesVersion, Set<String> cacheKeys,
-        String filePath, String imageNumPath) throws Exception{
+        String filePath, String imageNumPath, String version) throws Exception{
 
         //更新进度
         this.updateProgress(new BigDecimal(count.incrementAndGet()).divide(new BigDecimal(total), 6, BigDecimal.ROUND_HALF_UP),
-            num, SceneDownloadProgressStatus.DOWNLOADING.code(), null);
+            num, SceneDownloadProgressStatus.DOWNLOADING.code(), null, version);
 
         //某个目录不需要打包
         if(filePath.contains(imageNumPath + "panorama/panorama_edit/"))
@@ -298,32 +452,35 @@ public class SceneDownloadHandlerServiceImpl {
         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{
-        for (String v3localFilePath : v3localFilePaths) {
-            try (FileInputStream in = new FileInputStream(new File(v3localFilePath));){
-                this.zipInputStream(out, v3localFilePath.replace(v3localPath, ""), in);
+    private void zipLocalFiles(ZipOutputStream out, List<String> localFilePaths, String v3localPath, String num, AtomicInteger count, int total, String version) throws Exception{
+        for (String localFilePath : localFilePaths) {
+            try (FileInputStream in = new FileInputStream(new File(localFilePath));){
+                this.zipInputStream(out, localFilePath.replace(v3localPath, ""), in);
             }catch (Exception e){
                 throw e;
             }
             //更新进度
             this.updateProgress(
                 new BigDecimal(count.incrementAndGet()).divide(new BigDecimal(total), 6, BigDecimal.ROUND_HALF_UP),
-                num, SceneDownloadProgressStatus.DOWNLOAD_COMPRESSING.code(), null);
+                num, SceneDownloadProgressStatus.DOWNLOAD_COMPRESSING.code(), null, version);
         }
         //写入code.txt
         this.zipBytes(out, "code.txt", num.getBytes());
     }
 
-    private void zipBat(ZipOutputStream out, String num) throws Exception{
+    private void zipBat(ZipOutputStream out, String num, String version) throws Exception{
         String batContent = String.format(this.exeContent, num);
+        if("v3".equals(version)){
+            batContent = String.format(this.exeContentV3, num);
+        }
         this.zipBytes(out, exeName, batContent.getBytes());
 
         //更新进度为90%
         this.updateProgress(new BigDecimal("0.9").divide(new BigDecimal("0.8"), 6, BigDecimal.ROUND_HALF_UP), num,
-            SceneDownloadProgressStatus.DOWNLOAD_COMPRESSING.code(), null);
+            SceneDownloadProgressStatus.DOWNLOAD_COMPRESSING.code(), null, version);
     }
 
-    private Map<String, List<String>> getAllFiles(String num, String v3localPath, String bucket) throws Exception{
+    private Map<String, List<String>> getAllFiles(String num, String v4localPath, String bucket) throws Exception{
         //列出oss所有文件路径
         List<String> ossFilePaths = new ArrayList<>();
         for (String prefix : prefixArr) {
@@ -344,6 +501,37 @@ public class SceneDownloadHandlerServiceImpl {
         }
 
         //列出v3local所有文件路径
+        File file = new File(v4localPath);
+        List<String> v3localFilePaths = FileUtils.list(file);
+
+        HashMap<String, List<String>> map = new HashMap<>();
+        map.put("ossFilePaths", ossFilePaths);
+        map.put("v4localFilePaths", v3localFilePaths);
+
+        return map;
+    }
+
+    private Map<String, List<String>> getAllFilesV3(String num, String v3localPath, String bucket) throws Exception{
+        //列出oss所有文件路径
+        List<String> ossFilePaths = new ArrayList<>();
+        for (String prefix : prefixArr4v3) {
+            prefix = String.format(prefix, num);
+            List<String> keys = fYunFileService.listRemoteFiles(bucket, prefix);
+            if(CollUtil.isEmpty(keys)){
+                continue;
+            }
+            if(FYunTypeEnum.AWS.code().equals(this.uploadType)){
+                keys = keys.stream().filter(key->{
+                    if(key.contains("x-oss-process")){
+                        return false;
+                    }
+                    return true;
+                }).collect(Collectors.toList());
+            }
+            ossFilePaths.addAll(keys);
+        }
+
+        //列出v3local所有文件路径
         File file = new File(v3localPath);
         List<String> v3localFilePaths = FileUtils.list(file);
 
@@ -364,6 +552,13 @@ public class SceneDownloadHandlerServiceImpl {
         this.zipBytes(out, sceneJsonPath, sceneJson.toString().getBytes());
     }
 
+    private void zipGetInfoJson(ZipOutputStream out, String root, String num, JSONObject getInfo) throws Exception{
+
+        //访问密码置0
+        String getInfoKey = root + String.format("data/data%s/", num) + "getInfo.json";
+        this.zipBytes(out, getInfoKey, getInfo.toString().getBytes());
+    }
+
     private void processImage(String key, ZipOutputStream out, String resolution, int imagesVersion, Set<String> imgKeys) throws Exception{
 
         if(key.contains("x-oss-process") || key.endsWith("/")){
@@ -454,7 +649,7 @@ public class SceneDownloadHandlerServiceImpl {
     }
 
 
-    public void updateProgress(BigDecimal precent, String num, Integer status, String url){
+    public void updateProgress(BigDecimal precent, String num, Integer status, String url, String version){
 
         SceneDownloadProgressStatus progressStatus = SceneDownloadProgressStatus.get(status);
         switch (progressStatus){
@@ -470,6 +665,9 @@ public class SceneDownloadHandlerServiceImpl {
 
         DownLoadProgressBean progress = null;
         String key = String.format(RedisKey.PREFIX_DOWNLOAD_PROGRESS_V4, num);
+        if("v3".equals(version)){
+            key = RedisKey.PREFIX_DOWNLOAD_PROGRESS;
+        }
         String progressStr = redisUtil.get(key);
         if(StrUtil.isEmpty(progressStr)){
             progress =  DownLoadProgressBean.builder().percent(precent.intValue()).status(status).url(url).build();

+ 25 - 0
src/main/java/com/fdkankan/download/service/impl/SceneProServiceImpl.java

@@ -0,0 +1,25 @@
+package com.fdkankan.download.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.download.entity.ScenePro;
+import com.fdkankan.download.mapper.ISceneProMapper;
+import com.fdkankan.download.service.ISceneProService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * pro场景表 服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2022-10-17
+ */
+@Service
+public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro> implements ISceneProService {
+
+    @Override
+    public ScenePro getByNum(String num) {
+        return this.getOne(new LambdaQueryWrapper<ScenePro>().eq(ScenePro::getNum, num));
+    }
+}

+ 5 - 0
src/main/resources/mapper/download/SceneProMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fdkankan.download.mapper.ISceneProMapper">
+
+</mapper>