dengsixing %!s(int64=3) %!d(string=hai) anos
pai
achega
55ebedd612
Modificáronse 21 ficheiros con 641 adicións e 157 borrados
  1. 15 15
      pom.xml
  2. 0 2
      src/main/java/com/fdkankan/download/SceneDownloadApplication.java
  3. 29 0
      src/main/java/com/fdkankan/download/bean/DownLoadProgressBean.java
  4. 29 0
      src/main/java/com/fdkankan/download/bean/DownLoadTaskBean.java
  5. 36 64
      src/main/java/com/fdkankan/download/config/TestController.java
  6. 117 0
      src/main/java/com/fdkankan/download/entity/ScenePlus.java
  7. 162 0
      src/main/java/com/fdkankan/download/entity/ScenePlusExt.java
  8. 80 0
      src/main/java/com/fdkankan/download/generate/AutoGenerate.java
  9. 18 0
      src/main/java/com/fdkankan/download/mapper/IScenePlusExtMapper.java
  10. 18 0
      src/main/java/com/fdkankan/download/mapper/IScenePlusMapper.java
  11. 18 0
      src/main/java/com/fdkankan/download/service/IScenePlusExtService.java
  12. 18 0
      src/main/java/com/fdkankan/download/service/IScenePlusService.java
  13. 1 1
      src/main/java/com/fdkankan/download/service/impl/CheckProgressRunnerImpl.java
  14. 1 4
      src/main/java/com/fdkankan/download/service/impl/SceneDownLoadServiceImpl.java
  15. 31 66
      src/main/java/com/fdkankan/download/service/impl/SceneDownloadHandlerServiceImpl.java
  16. 25 0
      src/main/java/com/fdkankan/download/service/impl/ScenePlusExtServiceImpl.java
  17. 25 0
      src/main/java/com/fdkankan/download/service/impl/ScenePlusServiceImpl.java
  18. 7 4
      src/main/resources/bootstrap-test.yml
  19. 1 1
      src/main/resources/logback-spring.xml
  20. 5 0
      src/main/resources/mapper/download/ScenePlusExtMapper.xml
  21. 5 0
      src/main/resources/mapper/download/ScenePlusMapper.xml

+ 15 - 15
pom.xml

@@ -52,39 +52,39 @@
 
         <dependency>
             <groupId>com.fdkankan</groupId>
-            <artifactId>4dkankan-common</artifactId>
-            <version>2.0.0-SNAPSHOT</version>
+            <artifactId>4dkankan-common-web</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
         </dependency>
 
         <dependency>
             <groupId>com.fdkankan</groupId>
-            <artifactId>4dkankan-utils-redis</artifactId>
-            <version>2.0.0-SNAPSHOT</version>
+            <artifactId>4dkankan-utils-db</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
         </dependency>
 
-
         <dependency>
             <groupId>com.fdkankan</groupId>
-            <artifactId>4dkankan-utils-fyun</artifactId>
-            <version>2.0.0-SNAPSHOT</version>
+            <artifactId>4dkankan-utils-redis</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
         </dependency>
 
+
         <dependency>
-            <groupId>com.alibaba.csp</groupId>
-            <artifactId>sentinel-datasource-nacos</artifactId>
-            <version>1.7.2</version>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-utils-fyun-oss</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
         </dependency>
 
         <dependency>
             <groupId>com.fdkankan</groupId>
-            <artifactId>4dkankan-center-platform-api</artifactId>
-            <version>2.0.0-SNAPSHOT</version>
+            <artifactId>4dkankan-utils-fyun-s3</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
         </dependency>
 
         <dependency>
-            <groupId>com.fdkankan</groupId>
-            <artifactId>4dkankan-center-scene-api</artifactId>
-            <version>2.0.0-SNAPSHOT</version>
+            <groupId>com.alibaba.csp</groupId>
+            <artifactId>sentinel-datasource-nacos</artifactId>
+            <version>1.7.2</version>
         </dependency>
 
     </dependencies>

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

@@ -3,7 +3,6 @@ package com.fdkankan.download;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.context.config.annotation.RefreshScope;
-import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.EnableScheduling;
@@ -18,7 +17,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
  **/
 @SpringBootApplication
 @EnableScheduling
-@EnableFeignClients("com.fdkankan.*.api.feign")
 @ComponentScan(basePackages = {"com.fdkankan.*"})
 @RefreshScope
 @EnableAsync

