dengsixing 11 månader sedan
förälder
incheckning
7977119e60

+ 26 - 5
pom.xml

@@ -107,23 +107,44 @@
       <version>1.3.6</version>
     </dependency>
 
+<!--    <dependency>-->
+<!--      <groupId>com.oracle</groupId>-->
+<!--      <artifactId>ojdbc6</artifactId>-->
+<!--      <version>11.2.0.3</version>-->
+<!--    </dependency>-->
+
     <dependency>
-      <groupId>com.oracle</groupId>
-      <artifactId>ojdbc6</artifactId>
-      <version>11.2.0.3</version>
+      <groupId>com.oracle.ojdbc</groupId>
+      <artifactId>ojdbc8</artifactId>
+      <version>19.3.0.0</version>
+    </dependency>
+
+    <dependency>
+      <groupId>cn.easyproject</groupId>
+      <artifactId>orai18n</artifactId>
+      <version>12.1.0.2.0</version>
+      <scope>provided</scope>
     </dependency>
+
+
     <!--mybatis-plus整合依赖-->
     <dependency>
       <groupId>com.baomidou</groupId>
       <artifactId>mybatis-plus-boot-starter</artifactId>
-      <version>3.0.5</version>
+      <version>3.4.3.4</version>
     </dependency>
 
     <!-- mybatis-plus逆向工程依赖 -->
     <dependency>
       <groupId>com.baomidou</groupId>
       <artifactId>mybatis-plus-generator</artifactId>
-      <version>3.2.0</version>
+      <version>3.5.1</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.dtflys.forest</groupId>
+      <artifactId>forest-spring-boot-starter</artifactId>
+      <version>1.5.36</version>
     </dependency>
 
     <!-- freemarker 说明:mybatis-plus逆向工程需要freemarker模板引擎 -->

+ 3 - 1
src/main/java/com/fdkankan/modeldemo/constant/Constant.java

@@ -2,7 +2,7 @@ package com.fdkankan.modeldemo.constant;
 
 public class Constant {
 
-    public static final String QUEUE_SCENE_CONVERT = "queue-scene-convert";
+    public static final String QUEUE_SCENE_CONVERT = "queue-scene-convert-2";
 
     public static final String DATA_VIEW_PATH =  "scene_view_data/%s/data/";
     /**
@@ -10,6 +10,8 @@ public class Constant {
      */
     public static final String IMG_VIEW_PATH =  "scene_view_data/%s/images/";
 
+    public static final String REDIS_SCENE_CONVERT_ING = "scene:converting:%s";
+
 
 
 }

+ 29 - 0
src/main/java/com/fdkankan/modeldemo/controller/SceneController.java

@@ -0,0 +1,29 @@
+package com.fdkankan.modeldemo.controller;
+
+
+import com.fdkankan.modeldemo.bean.ResultData;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author dsx
+ * @since 2024-06-25
+ */
+@RestController
+@RequestMapping("/convert")
+public class SceneController {
+
+    @GetMapping(value = "/ping")
+    public ResultData ping(){
+        return ResultData.ok();
+    }
+
+
+
+
+}

+ 4 - 4
src/main/java/com/fdkankan/modeldemo/entity/Scene.java

@@ -58,9 +58,9 @@ public class Scene extends Model<Scene> {
     private Integer floorplanangle;
 
 
-    @Override
-    protected Serializable pkVal() {
-        return this.id;
-    }
+//    @Override
+//    protected Serializable pkVal() {
+//        return this.id;
+//    }
 
 }

+ 4 - 4
src/main/java/com/fdkankan/modeldemo/entity/SceneConvertLog.java

@@ -58,9 +58,9 @@ public class SceneConvertLog extends Model<SceneConvertLog> {
     private String timeConsuming;
 
 
-    @Override
-    protected Serializable pkVal() {
-        return this.id;
-    }
+//    @Override
+//    protected Serializable pkVal() {
+//        return this.id;
+//    }
 
 }

+ 4 - 4
src/main/java/com/fdkankan/modeldemo/entity/SceneFileMapping.java

@@ -42,9 +42,9 @@ public class SceneFileMapping extends Model<SceneFileMapping> {
     private String url;
 
 
-    @Override
-    protected Serializable pkVal() {
-        return this.id;
-    }
+//    @Override
+//    protected Serializable pkVal() {
+//        return this.id;
+//    }
 
 }

+ 185 - 185
src/main/java/com/fdkankan/modeldemo/generator/MappingGeneratorOracle.java

