From 19ccd594cd2ead844e32fd7eeb7e2d0a1ccaad5a Mon Sep 17 00:00:00 2001
From: SZH <szh_hello@163.com>
Date: 星期二, 19 七月 2022 15:26:15 +0800
Subject: [PATCH] 1、支持多数据源事务 2、增加事故管理模块 3、支持rocketmq 4、支持redis客户端redisson

---
 incident-manage/pom.xml                                                                                   |   25 ++
 incident-manage/incident-manage-service/pom.xml                                                           |   19 ++
 incident-manage/incident-manage-rpc-provider/pom.xml                                                      |   19 ++
 safePlatfrom-out-web/src/main/resources/config/application-dev.yaml                                       |   48 ++++
 safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigIncidentManage.java |   75 ++++++++
 safePlatfrom-out-web/src/main/resources/config/application-out-dev.yaml                                   |   50 ++++
 safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigGoalManage.java     |    2 
 pom.xml                                                                                                   |   48 +++++
 safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/DataSourceConfig.java            |   23 +-
 safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/DruidConfig.java                 |  165 ++++++++++++++++++
 safePlatfrom-out-web/src/main/resources/config/application.yaml                                           |    6 
 safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigEmergency.java      |    4 
 safePlatfrom-out-web/pom.xml                                                                              |   24 ++
 incident-manage/incident-manage-rpc-api/pom.xml                                                           |   19 ++
 14 files changed, 495 insertions(+), 32 deletions(-)

diff --git a/incident-manage/incident-manage-rpc-api/pom.xml b/incident-manage/incident-manage-rpc-api/pom.xml
new file mode 100644
index 0000000..f274386
--- /dev/null
+++ b/incident-manage/incident-manage-rpc-api/pom.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>incident-manage</artifactId>
+        <groupId>com.gkhy.safePlatfrom</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>incident-manage-rpc-api</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+</project>
\ No newline at end of file
diff --git a/incident-manage/incident-manage-rpc-provider/pom.xml b/incident-manage/incident-manage-rpc-provider/pom.xml
new file mode 100644
index 0000000..7e6d616
--- /dev/null
+++ b/incident-manage/incident-manage-rpc-provider/pom.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>incident-manage</artifactId>
+        <groupId>com.gkhy.safePlatfrom</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>incident-manage-rpc-provider</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+</project>
\ No newline at end of file
diff --git a/incident-manage/incident-manage-service/pom.xml b/incident-manage/incident-manage-service/pom.xml
new file mode 100644
index 0000000..ffb55bc
--- /dev/null
+++ b/incident-manage/incident-manage-service/pom.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>incident-manage</artifactId>
+        <groupId>com.gkhy.safePlatfrom</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>incident-manage-service</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+</project>
\ No newline at end of file
diff --git a/incident-manage/pom.xml b/incident-manage/pom.xml
new file mode 100644
index 0000000..491a44f
--- /dev/null
+++ b/incident-manage/pom.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>safe-platform</artifactId>
+        <groupId>com.gkhy.safePlatfrom</groupId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>incident-manage</artifactId>
+    <packaging>pom</packaging>
+    <modules>
+        <module>incident-manage-service</module>
+        <module>incident-manage-rpc-api</module>
+        <module>incident-manage-rpc-provider</module>
+    </modules>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+</project>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 4327bd3..b732223 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,6 +15,7 @@
         <module>emergency/emergency-service</module>
         <module>emergency/emergency-rpc-provider</module>
         <module>safePlatfrom-out-web</module>
+        <module>incident-manage</module>
     </modules>
 
     <properties>
@@ -31,6 +32,10 @@
         <guava.version>31.1-jre</guava.version>
         <account.rpc.model.version>1.0-SNAPSHOT</account.rpc.model.version>
         <mybatis.plus.version>3.5.2</mybatis.plus.version>
+        <jta.starter.version>2.7.1</jta.starter.version>
+        <rocketmq.starter.version>2.2.2</rocketmq.starter.version>
+        <redission.version>3.17.4</redission.version>
+        <com.alibaba.cloud.version>2.2.8.RELEASE</com.alibaba.cloud.version>
     </properties>
 
     <parent>