+ 29 - 0
src/main/java/com/fdkankan/download/bean/DownLoadProgressBean.java

@@ -0,0 +1,29 @@
+package com.fdkankan.download.bean;
+
+import java.io.Serializable;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * <p>
+ * 场景下载进度
+ * </p>
+ *
+ * @author dengsixing
+ * @since 2022/2/22
+ **/
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class DownLoadProgressBean implements Serializable {
+
+    private String url;
+
+    private Integer percent;
+
+    private Integer status;
+
+}

+ 29 - 0
src/main/java/com/fdkankan/download/bean/DownLoadTaskBean.java

@@ -0,0 +1,29 @@
+package com.fdkankan.download.bean;
+
+import java.io.Serializable;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * <p>
+ * TODO
+ * </p>
+ *
+ * @author dengsixing
+ * @since 2022/2/22
+ **/
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class DownLoadTaskBean implements Serializable {
+
+    private Long userId;
+
+    private String num;
+
+    private String type;
+
+}

+ 36 - 64
src/main/java/com/fdkankan/download/config/TestController.java

@@ -1,66 +1,38 @@
-package com.fdkankan.download.config;
-
-import com.alibaba.fastjson.JSON;
-import com.fdkankan.fyun.oss.UploadToOssUtil;
-import com.fdkankan.redis.util.RedisUtil;
-import com.fdkankan.common.bean.DownLoadTaskBean;
-import com.fdkankan.download.service.impl.SceneDownloadHandlerServiceImpl;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.client.RestTemplate;
-
-/**
- * <p>
- * TODO
- * </p>
- *
- * @author dengsixing
- * @since 2022/2/24
- **/
-@RestController
-@RequestMapping("/test")
-@Slf4j
-public class TestController {
-
-    @Autowired
-    UploadToOssUtil uploadToOssUtil;
-
-    @Autowired
-    SceneDownloadHandlerServiceImpl downloadHandlerService;
-    @Autowired
-    RedisUtil redisUtil;
-
-    @GetMapping("/test")
-    public String test() throws Exception{
-//        Map<String, String> param = new HashMap<>();
-//        param.put("num", "t-YhBCzQr");
-//        String getInfoStr = restTemplate.postForObject(serverUrl + "api/scene/getInfo?num=t-YhBCzQr", param, String.class);
+//package com.fdkankan.download.config;
 //
-//        ResultData resultData = JSONUtil.toBean(getInfoStr, ResultData.class);
-//        if(resultData == null || ServerCode.SUCCESS.code() != resultData.getCode()){
-//            log.error("getInfo请求失败,url:" + serverUrl + "api/scene/getInfo?num=t-YhBCzQr");
-//        }
+//import com.fdkankan.download.service.impl.SceneDownloadHandlerServiceImpl;
+//import com.fdkankan.fyun.face.FYunFileServiceInterface;
+//import com.fdkankan.redis.util.RedisUtil;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.web.bind.annotation.GetMapping;
+//import org.springframework.web.bind.annotation.RequestMapping;
+//import org.springframework.web.bind.annotation.RestController;
 //
-//        JSONObject dataJson = JSONUtil.parseObj(resultData.getData());
-//        dataJson.set("sceneScheme", 3);
-//        dataJson.set("needKey", 0);
-//        dataJson.set("sceneKey","");
-
-//        List<String> strings = uploadToOssUtil.listKeysFromAli("data/datat-ieXdyGl6Md");
-//        for (String string : strings) {
-//            System.out.println(string);
-//        }
-
-        redisUtil.lLeftPush("downloads:task:v4", JSON
-            .toJSONString(DownLoadTaskBean.builder().num("eur-3wdeOQaa0").type("local").build()));
-
-//        List<String> strings = uploadToOssUtil.listKeysFromAws("data/datawJ6cAq3tc");
-
-        return "123";
-    }
-
-}
+///**
+// * <p>
+// * TODO
+// * </p>
+// *
+// * @author dengsixing
+// * @since 2022/2/24
+// **/
+//@RestController
+//@RequestMapping("/test")
+//@Slf4j
+//public class TestController {
+//
+//    @Autowired
+//    private FYunFileServiceInterface fYunFileService;
+//    @Autowired
+//    private SceneDownloadHandlerServiceImpl downloadHandlerService;
+//    @Autowired
+//    private RedisUtil redisUtil;
+//
+//    @GetMapping("/test")
+//    public String test() throws Exception{
+//
+//        return "123";
+//    }
+//
+//}