@@ -1,188 +1,188 @@
-package com.fdkankan.modeldemo.generator;
-
-import com.baomidou.mybatisplus.annotation.DbType;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.generator.AutoGenerator;
-import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
-import com.baomidou.mybatisplus.generator.config.GlobalConfig;
-import com.baomidou.mybatisplus.generator.config.PackageConfig;
-import com.baomidou.mybatisplus.generator.config.StrategyConfig;
-import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
-import com.baomidou.mybatisplus.generator.config.rules.DateType;
-import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
-import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
-
-/**
- * 代码生成器
- *
- * <p>
- * 根据数据库中的表生成:数据库表映射对象、Mapper 接口、Mapper XML 文件(含基础的 ResultMap 和字段代码片段)、 Service
- * 接口、Service 接口实现累、基础的 Controller 类。
- * </p>
- * <p>
- * 如果数据库设计符合规范,并且代码没有特殊要求。设置好表名前缀(无则忽略)、表字段前缀(无则忽略)后, 直接修改输出的路径、JDBC
- * Url、数据库的账户和密码即可直接生成代码。
- * </p>
- * <p>
- * 生成后将 Mapper 中的 xml 包中的 XML 文件移动到 resource 下即可,XML 存放文件夹名为 Mapper
- * 接口包名(全包名)的同名文件夹<br/>
- * 如 Mapper 接口包名为:com.example.mapper,那么在 resource 下新建同名文件夹:com.example.mapper,将
- * xml 文件移动到该文件夹下即可。
- * </p>
- *
- * @author wayne
- * @since 2020-01-08 23:00
- */
-public class MappingGeneratorOracle {
-
-	/**
-	 * 生成代码输出路径,<strong>路径必须是绝对路径,不需要包含包名</strong>
-	 */
-	private static final String OUTPUT_DIR = ".\\src\\main\\java\\com\\fdkankan\\modeldemo\\generator";
-	/**
-	 * 生成代码输出的包名
-	 * <p>
-	 * 总包名,后续生成的 Mapper,Service 等将在该包下生成子包
-	 * </p>
-	 */
-	private static final String PACKAGE = "com.fdkankan.modeldemo";
-	/**
-	 * JDBC URL 说明: url地址前需要加上@,否则会报错
-	 */
-
-	private static final String JDBC_URL = "jdbc:oracle:thin:@//10.180.41.39:1521/resdb";
-	/**
-	 * 数据库账户
-	 */
-	private static final String DB_USERNAME = "RES_VR";
-	/**
-	 * 数据库账户密码
-	 */
-	private static final String DB_PASSWORD = "IDCqawsed@123.";
-
-	/**
-	 * 执行即可生成代码 需要添加 freemarker 依赖 <dependency> <groupId>org.freemarker</groupId>
-	 * <artifactId>freemarker</artifactId> <version>2.3.29</version> </dependency>
-	 */
-	// 不要在src/main/java里面使用main方法,否则springboot项目某人为main方法的类就是启动类
+//package com.fdkankan.modeldemo.generator;
+//
+//import com.baomidou.mybatisplus.annotation.DbType;
+//import com.baomidou.mybatisplus.annotation.IdType;
+//import com.baomidou.mybatisplus.generator.AutoGenerator;
+//import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
+//import com.baomidou.mybatisplus.generator.config.GlobalConfig;
+//import com.baomidou.mybatisplus.generator.config.PackageConfig;
+//import com.baomidou.mybatisplus.generator.config.StrategyConfig;
+//import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
+//import com.baomidou.mybatisplus.generator.config.rules.DateType;
+//import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
+//import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
+//
+///**
+// * 代码生成器
+// *
+// * <p>
+// * 根据数据库中的表生成:数据库表映射对象、Mapper 接口、Mapper XML 文件(含基础的 ResultMap 和字段代码片段)、 Service
+// * 接口、Service 接口实现累、基础的 Controller 类。
+// * </p>
+// * <p>
+// * 如果数据库设计符合规范,并且代码没有特殊要求。设置好表名前缀(无则忽略)、表字段前缀(无则忽略)后, 直接修改输出的路径、JDBC
+// * Url、数据库的账户和密码即可直接生成代码。
+// * </p>
+// * <p>
+// * 生成后将 Mapper 中的 xml 包中的 XML 文件移动到 resource 下即可,XML 存放文件夹名为 Mapper
+// * 接口包名(全包名)的同名文件夹<br/>
+// * 如 Mapper 接口包名为:com.example.mapper,那么在 resource 下新建同名文件夹:com.example.mapper,将
+// * xml 文件移动到该文件夹下即可。
+// * </p>
+// *
+// * @author wayne
+// * @since 2020-01-08 23:00
+// */
+//public class MappingGeneratorOracle {
+//
+//	/**
+//	 * 生成代码输出路径,<strong>路径必须是绝对路径,不需要包含包名</strong>
+//	 */
+//	private static final String OUTPUT_DIR = ".\\src\\main\\java\\com\\fdkankan\\modeldemo\\generator";
+//	/**
+//	 * 生成代码输出的包名
+//	 * <p>
+//	 * 总包名,后续生成的 Mapper,Service 等将在该包下生成子包
+//	 * </p>
+//	 */
+//	private static final String PACKAGE = "com.fdkankan.modeldemo";
+//	/**
+//	 * JDBC URL 说明: url地址前需要加上@,否则会报错
+//	 */
+//
+//	private static final String JDBC_URL = "jdbc:oracle:thin:@//10.180.41.39:1521/resdb";
+//	/**
+//	 * 数据库账户
+//	 */
+//	private static final String DB_USERNAME = "RES_VR";
+//	/**
+//	 * 数据库账户密码
+//	 */
+//	private static final String DB_PASSWORD = "IDCqawsed@123.";
+//
+//	/**
+//	 * 执行即可生成代码 需要添加 freemarker 依赖 <dependency> <groupId>org.freemarker</groupId>
+//	 * <artifactId>freemarker</artifactId> <version>2.3.29</version> </dependency>
+//	 */
+//	// 不要在src/main/java里面使用main方法,否则springboot项目某人为main方法的类就是启动类
+////	public static void main(String[] args) {
+////		autoGenerator().execute();
+////	}
+//
+//	public static AutoGenerator autoGenerator() {
+//		AutoGenerator autoGenerator = new AutoGenerator();
+//		autoGenerator.setGlobalConfig(globalConfig());
+//		autoGenerator.setDataSource(oracleDataSourceConfig());
+//		autoGenerator.setStrategy(strategyConfig());
+//		autoGenerator.setPackageInfo(packageConfig());
+//		autoGenerator.setTemplateEngine(new FreemarkerTemplateEngine());
+//		return autoGenerator;
+//	}
+//
 //	public static void main(String[] args) {
 //		autoGenerator().execute();
 //	}
-
-	public static AutoGenerator autoGenerator() {
-		AutoGenerator autoGenerator = new AutoGenerator();
-		autoGenerator.setGlobalConfig(globalConfig());
-		autoGenerator.setDataSource(oracleDataSourceConfig());
-		autoGenerator.setStrategy(strategyConfig());
-		autoGenerator.setPackageInfo(packageConfig());
-		autoGenerator.setTemplateEngine(new FreemarkerTemplateEngine());
-		return autoGenerator;
-	}
-
-	public static void main(String[] args) {
-		autoGenerator().execute();
-	}
-
-	/**
-	 * 全局配置
-	 *
-	 * @return {@link GlobalConfig}
-	 */
-	private static GlobalConfig globalConfig() {
-		GlobalConfig globalConfig = new GlobalConfig();
-		globalConfig.setAuthor("dsx");
-		// 设置代码输出位置,需要绝对路径
-		globalConfig.setOutputDir(OUTPUT_DIR);
-		// 覆盖已有的代码
-		globalConfig.setFileOverride(false);
-		// 基本表的 ResultMap
-		globalConfig.setBaseResultMap(true);
-		// 基本表字段片段
-		globalConfig.setBaseColumnList(true);
-		// 开启基于 Model 操作数据库
-		globalConfig.setActiveRecord(true);
-		// 设置 ID 类型
-		globalConfig.setIdType(IdType.AUTO);
-		globalConfig.setDateType(DateType.ONLY_DATE);
-//		// 生成基本 Swagger2 文档
-//		globalConfig.setSwagger2(true);
-		// 开启二级缓存
-//		globalConfig.setEnableCache(true);
-		// 设置生成的对象名称规则,%s 表示当前的 Entity
-		// 数据库表映射对象名称规则
-		globalConfig.setEntityName("%s");
-		// 也可以使用下面这种就是末尾会以DO结尾
-//		globalConfig.setEntityName("%sDO");
-		// Mapper 接口名称规则
-		globalConfig.setMapperName("%sMapper");
-		// Mapper XML 文件名称规则
-		globalConfig.setXmlName("%sMapper");
-		// Controller 生成规则
-		globalConfig.setControllerName("%sController");
-		// Service 接口生成名称规则
-		globalConfig.setServiceName("%sService");
-		// Service 实现类生成名称规则
-		globalConfig.setServiceImplName("%sServiceImpl");
-		return globalConfig;
-	}
-
-	/**
-	 * 生成策略配置
-	 *
-	 * @return StrategyConfig
-	 */
-	private static StrategyConfig strategyConfig() {
-		StrategyConfig strategyConfig = new StrategyConfig();
-		strategyConfig.setCapitalMode(false);
-		strategyConfig.setEntityLombokModel(true);
-		strategyConfig.setRestControllerStyle(true);
-		strategyConfig.setNaming(NamingStrategy.underline_to_camel);
-		strategyConfig.setColumnNaming(NamingStrategy.underline_to_camel);
-		// TODO 填写表前缀、表字段前缀,生成代码时去除字段前缀
-		strategyConfig.setTablePrefix("t_");
-		strategyConfig.setFieldPrefix("a_", "c_", "e_", "f_", "p_", "r_", "t_", "tf_");
-		strategyConfig.setInclude("T_FULLPHOTO_FILEINDEX");
-		return strategyConfig;
-	}
-
-	/**
-	 * MySQL 数据源配置
-	 *
-	 * @return DataSourceConfig
-	 */
-	private static DataSourceConfig oracleDataSourceConfig() {
-		DataSourceConfig dataSourceConfig = new DataSourceConfig();
-		dataSourceConfig.setDbType(DbType.ORACLE);
-		dataSourceConfig.setTypeConvert(new MySqlTypeConvert());
-		dataSourceConfig.setDriverName("oracle.jdbc.driver.OracleDriver");
-		dataSourceConfig.setUrl(JDBC_URL);
-		dataSourceConfig.setUsername(DB_USERNAME);
-		dataSourceConfig.setPassword(DB_PASSWORD);
-		return dataSourceConfig;
-	}
-
-	/**
-	 * 包相关配置信息
-	 * <p>
-	 * 配置生成代码的包信息,如生成的 Mapper 包,Service 包等
-	 * </p>
-	 */
-	private static PackageConfig packageConfig() {
-		PackageConfig packageConfig = new PackageConfig();
-		// 设置父包
-		packageConfig.setParent(PACKAGE);
-		// TODO 设置生成代码的包
-		// Controller 包
-		packageConfig.setController("controller");
-		// 数据库表映射对象包
-		packageConfig.setEntity("entity");
-		// Mapper 接口包,含 XML 文件
-		packageConfig.setMapper("mapper");
-		// Service 接口包
-		packageConfig.setService("service");
-		// Service 接口实现类包
-		packageConfig.setServiceImpl("service.impl");
-		return packageConfig;
-	}
-}
-
+//
+//	/**
+//	 * 全局配置
+//	 *
+//	 * @return {@link GlobalConfig}
+//	 */
+//	private static GlobalConfig globalConfig() {
+//		GlobalConfig globalConfig = new GlobalConfig();
+//		globalConfig.setAuthor("dsx");
+//		// 设置代码输出位置,需要绝对路径
+//		globalConfig.setOutputDir(OUTPUT_DIR);
+//		// 覆盖已有的代码
+//		globalConfig.setFileOverride(false);
+//		// 基本表的 ResultMap
+//		globalConfig.setBaseResultMap(true);
+//		// 基本表字段片段
+//		globalConfig.setBaseColumnList(true);
+//		// 开启基于 Model 操作数据库
+//		globalConfig.setActiveRecord(true);
+//		// 设置 ID 类型
+//		globalConfig.setIdType(IdType.AUTO);
+//		globalConfig.setDateType(DateType.ONLY_DATE);
+////		// 生成基本 Swagger2 文档
+////		globalConfig.setSwagger2(true);
+//		// 开启二级缓存
+////		globalConfig.setEnableCache(true);
+//		// 设置生成的对象名称规则,%s 表示当前的 Entity
+//		// 数据库表映射对象名称规则
+//		globalConfig.setEntityName("%s");
+//		// 也可以使用下面这种就是末尾会以DO结尾
+////		globalConfig.setEntityName("%sDO");
+//		// Mapper 接口名称规则
+//		globalConfig.setMapperName("%sMapper");
+//		// Mapper XML 文件名称规则
+//		globalConfig.setXmlName("%sMapper");
+//		// Controller 生成规则
+//		globalConfig.setControllerName("%sController");
+//		// Service 接口生成名称规则
+//		globalConfig.setServiceName("%sService");
+//		// Service 实现类生成名称规则
+//		globalConfig.setServiceImplName("%sServiceImpl");
+//		return globalConfig;
+//	}
+//
+//	/**
+//	 * 生成策略配置
+//	 *
+//	 * @return StrategyConfig
+//	 */
+//	private static StrategyConfig strategyConfig() {
+//		StrategyConfig strategyConfig = new StrategyConfig();
+//		strategyConfig.setCapitalMode(false);
+//		strategyConfig.setEntityLombokModel(true);
+//		strategyConfig.setRestControllerStyle(true);
+//		strategyConfig.setNaming(NamingStrategy.underline_to_camel);
+//		strategyConfig.setColumnNaming(NamingStrategy.underline_to_camel);
+//		// TODO 填写表前缀、表字段前缀,生成代码时去除字段前缀
+//		strategyConfig.setTablePrefix("t_");
+//		strategyConfig.setFieldPrefix("a_", "c_", "e_", "f_", "p_", "r_", "t_", "tf_");
+//		strategyConfig.setInclude("T_FULLPHOTO_FILEINDEX");
+//		return strategyConfig;
+//	}
+//
+//	/**
+//	 * MySQL 数据源配置
+//	 *
+//	 * @return DataSourceConfig
+//	 */
+//	private static DataSourceConfig oracleDataSourceConfig() {
+//		DataSourceConfig dataSourceConfig = new DataSourceConfig();
+//		dataSourceConfig.setDbType(DbType.ORACLE);
+//		dataSourceConfig.setTypeConvert(new MySqlTypeConvert());
+//		dataSourceConfig.setDriverName("oracle.jdbc.driver.OracleDriver");
+//		dataSourceConfig.setUrl(JDBC_URL);
+//		dataSourceConfig.setUsername(DB_USERNAME);
+//		dataSourceConfig.setPassword(DB_PASSWORD);
+//		return dataSourceConfig;
+//	}
+//
+//	/**
+//	 * 包相关配置信息
+//	 * <p>
+//	 * 配置生成代码的包信息,如生成的 Mapper 包,Service 包等
+//	 * </p>
+//	 */
+//	private static PackageConfig packageConfig() {
+//		PackageConfig packageConfig = new PackageConfig();
+//		// 设置父包
+//		packageConfig.setParent(PACKAGE);
+//		// TODO 设置生成代码的包
+//		// Controller 包
+//		packageConfig.setController("controller");
+//		// 数据库表映射对象包
+//		packageConfig.setEntity("entity");
+//		// Mapper 接口包,含 XML 文件
+//		packageConfig.setMapper("mapper");
+//		// Service 接口包
+//		packageConfig.setService("service");
+//		// Service 接口实现类包
+//		packageConfig.setServiceImpl("service.impl");
+//		return packageConfig;
+//	}
+//}
+//

