Browse Source

场景批量下载

dsx 1 year ago
parent
commit
2f427d7747
25 changed files with 1181 additions and 155 deletions
  1. 0 35
      .gitignore
  2. 1 0
      mybatis-flex.config
  3. 95 2
      pom.xml
  4. 5 0
      src/main/java/com/fdkankan/download/Application.java
  5. 29 0
      src/main/java/com/fdkankan/download/config/MyConfiguration.java
  6. 15 0
      src/main/java/com/fdkankan/download/config/MyConfigurationCustomizer.java
  7. 27 4
      src/main/java/com/fdkankan/download/controller/BatchDownloadController.java
  8. 78 0
      src/main/java/com/fdkankan/download/entity/Camera.java
  9. 107 0
      src/main/java/com/fdkankan/download/entity/ScenePlus.java
  10. 167 0
      src/main/java/com/fdkankan/download/entity/ScenePlusExt.java
  11. 148 0
      src/main/java/com/fdkankan/download/generate/Codegen.java
  12. 14 0
      src/main/java/com/fdkankan/download/mapper/CameraMapper.java
  13. 14 0
      src/main/java/com/fdkankan/download/mapper/ScenePlusExtMapper.java
  14. 14 0
      src/main/java/com/fdkankan/download/mapper/ScenePlusMapper.java
  15. 19 0
      src/main/java/com/fdkankan/download/service/ICameraService.java
  16. 16 0
      src/main/java/com/fdkankan/download/service/IScenePlusExtService.java
  17. 20 0
      src/main/java/com/fdkankan/download/service/IScenePlusService.java
  18. 27 0
      src/main/java/com/fdkankan/download/service/impl/CameraServiceImpl.java
  19. 115 114
      src/main/java/com/fdkankan/download/service/impl/CheckDownloadingRunnerImpl.java
  20. 116 0
      src/main/java/com/fdkankan/download/service/impl/GenSceneRunnerImpl.java
  21. 26 0
      src/main/java/com/fdkankan/download/service/impl/ScenePlusExtServiceImpl.java
  22. 36 0
      src/main/java/com/fdkankan/download/service/impl/ScenePlusServiceImpl.java
  23. 30 0
      src/main/java/com/fdkankan/download/util/ImgUtil.java
  24. 43 0
      src/main/resources/application-prod-eur.yml
  25. 19 0
      src/main/resources/application.yml

+ 0 - 35
.gitignore

@@ -1,35 +0,0 @@
-# Created by .ignore support plugin (hsz.mobi)
-### Java template
-# Compiled class file
-*.class
-
-# Log file
-*.log
-
-# BlueJ files
-*.ctxt
-
-# Mobile Tools for Java (J2ME)
-.mtj.tmp/
-
-# Package Files #
-*.jar
-*.war
-*.nar
-*.ear
-*.zip
-*.tar.gz
-*.rar
-
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-hs_err_pid*
-
-### Example user template template
-### Example user template
-
-# IntelliJ project files
-.idea
-*.iml
-out
-gen
-/**/target/

+ 1 - 0
mybatis-flex.config

@@ -0,0 +1 @@
+processor.enable=false

+ 95 - 2
pom.xml

@@ -50,9 +50,53 @@
 
     <dependencies>
 
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-starter-web</artifactId>-->
+<!--        </dependency>-->
+
         <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-web</artifactId>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-common-web</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.bytedeco</groupId>
+                    <artifactId>javacv</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.bytedeco</groupId>
+                    <artifactId>javacpp</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.bytedeco</groupId>
+                    <artifactId>javacv-platform</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>joinery</groupId>
+                    <artifactId>jave</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.aliyun</groupId>
+                    <artifactId>aliyun-java-sdk-dysmsapi</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.aliyun</groupId>
+                    <artifactId>aliyun-java-sdk-core</artifactId>
+                </exclusion>
+<!--                <exclusion>-->
+<!--                    <groupId>org.springframework</groupId>-->
+<!--                    <artifactId>spring-web</artifactId>-->
+<!--                </exclusion>-->
+                <exclusion>
+                    <groupId>com.alibaba.cloud</groupId>
+                    <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.alibaba.cloud</groupId>
+                    <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>
@@ -103,6 +147,55 @@
             <version>6.8.1</version>
         </dependency>
 
+<!--        <dependency>-->
+<!--            <groupId>com.fdkankan</groupId>-->
+<!--            <artifactId>4dkankan-utils-db</artifactId>-->
+<!--            <version>3.0.0-SNAPSHOT</version>-->
+<!--        </dependency>-->
+
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-spring-boot-starter</artifactId>
+            <version>1.7.5</version>
+        </dependency>
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-processor</artifactId>
+            <version>1.7.5</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.mybatis-flex</groupId>
+            <artifactId>mybatis-flex-codegen</artifactId>
+            <version>1.7.5</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.zaxxer</groupId>
+            <artifactId>HikariCP</artifactId>
+            <version>4.0.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.mysql</groupId>
+            <artifactId>mysql-connector-j</artifactId>
+            <version>8.0.32</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-utils-redis</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.github.oshi</groupId>
+            <artifactId>oshi-core</artifactId>
+            <version>6.4.1</version>
+        </dependency>
+
+
     </dependencies>
 
     <dependencyManagement>

+ 5 - 0
src/main/java/com/fdkankan/download/Application.java