+ 117 - 0
src/main/java/com/fdkankan/download/entity/ScenePlus.java

@@ -0,0 +1,117 @@
+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>
+ * 场景主表
+ * </p>
+ *
+ * @author 
+ * @since 2022-08-17
+ */
+@Getter
+@Setter
+@TableName("t_scene_plus")
+public class ScenePlus implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 场景码
+     */
+    @TableField("num")
+    private String num;
+
+    /**
+     * 用户id
+     */
+    @TableField("user_id")
+    private Long userId;
+
+    /**
+     * 相机id
+     */
+    @TableField("camera_id")
+    private Long cameraId;
+
+    /**
+     * 手机id
+     */
+    @TableField("phone_id")
+    private String phoneId;
+
+    /**
+     * 场景名称
+     */
+    @TableField("title")
+    private String title;
+
+    /**
+     * 场景描述
+     */
+    @TableField("description")
+    private String description;
+
+    /**
+     * 场景状态:0-未建好,1--已建好,-1-计算出错,-2--不在官网显示
+     */
+    @TableField("scene_status")
+    private Integer sceneStatus;
+
+    /**
+     * 场景来源:相机拍摄10以内表示,1表示八目,2双目,3转台,4 激光  其他来源10以上,11:一键换装,12:123看房,13文通虚拟场景
+     */
+    @TableField("scene_source")
+    private Integer sceneSource;
+
+    /**
+     * 支付状态:0表示未付款,1表示付款了,-1表示欠费,-2表示容量不足
+     */
+    @TableField("pay_status")
+    private Integer payStatus;
+
+    /**
+     * 场景类型  0-其他,1-文博,2-地产,3-电商,4-餐饮,5-家居,99-一件换装虚拟房源
+     */
+    @TableField("scene_type")
+    private Integer sceneType;
+
+    /**
+     * 是否推荐:0-否,1-是
+     */
+    @TableField("recommend")
+    private Integer recommend;
+
+    /**
+     * 创建时间
+     */
+    @TableField("create_time")
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    @TableField("update_time")
+    private Date updateTime;
+
+    /**
+     * 0-有效,1-删除, 2-禁用
+     */
+    @TableField("rec_status")
+    @TableLogic("A")
+    private String recStatus;
+
+
+}

+ 162 - 0
src/main/java/com/fdkankan/download/entity/ScenePlusExt.java

@@ -0,0 +1,162 @@
+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>
+ * 
+ * </p>
+ *
+ * @author 
+ * @since 2022-08-17
+ */
+@Getter
+@Setter
+@TableName("t_scene_plus_ext")
+public class ScenePlusExt implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * t_scene_plus主键
+     */
+    @TableField("plus_id")
+    private Long plusId;
+
+    /**
+     * 场景数据目录
+     */
+    @TableField("data_source")
+    private String dataSource;
+
+    /**
+     * 场景链接
+     */
+    @TableField("web_site")
+    private String webSite;
+
+    /**
+     * 缩略图链接
+     */
+    @TableField("thumb")
+    private String thumb;
+
+    /**
+     * 方案:1-双目,2-转台,3-六目,4-八目,10-获取4k图,11-获取2k,12-获取1k
+     */
+    @TableField("scene_scheme")
+    private Integer sceneScheme;
+
+    /**
+     * 使用用量
+     */
+    @TableField("space")
+    private Long space;
+
+    /**
+     * 云服务器类型
+     */
+    @TableField("ecs")
+    private String ecs;
+
+    /**
+     * 点位数量
+     */
+    @TableField("shoot_count")
+    private Integer shootCount;
+
+    /**
+     * 浏览次数
+     */
+    @TableField("view_count")
+    private Integer viewCount;
+
+    /**
+     * gps定位
+     */
+    @TableField("gps")
+    private String gps;
+
+    /**
+     * 算法类型(slam、sfm)
+     */
+    @TableField("algorithm")
+    private String algorithm;
+
+    /**
+     * 固件版本
+     */
+    @TableField("firmware_version")
+    private String firmwareVersion;
+
+    /**
+     * 算法类型(V2,V3)
+     */
+    @TableField("build_type")
+    private String buildType;
+
+    /**
+     * 分辨率(2k,4k)
+     */
+    @TableField("scene_resolution")
+    private String sceneResolution;
+
+    /**
+     * 场景来源,lite:双目lite相机,pro:八目相机,minion:双面转台相机,laser:激光相机,virtual:虚拟场景,sketch:图片建模场景
+     */
+    @TableField("scene_from")
+    private String sceneFrom;
+
+    /**
+     * 切图方式(tiles:瓦片图,face:切片图,pan:全景图 ,local:本地切片,cube:立体图)
+     */
+    @TableField("scene_kind")
+    private String sceneKind;
+
+    /**
+     * 点位视频
+     */
+    @TableField("videos")
+    private String videos;
+
+    /**
+     * 计算耗时
+     */
+    @TableField("compute_time")
+    private Long computeTime;
+
+    /**
+     * 创建时间
+     */
+    @TableField("create_time")
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    @TableField("update_time")
+    private Date updateTime;
+
+    /**
+     * 0-有效,1-删除, 2-禁用
+     */
+    @TableField("rec_status")
+    @TableLogic("A")
+    private String recStatus;
+
+    @TableField("yun_file_bucket")
+    private String yunFileBucket;
+
+
+}

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