+ 15 - 0
src/main/java/com/fdkankan/modeldemo/httpclient/HttpClient.java

@@ -0,0 +1,15 @@
+package com.fdkankan.modeldemo.httpclient;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.dtflys.forest.annotation.JSONBody;
+import com.dtflys.forest.annotation.Post;
+import com.dtflys.forest.annotation.Var;
+
+public interface HttpClient {
+
+    @Post(url = "{url}", connectTimeout = 30000,  readTimeout = 30000, maxRetryInterval = 3)
+    JSONObject postJson(@Var("url") String url, @JSONBody Object object);
+
+
+}

+ 38 - 28
src/main/java/com/fdkankan/modeldemo/mq/ConvertListener.java

@@ -4,6 +4,7 @@ import cn.hutool.core.date.TimeInterval;
 import cn.hutool.core.exceptions.ExceptionUtil;
 import cn.hutool.core.img.ImgUtil;
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.ZipUtil;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
@@ -21,6 +22,7 @@ import com.fdkankan.modeldemo.service.SceneService;
 import com.fdkankan.modeldemo.utils.ConvertUtil;
 import com.fdkankan.modeldemo.utils.FdfsUtil;
 import com.fdkankan.modeldemo.utils.HttpUtilExt;
+import com.fdkankan.redis.RedisClient;
 import com.rabbitmq.client.Channel;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.amqp.core.Message;