@@ -1,12 +1,17 @@
 package com.fdkankan.download;
 
 import com.dtflys.forest.springboot.annotation.ForestScan;
+import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.annotation.ComponentScan;
+import org.springframework.scheduling.annotation.EnableAsync;
 
 @SpringBootApplication
 @ForestScan(basePackages = "com.fdkankan.download.httpclient")
+@MapperScan("com.fdkankan.**.mapper")
+@ComponentScan(basePackages = {"com.fdkankan.*"})
+@EnableAsync
 public class Application {
     public static void main(String[] args) {
         SpringApplication.run(Application.class, args);

+ 29 - 0
src/main/java/com/fdkankan/download/config/MyConfiguration.java

@@ -0,0 +1,29 @@
+package com.fdkankan.download.config;
+
+import com.mybatisflex.core.FlexGlobalConfig;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.annotation.Order;
+
+@Configuration
+public class MyConfiguration {
+
+    @Bean
+    @Order()
+    public FlexGlobalConfig logicDeleteProcessor(){
+
+        FlexGlobalConfig globalConfig = FlexGlobalConfig.getDefaultConfig();
+
+        globalConfig.setLogicDeleteColumn("recStatus");
+
+        //设置数据库正常时的值
+        globalConfig.setNormalValueOfLogicDelete("A");
+
+        //设置数据已被删除时的值
+        globalConfig.setDeletedValueOfLogicDelete("I");
+
+
+        return globalConfig;
+    }
+
+}

+ 15 - 0
src/main/java/com/fdkankan/download/config/MyConfigurationCustomizer.java

@@ -0,0 +1,15 @@
+package com.fdkankan.download.config;
+
+import com.mybatisflex.core.mybatis.FlexConfiguration;
+import com.mybatisflex.spring.boot.ConfigurationCustomizer;
+import org.apache.ibatis.logging.stdout.StdOutImpl;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class MyConfigurationCustomizer implements ConfigurationCustomizer {
+
+    @Override
+    public void customize(FlexConfiguration configuration) {
+        configuration.setLogImpl(StdOutImpl.class);
+    }
+}

+ 27 - 4
src/main/java/com/fdkankan/download/controller/BatchDownloadController.java

@@ -1,14 +1,18 @@
 package com.fdkankan.download.controller;
 
+import cn.hutool.system.HostInfo;
+import cn.hutool.system.SystemUtil;
+import cn.hutool.system.oshi.OshiUtil;
 import com.fdkankan.download.bean.ResultData;
 import com.fdkankan.download.service.IBatchDonloadService;
+import com.fdkankan.download.service.ISnService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
+import oshi.software.os.OperatingSystem;
+import oshi.software.os.linux.LinuxOperatingSystem;
+import oshi.software.os.windows.WindowsOperatingSystem;
 
 /**
  * <p>
@@ -25,6 +29,8 @@ public class BatchDownloadController {
 
     @Autowired
     private IBatchDonloadService batchDonloadService;
+    @Autowired
+    private ISnService snService;
 
     @PostMapping("download")
     public ResultData bacthDownload(@RequestParam(value = "file") MultipartFile file) throws Exception {
@@ -36,5 +42,22 @@ public class BatchDownloadController {
         return batchDonloadService.getDownloadDetail(uuid);
     }
 
+    @GetMapping("test")
+    public ResultData test() throws Exception {
+        final OperatingSystem os = OshiUtil.getOs();
+        String type = null;
+        if (os instanceof WindowsOperatingSystem){
+            type = "windows";
+        }
+        if(os instanceof LinuxOperatingSystem){
+            type = "linux";
+        }
+        HostInfo hostInfo = SystemUtil.getHostInfo();
+        return ResultData.ok(hostInfo.getAddress() + "-" + hostInfo.getName());
+//        return ResultData.ok(snService.list());
+    }
+
+
+
 
 }

+ 78 - 0
src/main/java/com/fdkankan/download/entity/Camera.java

@@ -0,0 +1,78 @@
+package com.fdkankan.download.entity;
+
+import com.mybatisflex.annotation.Column;
+import com.mybatisflex.annotation.Id;
+import com.mybatisflex.annotation.KeyType;
+import com.mybatisflex.annotation.Table;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+
+/**
+ * 相机主表 实体类。
+ *
+ * @author dsx
+ * @since 2023-12-08
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@Table(value = "t_camera")
+public class Camera implements Serializable {
+
+    @Id(keyType = KeyType.Auto)
+    private Long id;
+
+    /**
+     * 相机的Mac地址
+     */
+    private String childName;
+
+    /**
+     * 激活时间
+     */
+    private LocalDateTime activatedTime;
+
+    /**
+     * 相机密码
+     */
+    private String childPassword;
+
+    /**
+     * sn码
+     */
+    private String snCode;
+
+    /**
+     * wifi名称
+     */
+    private String wifiName;
+
+    /**
+     * wifi密码
+     */
+    private String wifiPassword;
+
+    /**
+     * 创建时间
+     */
+    private Timestamp createTime;
+
+    /**
+     * 更新时间
+     */
+    private Timestamp updateTime;
+
+    /**
+     * 记录的状态,A: 生效,I: 禁用
+     */
+    @Column(isLogicDelete = true)
+    private String recStatus;
+
+}

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

@@ -0,0 +1,107 @@
+package com.fdkankan.download.entity;
+
+import com.mybatisflex.annotation.Column;
+import com.mybatisflex.annotation.Id;
+import com.mybatisflex.annotation.KeyType;
+import com.mybatisflex.annotation.Table;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * 场景主表 实体类。
+ *
+ * @author dsx
+ * @since 2023-12-08
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@Table(value = "t_scene_plus")
+public class ScenePlus implements Serializable {
+
+    @Id(keyType = KeyType.Auto)
+    private Long id;
+
+    /**
+     * 场景码
+     */
+    private String num;
+
+    /**
+     * 用户id
+     */
+    private Long userId;
+
+    /**
+     * 相机id
+     */
+    private Long cameraId;
+
+    /**
+     * 手机id
+     */
+    private String phoneId;
+
+    /**
+     * 场景名称
+     */
+    private String title;
+
+    /**
+     * 场景描述
+     */
+    private String description;
+
+    /**
+     * 场景状态:0-未建好,1--已建好,-1-计算出错,-2--不在官网显示
+     */
+    private Integer sceneStatus;
+
+    /**
+     * 场景来源:相机拍摄10以内表示,1表示八目,2双目,3转台,4 激光  其他来源10以上,11:一键换装,12:123看房,13文通虚拟场景
+     */
+    private Integer sceneSource;
+
+    /**
+     * 支付状态:0表示未付款,1表示付款了,-1表示欠费,-2表示容量不足
+     */
+    private Integer payStatus;
+
+    /**
+     * 场景类型  0-其他,1-文博,2-地产,3-电商,4-餐饮,5-家居,99-一件换装虚拟房源
+     */
+    private Integer sceneType;
+
+    /**
+     * 是否推荐:0-否,1-是
+     */
+    private Integer recommend;
+
+    /**
+     * 是否有housetype文件(0-否,1-是)
+     */
+    private Integer houseType;
+
+    /**
+     * 创建时间
+     */
+    private Timestamp createTime;
+
+    /**
+     * 更新时间
+     */
+    private Timestamp updateTime;
+
+    /**
+     * A-有效,I-无效
+     */
+    @Column(isLogicDelete = true)
+    private String recStatus;
+
+}

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

@@ -0,0 +1,167 @@
+package com.fdkankan.download.entity;
+
+import com.mybatisflex.annotation.Column;
+import com.mybatisflex.annotation.Id;
+import com.mybatisflex.annotation.KeyType;
+import com.mybatisflex.annotation.Table;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ *  实体类。
+ *
+ * @author dsx
+ * @since 2023-12-11
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@Table(value = "t_scene_plus_ext")
+public class ScenePlusExt implements Serializable {
+
+    @Id(keyType = KeyType.Auto)
+    private Long id;
+
+    /**
+     * t_scene_plus主键
+     */
+    private Long plusId;
+
+    /**
+     * 场景数据目录
+     */
+    private String dataSource;
+
+    /**
+     * 场景链接
+     */
+    private String webSite;
+
+    /**
+     * 缩略图链接
+     */
+    private String thumb;
+
+    /**
+     * 方案:1-双目,2-转台,3-六目,4-八目,10-获取4k图,11-获取2k,12-获取1k
+     */
+    private Integer sceneScheme;
+
+    /**
+     * 使用用量
+     */
+    private Long space;
+
+    /**
+     * 原始文件容量
+     */
+    private Long origSpace;
+
+    /**
+     * 云服务器类型
+     */
+    private String ecs;
+
+    /**
+     * 点位数量
+     */
+    private Long shootCount;
+
+    /**
+     * 浏览次数
+     */
+    private Integer viewCount;
+
+    /**
+     * gps定位
+     */
+    private String gps;
+
+    /**
+     * 算法类型(slam、sfm)
+     */
+    private String algorithm;
+
+    /**
+     * 固件版本
+     */
+    private String firmwareVersion;
+
+    /**
+     * 算法类型(V2,V3)
+     */
+    private String buildType;
+
+    /**
+     * 分辨率(2k,4k)
+     */
+    private String sceneResolution;
+
+    /**
+     * 场景来源,lite:双目lite相机,pro:八目相机,minion:双面转台相机,laser:激光相机,virtual:虚拟场景,sketch:图片建模场景
+     */
+    private String sceneFrom;
+
+    /**
+     * 切图方式(tiles:瓦片图,face:切片图,pano:全景图 ,local:本地切片,cube:立体图)
+     */
+    private String sceneKind;
+
+    /**
+     * 算法生成模型类型(dam,3dtiles)
+     */
+    private String modelKind;
+
+    /**
+     * 点位视频
+     */
+    private String videos;
+
+    /**
+     * oss桶名
+     */
+    private String yunFileBucket;
+
+    /**
+     * 算法计算完成时间
+     */
+    private Timestamp algorithmTime;
+
+    /**
+     * 计算耗时
+     */
+    private Long computeTime;
+
+    /**
+     * 拍摄模式:3(SFM架站式-看看场景), 
+        4(SFM架站式-看见/深时/深光场景),
+        5(SLAM移动定位模式) ,
+        6(SLAM移动定位模式-有点位)
+     */
+    private Integer location;
+
+    /**
+     * 创建时间
+     */
+    private Timestamp createTime;
+
+    /**
+     * 更新时间
+     */
+    private Timestamp updateTime;
+
+    /**
+     * A-有效,I-无效
+     */
+    @Column(isLogicDelete = true)
+    private String recStatus;
+
+    private Integer isObj;
+
+}

+ 148 - 0
src/main/java/com/fdkankan/download/generate/Codegen.java

@@ -0,0 +1,148 @@
+package com.fdkankan.download.generate;
+
+import com.mybatisflex.codegen.Generator;
+import com.mybatisflex.codegen.config.ColumnConfig;
+import com.mybatisflex.codegen.config.GlobalConfig;
+import com.zaxxer.hikari.HikariDataSource;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Codegen {
+
+    public static void main(String[] args) {
+        //配置数据源
+        HikariDataSource dataSource = new HikariDataSource();
+        dataSource.setJdbcUrl("jdbc:mysql://120.24.144.164:3306/4dkankan_scene_download_tool");
+        dataSource.setUsername("root");
+        dataSource.setPassword("4Dage@4Dage#@168");
+
+        String[] tables = new String[]{"t_download_log"};
+
+                //创建配置内容,两种风格都可以。
+        GlobalConfig globalConfig = createGlobalConfigUseStylePrimary(tables);
+//        GlobalConfig globalConfig = createGlobalConfigUseStyle4Laser(tables);
+
+        //通过 datasource 和 globalConfig 创建代码生成器
+        Generator generator = new Generator(dataSource, globalConfig);
+
+        //生成代码
+        generator.generate();
+    }
+
+    public static GlobalConfig createGlobalConfigUseStylePrimary(String[] tables) {
+        //创建配置内容
+        GlobalConfig globalConfig = new GlobalConfig();
+
+        globalConfig.setEntityOverwriteEnable(true);
+
+        //设置根包
+        globalConfig.setBasePackage("com.fdkankan.download");
+
+        //设置表前缀和只生成哪些表
+        globalConfig.setTablePrefix("t_");
+        globalConfig.setGenerateTable(tables);
+
+
+        //设置生成 entity 并启用 Lombok
+        globalConfig.setEntityGenerateEnable(true);
+        globalConfig.setEntityWithLombok(true);
+
+        //设置生成 mapper
+        globalConfig.setMapperGenerateEnable(true);
+
+        globalConfig.setServiceGenerateEnable(true);
+        globalConfig.setServiceClassPrefix("I");
+
+        globalConfig.setServiceImplGenerateEnable(true);
+
+        Map<String, ColumnConfig> columnConfigMap = new HashMap<>();
+
+        //主键设置
+        ColumnConfig primaryKey = new ColumnConfig();
+        primaryKey.setPrimaryKey(true);
+        columnConfigMap.put("id", primaryKey);
+
+        ColumnConfig deleteKey = new ColumnConfig();
+        deleteKey.setLogicDelete(true);
+        columnConfigMap.put("is_delete", deleteKey);
+
+        globalConfig.setColumnConfigMap(columnConfigMap);
+
+        return globalConfig;
+    }
+
+    public static GlobalConfig createGlobalConfigUseStyle4Laser(String[] tables) {
+        //创建配置内容
+        GlobalConfig globalConfig = new GlobalConfig();
+
+        globalConfig.setEntityOverwriteEnable(true);
+
+        //设置根包
+        globalConfig.setBasePackage("com.fdkankan.external");
+
+        //设置表前缀和只生成哪些表
+        globalConfig.setTablePrefix("t_");
+        globalConfig.setGenerateTable(tables);
+
+
+        //设置生成 entity 并启用 Lombok
+        globalConfig.setEntityGenerateEnable(true);
+        globalConfig.setEntityWithLombok(true);
+
+        //设置生成 mapper
+        globalConfig.setMapperGenerateEnable(true);
+
+        globalConfig.setServiceGenerateEnable(true);
+        globalConfig.setServiceClassPrefix("I");
+
+        globalConfig.setServiceImplGenerateEnable(true);
+
+        Map<String, ColumnConfig> columnConfigMap = new HashMap<>();
+
+        //主键设置
+        ColumnConfig primaryKey = new ColumnConfig();
+        primaryKey.setPrimaryKey(true);
+        columnConfigMap.put("id", primaryKey);
+
+        //逻辑删除字段设置
+        ColumnConfig logicDelete = new ColumnConfig();
+        logicDelete.setLogicDelete(true);
+        columnConfigMap.put("rec_status", logicDelete);
+
+        globalConfig.setColumnConfigMap(columnConfigMap);
+
+        return globalConfig;
+    }
+
+    public static GlobalConfig createGlobalConfigUseStyle2() {
+        //创建配置内容
+        GlobalConfig globalConfig = new GlobalConfig();
+
+        //设置根包
+        globalConfig.getPackageConfig()
+                .setBasePackage("com.test");
+
+        //设置表前缀和只生成哪些表,setGenerateTable 未配置时,生成所有表
+        globalConfig.getStrategyConfig()
+                .setTablePrefix("tb_")
+                .setGenerateTable("tb_account", "tb_account_session");
+
+        //设置生成 entity 并启用 Lombok
+        globalConfig.enableEntity()
+                .setWithLombok(true);
+
+        //设置生成 mapper
+        globalConfig.enableMapper();
+
+        //可以单独配置某个列
+        ColumnConfig columnConfig = new ColumnConfig();
+        columnConfig.setColumnName("tenant_id");
+        columnConfig.setLarge(true);
+        columnConfig.setVersion(true);
+        globalConfig.getStrategyConfig()
+                .setColumnConfig("tb_account", columnConfig);
+
+        return globalConfig;
+    }
+}

+ 14 - 0
src/main/java/com/fdkankan/download/mapper/CameraMapper.java

@@ -0,0 +1,14 @@
+package com.fdkankan.download.mapper;
+
+import com.fdkankan.download.entity.Camera;
+import com.mybatisflex.core.BaseMapper;
+
+/**
+ * 相机主表 映射层。
+ *
+ * @author dsx
+ * @since 2023-12-08
+ */
+public interface CameraMapper extends BaseMapper<Camera> {
+
+}

+ 14 - 0
src/main/java/com/fdkankan/download/mapper/ScenePlusExtMapper.java

@@ -0,0 +1,14 @@
+package com.fdkankan.download.mapper;
+
+import com.fdkankan.download.entity.ScenePlusExt;
+import com.mybatisflex.core.BaseMapper;
+
+/**
+ *  映射层。
+ *
+ * @author dsx
+ * @since 2023-12-11
+ */
+public interface ScenePlusExtMapper extends BaseMapper<ScenePlusExt> {
+
+}

+ 14 - 0
src/main/java/com/fdkankan/download/mapper/ScenePlusMapper.java

@@ -0,0 +1,14 @@
+package com.fdkankan.download.mapper;
+
+import com.fdkankan.download.entity.ScenePlus;
+import com.mybatisflex.core.BaseMapper;
+
+/**
+ * 场景主表 映射层。
+ *
+ * @author dsx
+ * @since 2023-12-08
+ */
+public interface ScenePlusMapper extends BaseMapper<ScenePlus> {
+
+}

+ 19 - 0
src/main/java/com/fdkankan/download/service/ICameraService.java

@@ -0,0 +1,19 @@
+package com.fdkankan.download.service;
+
+import com.fdkankan.download.entity.Camera;
+import com.mybatisflex.core.service.IService;
+
+import java.util.List;
+
+/**
+ * 相机主表 服务层。
+ *
+ * @author dsx
+ * @since 2023-12-08
+ */
+public interface ICameraService extends IService<Camera> {
+
+    List<Camera> listBySnCodeList(List<String> snCodeList);
+
+
+}

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

@@ -0,0 +1,16 @@
+package com.fdkankan.download.service;
+
+import com.fdkankan.download.entity.ScenePlusExt;
+import com.mybatisflex.core.service.IService;
+
+/**
+ *  服务层。
+ *
+ * @author dsx
+ * @since 2023-12-11
+ */
+public interface IScenePlusExtService extends IService<ScenePlusExt> {
+
+    ScenePlusExt getByPlusId(Long plusId);
+
+}

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

@@ -0,0 +1,20 @@
+package com.fdkankan.download.service;
+
+import com.fdkankan.download.entity.ScenePlus;
+import com.mybatisflex.core.service.IService;
+
+import java.util.List;
+
+/**
+ * 场景主表 服务层。
+ *
+ * @author dsx
+ * @since 2023-12-08
+ */
+public interface IScenePlusService extends IService<ScenePlus> {
+
+    List<ScenePlus> listByCameraIdList(List<Long> cameraIdList);
+
+    ScenePlus getByNum(String num);
+
+}

+ 27 - 0
src/main/java/com/fdkankan/download/service/impl/CameraServiceImpl.java

@@ -0,0 +1,27 @@
+package com.fdkankan.download.service.impl;
+
+import com.fdkankan.download.entity.Camera;
+import com.fdkankan.download.mapper.CameraMapper;
+import com.fdkankan.download.service.ICameraService;
+import com.mybatisflex.annotation.UseDataSource;
+import com.mybatisflex.core.query.QueryWrapper;
+import com.mybatisflex.spring.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 相机主表 服务层实现。
+ *
+ * @author dsx
+ * @since 2023-12-08
+ */
+@UseDataSource("www")
+@Service
+public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> implements ICameraService {
+
+    @Override
+    public List<Camera> listBySnCodeList(List<String> snCodeList) {
+        return this.list(new QueryWrapper().in(Camera::getSnCode, snCodeList));
+    }
+}

+ 115 - 114
src/main/java/com/fdkankan/download/service/impl/CheckDownloadingRunnerImpl.java

@@ -1,114 +1,115 @@
-package com.fdkankan.download.service.impl;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.lang.UUID;
-import com.alibaba.fastjson.JSON;
-import com.fdkankan.download.bean.ResultData;
-import com.fdkankan.download.service.IBatchDonloadService;
-import com.fdkankan.download.service.ISsoService;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.CommandLineRunner;
-import org.springframework.stereotype.Component;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-/**
- * <p>
- * 应用启动校验是否有下载任务正在进行,如有过就重新入队头,从新下载
- * </p>
- *
- * @author dengsixing
- * @since 2022/2/22
- **/
-@Slf4j
-@Component
-public class CheckDownloadingRunnerImpl implements CommandLineRunner {
-
-    @Value("${download.dir}")
-    private String parentPath;
-    @Value("${download.task}")
-    private String taskLogPath;
-    @Value("${download.id}")
-    private String idLogPath;
-
-    @Autowired
-    private ISsoService ssoService;
-    @Autowired
-    private IBatchDonloadService batchDonloadService;
-
-    @Override
-    public void run(String... args) throws Exception {
-
-        //读取正在执行的任务
-        Set<String> set = null;
-        try {
-            String taskStr = FileUtil.readUtf8String(taskLogPath);
-            set = (Set<String>) JSON.parseObject(taskStr, Set.class);
-            BatchDonloadServiceImpl.taskSet.addAll(set);
-        }catch (Exception e){
-            log.info("读取正在执行的下载任务失败");
-        }
-
-        if(CollUtil.isEmpty(set)){
-            return;
-        }
-        Map<String, Object> headers = new HashMap<>();
-        try {
-            String token = ssoService.login();
-            headers.put("token", token);
-        }catch (Exception e){
-            log.error("登录失败", e);
-            return;
-        }
-
-        for (String uuid : set) {
-            String dir = parentPath.concat(uuid).concat(File.separator);
-            String origFilePath = dir.concat(uuid + ".txt");
-            if (!FileUtil.exist(origFilePath)) {
-                log.error("原始文件不存在,filePath:{}", origFilePath);
-                continue;
-            }
-            List<String> numList = FileUtil.readUtf8Lines(origFilePath);
-            if (CollUtil.isEmpty(numList)) {
-                log.error("场景码为空,filePath:{}", origFilePath);
-                continue;
-            }
-            String downloadResultLog = dir.concat("log.txt");
-            String downloadingLog = dir.concat("downloading.txt");
-
-            //过滤出需要下载的场景码
-            Set<String> numSet = numList.stream().collect(Collectors.toSet());
-            Map<String, String> map = new HashMap<>();
-            List<String> logList = null;
-            try {
-                logList = FileUtil.readUtf8Lines(downloadResultLog);
-                logList.stream().forEach(str->{
-                    String[] s = str.split(" ");
-                    map.put(s[0], str);
-                });
-            }catch (Exception e){
-
-            }
-            Set<String> collect = numSet.stream().filter(num -> {
-                if(map.containsKey(num)){
-                    return false;
-                }
-                return true;
-            }).collect(Collectors.toSet());
-
-            batchDonloadService.downloadHandler(uuid, collect, headers, dir, downloadingLog, downloadResultLog);
-
-        }
-
-
-    }
-
-}
+//package com.fdkankan.download.service.impl;
+//
+//import cn.hutool.core.collection.CollUtil;
+//import cn.hutool.core.io.FileUtil;
+//import cn.hutool.core.lang.UUID;
+//import com.alibaba.fastjson.JSON;
+//import com.fdkankan.download.bean.ResultData;
+//import com.fdkankan.download.service.IBatchDonloadService;
+//import com.fdkankan.download.service.ISsoService;
+//import lombok.extern.slf4j.Slf4j;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.boot.CommandLineRunner;
+//import org.springframework.stereotype.Component;
+//
+//import java.io.File;
+//import java.util.HashMap;
+//import java.util.List;
+//import java.util.Map;
+//import java.util.Set;
+//import java.util.stream.Collectors;
+//
+///**
+// * <p>
+// * 应用启动校验是否有下载任务正在进行,如有过就重新入队头,从新下载
+// * </p>
+// *
+// * @author dengsixing
+// * @since 2022/2/22
+// **/
+//@Slf4j
+//@Component
+//public class CheckDownloadingRunnerImpl implements CommandLineRunner {
+//
+//    @Value("${download.dir}")
+//    private String parentPath;
+//    @Value("${download.task}")
+//    private String taskLogPath;
+//    @Value("${download.id}")
+//    private String idLogPath;
+//
+//    @Autowired
+//    private ISsoService ssoService;
+//    @Autowired
+//    private IBatchDonloadService batchDonloadService;
+//
+//    @Override
+//    public void run(String... args) throws Exception {
+//
+//        //读取正在执行的任务
+//        Set<String> set = null;
+//        try {
+//            String taskStr = FileUtil.readUtf8String(taskLogPath);
+//            set = (Set<String>) JSON.parseObject(taskStr, Set.class);
+//            BatchDonloadServiceImpl.taskSet.addAll(set);
+//        }catch (Exception e){
+//            log.info("读取正在执行的下载任务失败");
+//        }
+//
+//        if(CollUtil.isEmpty(set)){
+//            return;
+//        }
+//        Map<String, Object> headers = new HashMap<>();
+//        try {
+//            String token = ssoService.login();
+//            headers.put("token", token);
+//        }catch (Exception e){
+//            log.error("登录失败", e);
+//            return;
+//        }
+//
+//        for (String uuid : set) {
+//            String dir = parentPath.concat(uuid).concat(File.separator);
+//            String origFilePath = dir.concat(uuid + ".txt");
+//            if (!FileUtil.exist(origFilePath)) {
+//                log.error("原始文件不存在,filePath:{}", origFilePath);
+//                continue;
+//            }
+//            List<String> numList = FileUtil.readUtf8Lines(origFilePath);
+//            if (CollUtil.isEmpty(numList)) {
+//                log.error("场景码为空,filePath:{}", origFilePath);
+//                continue;
+//            }
+//            String downloadResultLog = dir.concat("log.txt");
+//            String downloadingLog = dir.concat("downloading.txt");
+//
+//            //过滤出需要下载的场景码
+//
+//            Set<String> numSet = numList.stream().collect(Collectors.toSet());
+//            Map<String, String> map = new HashMap<>();
+//            List<String> logList = null;
+//            try {
+//                logList = FileUtil.readUtf8Lines(downloadResultLog);
+//                logList.stream().forEach(str->{
+//                    String[] s = str.split(" ");
+//                    map.put(s[0], str);
+//                });
+//            }catch (Exception e){
+//
+//            }
+//            Set<String> collect = numSet.stream().filter(num -> {
+//                if(map.containsKey(num)){
+//                    return false;
+//                }
+//                return true;
+//            }).collect(Collectors.toSet());
+//
+//            batchDonloadService.downloadHandler(uuid, collect, headers, dir, downloadingLog, downloadResultLog);
+//
+//        }
+//
+//
+//    }
+//
+//}

+ 116 - 0
src/main/java/com/fdkankan/download/service/impl/GenSceneRunnerImpl.java

@@ -0,0 +1,116 @@
+package com.fdkankan.download.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.thread.ExecutorBuilder;
+import cn.hutool.core.util.ArrayUtil;
+import cn.hutool.system.HostInfo;
+import cn.hutool.system.SystemUtil;
+import com.fdkankan.common.constant.CommonStatus;
+import com.fdkankan.common.constant.SceneSource;
+import com.fdkankan.download.entity.*;
+import com.fdkankan.download.service.*;
+import com.fdkankan.redis.util.RedisLockUtil;
+import com.fdkankan.redis.util.RedisUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.stereotype.Component;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Component
+public class GenSceneRunnerImpl implements CommandLineRunner {
+
+    @Autowired
+    private ISnService snService;
+    @Autowired
+    private IScenePlusService scenePlusService;
+    @Autowired
+    private ICameraService cameraService;
+    @Autowired
+    private IScenePlusExtService scenePlusExtService;
+    @Autowired
+    private IDownloadLogService downloadLogService;
+    @Autowired
+    private RedisUtil redisUtil;
+    @Autowired
+    private RedisLockUtil redisLockUtil;
+
+    private final static ThreadPoolExecutor threadPoolExecutor = ExecutorBuilder.create().setCorePoolSize(5).setMaxPoolSize(5).build();
+
+
+    @Override
+    public void run(String... args) throws Exception {
+        List<Sn> snList = snService.list();
+        if (CollUtil.isEmpty(snList)) {
+            return;
+        }
+        for (Sn sn : snList) {
+            List<Camera> cameras = cameraService.listBySnCodeList(Arrays.asList(sn.getSn()));
+            if (CollUtil.isEmpty(cameras)) {
+                continue;
+            }
+            Camera camera = cameras.get(0);
+            List<ScenePlus> scenePluses = scenePlusService.listByCameraIdList(Arrays.asList(camera.getId()));
+            if (CollUtil.isEmpty(scenePluses)) {
+                continue;
+            }
+            for (ScenePlus scenePlus : scenePluses) {
+                //上锁
+                HostInfo hostInfo = SystemUtil.getHostInfo();
+                String key = "download:tool:" + scenePlus.getNum();
+                String lockVal = hostInfo.getAddress();
+                try {
+                    boolean lock = redisLockUtil.lock(key, lockVal, 24 * 60 * 60 * 100);
+                    if(!lock){
+                        continue;
+                    }
+
+                    List<DownloadLog> downloadLogList = downloadLogService.getByNum(scenePlus.getNum());
+                    Set<String> types = downloadLogList.stream().map(DownloadLog::getType).collect(Collectors.toSet());
+
+                    int isObj = CommonStatus.NO.code();
+                    //下载点云场景
+                    if (scenePlus.getSceneSource() == SceneSource.JG.code() || scenePlus.getSceneSource() == SceneSource.SG.code()) {
+                        if(!types.contains("laser")){
+                            threadPoolExecutor.submit(() -> {
+                                try {
+
+                                    // TODO: 2024/1/3 文杰实现
+
+                                } catch (Exception e) {
+                                    log.error("点云场景打包失败,num:{}", scenePlus.getNum(), e);
+                                }
+                            });
+                        }
+                        ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
+                        isObj = scenePlusExt.getIsObj();
+                    }
+
+                    if (scenePlus.getSceneSource() == SceneSource.BM.code()
+                            || scenePlus.getSceneSource() == SceneSource.ZT.code()
+                            || isObj == CommonStatus.YES.code()) {
+                        if(!types.contains("kankan")) {
+                            threadPoolExecutor.submit(() -> {
+                                try {
+
+                                    // TODO: 2024/1/3 老邓实现
+
+                                } catch (Exception e) {
+                                    log.error("看看场景打包失败,num:{}", scenePlus.getNum(), e);
+                                }
+                            });
+                        }
+                    }
+                }catch (Exception e){
+                    log.error("场景打包失败:{}", scenePlus.getNum(), e);
+                }
+            }
+        }
+    }
+}

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

@@ -0,0 +1,26 @@
+package com.fdkankan.download.service.impl;
+
+import com.fdkankan.download.entity.ScenePlusExt;
+import com.fdkankan.download.mapper.ScenePlusExtMapper;
+import com.fdkankan.download.service.IScenePlusExtService;
+import com.mybatisflex.annotation.UseDataSource;
+import com.mybatisflex.core.query.QueryWrapper;
+import com.mybatisflex.spring.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ *  服务层实现。
+ *
+ * @author dsx
+ * @since 2023-12-11
+ */
+@UseDataSource("www")
+@Service
+public class ScenePlusExtServiceImpl extends ServiceImpl<ScenePlusExtMapper, ScenePlusExt> implements IScenePlusExtService {
+
+
+    @Override
+    public ScenePlusExt getByPlusId(Long plusId) {
+        return this.getOne(QueryWrapper.create().eq(ScenePlusExt::getPlusId, plusId));
+    }
+}

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

@@ -0,0 +1,36 @@
+package com.fdkankan.download.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import com.fdkankan.download.entity.ScenePlus;
+import com.fdkankan.download.mapper.ScenePlusMapper;
+import com.fdkankan.download.service.IScenePlusService;
+import com.mybatisflex.annotation.UseDataSource;
+import com.mybatisflex.core.query.QueryWrapper;
+import com.mybatisflex.spring.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 场景主表 服务层实现。
+ *
+ * @author dsx
+ * @since 2023-12-08
+ */
+@UseDataSource("www")
+@Service
+public class ScenePlusServiceImpl extends ServiceImpl<ScenePlusMapper, ScenePlus> implements IScenePlusService {
+
+    @Override
+    public List<ScenePlus> listByCameraIdList(List<Long> cameraIdList) {
+        if(CollUtil.isEmpty(cameraIdList)){
+            return null;
+        }
+        return this.list(new QueryWrapper().in(ScenePlus::getCameraId, cameraIdList).in(ScenePlus::getSceneStatus, -2, 1).eq(ScenePlus::getPayStatus, 1));
+    }
+
+    @Override
+    public ScenePlus getByNum(String num) {
+        return this.getOne(QueryWrapper.create().eq(ScenePlus::getNum, num));
+    }
+}

+ 30 - 0
src/main/java/com/fdkankan/download/util/ImgUtil.java

@@ -0,0 +1,30 @@
+package com.fdkankan.download.util;
+
+import cn.hutool.system.HostInfo;
+import cn.hutool.system.SystemUtil;
+import cn.hutool.system.oshi.OshiUtil;
+import oshi.software.os.OperatingSystem;
+import oshi.software.os.windows.WindowsOperatingSystem;
+
+public class ImgUtil {
+
+    public static void cutImage(int x, int y, int width, int height, String input, String output){
+        String cmd = null;
+        OperatingSystem os = OshiUtil.getOs();
+        if (os instanceof WindowsOperatingSystem){
+            cmd = "go_build_crop_win.exe";
+        }else{
+            cmd = " /opt/crop/go_crop";
+        }
+        cmd = cmd + " ";
+
+
+
+    }
+
+    public static void main(String[] args) {
+        HostInfo hostInfo = SystemUtil.getHostInfo();
+        System.out.println(hostInfo.toString());
+    }
+
+}

+ 43 - 0
src/main/resources/application-prod-eur.yml

@@ -0,0 +1,43 @@
+server:
+  port: 10002
+spring:
+  application:
+    name: 4dkankan-scene-download-tool
+account:
+  username: super-admin
+  password: 4Dagemanage
+host: https://eur.4dkankan.com
+api:
+  login: /service/manage/login
+  checkDownLoad: /service/manage/scene/checkDownLoad?num=%s
+  downScene: /service/manage/scene/downScene?num=%s
+  downloadProcess: /service/manage/scene/downloadProcess?num=%s
+
+download:
+  dir: /mnt/scene_download/
+  task: ${download.dir}task.txt
+  id: ${download.dir}id.txt
+
+forest:
+  ## 日志总开关,打开/关闭Forest请求/响应日志(默认为 true)
+  log-enabled: true
+  ## 打开/关闭Forest请求日志(默认为 true)
+  log-request: true
+  ## 打开/关闭Forest响应状态日志(默认为 true)
+  log-response-status: true
+  ## 打开/关闭Forest响应内容日志(默认为 false)
+  log-response-content: true
+  ## 请求超时时间,单位为毫秒, 默认值为3000
+  timeout: 10000
+  ## 连接超时时间,单位为毫秒, 默认值为2000
+  connect-timeout: 10000
+
+logging:
+  path: /home/backend/4dkankan_v4
+
+
+
+
+
+
+

+ 19 - 0
src/main/resources/application.yml

@@ -3,6 +3,22 @@ server:
 spring:
   application:
     name: 4dkankan-scene-download-tool
+
+mybatis-flex:
+  datasource:
+    primary:
+      url: jdbc:mysql://120.24.144.164:3306/4dkankan_scene_download_tool
+      username: root
+      password: 4Dage@4Dage#@168
+    www:
+      url: jdbc:mysql://120.24.144.164:3306/4dkankan_v4
+      username: root
+      password: 4Dage@4Dage#@168
+#    laser:
+#      url: jdbc:mysql://120.25.146.52:13306/fdkk_laser
+#      username: root
+#      password: JK123456%JIK
+
 account:
   username: super-admin
   password: Aa123456
@@ -39,3 +55,6 @@ logging:
 
 
 
+
+
+