@@ -0,0 +1,80 @@
+package com.fdkankan.download.generate;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.generator.FastAutoGenerator;
+import com.baomidou.mybatisplus.generator.config.OutputFile;
+import com.baomidou.mybatisplus.generator.config.rules.DateType;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+public class AutoGenerate {
+
+
+    public static void main(String[] args) {
+
+        String path =System.getProperty("user.dir") + ".";
+
+        generate(path,"test", getTables(new String[]{
+                "t_scene_plus","t_scene_plus_ext"
+        }));
+
+    }
+
+    public static List<String> getTables(String [] tableNames){
+        return new ArrayList<>(Arrays.asList(tableNames));
+    }
+
+
+    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")
+                .globalConfig(builder -> {
+                    builder.author("")               //作者
+                            .outputDir(path+"\\src\\main\\java")    //输出路径(写到java目录)
+                            //.enableSwagger()           //开启swagger
+                            .commentDate("yyyy-MM-dd")
+                            .dateType(DateType.ONLY_DATE)
+                            .fileOverride();            //开启覆盖之前生成的文件
+
+                })
+                .packageConfig(builder -> {
+                    builder.parent("com.fdkankan")
+                            .moduleName(moduleName)
+                            .entity("entity")
+                            .service("service")
+                            .serviceImpl("service.impl")
+                            .controller("controller")
+                            .mapper("mapper")
+                            .xml("test.mapper")
+                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml,path+"\\src\\main\\resources\\mapper\\"+moduleName));
+                })
+                .strategyConfig(builder -> {
+                    builder.addInclude(tables)
+                            .addTablePrefix("t_")
+
+                            .serviceBuilder()
+                            .formatServiceFileName("I%sService")
+                            .formatServiceImplFileName("%sServiceImpl")
+
+                            .entityBuilder()
+                            .enableLombok()
+                            .logicDeleteColumnName("rec_status")
+                            .enableTableFieldAnnotation()
+//                            .superClass(BaseEntity.class)
+
+                            .controllerBuilder()
+                            .formatFileName("%sController")
+                            .enableRestStyle()
+
+                            .mapperBuilder()
+                            .superClass(BaseMapper.class)
+                            .formatMapperFileName("I%sMapper")
+                            .enableMapperAnnotation()
+                            .formatXmlFileName("%sMapper");
+                })
+                // .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
+                .execute();
+    }
+}

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

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

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

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

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

@@ -0,0 +1,18 @@
+package com.fdkankan.download.service;
+
+import com.fdkankan.download.entity.ScenePlusExt;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 
+ * @since 2022-08-17
+ */
+public interface IScenePlusExtService extends IService<ScenePlusExt> {
+
+    ScenePlusExt getByScenePlusId(long scenePlusId);
+
+}

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

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

+ 1 - 1
src/main/java/com/fdkankan/download/service/impl/CheckProgressRunnerImpl.java

@@ -2,11 +2,11 @@ package com.fdkankan.download.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
 import com.alibaba.fastjson.JSON;
+import com.fdkankan.download.bean.DownLoadTaskBean;
 import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.constant.RedisLockKey;
 import com.fdkankan.redis.util.RedisLockUtil;
 import com.fdkankan.redis.util.RedisUtil;