@@ -62,6 +64,8 @@ public class ConvertListener{
 
     @Autowired
     private SceneConvertLogService sceneConvertLogService;
+    @Resource
+    private RedisClient redisClient;
 
 //    @RabbitListener(
 //            queuesToDeclare = @Queue(Constant.QUEUE_SCENE_CONVERT),
@@ -124,11 +128,15 @@ public class ConvertListener{
         TimeInterval timeInterval = new TimeInterval();
         timeInterval.start();
 
+        String messageId = message.getMessageProperties().getMessageId();
+        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+
         String stationCode = null;
         String entityId = null;
         JSONArray fileList = null;
         SceneConvertLog sceneConvertLog = new SceneConvertLog();
         String dataSource = null;
+        String convertIngKey = null;
         try {
             String msg = new String(message.getBody(), StandardCharsets.UTF_8);
             log.info("msg:{}", msg);
@@ -136,6 +144,15 @@ public class ConvertListener{
             stationCode = jsonObject.getString("stationCode");
             entityId = jsonObject.getString("entityId");
             fileList = jsonObject.getJSONArray("fileList");
+            convertIngKey = String.format(Constant.REDIS_SCENE_CONVERT_ING, messageId);
+            String convert = redisClient.get(convertIngKey);
+            log.info("-----------------convert:{}-----------------", convert);
+            if(StrUtil.isNotEmpty(convert)){//正在转换,直接丢弃
+                log.warn("场景正在转换,此消息丢弃, stationCode:{}, entityId:{}", stationCode, entityId);
+                convertIngKey = null;
+                return;
+            }
+            redisClient.add(convertIngKey, stationCode + "_" + entityId, 60 * 60 * 1000L);
 
             sceneConvertLog.setStationCode(stationCode);
             sceneConvertLog.setEntityId(entityId);
@@ -168,19 +185,19 @@ public class ConvertListener{
             FileUtil.mkdir(image512Path);
             FileUtil.mkdir(image4kPath);
 
-            fileList.parallelStream().forEach(o->{
+            fileList.stream().forEach(o->{
                 JSONObject obj = (JSONObject) o;
                 String fileName = obj.getString("fileName");
                 String fileType = obj.getString("fileType");
                 String fileUrl = obj.getString("fileUrl");
                 if("7".equals(fileType)){//vision.txt
-                    HttpUtilExt.downloadFileAndCheck(fileUrl, imagePath + fileName, 3000);
+                    HttpUtilExt.downloadFileAndCheck(fileUrl, imagePath + fileName, 300000);
                 }
                 if("1".equals(fileType)){//512图
-                    HttpUtilExt.downloadFileAndCheck(fileUrl, image512Path + fileName, 30000);
+                    HttpUtilExt.downloadFileAndCheck(fileUrl, image512Path + fileName, 300000);
                 }
                 if("2".equals(fileType)){//4k图
-                    HttpUtilExt.downloadFileAndCheck(fileUrl, image4kPath + fileName, 30000);
+                    HttpUtilExt.downloadFileAndCheck(fileUrl, image4kPath + fileName, 300000);
                     if(!exists512){
                         ImgUtil.scale(new File(image4kPath + fileName), new File(image512Path + fileName), 0.125f);
                     }
@@ -198,45 +215,38 @@ public class ConvertListener{
                     HttpUtilExt.downloadFileAndCheck(fileUrl, meshPath + fileName, 300000);
                 }
                 if("5".equals(fileType)){//floorplan.json
-                    HttpUtilExt.downloadFileAndCheck(fileUrl, dataPath + fileName, 3000);
+                    HttpUtilExt.downloadFileAndCheck(fileUrl, dataPath + fileName, 300000);
                 }
                 if("12".equals(fileType)){//scene.json
-                    HttpUtilExt.downloadFileAndCheck(fileUrl, dataPath + fileName, 3000);
+                    HttpUtilExt.downloadFileAndCheck(fileUrl, dataPath + fileName, 300000);
                 }
             });
 
-            Map<String, String> uploadFileMap = convertUtil.convert(dataSource, entityId);
-            String finalRoomId = entityId;
-            uploadFileMap.keySet().parallelStream().forEach(key->{
-                SceneFileMapping sceneFileMapping = sceneFileMappingService.getByNumAndKey(finalRoomId, key);
-                if(Objects.isNull(sceneFileMapping)){
-                    sceneFileMapping = new SceneFileMapping();
-                }
-                Map<String, String> mapping = fdfsUtil.uploadFile(uploadFileMap.get(key));
-                sceneFileMapping.setNum(finalRoomId);
-                sceneFileMapping.setFileid(mapping.get("file_id"));
-                sceneFileMapping.setUrl(mapping.get("http_url"));
-                sceneFileMapping.setKey(key);
-                sceneFileMappingService.saveOrUpdate(sceneFileMapping);
-            });
+            //转换并上传文件
+            convertUtil.convert(dataSource, entityId);
 
             sceneConvertLog.setStatus("1");
+            sceneConvertLog.setTimeConsuming(String.valueOf(timeInterval.intervalSecond()));
+            sceneConvertLogService.save(sceneConvertLog);
 
         }catch (Exception e){
             log.error("convert fail, stationCode:{}, roomId:{}", stationCode, entityId, e);
             sceneConvertLog.setStatus("0");
             sceneConvertLog.setRemark(ExceptionUtil.stacktraceToString(e, 4000));
-        }
+            sceneConvertLog.setTimeConsuming(String.valueOf(timeInterval.intervalSecond()));
+            sceneConvertLogService.save(sceneConvertLog);
+        }finally{
+            if(dataSource != null){
+                FileUtil.del(dataSource);
+                FileUtil.del(dataSource.substring(0, dataSource.lastIndexOf("/")) + "_obj2txt");
+            }
 
-        if(dataSource != null){
-//            FileUtil.del(dataSource);
-//            FileUtil.del(dataSource.substring(0, dataSource.lastIndexOf("/")) + "_obj2txt");
+            if(StrUtil.isNotEmpty(convertIngKey)){
+                redisClient.del(convertIngKey);
+            }
         }
 
-        sceneConvertLog.setTimeConsuming(String.valueOf(timeInterval.intervalSecond()));
-        sceneConvertLogService.save(sceneConvertLog);
-
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+//        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
     }
 
 //    public boolean checkNead8kPic(JSONArray array){

+ 3 - 1
src/main/java/com/fdkankan/modeldemo/service/SceneFileMappingService.java

@@ -3,6 +3,8 @@ package com.fdkankan.modeldemo.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.modeldemo.entity.SceneFileMapping;
 
+import java.util.List;
+
 /**
  * <p>
  *  服务类
@@ -13,6 +15,6 @@ import com.fdkankan.modeldemo.entity.SceneFileMapping;
  */
 public interface SceneFileMappingService extends IService<SceneFileMapping> {
 
-    SceneFileMapping getByNumAndKey(String num, String key);
+    List<SceneFileMapping> getByNumAndKey(String num, String key);
 
 }

+ 4 - 2
src/main/java/com/fdkankan/modeldemo/service/impl/SceneFileMappingServiceImpl.java

@@ -7,6 +7,8 @@ import com.fdkankan.modeldemo.mapper.SceneFileMappingMapper;
 import com.fdkankan.modeldemo.service.SceneFileMappingService;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  *  服务实现类
@@ -19,7 +21,7 @@ import org.springframework.stereotype.Service;
 public class SceneFileMappingServiceImpl extends ServiceImpl<SceneFileMappingMapper, SceneFileMapping> implements SceneFileMappingService {
 
     @Override
-    public SceneFileMapping getByNumAndKey(String num, String key) {
-        return this.getOne(new LambdaQueryWrapper<SceneFileMapping>().eq(SceneFileMapping::getNum, num).eq(SceneFileMapping::getKey, key));
+    public List<SceneFileMapping> getByNumAndKey(String num, String key) {
+        return this.list(new LambdaQueryWrapper<SceneFileMapping>().eq(SceneFileMapping::getNum, num).eq(SceneFileMapping::getKey, key));
     }
 }

+ 31 - 7
src/main/java/com/fdkankan/modeldemo/utils/ConvertUtil.java

@@ -1,5 +1,6 @@
 package com.fdkankan.modeldemo.utils;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
@@ -9,16 +10,20 @@ import com.fdkankan.modeldemo.bean.SceneEditControlsBean;
 import com.fdkankan.modeldemo.bean.SceneJsonBean;
 import com.fdkankan.modeldemo.constant.Constant;
 import com.fdkankan.modeldemo.entity.Scene;
+import com.fdkankan.modeldemo.entity.SceneFileMapping;
+import com.fdkankan.modeldemo.service.SceneFileMappingService;
 import com.fdkankan.modeldemo.service.SceneService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.Resource;
 import java.io.File;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 @Component
 public class ConvertUtil {
@@ -26,6 +31,10 @@ public class ConvertUtil {
     @Autowired
     private SceneService sceneService;
 
+    @Autowired
+    private SceneFileMappingService sceneFileMappingService;
+    @Resource
+    private FdfsUtil fdfsUtil;
     public static void main(String[] args) throws Exception {
 
         String srcPath = args[0];
@@ -157,17 +166,28 @@ public class ConvertUtil {
         FileUtil.writeUtf8String(JSON.toJSONString(sceneJsonBean), sourcePath + "data/scene.json");
         map.put(dataViewPath + "scene.json", sourcePath + "data/scene.json");
 
-        return map;
-    }
-
-    private SceneJsonBean genSceneJson(String roomId, String title){
-
-        Scene scene = sceneService.getByNum(roomId);
+        String finalRoomId = num;
+        map.keySet().stream().forEach(key->{
+            List<SceneFileMapping> sceneFileMappingList = sceneFileMappingService.getByNumAndKey(finalRoomId, key);
+            if(CollUtil.isNotEmpty(sceneFileMappingList)){
+                List<String> deleteIds = sceneFileMappingList.stream().map(v -> v.getId()).collect(Collectors.toList());
+                sceneFileMappingService.removeByIds(deleteIds);
+            }
+            SceneFileMapping sceneFileMapping = new SceneFileMapping();
+            Map<String, String> mapping = fdfsUtil.uploadFile(map.get(key));
+            sceneFileMapping.setNum(finalRoomId);
+            sceneFileMapping.setFileid(mapping.get("file_id"));
+            sceneFileMapping.setUrl(mapping.get("http_url"));
+            sceneFileMapping.setKey(key);
+            sceneFileMappingService.save(sceneFileMapping);
+        });
+
+        Scene scene = sceneService.getByNum(num);
         if(Objects.isNull(scene)){
             scene = new Scene();
         }
         scene.setTitle(title);
-        scene.setNum(roomId);
+        scene.setNum(num);
         scene.setFloorlogosize(100);
         scene.setScenekind("pano");
         scene.setSceneresolution("4k");
@@ -176,6 +196,10 @@ public class ConvertUtil {
         scene.setFloorplanangle(0);
         sceneService.saveOrUpdate(scene);
 
+        return map;
+    }
+
+    private SceneJsonBean genSceneJson(String roomId, String title){
         SceneEditControlsBean sceneEditControlsBean = SceneEditControlsBean.builder()
                 .showDollhouse(1).showMap(1).showPanorama(1).showVR(1).showTitle(1).showFloorplan(1).build();
 

+ 17 - 2
src/main/java/com/fdkankan/modeldemo/utils/FdfsUtil.java

@@ -1,5 +1,6 @@
 package com.fdkankan.modeldemo.utils;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.lang.UUID;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.http.HttpResponse;
@@ -59,7 +60,7 @@ public class FdfsUtil {
         test.put("visibilityLevel", "1003");
         test.put("file", new File(filePath));
         test.put("userId", "111111");
-        HttpRequest httpRequest = HttpRequest.post(address.concat(api_uploadFile)).form(test).addHeaders(headers).timeout(60000);
+        HttpRequest httpRequest = HttpRequest.post(address.concat(api_uploadFile)).form(test).addHeaders(headers).timeout(120000);
         HttpResponse res = httpRequest.execute();
         String resBody = res.body();
         log.info("upload file response : {}", resBody);
@@ -76,7 +77,21 @@ public class FdfsUtil {
         String nonce = UUID.fastUUID().toString();
         String timestamp = String.valueOf(new Date().getTime());
         String signature = getSignature(nonce, timestamp);
-        return uploadFile(nonce, timestamp, signature, filePath);
+        Map<String, String> stringStringMap = null;
+        for(int i = 0; i< 5; i++){
+            try {
+                stringStringMap = uploadFile(nonce, timestamp, signature, filePath);
+                if(CollUtil.isNotEmpty(stringStringMap)){
+                    break;
+                }
+            }catch (Exception e){
+                log.warn("第{}上传文件失败,path:{}", i + 1, filePath, e);
+            }
+        }
+        if(CollUtil.isEmpty(stringStringMap)){
+            throw new RuntimeException("上传文件FASTDFS失败,path:{}" + filePath);
+        }
+        return stringStringMap;
     }
 
     public static void main(String[] args) {

+ 9 - 8
src/main/java/com/fdkankan/modeldemo/utils/HttpUtilExt.java

@@ -11,15 +11,16 @@ import java.io.File;
 public class HttpUtilExt extends HttpUtil {
 
     public static void downloadFileAndCheck(String url, String localPath, int timeout){
-        int times = 0;
-        do {
-            downloadFile(url, new File(localPath), timeout);
-            if(FileUtil.exist(localPath) && FileUtil.size(new File(localPath)) > 0){
-                return;
+        for (int i = 0; i < 5; i++){
+            try {
+                downloadFile(url, new File(localPath), timeout);
+                if(FileUtil.exist(localPath) && FileUtil.size(new File(localPath)) > 0){
+                    return;
+                }
+            }catch (Exception e){
+                log.warn("第{}次文件下载失败,url{}", i+1, url);
             }
-            times++;
-        }while (times < 5);
-        throw new RuntimeException("文件下载失败,url=" + url + ",localPath=" + localPath);
+        }
     }
 
 }

+ 75 - 0
src/main/java/com/fdkankan/redis/RedisClient.java

@@ -0,0 +1,75 @@
+package com.fdkankan.redis;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.modeldemo.httpclient.HttpClient;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+@Component
+public class RedisClient {
+
+    public final static String url_str_add = "/redis/string/add/";
+
+    public final static String url_str_get = "/redis/string/get/";
+
+    public final static String url_str_del = "/redis/string/delete";
+
+    @Value("${redis.host}")
+    private String host;
+
+    @Value("${tieta.sysCode}")
+    private String sysCode;
+
+    @Value("${tieta.serverName}")
+    private String serverName;
+
+    @Resource
+    private HttpClient httpClient;
+
+
+     public void add(String key, String value, Long time){
+         String url = host + url_str_add;
+         Map<String, Object> params = new HashMap<>();
+         params.put("key", this.genKey(key));
+         params.put("value", value);
+         if(Objects.nonNull(time)){
+             params.put("time", time);
+         }
+         JSONObject jsonObject = httpClient.postJson(url, params);
+         if(Objects.isNull(jsonObject) || !"0".equals(jsonObject.getString("status"))){
+             throw new RuntimeException("redis add string error");
+         }
+     }
+
+    public String get(String key){
+        String url = host + url_str_get;
+        Map<String, Object> params = new HashMap<>();
+        params.put("key", this.genKey(key));
+        JSONObject jsonObject = httpClient.postJson(url, params);
+        if(Objects.isNull(jsonObject) || !"0".equals(jsonObject.getString("status"))){
+            throw new RuntimeException("redis get string error");
+        }
+        return jsonObject.getString("data");
+    }
+
+    public String del(String key){
+        String url = host + url_str_del;
+        Map<String, Object> params = new HashMap<>();
+        params.put("key", this.genKey(key));
+        JSONObject jsonObject = httpClient.postJson(url, params);
+        if(Objects.isNull(jsonObject) || !"0".equals(jsonObject.getString("status"))){
+            throw new RuntimeException("redis del string error");
+        }
+        return jsonObject.getString("data");
+    }
+
+    private String genKey(String key){
+         return sysCode + "_" + serverName + "_" + key;
+    }
+}
+

+ 20 - 1
src/main/resources/application-dev.yml

@@ -20,6 +20,24 @@ spring:
     username: RES_VR
     password: IDCqawsed@123.
     driver-class-name: oracle.jdbc.OracleDriver
+    hikari:
+      maximum-pool-size: 20 #连接池最大连接数
+      minimum-idle: 5 #连接池最小连接数
+      connection-timeout: 30000
+      idle-timeout: 600000
+      max-lifetime: 1800000
+      login-timeout: 60000
+      pool-name: MyHikariCP
+      connection-test-query: SELECT 1 FROM DUAL
+
+mybatis-plus:
+  mapper-locations: classpath:mapper/*Mapper.xml
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+
+tieta:
+  sysCode: CT00017
+  serverName: vrconvert
 
 fdfs:
   sysCode: CT00017
@@ -28,7 +46,8 @@ fdfs:
     getSignature: /ChinatowerFileService/getSignature
     uploadFile: /ChinatowerFileService/uploadFile/
 
-
+redis:
+  host: http://10.180.22.54:8081
 
 
 

+ 20 - 1
src/main/resources/application-preprod.yml

@@ -20,6 +20,24 @@ spring:
     username: RES_VR
     password: qawsed@123.
     driver-class-name: oracle.jdbc.OracleDriver
+    hikari:
+      maximum-pool-size: 20 #连接池最大连接数
+      minimum-idle: 5 #连接池最小连接数
+      connection-timeout: 30000
+      idle-timeout: 600000
+      max-lifetime: 1800000
+      login-timeout: 60000
+      pool-name: MyHikariCP
+      connection-test-query: SELECT 1 FROM DUAL
+
+mybatis-plus:
+  mapper-locations: classpath:mapper/*Mapper.xml
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+
+tieta:
+  sysCode: CT00017
+  serverName: vrconvert
 
 fdfs:
   sysCode: CT00017
@@ -28,7 +46,8 @@ fdfs:
     getSignature: /ChinatowerFileService/getSignature
     uploadFile: /ChinatowerFileService/uploadFile/
 
-
+redis:
+  host: http://10.34.53.34:8081
 
 
 

+ 20 - 1
src/main/resources/application-prod.yml

@@ -20,6 +20,24 @@ spring:
     username: RES_VR
     password: qawsed@123.
     driver-class-name: oracle.jdbc.OracleDriver
+    hikari:
+      maximum-pool-size: 20 #连接池最大连接数
+      minimum-idle: 5 #连接池最小连接数
+      connection-timeout: 30000
+      idle-timeout: 600000
+      max-lifetime: 1800000
+      login-timeout: 60000
+      pool-name: MyHikariCP
+      connection-test-query: SELECT 1 FROM DUAL
+
+mybatis-plus:
+  mapper-locations: classpath:mapper/*Mapper.xml
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+
+tieta:
+  sysCode: CT00017
+  serverName: vrconvert
 
 fdfs:
   sysCode: CT00017
@@ -28,7 +46,8 @@ fdfs:
     getSignature: /ChinatowerFileService/getSignature
     uploadFile: /ChinatowerFileService/uploadFile/
 
-
+redis:
+  host: http://192.168.53.243:8081
 
 
 

+ 21 - 0
src/main/resources/application-test.yml

@@ -20,6 +20,24 @@ spring:
     username: RES_VR
     password: IDCqawsed@123.
     driver-class-name: oracle.jdbc.OracleDriver
+    hikari:
+      maximum-pool-size: 20 #连接池最大连接数
+      minimum-idle: 5 #连接池最小连接数
+      connection-timeout: 30000
+      idle-timeout: 600000
+      max-lifetime: 1800000
+      login-timeout: 60000
+      pool-name: MyHikariCP
+      connection-test-query: SELECT 1 FROM DUAL
+
+mybatis-plus:
+  mapper-locations: classpath:mapper/*Mapper.xml
+  configuration:
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+
+tieta:
+  sysCode: CT00017
+  serverName: vrconvert
 
 fdfs:
   sysCode: CT00017
@@ -28,6 +46,9 @@ fdfs:
     getSignature: /ChinatowerFileService/getSignature
     uploadFile: /ChinatowerFileService/uploadFile/
 
+redis:
+  host: http://10.190.22.99:8081
+
 
 
 

+ 1 - 1
src/main/resources/mapper/SceneFileMappingMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="com.fdkankan.modeldemo.mapper.SceneFileMappingMapper">
 
     <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.fdkankan.project.tieta.entity.SceneFileMapping">
+    <resultMap id="BaseResultMap" type="com.fdkankan.modeldemo.entity.SceneFileMapping">
         <id column="ID" property="id" />
         <result column="NUM" property="num" />
         <result column="FILEID" property="fileid" />

+ 1 - 1
src/main/resources/mapper/SceneMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="com.fdkankan.modeldemo.mapper.SceneMapper">
 
     <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.fdkankan.project.tieta.entity.Scene">
+    <resultMap id="BaseResultMap" type="com.fdkankan.modeldemo.entity.Scene">
         <id column="ID" property="id" />
         <result column="TITLE" property="title" />
         <result column="DESCRIPTION" property="description" />