@@ -100,7 +105,36 @@
                 <artifactId>mybatis-plus-extension</artifactId>
                 <version>${mybatis.plus.version}</version>
             </dependency>
-
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-starter-jta-atomikos</artifactId>
+                <version>${jta.starter.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.rocketmq</groupId>
+                <artifactId>rocketmq-spring-boot</artifactId>
+                <version>${rocketmq.starter.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.redisson</groupId>
+                <artifactId>redisson-spring-boot-starter</artifactId>
+                <version>${redission.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>com.alibaba.cloud</groupId>
+                <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+                <version>${com.alibaba.cloud.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.springframework.cloud</groupId>
+                <artifactId>spring-cloud-starter-gateway</artifactId>
+                <version>3.1.3</version>
+            </dependency>
+            <dependency>
+                <groupId>com.alibaba.cloud</groupId>
+                <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+                <version>${com.alibaba.cloud.version}</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 
@@ -194,6 +228,18 @@
             <groupId>com.squareup.okhttp3</groupId>
             <artifactId>okhttp</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.rocketmq</groupId>
+            <artifactId>rocketmq-spring-boot</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.redisson</groupId>
+            <artifactId>redisson-spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-jta-atomikos</artifactId>
+        </dependency>
 
         <!-- 安全平台业务组件 -->
         <dependency>
diff --git a/safePlatfrom-out-web/pom.xml b/safePlatfrom-out-web/pom.xml
index 9ee4ea0..e172abe 100644
--- a/safePlatfrom-out-web/pom.xml
+++ b/safePlatfrom-out-web/pom.xml
@@ -38,7 +38,29 @@
             <artifactId>goal-manage-rpc-provider</artifactId>
             <version>1.0-SNAPSHOT</version>
         </dependency>
-
+        <dependency>
+            <groupId>com.gkhy.safePlatfrom</groupId>
+            <artifactId>incident-manage-service</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.gkhy.safePlatfrom</groupId>
+            <artifactId>incident-manage-rpc-provider</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.aspectj</groupId>
+            <artifactId>aspectjweaver</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+            <version>2021.0.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+        </dependency>
 
 
     </dependencies>
diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/DataSourceConfig.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/DataSourceConfig.java
index 159f486..396299d 100644
--- a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/DataSourceConfig.java
+++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/DataSourceConfig.java
@@ -15,23 +15,18 @@
 @Configuration
 public class DataSourceConfig {
 
-    @Bean
-    @ConfigurationProperties("spring.datasource.goalmanage")
-    DataSource dsGoalManage(){
-        return DruidDataSourceBuilder.create().build();
-    }
-
-    @Bean
-    @ConfigurationProperties("spring.datasource.emergency")
-    DataSource dsEmergency(){
-        return DruidDataSourceBuilder.create().build();
-    }
-
 //    @Bean
-//    @ConfigurationProperties("spring.datasource.two")
-//    DataSource dsTwo(){
+//    @ConfigurationProperties("spring.datasource.goalmanage")
+//    DataSource dsGoalManage(){
 //        return DruidDataSourceBuilder.create().build();
 //    }
+//
+//    @Bean
+//    @ConfigurationProperties("spring.datasource.emergency")
+//    DataSource dsEmergency(){
+//        return DruidDataSourceBuilder.create().build();
+//    }
+
 
 
 
diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/DruidConfig.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/DruidConfig.java
new file mode 100644
index 0000000..065a578
--- /dev/null
+++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/DruidConfig.java
@@ -0,0 +1,165 @@
+package com.gkhy.safePlatform.config.database;
+
+import com.alibaba.druid.filter.stat.StatFilter;
+import com.alibaba.druid.support.http.StatViewServlet;
+import com.alibaba.druid.support.http.WebStatFilter;
+import com.alibaba.druid.wall.WallConfig;
+import com.alibaba.druid.wall.WallFilter;
+import com.atomikos.icatch.jta.UserTransactionImp;
+import com.atomikos.icatch.jta.UserTransactionManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.jta.atomikos.AtomikosDataSourceBean;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.boot.web.servlet.ServletRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.jta.JtaTransactionManager;
+
+import javax.sql.DataSource;
+import javax.transaction.UserTransaction;
+import java.util.Properties;
+
+/**
+ * Druid配置
+ *
+ *
+ */
+@Component
+@Configuration
+public class DruidConfig {
+
+    @Value("${spring.datasource.type}")
+    private String datasourceClass;
+
+    @Bean(name = "dsGoalManage")
+    @Primary
+    @Autowired
+    public DataSource dsAccount(Environment env) {
+        AtomikosDataSourceBean ds = new AtomikosDataSourceBean();
+        Properties prop = build(env, "spring.datasource.goalmanage.");
+//        ds.setXaDataSourceClassName("com.alibaba.druid.pool.xa.DruidXADataSource");
+        ds.setXaDataSourceClassName(datasourceClass);
+        ds.setUniqueResourceName("goalmanage");
+        ds.setPoolSize(5);
+        ds.setXaProperties(prop);
+        return ds;
+
+    }
+
+
+    @Autowired
+    @Primary
+    @Bean(name = "dsEmergency")
+    public AtomikosDataSourceBean dsDoublePrevent(Environment env) {
+        AtomikosDataSourceBean ds = new AtomikosDataSourceBean();
+        Properties prop = build(env, "spring.datasource.emergency.");
+//        ds.setXaDataSourceClassName("com.alibaba.druid.pool.xa.DruidXADataSource");
+        ds.setXaDataSourceClassName(datasourceClass);
+        ds.setUniqueResourceName("emergency");
+        ds.setPoolSize(5);
+        ds.setXaProperties(prop);
+        return ds;
+    }
+
+    @Autowired
+    @Primary
+    @Bean(name = "dsIncidentManage")
+    public AtomikosDataSourceBean dsSafeCheck(Environment env) {
+        AtomikosDataSourceBean ds = new AtomikosDataSourceBean();
+        Properties prop = build(env, "spring.datasource.incidentmanage.");
+        ds.setXaDataSourceClassName(datasourceClass);
+//        ds.setXaDataSourceClassName("com.alibaba.druid.pool.xa.DruidXADataSource");
+        ds.setUniqueResourceName("incidentmanage");
+        ds.setPoolSize(5);
+        ds.setXaProperties(prop);
+        return ds;
+    }
+
+
+    /**
+     * 注入事物管理器
+     * @return
+     */
+    @Bean(name = "xatx")
+    public JtaTransactionManager regTransactionManager () {
+        UserTransactionManager userTransactionManager = new UserTransactionManager();
+        UserTransaction userTransaction = new UserTransactionImp();
+        return new JtaTransactionManager(userTransaction, userTransactionManager);
+    }
+
+
+    private Properties build(Environment env, String prefix) {
+
+        Properties prop = new Properties();
+        prop.put("url", env.getProperty(prefix + "url"));
+        prop.put("username", env.getProperty(prefix + "username"));
+        prop.put("password", env.getProperty(prefix + "password"));
+        prop.put("driverClassName", env.getProperty(prefix + "driver-class-name", ""));
+//        prop.put("initialSize", env.getProperty(prefix + "initialSize", Integer.class));
+//        prop.put("maxActive", env.getProperty(prefix + "maxActive", Integer.class));
+//        prop.put("minIdle", env.getProperty(prefix + "minIdle", Integer.class));
+//        prop.put("maxWait", env.getProperty(prefix + "maxWait", Integer.class));
+//        prop.put("poolPreparedStatements", env.getProperty(prefix + "poolPreparedStatements", Boolean.class));
+//
+//        prop.put("maxPoolPreparedStatementPerConnectionSize",
+//                env.getProperty(prefix + "maxPoolPreparedStatementPerConnectionSize", Integer.class));
+//
+//        prop.put("maxPoolPreparedStatementPerConnectionSize",
+//                env.getProperty(prefix + "maxPoolPreparedStatementPerConnectionSize", Integer.class));
+//        prop.put("validationQuery", env.getProperty(prefix + "validationQuery"));
+//        prop.put("validationQueryTimeout", env.getProperty(prefix + "validationQueryTimeout", Integer.class));
+//        prop.put("testOnBorrow", env.getProperty(prefix + "testOnBorrow", Boolean.class));
+//        prop.put("testOnReturn", env.getProperty(prefix + "testOnReturn", Boolean.class));
+//        prop.put("testWhileIdle", env.getProperty(prefix + "testWhileIdle", Boolean.class));
+//        prop.put("timeBetweenEvictionRunsMillis",
+//                env.getProperty(prefix + "timeBetweenEvictionRunsMillis", Integer.class));
+//        prop.put("minEvictableIdleTimeMillis", env.getProperty(prefix + "minEvictableIdleTimeMillis", Integer.class));
+//        prop.put("filters", env.getProperty(prefix + "filters"));
+
+        return prop;
+    }
+
+//    @Bean
+    public ServletRegistrationBean druidServlet() {
+        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
+
+        //控制台管理用户,加入下面2行 进入druid后台就需要登录
+        //servletRegistrationBean.addInitParameter("loginUsername", "admin");
+        //servletRegistrationBean.addInitParameter("loginPassword", "admin");
+        return servletRegistrationBean;
+    }
+
+//    @Bean
+    public FilterRegistrationBean filterRegistrationBean() {
+        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
+        filterRegistrationBean.setFilter(new WebStatFilter());
+        filterRegistrationBean.addUrlPatterns("/*");
+        filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
+        filterRegistrationBean.addInitParameter("profileEnable", "true");
+        return filterRegistrationBean;
+    }
+
+//    @Bean
+    public StatFilter statFilter(){
+        StatFilter statFilter = new StatFilter();
+        statFilter.setLogSlowSql(true); //slowSqlMillis用来配置SQL慢的标准,执行时间超过slowSqlMillis的就是慢。
+        statFilter.setMergeSql(true); //SQL合并配置
+        statFilter.setSlowSqlMillis(1000);//slowSqlMillis的缺省值为3000,也就是3秒。
+        return statFilter;
+    }
+
+//    @Bean
+    public WallFilter wallFilter(){
+        WallFilter wallFilter = new WallFilter();
+        //允许执行多条SQL
+        WallConfig config = new WallConfig();
+        config.setMultiStatementAllow(true);
+        wallFilter.setConfig(config);
+        return wallFilter;
+    }
+
+}
\ No newline at end of file
diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigEmergency.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigEmergency.java
index 685c3a7..1424c46 100644
--- a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigEmergency.java
+++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigEmergency.java
@@ -23,7 +23,7 @@
 import java.util.Arrays;
 
 @Configuration
-@MapperScan(basePackages = {"com.gkhy.safePlatform.emergency","com.gkhy.safePlatform.emergency"},
+@MapperScan(basePackages = {"com.gkhy.safePlatform.emergency"},
         sqlSessionTemplateRef = "sqlTemplateEmergency",annotationClass =
         Repository.class)
 public class MyBatisConfigEmergency {
@@ -50,7 +50,7 @@
         ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
 
         //-------------------
-        Resource[] rs1 = resolver.getResources("classpath*:config/mapper/emergency/**Mapper.xml");
+        Resource[] rs1 = resolver.getResources("classpath*:config/mapper/emergency/**/**Mapper.xml");
 //        Resource[] rs2 = resolver.getResources("classpath*:config/mapper/goalManage/**Mapper.xml");
         ArrayList<Resource> resourceArrayList = new ArrayList<>(Arrays.asList(rs1));
 //        resourceArrayList.addAll(new ArrayList<>(Arrays.asList(rs2)));
diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigGoalManage.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigGoalManage.java
index cb05d9e..38148be 100644
--- a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigGoalManage.java
+++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigGoalManage.java
@@ -50,7 +50,7 @@
         ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
 
         //-------------------
-        Resource[] rs1 = resolver.getResources("classpath*:config/mapper/goalManage/**Mapper.xml");
+        Resource[] rs1 = resolver.getResources("classpath*:config/mapper/goalManage/**/**Mapper.xml");
 //        Resource[] rs2 = resolver.getResources("classpath*:config/mapper/goalManage/**Mapper.xml");
         ArrayList<Resource> resourceArrayList = new ArrayList<>(Arrays.asList(rs1));
 //        resourceArrayList.addAll(new ArrayList<>(Arrays.asList(rs2)));
diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigIncidentManage.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigIncidentManage.java
new file mode 100644
index 0000000..d372a3d
--- /dev/null
+++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/config/database/MyBatisConfigIncidentManage.java
@@ -0,0 +1,75 @@
+package com.gkhy.safePlatform.config.database;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
+import org.apache.ibatis.plugin.Interceptor;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.core.io.support.ResourcePatternResolver;
+import org.springframework.stereotype.Repository;
+
+import javax.sql.DataSource;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+@Configuration
+@MapperScan(basePackages = {"com.gkhy.safePlatform.incidentManage"},
+        sqlSessionTemplateRef = "sqlTemplateIncidentManage",annotationClass =
+        Repository.class)
+public class MyBatisConfigIncidentManage {
+
+    @Autowired
+    @Qualifier("dsIncidentManage")
+    DataSource dsIncidentManage;
+
+    @Autowired
+    private MybatisPlusInterceptor mybatisPlusInterceptor;
+
+    @Bean(name = "dataSourceIncidentManage")
+    @ConfigurationProperties(prefix = "spring.datasource.incidentmanage")
+    public DruidDataSource dataSourceIncidentManage(){
+        return DruidDataSourceBuilder.create().build();
+    }
+
+    @Bean(name = "sqlFactoryIncidentManage")
+    public SqlSessionFactory sqlSessionFactory(@Qualifier("dataSourceIncidentManage") DruidDataSource dataSource)
+            throws Exception
+    {
+        MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
+        factoryBean.setDataSource(dataSource);
+        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
+
+        //-------------------
+        Resource[] rs1 = resolver.getResources("classpath*:config/mapper/incidentManage/**/**Mapper.xml");
+//        Resource[] rs2 = resolver.getResources("classpath*:config/mapper/incidentManage/**Mapper.xml");
+        ArrayList<Resource> resourceArrayList = new ArrayList<>(Arrays.asList(rs1));
+//        resourceArrayList.addAll(new ArrayList<>(Arrays.asList(rs2)));
+        Resource[] resourceArray = new Resource[resourceArrayList.size()];
+        resourceArrayList.toArray(resourceArray);
+        factoryBean.setMapperLocations(resourceArray);
+        //-------------------
+
+//        factoryBean.setMapperLocations(resolver.getResources("classpath*:config/mapper/**/**Mapper.xml"));
+        //设置分页插件
+        Interceptor[] plugins = {mybatisPlusInterceptor};
+        factoryBean.setPlugins(plugins);
+        return factoryBean.getObject();
+    }
+
+    @Bean(name = "sqlTemplateIncidentManage")
+    public SqlSessionTemplate sqlSessionTemplate(@Qualifier("sqlFactoryIncidentManage") SqlSessionFactory sqlSessionFactory)
+    {
+        return new SqlSessionTemplate(sqlSessionFactory);
+    }
+
+}
diff --git a/safePlatfrom-out-web/src/main/resources/config/application-dev.yaml b/safePlatfrom-out-web/src/main/resources/config/application-dev.yaml
index 589bb65..fdbf22d 100644
--- a/safePlatfrom-out-web/src/main/resources/config/application-dev.yaml
+++ b/safePlatfrom-out-web/src/main/resources/config/application-dev.yaml
@@ -8,16 +8,25 @@
 
 # mysql
 spring:
+  jta:
+    transaction-manager-id: txManager
   datasource:
+    type: com.alibaba.druid.pool.xa.DruidXADataSource
     emergency:
       driver-class-name: com.mysql.cj.jdbc.Driver
-      url: jdbc:mysql://192.168.0.52:3306/safeplatform.emergency.dev?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
+      url: jdbc:mysql://192.168.0.52:3306/safeplatform.emergency.dev?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
       username: gkhy_dev_out_team
       password: Adsdf675T6AC7yga
       type: com.alibaba.druid.pool.DruidDataSource
     goalmanage:
       driver-class-name: com.mysql.cj.jdbc.Driver
-      url: jdbc:mysql://192.168.0.52:3306/safeplatform.goalmanage.dev?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
+      url: jdbc:mysql://192.168.0.52:3306/safeplatform.goalmanage.dev?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
+      username: gkhy_dev_out_team
+      password: Adsdf675T6AC7yga
+      type: com.alibaba.druid.pool.DruidDataSource
+    incidentmanage:
+      driver-class-name: com.mysql.cj.jdbc.Driver
+      url: jdbc:mysql://192.168.0.52:3306/safeplatform.incidentmanage.dev?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
       username: gkhy_dev_out_team
       password: Adsdf675T6AC7yga
       type: com.alibaba.druid.pool.DruidDataSource
@@ -27,14 +36,33 @@
     password: SEF98uvs98dUAUEF90Udssa
     database: 0           # Redis 数据库号,默认为 0
     timeout: 15000        # Redis 连接超时时间,单位:毫秒。
+    lettuce:
+      pool:
+        max-active: 4
+        max-idle: 4
     # 对应 RedisProperties.Jedis 内部类
     jedis:
       pool:
-        max-active: 8     # 连接池最大连接数,默认为 8 。使用负数表示没有限制    同一时间最大只能执行8条sql语句,每执行一条语句就会建立一个连接
-        max-idle: 8       # 默认连接数最大空闲的连接数,默认为 8 。使用负数表示没有限制。
+        max-active: 4     # 连接池最大连接数,默认为 8 。使用负数表示没有限制    同一时间最大只能执行8条sql语句,每执行一条语句就会建立一个连接
+        max-idle: 4       # 默认连接数最大空闲的连接数,默认为 8 。使用负数表示没有限制。
         min-idle: 0       # 默认连接池最小空闲的连接数,默认为 0 。允许设置 0 和 正数。
         max-wait: -1
-
+  cloud:
+    nacos:
+      discovery:
+        #        server-addr: nacos://121.239.169.27:18848?username=nacos&password=guokehongyu
+        #        server-addr: 192.168.0.52:8848?namespace=e07a2454-136b-4498-99eb-09dae3336ebe&username=gkhy_team_safeplatform_dev&password=nacosadmin
+        server-addr: http://192.168.0.52:8848
+        namespace: e07a2454-136b-4498-99eb-09dae3336ebe
+        username: gkhy_safeplatform_out
+        password: 9485uyJHISes09t
+        enabled: true
+        register-enabled: true
+      config:
+        server-addr: http://192.168.0.52:8848
+        namespace: e07a2454-136b-4498-99eb-09dae3336ebe
+        username: gkhy_safeplatform_out
+        password: 9485uyJHISes09t
 
 mybatis-plus:
   configuration:
@@ -59,6 +87,16 @@
     # 取消服务启动检查
     check: false
 
+rocketmq:
+  name-server: 192.168.0.52:9876
+  producer:
+    group: gkhy-safeplatform-dev
+    sendMessageTimeout: 300000
+  consumer:
+    group: gkhy-safeplatform-out-dev
+  topic:
+    demoTopic: gkhy-safeplatform-topic-demo
+
 minio:
   endPoint: 192.168.0.52
   port: 9001
diff --git a/safePlatfrom-out-web/src/main/resources/config/application-out-dev.yaml b/safePlatfrom-out-web/src/main/resources/config/application-out-dev.yaml
index bfed9b6..017d327 100644
--- a/safePlatfrom-out-web/src/main/resources/config/application-out-dev.yaml
+++ b/safePlatfrom-out-web/src/main/resources/config/application-out-dev.yaml
@@ -8,33 +8,61 @@
 
 # mysql
 spring:
+  jta:
+    transaction-manager-id: txManager
   datasource:
+    type: com.alibaba.druid.pool.xa.DruidXADataSource
     emergency:
       driver-class-name: com.mysql.cj.jdbc.Driver
-      url: jdbc:mysql://192.168.0.52:3306/safeplatform.emergency.dev?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
+      url: jdbc:mysql://192.168.0.52:3306/safeplatform.emergency.dev?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
       username: gkhy_dev_out_team
       password: Adsdf675T6AC7yga
       type: com.alibaba.druid.pool.DruidDataSource
     goalmanage:
       driver-class-name: com.mysql.cj.jdbc.Driver
-      url: jdbc:mysql://192.168.0.52:3306/safeplatform.goalmanage.dev?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
+      url: jdbc:mysql://192.168.0.52:3306/safeplatform.goalmanage.dev?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
+      username: gkhy_dev_out_team
+      password: Adsdf675T6AC7yga
+      type: com.alibaba.druid.pool.DruidDataSource
+    incidentmanage:
+      driver-class-name: com.mysql.cj.jdbc.Driver
+      url: jdbc:mysql://192.168.0.52:3306/safeplatform.incidentmanage.dev?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
       username: gkhy_dev_out_team
       password: Adsdf675T6AC7yga
       type: com.alibaba.druid.pool.DruidDataSource
   redis:
     host: 192.168.0.52
-    port: 6378
+    port: 6379
     password: SEF98uvs98dUAUEF90Udssa
     database: 0           # Redis 数据库号,默认为 0
     timeout: 15000        # Redis 连接超时时间,单位:毫秒。
+    lettuce:
+      pool:
+        max-active: 4
+        max-idle: 4
     # 对应 RedisProperties.Jedis 内部类
     jedis:
       pool:
-        max-active: 8     # 连接池最大连接数,默认为 8 。使用负数表示没有限制    同一时间最大只能执行8条sql语句,每执行一条语句就会建立一个连接
-        max-idle: 8       # 默认连接数最大空闲的连接数,默认为 8 。使用负数表示没有限制。
+        max-active: 4     # 连接池最大连接数,默认为 8 。使用负数表示没有限制    同一时间最大只能执行8条sql语句,每执行一条语句就会建立一个连接
+        max-idle: 4       # 默认连接数最大空闲的连接数,默认为 8 。使用负数表示没有限制。
         min-idle: 0       # 默认连接池最小空闲的连接数,默认为 0 。允许设置 0 和 正数。
         max-wait: -1
-
+  cloud:
+    nacos:
+      discovery:
+        #        server-addr: nacos://121.239.169.27:18848?username=nacos&password=guokehongyu
+        #        server-addr: 192.168.0.52:8848?namespace=e07a2454-136b-4498-99eb-09dae3336ebe&username=gkhy_team_safeplatform_dev&password=nacosadmin
+        server-addr: http://192.168.0.52:8848
+        namespace: 11ee8fe9-ea10-4f63-9752-c33c7ac36e36
+        username: gkhy_safeplatform_out
+        password: 9485uyJHISes09t
+        enabled: true
+        register-enabled: true
+      config:
+        server-addr: http://192.168.0.52:8848
+        namespace: 11ee8fe9-ea10-4f63-9752-c33c7ac36e36
+        username: gkhy_safeplatform_out
+        password: 9485uyJHISes09t
 
 mybatis-plus:
   configuration:
@@ -59,6 +87,16 @@
     # 取消服务启动检查
     check: false
 
+rocketmq:
+  name-server: 192.168.0.52:9876
+  producer:
+    group: gkhy-safeplatform-dev
+    sendMessageTimeout: 300000
+  consumer:
+    group: gkhy-safeplatform-out-dev
+  topic:
+    demoTopic: gkhy-safeplatform-topic-demo
+
 minio:
   endPoint: 192.168.0.52
   port: 9001
diff --git a/safePlatfrom-out-web/src/main/resources/config/application.yaml b/safePlatfrom-out-web/src/main/resources/config/application.yaml
index cbaaeea..ed41ebd 100644
--- a/safePlatfrom-out-web/src/main/resources/config/application.yaml
+++ b/safePlatfrom-out-web/src/main/resources/config/application.yaml
@@ -5,10 +5,12 @@
 #    active: prod
     active: out-dev
 
-mybatis-plus:
-  mapper-locations: classpath:config/mapper/**/*.xml
+#mybatis-plus:
+#  mapper-locations: classpath:config/mapper/**/*.xml
 
 logging:
   config: classpath:config/log/log4j2.xml
   level:
     com.gkhy: info
+    com.atomikos: ERROR
+    javax.transaction: ERROR

--
Gitblit v1.9.2