-import com.fdkankan.common.bean.DownLoadTaskBean;
 import java.util.List;
 import java.util.stream.Collectors;
 import org.springframework.beans.factory.annotation.Autowired;

+ 1 - 4
src/main/java/com/fdkankan/download/service/impl/SceneDownLoadServiceImpl.java

@@ -2,8 +2,8 @@ package com.fdkankan.download.service.impl;
 
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
-import com.fdkankan.common.bean.DownLoadTaskBean;
 import com.fdkankan.download.bean.CurrentDownloadNumUtil;
+import com.fdkankan.download.bean.DownLoadTaskBean;
 import com.fdkankan.download.service.ISceneDownLoadService;
 import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.util.RedisUtil;
@@ -31,9 +31,6 @@ public class SceneDownLoadServiceImpl implements ISceneDownLoadService {
     @Autowired
     RedisUtil redisUtil;
 
-//    @Autowired
-//    ExecutorCompletionService completionService;
-
     @Autowired
     SceneDownloadHandlerServiceImpl handlerService;
 

+ 31 - 66
src/main/java/com/fdkankan/download/service/impl/SceneDownloadHandlerServiceImpl.java

@@ -7,24 +7,28 @@ 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.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.constant.UploadFilePath;
+import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.response.ResultData;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.download.bean.CurrentDownloadNumUtil;
+import com.fdkankan.download.bean.DownLoadProgressBean;
+import com.fdkankan.download.bean.DownLoadTaskBean;
 import com.fdkankan.download.bean.ImageType;
 import com.fdkankan.download.bean.ImageTypeDetail;
-import com.fdkankan.fyun.constant.StorageType;
-import com.fdkankan.fyun.oss.UploadToOssUtil;
+import com.fdkankan.download.entity.ScenePlus;
+import com.fdkankan.download.entity.ScenePlusExt;
+import com.fdkankan.download.service.IScenePlusExtService;
+import com.fdkankan.download.service.IScenePlusService;
+import com.fdkankan.fyun.constant.FYunTypeEnum;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.redis.constant.RedisKey;
 import com.fdkankan.redis.util.RedisUtil;
-import com.fdkankan.scene.api.dto.SceneInfoDTO;
-import com.fdkankan.scene.api.feign.SceneUserSceneClient;
 import com.google.common.collect.Lists;
 import java.io.File;
 import java.io.FileInputStream;
@@ -81,27 +85,18 @@ public class SceneDownloadHandlerServiceImpl {
         imageTypes.add(ImageType.builder().name("512_face").size("512").ranges(new String[]{"0"}).build());
     }
 
-    @Autowired
-    private SceneUserSceneClient sceneUserSceneClient;
-
     @Value("${path.v4school}")
     private String v4localPath;
-
     @Value("${path.zip-local}")
     private String zipLocalFormat;
-
     @Value("${path.zip-oss}")
     private String zipOssFormat;
-
     @Value("${path.zip-root}")
     private String wwwroot;
-
     @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}")
@@ -112,13 +107,15 @@ public class SceneDownloadHandlerServiceImpl {
     private String exeName;
     @Value("${download.config.exe-content}")
     private String exeContent;
-    @Autowired
-    RestTemplate restTemplate;
 
     @Autowired
-    RedisUtil redisUtil;
+    private RedisUtil redisUtil;
+    @Autowired
+    private FYunFileServiceInterface fYunFileService;
     @Autowired
-    UploadToOssUtil uploadToOssUtil;
+    private IScenePlusService scenePlusService;
+    @Autowired
+    private IScenePlusExtService scenePlusExtService;
 
     @Async("sceneDownLoadExecutror")
     public void download(DownLoadTaskBean downLoadTaskBean){
@@ -159,9 +156,16 @@ public class SceneDownloadHandlerServiceImpl {
         String zipPath = null;
 
         try {
+
+            ScenePlus scenePlus = scenePlusService.getByNum(num);
+            if(Objects.isNull(scenePlus))
+                throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
+            ScenePlusExt scenePlusExt = scenePlusExtService.getByScenePlusId(scenePlus.getId());
+            String bucket = scenePlusExt.getYunFileBucket();
+
             Set<String> cacheKeys = new ConcurrentHashSet<>();
 
-            Map<String, List<String>> allFiles = this.getAllFiles(num, v4localPath);
+            Map<String, List<String>> allFiles = this.getAllFiles(num, v4localPath, bucket);
             List<String> ossFilePaths = allFiles.get("ossFilePaths");
             List<String> v3localFilePaths = allFiles.get("v3localFilePaths");
 
@@ -176,8 +180,7 @@ public class SceneDownloadHandlerServiceImpl {
             }
             ZipOutputStream out = new ZipOutputStream(zipFile);
 
-//            JSONObject getInfoJson = this.zipGetInfoJson(out, this.wwwroot, num);
-            String sceneJsonData = uploadToOssUtil.getObjectContent(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json");
+            String sceneJsonData = fYunFileService.getFileContent(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json");
             JSONObject sceneJson = JSONUtil.parseObj(sceneJsonData);
             String resolution = "4k";
             String sceneForm = sceneJson.getStr("sceneFrom");
@@ -191,10 +194,6 @@ public class SceneDownloadHandlerServiceImpl {
             }
 
             int imagesVersion = -1;
-            // TODO: 2022/3/29  V4版本目前没有imagesVersion字段,暂时用version字段替代
-//            if(getInfoJson.getInt("imagesVersion") != null){
-//                imagesVersion = getInfoJson.getInt("imagesVersion");
-//            }
             Integer version = sceneJson.getInt("version");
             if(Objects.nonNull(version)){
                 imagesVersion = version;
@@ -223,27 +222,16 @@ public class SceneDownloadHandlerServiceImpl {
 
             //上传压缩包
             String uploadPath = String.format(this.zipOssFormat, num);
-            uploadToOssUtil.uploadBySh(zipPath, uploadPath);
+            fYunFileService.uploadFileByCommand(bucket, zipPath, uploadPath);
 
             //更新进度100
             String url = this.publicUrl + uploadPath + "?t=" + Calendar.getInstance().getTimeInMillis();
             this.updateProgress(null, num, SceneDownloadProgressStatus.DOWNLOAD_SUCCESS.code(), url);
 
-            // TODO: 2022/5/24 v3 停止后要开启-----------------------start
-            //更新用户场景已下载次数
-//            platformUserClient.updateDownloadNum(userId, 1);
-//
-//            //更新下载log状态为成功
-//            sceneUserSceneClient.updateSceneDownloadLog(num, DownloadStatus.SUCCESS.code(), url, null);
-            // TODO: 2022/5/24 v3 停止后要开启-----------------------end
 
         }catch (Exception e){
             //更新进度为下载失败
             this.updateProgress( null, num, SceneDownloadProgressStatus.DOWNLOAD_FAILED.code(), null);
-            //更新下载log状态为成功
-            // TODO: 2022/5/24 v3 停止后要开启-----------------------start
-//            sceneUserSceneClient.updateSceneDownloadLog(num, DownloadStatus.FAILD.code(), null, ExceptionUtil.stacktraceToString(e));
-            // TODO: 2022/5/24 v3 停止后要开启-----------------------send
             throw e;
         }finally {
             if(StrUtil.isNotBlank(zipPath)){
@@ -338,16 +326,16 @@ public class SceneDownloadHandlerServiceImpl {
             SceneDownloadProgressStatus.DOWNLOAD_COMPRESSING.code(), null);
     }
 
-    private Map<String, List<String>> getAllFiles(String num, String v3localPath) throws Exception{
+    private Map<String, List<String>> getAllFiles(String num, String v3localPath, String bucket) throws Exception{
         //列出oss所有文件路径
         List<String> ossFilePaths = new ArrayList<>();
         for (String prefix : prefixArr) {
             prefix = String.format(prefix, num);
-            List<String> keys = uploadToOssUtil.listKeys(prefix);
+            List<String> keys = fYunFileService.listRemoteFiles(bucket, prefix);
             if(CollUtil.isEmpty(keys)){
                 continue;
             }
-            if(StorageType.AWS.code().equals(this.uploadType)){
+            if(FYunTypeEnum.AWS.code().equals(this.uploadType)){
                 keys = keys.stream().filter(key->{
                     if(key.contains("x-oss-process")){
                         return false;
@@ -369,29 +357,6 @@ public class SceneDownloadHandlerServiceImpl {
         return map;
     }
 
-    private JSONObject zipGetInfoJson(ZipOutputStream out, String root, String num) throws Exception{
-
-        ResultData<SceneInfoDTO> sceneViewInfo = sceneUserSceneClient.getSceneViewInfo(num);
-        if(!sceneViewInfo.getSuccess()){
-            throw new Exception(ServerCode.FEIGN_REQUEST_FAILD.message());
-        }
-        SceneInfoDTO data = sceneViewInfo.getData();
-        JSONObject getInfoJson = null;
-        if(Objects.isNull(data)){
-            getInfoJson = new JSONObject();
-        }else {
-            getInfoJson = JSONUtil.parseObj(data);
-        }
-
-        getInfoJson.set("sceneScheme", 3);
-        getInfoJson.set("needKey", 0);
-        getInfoJson.set("sceneKey","");
-        //写入getInfo.json
-        String getInfoJsonPath = root + String.format(UploadFilePath.DATA_VIEW_PATH, num) + "getInfo.json";
-        this.zipBytes(out, getInfoJsonPath, getInfoJson.toString().getBytes());
-        return getInfoJson;
-    }
-
     private void zipSceneJson(ZipOutputStream out, String root, String num, JSONObject sceneJson) throws Exception{
 
         //访问密码置0
@@ -440,13 +405,13 @@ public class SceneDownloadHandlerServiceImpl {
             }
             for (ImageTypeDetail item : items) {
                 String par = "?x-oss-process=image/resize,m_lfit,w_" + imageType.getSize() + "/crop,w_512,h_512,x_" + item.getX() + ",y_" + item.getY();
-                if(StorageType.AWS.code().equals(uploadType)){
+                if(FYunTypeEnum.AWS.code().equals(uploadType)){
                     par += "&imagesVersion="+ imagesVersion;
                 }
 
                 var url = this.
                     resourceUrl + key;
-                StorageType storageType = StorageType.get(uploadType);
+                FYunTypeEnum storageType = FYunTypeEnum.get(uploadType);
                 switch (storageType){
                     case OSS:
                         url += par;

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

@@ -0,0 +1,25 @@
+package com.fdkankan.download.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.download.entity.ScenePlusExt;
+import com.fdkankan.download.mapper.IScenePlusExtMapper;
+import com.fdkankan.download.service.IScenePlusExtService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2022-08-17
+ */
+@Service
+public class ScenePlusExtServiceImpl extends ServiceImpl<IScenePlusExtMapper, ScenePlusExt> implements IScenePlusExtService {
+
+    @Override
+    public ScenePlusExt getByScenePlusId(long scenePlusId) {
+        return this.getOne(new LambdaQueryWrapper<ScenePlusExt>().eq(ScenePlusExt::getPlusId, scenePlusId));
+    }
+}

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

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

+ 7 - 4
src/main/resources/bootstrap-test.yml

@@ -10,14 +10,17 @@ spring:
       config:
         server-addr: 120.24.144.164:8848
         file-extension: yaml
-        namespace: 4dkankan-test
+        namespace: 4dkankan-v4
         extension-configs:
           - data-id: 4dkankan-center-scene-download.yaml
             group: DEFAULT_GROUP
             refresh: true
         shared-configs:
+          - data-id: common-db-config.yaml
+            group: DEFAULT_GROUP
+            refresh: true
 
-          - data-id: common-redis-config-52.yaml
+          - data-id: common-redis-config.yaml
             group: DEFAULT_GROUP
             refresh: true
 
@@ -25,11 +28,11 @@ spring:
             group: DEFAULT_GROUP
             refresh: true
 
-          - data-id: common-upload-config.yaml
+          - data-id: common-fyun-config.yaml
             group: DEFAULT_GROUP
             refresh: true
       discovery:
         server-addr: 120.24.144.164:8848
-        namespace: 4dkankan-test
+        namespace: 4dkankan-v4
 
 

+ 1 - 1
src/main/resources/logback-spring.xml

@@ -5,7 +5,7 @@
 <!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
 <configuration scan="true" scanPeriod="10 seconds">
 	<springProperty scope="context" name="LOG_PATH" source="logging.path"/>
-	<define name="hostName" class = "com.fdkankan.common.config.LogPathHostNameProperty"/>
+	<define name="hostName" class = "com.fdkankan.web.config.LogPathHostNameProperty"/>
 	<contextName>logback</contextName>
 	<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
 	<property name="log.path" value="${LOG_PATH}/download" />

+ 5 - 0
src/main/resources/mapper/download/ScenePlusExtMapper.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.IScenePlusExtMapper">
+
+</mapper>

+ 5 - 0
src/main/resources/mapper/download/ScenePlusMapper.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.IScenePlusMapper">
+
+</mapper>