Răsfoiți Sursa

1.mqtt项目搭建集成
2.测试验证tdengine

lengfaqiang 2 ani în urmă
părinte
comite
e156f89a25
42 a modificat fișierele cu 1155 adăugiri și 381 ștergeri
  1. BIN
      slope-common/slope-common-excel/src/main/resources/excel/商品主档信息导入模板.xlsx
  2. 15 4
      slope-common/slope-common-stream/pom.xml
  3. 2 0
      slope-common/slope-common-stream/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  4. 4 4
      slope-modules-api/pom.xml
  5. 0 3
      slope-modules-api/slope-crossService-api/target/maven-archiver/pom.properties
  6. 5 5
      slope-modules-api/slope-detection-api/pom.xml
  7. 4 0
      slope-modules/pom.xml
  8. 7 0
      slope-modules/slope-detection/pom.xml
  9. 0 19
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/DB.java
  10. 0 21
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/DynamicDataSource.java
  11. 0 40
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/DynamicDataSourceAspect.java
  12. 0 35
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/DynamicDataSourceSwitcher.java
  13. 39 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/MqSendMessageGateWay.java
  14. 207 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/MqttConfig.java
  15. 0 53
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/MultipleDataSourceConfig.java
  16. 18 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/consumer/MqttCallbackHandler.java
  17. 49 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/MqttController.java
  18. 19 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/KwsDeviceIntegrationMapper.java
  19. 19 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/KwsIntegrationMapper.java
  20. 3 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsAlarm.java
  21. 18 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDevice.java
  22. 61 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceIntegration.java
  23. 3 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceModel.java
  24. 4 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceModelPart.java
  25. 4 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceReference.java
  26. 3 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceRelation.java
  27. 5 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDict.java
  28. 5 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDictType.java
  29. 10 92
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsIntegration.java
  30. 12 10
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsLog.java
  31. 3 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsProject.java
  32. 20 18
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsProjectArea.java
  33. 4 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsProjectDevice.java
  34. 45 42
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsReportData.java
  35. 25 22
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsReportTemplate.java
  36. 3 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsThreshold.java
  37. 15 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/MqttMsg.java
  38. 137 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/utils/SpringUtils.java
  39. 25 0
      slope-modules/slope-detection/src/main/resources/bootstrap-dev.yml
  40. 25 0
      slope-modules/slope-detection/src/main/resources/bootstrap-lfdc.yml
  41. 151 0
      slope-modules/slope-detection/src/main/resources/mapper/KwsDeviceIntegrationMapper.xml
  42. 186 0
      slope-modules/slope-detection/src/main/resources/mapper/KwsIntegrationMapper.xml

BIN
slope-common/slope-common-excel/src/main/resources/excel/商品主档信息导入模板.xlsx


+ 15 - 4
slope-common/slope-common-stream/pom.xml

@@ -30,15 +30,26 @@
             <artifactId>spring-cloud-stream</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.cloud</groupId>-->
+<!--            <artifactId>spring-cloud-starter-stream-rabbit</artifactId>-->
+<!--        </dependency>-->
 
         <dependency>
             <groupId>com.alibaba.cloud</groupId>
             <artifactId>spring-cloud-alicloud-sms</artifactId>
         </dependency>
 
+        <!-- mqtt -->
+        <dependency>
+            <groupId>org.springframework.integration</groupId>
+            <artifactId>spring-integration-mqtt</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.eclipse.paho</groupId>
+            <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
+            <version>1.2.2</version>
+        </dependency>
     </dependencies>
 </project>

+ 2 - 0
slope-common/slope-common-stream/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -0,0 +1,2 @@
+com.sckw.redis.config.RedissonConfig
+com.sckw.redis.config.RedisLockUtil

+ 4 - 4
slope-modules-api/pom.xml

@@ -18,10 +18,10 @@
 
     <artifactId>slope-modules-api</artifactId>
     <packaging>pom</packaging>
-<!--    <modules>-->
-<!--        <module>slope-modules-bom</module>-->
-<!--        <module>slope-crossService-api</module>-->
-<!--    </modules>-->
+    <modules>
+        <module>slope-modules-bom</module>
+        <module>slope-detection-api</module>
+    </modules>
 
     <properties>
         <maven.compiler.source>17</maven.compiler.source>

+ 0 - 3
slope-modules-api/slope-crossService-api/target/maven-archiver/pom.properties

@@ -1,3 +0,0 @@
-artifactId=slope-crossService-api
-groupId=com.sckw
-version=1.0.0

+ 5 - 5
slope-modules-api/slope-crossService-api/pom.xml → slope-modules-api/slope-detection-api/pom.xml

@@ -9,7 +9,7 @@
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>slope-crossService-api</artifactId>
+    <artifactId>slope-detection-api</artifactId>
 
     <properties>
         <maven.compiler.source>17</maven.compiler.source>
@@ -22,10 +22,10 @@
             <artifactId>lombok</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-openfeign-core</artifactId>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.cloud</groupId>-->
+<!--            <artifactId>spring-cloud-openfeign-core</artifactId>-->
+<!--        </dependency>-->
 
 <!--        <dependency>-->
 <!--            <groupId>com.sckw</groupId>-->

+ 4 - 0
slope-modules/pom.xml

@@ -11,6 +11,10 @@
 
     <artifactId>slope-modules</artifactId>
     <packaging>pom</packaging>
+    <modules>
+<!--        <module>slope-message</module>-->
+        <module>slope-detection</module>
+    </modules>
     <properties>
         <maven.compiler.source>17</maven.compiler.source>
         <maven.compiler.target>17</maven.compiler.target>

+ 7 - 0
slope-modules/slope-detection/pom.xml

@@ -49,6 +49,13 @@
             <artifactId>slope-common-tdengine</artifactId>
             <version>1.0.0</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>slope-common-stream</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-web</artifactId>

+ 0 - 19
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/DB.java

@@ -1,19 +0,0 @@
-//package com.sckw.slope.detection.common.config;
-//
-//import java.lang.annotation.ElementType;
-//import java.lang.annotation.Retention;
-//import java.lang.annotation.RetentionPolicy;
-//import java.lang.annotation.Target;
-//
-///**
-// * @author lfdc
-// * @description
-// * @date 2023-10-24 15:10:59
-// */
-//
-//@Retention(RetentionPolicy.RUNTIME)
-//@Target({ElementType.TYPE, ElementType.METHOD})
-//public @interface DB{
-//    String value() default "master";
-//
-//}

+ 0 - 21
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/DynamicDataSource.java

@@ -1,21 +0,0 @@
-//package com.sckw.slope.detection.common.config;
-//
-//import lombok.extern.slf4j.Slf4j;
-//import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
-//
-///**
-// * @author lfdc
-// * @description
-// * @date 2023-10-24 16:10:00
-// */
-//@Slf4j
-//public class DynamicDataSource extends AbstractRoutingDataSource {
-//
-//
-//    @Override
-//    protected Object determineCurrentLookupKey() {
-//        log.info("------------------当前数据源 {}", DynamicDataSourceSwitcher.getDataSource());
-//        return DynamicDataSourceSwitcher.getDataSource();
-//    }
-//
-//}

+ 0 - 40
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/DynamicDataSourceAspect.java

@@ -1,40 +0,0 @@
-//package com.sckw.slope.detection.common.config;
-//
-//import org.aspectj.lang.annotation.After;
-//import org.aspectj.lang.annotation.Aspect;
-//import org.aspectj.lang.annotation.Before;
-//import org.aspectj.lang.annotation.Pointcut;
-//import org.springframework.core.annotation.Order;
-//import org.springframework.stereotype.Component;
-//
-///**
-// * @author lfdc
-// * @description 切换数据源 选择非master数据源时, 通过切面切换数据源
-// * @date 2023-10-24 16:10:03
-// */
-//@Aspect
-//@Component
-//@Order(1)
-//public class DynamicDataSourceAspect {
-//    /**
-//     * 切入点只对@Service注解的类上的@Db注解生效 , 无注解 , 默认使用master
-//     * @param db
-//     */
-//    @Pointcut(value="@within(org.springframework.stereotype.Service) && @annotation(db)" )
-//    public void dynamicDataSourcePointCut(DB db){}
-//
-//    @Before(value = "dynamicDataSourcePointCut(db)")
-//    public void switchDataSource(DB db) {
-//        DynamicDataSourceSwitcher.setDataSource(db.value());
-//    }
-//
-//    /**
-//     * 切点执行完后 切换成主数据库
-//     * @param db
-//     */
-//    @After(value="dynamicDataSourcePointCut(db)")
-//    public void after(DB db){
-//        DynamicDataSourceSwitcher.cleanDataSource();
-//    }
-//
-//}

+ 0 - 35
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/DynamicDataSourceSwitcher.java

@@ -1,35 +0,0 @@
-//package com.sckw.slope.detection.common.config;
-//
-//import com.sckw.core.utils.StringUtils;
-//import lombok.extern.slf4j.Slf4j;
-//
-///**
-// * @author lfdc
-// * @description
-// * @date 2023-10-24 15:10:59
-// */
-//@Slf4j
-//public class DynamicDataSourceSwitcher {
-//
-//
-//    public static final String Mater = "master";
-//    public static final String Slave1 = "td";
-//
-//    private static final ThreadLocal<String> contextHolder = new ThreadLocal<>();
-//
-//    public static void setDataSource(String name) {
-//        log.info("-------- 设置数据源数据源为 :{} ", name);
-//        contextHolder.set(name);
-//    }
-//
-//    public static String getDataSource() {
-//        if (StringUtils.isEmpty(contextHolder.get())) {
-//            setDataSource(Mater);
-//        }
-//        return contextHolder.get();
-//    }
-//
-//    public static void cleanDataSource() {
-//        contextHolder.remove();
-//    }
-//}

+ 39 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/MqSendMessageGateWay.java

@@ -0,0 +1,39 @@
+package com.sckw.slope.detection.common.config;
+
+import org.springframework.integration.annotation.MessagingGateway;
+import org.springframework.integration.mqtt.support.MqttHeaders;
+import org.springframework.messaging.handler.annotation.Header;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2023-10-26 11:10:01
+ */
+@Component
+@MessagingGateway(defaultRequestChannel = MqttConfig.CHANNEL_NAME_OUT)
+public interface MqSendMessageGateWay {
+    /**
+     * 默认的消息机制
+     *
+     * @param data
+     */
+    void sendToMqtt(String data);
+
+    /**
+     * 发送消息 向mqtt指定topic发送消息
+     *
+     * @param topic
+     * @param payload
+     */
+    void sendToMqtt(@Header(MqttHeaders.TOPIC) String topic, String payload);
+
+    /**
+     * 发送消息 向mqtt指定topic发送消息
+     *
+     * @param topic 主题
+     * @param qos   机制
+     * @param payload   消息
+     */
+    void sendToMqtt(@Header(MqttHeaders.TOPIC) String topic, @Header(MqttHeaders.QOS) int qos, String payload);
+}

+ 207 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/MqttConfig.java

@@ -0,0 +1,207 @@
+package com.sckw.slope.detection.common.config;
+
+import com.sckw.slope.detection.consumer.MqttCallbackHandler;
+import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.integration.annotation.ServiceActivator;
+import org.springframework.integration.channel.DirectChannel;
+import org.springframework.integration.core.MessageProducer;
+import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory;
+import org.springframework.integration.mqtt.core.MqttPahoClientFactory;
+import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter;
+import org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler;
+import org.springframework.integration.mqtt.support.DefaultPahoMessageConverter;
+import org.springframework.messaging.MessageChannel;
+import org.springframework.messaging.MessageHandler;
+
+/**
+ * @author lfdc
+ * @description MQTT配置,生产者
+ * @date 2023-10-26 10:10:59
+ */
+@Configuration
+public class MqttConfig {
+
+    private static final byte[] WILL_DATA;
+
+    static {
+        WILL_DATA = "offline".getBytes();
+    }
+
+    /**
+     * mqtt订阅者使用信道名称
+     */
+    public static final String CHANNEL_NAME_IN = "mqttInboundChannel";
+    /**
+     * mqtt发布者信道名称
+     */
+    public static final String CHANNEL_NAME_OUT = "mqttOutboundChannel";
+    /**
+     * mqtt发送者用户名
+     */
+    @Value("${mqtt.send.username}")
+    private String username;
+
+    /**
+     * mqtt发送者密码
+     */
+    @Value("${mqtt.send.password}")
+    private String password;
+
+    /**
+     * mqtt发送者url
+     */
+    @Value("${mqtt.send.url}")
+    private String hostUrl;
+    /**
+     * mqtt发送者客户端id
+     */
+    @Value("${mqtt.send.clientId}")
+    private String clientId;
+    /**
+     * mqtt发送者主题
+     */
+    @Value("${mqtt.send.topic}")
+    private String msgTopic;
+
+    /**
+     * mqtt发送者主题
+     */
+    @Value("${mqtt.receive.topic}")
+    private String msgReceiveTopic;
+
+    /**
+     * mqtt发送者超时时间
+     */
+    @Value("${mqtt.send.completionTimeout}")
+    private int completionTimeout;
+
+    @Value("${mqtt.send.keepAliveInterval}")
+    private int keepAliveInterval;
+
+    @Value("${mqtt.send.connectionTimeout}")
+    private int connectionTimeout;
+
+    @Autowired
+    private MqttCallbackHandler mqttCallbackHandler;
+
+
+    /**
+     * 新建MqttConnectionOptionsBean  MQTT连接器选项
+     * @return
+     */
+    @Bean
+    public MqttConnectOptions getSenderMqttConnectOptions() {
+        MqttConnectOptions options = new MqttConnectOptions();
+        // 设置连接的用户名
+        if (!username.trim().equals("")) {
+            //将用户名去掉前后空格
+            options.setUserName(username);
+        }
+        // 设置连接的密码
+        options.setPassword(password.toCharArray());
+        // 转化连接的url地址
+        String[] uris = {hostUrl};
+        // 设置连接的地址
+        options.setServerURIs(uris);
+        // 设置超时时间 单位为秒
+        options.setConnectionTimeout(completionTimeout);
+        // 设置会话心跳时间 单位为秒 服务器会每隔1.5*20秒的时间向客户端发送心跳判断客户端是否在线
+        // 但这个方法并没有重连的机制
+        options.setKeepAliveInterval(keepAliveInterval);
+        // 设置“遗嘱”消息的话题,若客户端与服务器之间的连接意外中断,服务器将发布客户端的“遗嘱”消息。
+        //设置超时时间
+        options.setConnectionTimeout(connectionTimeout);
+        options.setCleanSession(true);
+        options.setAutomaticReconnect(true);
+        return options;
+    }
+
+    /**
+     * 创建MqttPathClientFactoryBean
+     */
+    @Bean
+    public MqttPahoClientFactory senderMqttClientFactory() {
+        //创建mqtt客户端工厂
+        DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory();
+        //设置mqtt的连接设置
+        factory.setConnectionOptions(getSenderMqttConnectOptions());
+        return factory;
+    }
+
+    /**
+     * 发布者-MQTT信息通道(生产者)
+     */
+    @Bean(name = CHANNEL_NAME_OUT)
+    public MessageChannel mqttOutboundChannel() {
+        return new DirectChannel();
+    }
+
+
+    /**
+     * 发布者-MQTT消息处理器(生产者)  将channel绑定到MqttClientFactory上
+     *
+     * @return {@link org.springframework.messaging.MessageHandler}
+     */
+    @Bean
+    @ServiceActivator(inputChannel = CHANNEL_NAME_OUT)
+    public MessageHandler mqttOutbound() {
+        //创建消息处理器
+        MqttPahoMessageHandler messageHandler = new MqttPahoMessageHandler(
+                clientId + "_pub",
+                senderMqttClientFactory());
+        //设置消息处理类型为异步
+        messageHandler.setAsync(true);
+        //设置消息的默认主题
+        messageHandler.setDefaultTopic(msgTopic);
+        messageHandler.setDefaultRetained(false);
+        //1.重新连接MQTT服务时,不需要接收该主题最新消息,设置retained为false;
+        //2.重新连接MQTT服务时,需要接收该主题最新消息,设置retained为true;
+        return messageHandler;
+    }
+
+
+    /************                             消费者,订阅者的消费信息                               *****/
+
+    /**
+     * MQTT信息通道(消费者)
+     */
+    @Bean(name = CHANNEL_NAME_IN)
+    public MessageChannel mqttInboundChannel() {
+        return new DirectChannel();
+    }
+
+    /**
+     * MQTT消息订阅绑定(消费者)
+     */
+    @Bean
+    public MessageProducer inbound() {
+//        System.out.println("topics:" + msgTopic);
+        // 可以同时消费(订阅)多个Topic
+        MqttPahoMessageDrivenChannelAdapter adapter =
+                new MqttPahoMessageDrivenChannelAdapter(
+                        clientId + "_sub", senderMqttClientFactory(), msgReceiveTopic.split(","));
+        adapter.setCompletionTimeout(5000);
+        adapter.setConverter(new DefaultPahoMessageConverter());
+        adapter.setQos(0);
+        // 设置订阅通道
+        adapter.setOutputChannel(mqttInboundChannel());
+        return adapter;
+    }
+
+    /**
+     * MQTT消息处理器(消费者)
+     */
+    @Bean
+    @ServiceActivator(inputChannel = CHANNEL_NAME_IN)
+    public MessageHandler handler() {
+        return message -> {
+            String topic = message.getHeaders().get("mqtt_receivedTopic").toString();
+            String payload = message.getPayload().toString();
+            mqttCallbackHandler.handle(topic, payload);
+        };
+    }
+}

+ 0 - 53
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/MultipleDataSourceConfig.java

@@ -1,53 +0,0 @@
-//package com.sckw.slope.detection.common.config;
-//
-//import com.alibaba.druid.pool.DruidDataSource;
-//import lombok.extern.slf4j.Slf4j;
-//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.Primary;
-//import org.springframework.stereotype.Component;
-//
-//import javax.sql.DataSource;
-//import java.util.HashMap;
-//import java.util.Map;
-//
-///**
-// * @author lfdc
-// * @description
-// * @date 2023-10-24 16:10:02
-// */
-//@Slf4j
-//@Component
-//public class MultipleDataSourceConfig {
-//    @Bean("master")
-//    @ConfigurationProperties(prefix = "spring.datasource.dynamic.master")
-//    public DataSource createMasterDataSource(){
-//        return new DruidDataSource();
-//    }
-//
-//    @Bean("td")
-//    @ConfigurationProperties(prefix = "spring.datasource.dynamic.td")
-//    public DataSource createSlave1DataSource(){
-//        return new DruidDataSource();
-//    }
-//
-//    /**
-//     * 设置动态数据源,通过@Primary 来确定主DataSource
-//     * @return
-//     */
-//    @Bean
-//    @Primary
-//    public DataSource createDynamicDataSource(@Qualifier("master") DataSource master, @Qualifier("td") DataSource slave1){
-//        DynamicDataSource dynamicDataSource = new DynamicDataSource();
-//        //设置默认数据源
-//        dynamicDataSource.setDefaultTargetDataSource(master);
-//        //配置多数据源
-//        Map<Object, Object> map = new HashMap<>();
-//        map.put("master",master);
-//        map.put("td",slave1);
-//        dynamicDataSource.setTargetDataSources(map);
-//        return  dynamicDataSource;
-//    }
-//
-//}

+ 18 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/consumer/MqttCallbackHandler.java

@@ -0,0 +1,18 @@
+package com.sckw.slope.detection.consumer;
+
+import org.springframework.stereotype.Service;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2023-10-26 08:10:45
+ */
+@Service
+public class MqttCallbackHandler {
+    public void handle(String topic, String payload) {
+        System.out.println(topic);
+        // 根据topic分别进行消息处理。
+        System.out.println("MqttCallbackHandle:" + topic + "|" + payload);
+    }
+}
+

+ 49 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/MqttController.java

@@ -0,0 +1,49 @@
+package com.sckw.slope.detection.controller;
+
+import com.sckw.slope.detection.common.config.MqSendMessageGateWay;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2023-10-25 17:10:36
+ */
+@RestController
+@RequestMapping("/sun/mqtt")
+public class MqttController {
+
+    @Autowired
+    private MqSendMessageGateWay mqSendMessageGateWay;
+
+    @RequestMapping("/send")
+    @ResponseBody
+    private ResponseEntity<String> send() {
+        String data = "我是springboot发送的数据";
+        System.out.println(data);
+        mqSendMessageGateWay.sendToMqtt(data);
+        return new ResponseEntity<>("OK", HttpStatus.OK);
+    }
+
+
+
+    /**
+     * 动态增加主题
+     *
+     * @param
+     * @param
+     */
+    @ResponseBody
+    @RequestMapping("/sendToTopic")
+    private ResponseEntity<String> sendToTopic() {
+        String topic = "sharjeck/ai/test/out";
+        String data = "这是出的主题";
+        System.out.println(data);
+        mqSendMessageGateWay.sendToMqtt(topic, data);
+        return new ResponseEntity<>("OK", HttpStatus.OK);
+    }
+}

+ 19 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/KwsDeviceIntegrationMapper.java

@@ -0,0 +1,19 @@
+package com.sckw.slope.detection.dao;
+
+import com.sckw.slope.detection.model.dos.mysql.KwsDeviceIntegration;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface KwsDeviceIntegrationMapper {
+    int deleteByPrimaryKey(Long id);
+
+    int insert(KwsDeviceIntegration record);
+
+    int insertSelective(KwsDeviceIntegration record);
+
+    KwsDeviceIntegration selectByPrimaryKey(Long id);
+
+    int updateByPrimaryKeySelective(KwsDeviceIntegration record);
+
+    int updateByPrimaryKey(KwsDeviceIntegration record);
+}

+ 19 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/KwsIntegrationMapper.java

@@ -0,0 +1,19 @@
+package com.sckw.slope.detection.dao;
+
+import com.sckw.slope.detection.model.dos.mysql.KwsIntegration;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface KwsIntegrationMapper {
+    int deleteByPrimaryKey(Long id);
+
+    int insert(KwsIntegration record);
+
+    int insertSelective(KwsIntegration record);
+
+    KwsIntegration selectByPrimaryKey(Long id);
+
+    int updateByPrimaryKeySelective(KwsIntegration record);
+
+    int updateByPrimaryKey(KwsIntegration record);
+}

+ 3 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsAlarm.java

@@ -7,7 +7,9 @@ import java.io.Serializable;
 import java.util.Date;
 
 /**
- * 告警表(存TD)
+ * @author lfdc
+ * @description 告警表(存TD)
+ * @date 2023-10-25 13:46:12
  */
 @Data
 @TableName("kws_alarm")

+ 18 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDevice.java

@@ -9,7 +9,9 @@ import java.time.LocalDateTime;
 import java.util.Date;
 
 /**
- * 设备
+ * @author lfdc
+ * @description 设备
+ * @date 2023-10-25 13:46:12
  */
 @Data
 @TableName("kws_device")
@@ -92,6 +94,21 @@ public class KwsDevice implements Serializable {
     @TableLogic(value = "0")
     private int delFlag;
 
+    /**
+     * 逻辑经度(测点布设的值)
+     */
+    private String logicLng;
+
+    /**
+     * 逻辑纬度(测点布设的值)
+     */
+    private String logicLat;
+
+    /**
+     * 逻辑海拔(测点布设的值)
+     */
+    private String logicAlt;
+
     private static final long serialVersionUID = 1L;
 
 }

+ 61 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceIntegration.java

@@ -0,0 +1,61 @@
+package com.sckw.slope.detection.model.dos.mysql;
+
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+    * 设备-集成要素关联关系表
+    */
+@Data
+@TableName("kws_device_integration")
+public class KwsDeviceIntegration implements Serializable {
+    private Long id;
+
+    /**
+    * 设备id
+    */
+    private Long deviceId;
+
+    /**
+    * 集成要素id
+    */
+    private Long integrationId;
+
+    /**
+    * 状态
+    */
+    private Byte status;
+
+    /**
+    * 创建人
+    */
+    private Long createBy;
+
+    /**
+    * 创建时间
+    */
+    private Date createTime;
+
+    /**
+    * 修改人
+    */
+    private Long updateBy;
+
+    /**
+    * 修改时间
+    */
+    private Date updateTime;
+
+    /**
+    * 删除标识
+    */
+    @TableLogic(value = "0")
+    private int delFlag;
+
+    private static final long serialVersionUID = 1L;
+
+}

+ 3 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceModel.java

@@ -7,7 +7,9 @@ import java.io.Serializable;
 import java.util.Date;
 
 /**
- * 设备型号
+ * @author lfdc
+ * @description 设备型号
+ * @date 2023-10-25 13:46:12
  */
 @Data
 @TableName("kws_device_model")

+ 4 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceModelPart.java

@@ -7,8 +7,10 @@ import java.io.Serializable;
 import java.util.Date;
 
 /**
-    * 设备-要素关联表
-    */
+ * @author lfdc
+ * @description 设备-要素关联表
+ * @date 2023-10-25 13:46:12
+ */
 @TableName("kws_device_model_part")
 public class KwsDeviceModelPart implements Serializable {
     private Long id;

+ 4 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceReference.java

@@ -10,8 +10,10 @@ import java.time.LocalDateTime;
 import java.util.Date;
 
 /**
-    * 设备基准参数(不允许修改,只能新增,软删除以前的数据)
-    */
+ * @author lfdc
+ * @description 设备基准参数(不允许修改,只能新增,软删除以前的数据)
+ * @date 2023-10-25 13:46:12
+ */
 @Data
 @TableName("kws_device_reference")
 public class KwsDeviceReference implements Serializable {

+ 3 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceRelation.java

@@ -7,7 +7,9 @@ import java.io.Serializable;
 import java.util.Date;
 
 /**
- * 设备关联信息(检测设备和视频设备的关联)
+ * @author lfdc
+ * @description 设备关联信息(检测设备和视频设备的关联)
+ * @date 2023-10-25 13:46:12
  */
 @Data
 @TableName("kws_device_relation")

+ 5 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDict.java

@@ -5,7 +5,11 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.util.Date;
-
+/**
+ * @author lfdc
+ * @description 字典表
+ * @date 2023-10-25 13:46:12
+ */
 @Data
 @TableName("kws_dict")
 public class KwsDict implements Serializable {

+ 5 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDictType.java

@@ -5,6 +5,11 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.util.Date;
+/**
+ * @author lfdc
+ * @description 字典表
+ * @date 2023-10-25 13:46:12
+ */
 @Data
 @TableName("kws_dict_type")
 public class KwsDictType implements Serializable {

+ 10 - 92
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsIntegration.java

@@ -14,11 +14,6 @@ import java.util.Date;
 public class KwsIntegration implements Serializable {
     private Long id;
 
-    /**
-     * 设备id
-     */
-    private Long deviceId;
-
     /**
      * 集成分析方案名(字典value)
      */
@@ -34,6 +29,16 @@ public class KwsIntegration implements Serializable {
      */
     private String unit;
 
+    /**
+     * 公式(字典value)
+     */
+    private String formula;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
     /**
      * 状态
      */
@@ -66,91 +71,4 @@ public class KwsIntegration implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public Long getDeviceId() {
-        return deviceId;
-    }
-
-    public void setDeviceId(Long deviceId) {
-        this.deviceId = deviceId;
-    }
-
-    public String getIntegrationName() {
-        return integrationName;
-    }
-
-    public void setIntegrationName(String integrationName) {
-        this.integrationName = integrationName;
-    }
-
-    public String getPartNames() {
-        return partNames;
-    }
-
-    public void setPartNames(String partNames) {
-        this.partNames = partNames;
-    }
-
-    public String getUnit() {
-        return unit;
-    }
-
-    public void setUnit(String unit) {
-        this.unit = unit;
-    }
-
-    public Byte getStatus() {
-        return status;
-    }
-
-    public void setStatus(Byte status) {
-        this.status = status;
-    }
-
-    public Long getCreateBy() {
-        return createBy;
-    }
-
-    public void setCreateBy(Long createBy) {
-        this.createBy = createBy;
-    }
-
-    public Date getCreateTime() {
-        return createTime;
-    }
-
-    public void setCreateTime(Date createTime) {
-        this.createTime = createTime;
-    }
-
-    public Long getUpdateBy() {
-        return updateBy;
-    }
-
-    public void setUpdateBy(Long updateBy) {
-        this.updateBy = updateBy;
-    }
-
-    public Date getUpdateTime() {
-        return updateTime;
-    }
-
-    public void setUpdateTime(Date updateTime) {
-        this.updateTime = updateTime;
-    }
-
-    public Byte getDelFlag() {
-        return delFlag;
-    }
-
-    public void setDelFlag(Byte delFlag) {
-        this.delFlag = delFlag;
-    }
 }

+ 12 - 10
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsLog.java

@@ -7,31 +7,33 @@ import java.io.Serializable;
 import java.util.Date;
 
 /**
-    * 操作日志表
-    */
+ * @author lfdc
+ * @description 操作日志表
+ * @date 2023-10-25 13:46:12
+ */
 @Data
 @TableName("kws_log")
 public class KwsLog implements Serializable {
     private Long id;
 
     /**
-    * 操作类型
-    */
+     * 操作类型
+     */
     private String type;
 
     /**
-    * 操作内容
-    */
+     * 操作内容
+     */
     private String content;
 
     /**
-    * 操作人
-    */
+     * 操作人
+     */
     private Long createBy;
 
     /**
-    * 操作时间
-    */
+     * 操作时间
+     */
     private Date createTime;
 
     private static final long serialVersionUID = 1L;

+ 3 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsProject.java

@@ -8,7 +8,9 @@ import java.io.Serializable;
 import java.util.Date;
 
 /**
- * 矿山项目
+ * @author lfdc
+ * @description 矿山项目
+ * @date 2023-10-25 13:46:12
  */
 @Data
 @TableName("kws_project")

+ 20 - 18
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsProjectArea.java

@@ -8,51 +8,53 @@ import java.math.BigDecimal;
 import java.util.Date;
 
 /**
-    * 项目-区域表
-    */
+ * @author lfdc
+ * @description 项目-区域表
+ * @date 2023-10-25 13:46:12
+ */
 @Data
 @TableName("kws_project_area")
 public class KwsProjectArea implements Serializable {
     private Long id;
 
     /**
-    * 矿山项目id
-    */
+     * 矿山项目id
+     */
     private Long projectId;
 
     /**
-    * 选中区域
-    */
+     * 选中区域
+     */
     private String fence;
 
     /**
-    * 面积
-    */
+     * 面积
+     */
     private BigDecimal area;
 
     /**
-    * 创建人
-    */
+     * 创建人
+     */
     private Long createBy;
 
     /**
-    * 创建时间
-    */
+     * 创建时间
+     */
     private Date createTime;
 
     /**
-    * 修改人
-    */
+     * 修改人
+     */
     private Long updateBy;
 
     /**
-    * 修改时间
-    */
+     * 修改时间
+     */
     private Date updateTime;
 
     /**
-    * 删除标识
-    */
+     * 删除标识
+     */
     private Byte delFlag;
 
     private static final long serialVersionUID = 1L;

+ 4 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsProjectDevice.java

@@ -6,8 +6,11 @@ import lombok.Data;
 import java.io.Serializable;
 import java.util.Date;
 
+
 /**
- * 矿山项目、设备关联关系
+ * @author lfdc
+ * @description 矿山项目、设备关联关系
+ * @date 2023-10-25 13:46:12
  */
 @Data
 @TableName("kws_project_device")

+ 45 - 42
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsReportData.java

@@ -6,112 +6,115 @@ import lombok.Data;
 import java.io.Serializable;
 import java.util.Date;
 
+
 /**
-    * 报表数据
-    */
+ * @author lfdc
+ * @description 报表数据
+ * @date 2023-10-25 13:46:12
+ */
 @Data
 @TableName("kws_report_data")
 public class KwsReportData implements Serializable {
     private Long id;
 
     /**
-    * 报表模板id 
-    */
+     * 报表模板id
+     */
     private Long templateId;
 
     /**
-    * 矿山项目id
-    */
+     * 矿山项目id
+     */
     private Long projectId;
 
     /**
-    * 矿山项目名
-    */
+     * 矿山项目名
+     */
     private String projectName;
 
     /**
-    * 设备id
-    */
+     * 设备id
+     */
     private Long deviceId;
 
     /**
-    * 设备名
-    */
+     * 设备名
+     */
     private String deviceName;
 
     /**
-    * 设备sncode
-    */
+     * 设备sncode
+     */
     private String snCode;
 
     /**
-    * 设备别名(单元名称)
-    */
+     * 设备别名(单元名称)
+     */
     private String alias;
 
     /**
-    * 设备型号id
-    */
+     * 设备型号id
+     */
     private Long modelId;
 
     /**
-    * 设备型号名称
-    */
+     * 设备型号名称
+     */
     private String modelName;
 
     /**
-    * 设备类型(字典表value)
-    */
+     * 设备类型(字典表value)
+     */
     private String deviceType;
 
     /**
-    * 设备类型(字典表label)
-    */
+     * 设备类型(字典表label)
+     */
     private String deviceLabel;
 
     /**
-    * 纬度
-    */
+     * 纬度
+     */
     private String lat;
 
     /**
-    * 经度
-    */
+     * 经度
+     */
     private String lng;
 
     /**
-    * 海拔
-    */
+     * 海拔
+     */
     private String alt;
 
     /**
-    * 告警类型
-    */
+     * 告警类型
+     */
     private Integer alarmType;
 
     /**
-    * 告警标题
-    */
+     * 告警标题
+     */
     private String alarmTitle;
 
     /**
-    * 告警内容
-    */
+     * 告警内容
+     */
     private String content;
 
     /**
-    * 监测要素、值的json字符串
-    */
+     * 监测要素、值的json字符串
+     */
     private String items;
 
     /**
-    * 告警时间
-    */
+     * 告警时间
+     */
     private Date alarmTime;
 
     /**
-    * 创建时间
-    */
+     * 创建时间
+     */
     private Date createTime;
 
     private static final long serialVersionUID = 1L;

+ 25 - 22
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsReportTemplate.java

@@ -6,62 +6,65 @@ import lombok.Data;
 import java.io.Serializable;
 import java.util.Date;
 
+
 /**
-    * 报表配置模型(不要在零点汇聚数据)
-    */
+ * @author lfdc
+ * @description 报表配置模型(不要在零点汇聚数据)
+ * @date 2023-10-25 13:46:12
+ */
 @Data
 @TableName("kws_report_template")
 public class KwsReportTemplate implements Serializable {
     private Long id;
 
     /**
-    * 模版名称
-    */
+     * 模版名称
+     */
     private String name;
 
     /**
-    * 模版类型
-    */
+     * 模版类型
+     */
     private Integer type;
 
     /**
-    * 要素名字符串
-    */
+     * 要素名字符串
+     */
     private String partNames;
 
     /**
-    * 集成分析方案名字符串
-    */
+     * 集成分析方案名字符串
+     */
     private String intergrationNames;
 
     /**
-    * 状态
-    */
+     * 状态
+     */
     private Byte status;
 
     /**
-    * 创建人
-    */
+     * 创建人
+     */
     private Long createBy;
 
     /**
-    * 创建时间
-    */
+     * 创建时间
+     */
     private Date createTime;
 
     /**
-    * 修改人
-    */
+     * 修改人
+     */
     private Long updateBy;
 
     /**
-    * 修改时间
-    */
+     * 修改时间
+     */
     private Date updateTime;
 
     /**
-    * 删除标识
-    */
+     * 删除标识
+     */
     private Byte delFlag;
 
     private static final long serialVersionUID = 1L;

+ 3 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsThreshold.java

@@ -7,8 +7,9 @@ import java.io.Serializable;
 import java.util.Date;
 
 /**
- * 要素阈值(不允许修改)
- * 修改流程: 新增一条,软删除之前的数据
+ * @author lfdc
+ * @description 要素阈值(不允许修改)修改流程: 新增一条,软删除之前的数据
+ * @date 2023-10-25 13:46:12
  */
 @Data
 @TableName("kws_threshold")

+ 15 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/MqttMsg.java

@@ -0,0 +1,15 @@
+package com.sckw.slope.detection.model.dto;
+
+import lombok.Data;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2023-10-25 17:10:35
+ */
+@Data
+public class MqttMsg {
+    private String name = "张三";
+    private String content = "消息数据";
+    private String time = "";
+}

+ 137 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/utils/SpringUtils.java

@@ -0,0 +1,137 @@
+package com.sckw.slope.detection.utils;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2023-10-25 17:10:39
+ */
+
+import com.sckw.core.utils.StringUtils;
+import org.springframework.aop.framework.AopContext;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+/**
+ * spring工具类 方便在非spring管理环境中获取bean
+ *
+ * @author lfdc
+ */
+@Component
+public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware {
+    /**
+     * Spring应用上下文环境
+     */
+    private static ConfigurableListableBeanFactory beanFactory;
+
+    private static ApplicationContext applicationContext;
+
+    @Override
+    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
+        SpringUtils.beanFactory = beanFactory;
+    }
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        SpringUtils.applicationContext = applicationContext;
+    }
+
+    /**
+     * 获取对象
+     *
+     * @param name
+     * @return Object 一个以所给名字注册的bean的实例
+     * @throws org.springframework.beans.BeansException
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> T getBean(String name) throws BeansException {
+        return (T) beanFactory.getBean(name);
+    }
+
+    /**
+     * 获取类型为requiredType的对象
+     *
+     * @param clz
+     * @return
+     * @throws org.springframework.beans.BeansException
+     */
+    public static <T> T getBean(Class<T> clz) throws BeansException {
+        T result = (T) beanFactory.getBean(clz);
+        return result;
+    }
+
+    /**
+     * 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true
+     *
+     * @param name
+     * @return boolean
+     */
+    public static boolean containsBean(String name) {
+        return beanFactory.containsBean(name);
+    }
+
+    /**
+     * 判断以给定名字注册的bean定义是一个singleton还是一个prototype。 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException)
+     *
+     * @param name
+     * @return boolean
+     * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
+     */
+    public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
+        return beanFactory.isSingleton(name);
+    }
+
+    /**
+     * @param name
+     * @return Class 注册对象的类型
+     * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
+     */
+    public static Class<?> getType(String name) throws NoSuchBeanDefinitionException {
+        return beanFactory.getType(name);
+    }
+
+    /**
+     * 如果给定的bean名字在bean定义中有别名,则返回这些别名
+     *
+     * @param name
+     * @return
+     * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
+     */
+    public static String[] getAliases(String name) throws NoSuchBeanDefinitionException {
+        return beanFactory.getAliases(name);
+    }
+
+    /**
+     * 获取aop代理对象
+     *
+     * @param invoker
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> T getAopProxy(T invoker) {
+        return (T) AopContext.currentProxy();
+    }
+
+    /**
+     * 获取当前的环境配置,无配置返回null
+     *
+     * @return 当前的环境配置
+     */
+    public static String[] getActiveProfiles() {
+        return applicationContext.getEnvironment().getActiveProfiles();
+    }
+
+    /**
+     * 获取当前的环境配置,当有多个环境配置时,只获取第一个
+     *
+     * @return 当前的环境配置
+     */
+    public static String getActiveProfile() {
+        final String[] activeProfiles = getActiveProfiles();
+        return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null;
+    }
+}

+ 25 - 0
slope-modules/slope-detection/src/main/resources/bootstrap-dev.yml

@@ -24,3 +24,28 @@ spring:
           - dataId: slope-common.yml
             group: slope-manage-service
             refresh: true
+## MQTT##
+mqtt:
+  send:
+    #完成超时时间
+    completionTimeout: 3000
+    #通过mqtt发送消息验证所需用户名
+    username: test
+    #通过mqtt发送消息验证所需密码
+    password: test
+    #连接的mqtt地址
+    url: tcp://10.10.10.225:1883
+    #客户端id
+    clientId: mqttx_12411c5cec
+    #推送主题  后面跟着#是监控下面所有的话题
+    topic: slope
+    #topic: my-test
+    # 会话心跳时间
+    keepAliveInterval: 20
+    # 设置连接超时时间
+    connectionTimeout: 3000
+    timeout: 10
+    keepalive: 20
+  # 要消费的topic配置
+  receive:
+    topic: slopePush/slopePull/test/out,test,slope,sharjeck/ai/test/out

+ 25 - 0
slope-modules/slope-detection/src/main/resources/bootstrap-lfdc.yml

@@ -22,3 +22,28 @@ spring:
           - dataId: slope-common.yml
             group: slope-manage-service
             refresh: true
+## MQTT##
+mqtt:
+  send:
+    #完成超时时间
+    completionTimeout: 3000
+    #通过mqtt发送消息验证所需用户名
+    username: test
+    #通过mqtt发送消息验证所需密码
+    password: test
+    #连接的mqtt地址
+    url: tcp://10.10.10.225:1883
+    #客户端id
+    clientId: mqttx_12411c5cec
+    #推送主题  后面跟着#是监控下面所有的话题
+    topic: slope
+    #topic: my-test
+    # 会话心跳时间
+    keepAliveInterval: 20
+    # 设置连接超时时间
+    connectionTimeout: 3000
+    timeout: 10
+    keepalive: 20
+  # 要消费的topic配置
+  receive:
+    topic: slopePush/slopePull/test/out,test,slope,sharjeck/ai/test/out

+ 151 - 0
slope-modules/slope-detection/src/main/resources/mapper/KwsDeviceIntegrationMapper.xml

@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sckw.slope.detection.dao.KwsDeviceIntegrationMapper">
+  <resultMap id="BaseResultMap" type="com.sckw.slope.detection.model.dos.mysql.KwsDeviceIntegration">
+    <!--@mbg.generated-->
+    <!--@Table kws_device_integration-->
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="device_id" jdbcType="BIGINT" property="deviceId" />
+    <result column="integration_id" jdbcType="BIGINT" property="integrationId" />
+    <result column="status" jdbcType="TINYINT" property="status" />
+    <result column="create_by" jdbcType="BIGINT" property="createBy" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="update_by" jdbcType="BIGINT" property="updateBy" />
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+    <result column="del_flag" jdbcType="TINYINT" property="delFlag" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, device_id, integration_id, `status`, create_by, create_time, update_by, update_time, 
+    del_flag
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+    <!--@mbg.generated-->
+    select 
+    <include refid="Base_Column_List" />
+    from kws_device_integration
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    <!--@mbg.generated-->
+    delete from kws_device_integration
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <insert id="insert" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceIntegration">
+    <!--@mbg.generated-->
+    insert into kws_device_integration (id, device_id, integration_id, 
+      `status`, create_by, create_time, 
+      update_by, update_time, del_flag
+      )
+    values (#{id,jdbcType=BIGINT}, #{deviceId,jdbcType=BIGINT}, #{integrationId,jdbcType=BIGINT}, 
+      #{status,jdbcType=TINYINT}, #{createBy,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{updateBy,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=TINYINT}
+      )
+  </insert>
+  <insert id="insertSelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceIntegration">
+    <!--@mbg.generated-->
+    insert into kws_device_integration
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="deviceId != null">
+        device_id,
+      </if>
+      <if test="integrationId != null">
+        integration_id,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="createBy != null">
+        create_by,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+      <if test="updateBy != null">
+        update_by,
+      </if>
+      <if test="updateTime != null">
+        update_time,
+      </if>
+      <if test="delFlag != null">
+        del_flag,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="deviceId != null">
+        #{deviceId,jdbcType=BIGINT},
+      </if>
+      <if test="integrationId != null">
+        #{integrationId,jdbcType=BIGINT},
+      </if>
+      <if test="status != null">
+        #{status,jdbcType=TINYINT},
+      </if>
+      <if test="createBy != null">
+        #{createBy,jdbcType=BIGINT},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateBy != null">
+        #{updateBy,jdbcType=BIGINT},
+      </if>
+      <if test="updateTime != null">
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="delFlag != null">
+        #{delFlag,jdbcType=TINYINT},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceIntegration">
+    <!--@mbg.generated-->
+    update kws_device_integration
+    <set>
+      <if test="deviceId != null">
+        device_id = #{deviceId,jdbcType=BIGINT},
+      </if>
+      <if test="integrationId != null">
+        integration_id = #{integrationId,jdbcType=BIGINT},
+      </if>
+      <if test="status != null">
+        `status` = #{status,jdbcType=TINYINT},
+      </if>
+      <if test="createBy != null">
+        create_by = #{createBy,jdbcType=BIGINT},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateBy != null">
+        update_by = #{updateBy,jdbcType=BIGINT},
+      </if>
+      <if test="updateTime != null">
+        update_time = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="delFlag != null">
+        del_flag = #{delFlag,jdbcType=TINYINT},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceIntegration">
+    <!--@mbg.generated-->
+    update kws_device_integration
+    set device_id = #{deviceId,jdbcType=BIGINT},
+      integration_id = #{integrationId,jdbcType=BIGINT},
+      `status` = #{status,jdbcType=TINYINT},
+      create_by = #{createBy,jdbcType=BIGINT},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      update_by = #{updateBy,jdbcType=BIGINT},
+      update_time = #{updateTime,jdbcType=TIMESTAMP},
+      del_flag = #{delFlag,jdbcType=TINYINT}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+</mapper>

+ 186 - 0
slope-modules/slope-detection/src/main/resources/mapper/KwsIntegrationMapper.xml

@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sckw.slope.detection.dao.KwsIntegrationMapper">
+  <resultMap id="BaseResultMap" type="com.sckw.slope.detection.model.dos.mysql.KwsIntegration">
+    <!--@mbg.generated-->
+    <!--@Table kws_integration-->
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="integration_name" jdbcType="VARCHAR" property="integrationName" />
+    <result column="part_names" jdbcType="VARCHAR" property="partNames" />
+    <result column="unit" jdbcType="VARCHAR" property="unit" />
+    <result column="formula" jdbcType="VARCHAR" property="formula" />
+    <result column="remark" jdbcType="VARCHAR" property="remark" />
+    <result column="status" jdbcType="TINYINT" property="status" />
+    <result column="create_by" jdbcType="BIGINT" property="createBy" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="update_by" jdbcType="BIGINT" property="updateBy" />
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+    <result column="del_flag" jdbcType="TINYINT" property="delFlag" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, integration_name, part_names, unit, formula, remark, `status`, create_by, create_time, 
+    update_by, update_time, del_flag
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+    <!--@mbg.generated-->
+    select 
+    <include refid="Base_Column_List" />
+    from kws_integration
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    <!--@mbg.generated-->
+    delete from kws_integration
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <insert id="insert" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsIntegration">
+    <!--@mbg.generated-->
+    insert into kws_integration (id, integration_name, part_names, 
+      unit, formula, remark, 
+      `status`, create_by, create_time, 
+      update_by, update_time, del_flag
+      )
+    values (#{id,jdbcType=BIGINT}, #{integrationName,jdbcType=VARCHAR}, #{partNames,jdbcType=VARCHAR}, 
+      #{unit,jdbcType=VARCHAR}, #{formula,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, 
+      #{status,jdbcType=TINYINT}, #{createBy,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{updateBy,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=TINYINT}
+      )
+  </insert>
+  <insert id="insertSelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsIntegration">
+    <!--@mbg.generated-->
+    insert into kws_integration
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="integrationName != null">
+        integration_name,
+      </if>
+      <if test="partNames != null">
+        part_names,
+      </if>
+      <if test="unit != null">
+        unit,
+      </if>
+      <if test="formula != null">
+        formula,
+      </if>
+      <if test="remark != null">
+        remark,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="createBy != null">
+        create_by,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+      <if test="updateBy != null">
+        update_by,
+      </if>
+      <if test="updateTime != null">
+        update_time,
+      </if>
+      <if test="delFlag != null">
+        del_flag,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="integrationName != null">
+        #{integrationName,jdbcType=VARCHAR},
+      </if>
+      <if test="partNames != null">
+        #{partNames,jdbcType=VARCHAR},
+      </if>
+      <if test="unit != null">
+        #{unit,jdbcType=VARCHAR},
+      </if>
+      <if test="formula != null">
+        #{formula,jdbcType=VARCHAR},
+      </if>
+      <if test="remark != null">
+        #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        #{status,jdbcType=TINYINT},
+      </if>
+      <if test="createBy != null">
+        #{createBy,jdbcType=BIGINT},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateBy != null">
+        #{updateBy,jdbcType=BIGINT},
+      </if>
+      <if test="updateTime != null">
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="delFlag != null">
+        #{delFlag,jdbcType=TINYINT},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsIntegration">
+    <!--@mbg.generated-->
+    update kws_integration
+    <set>
+      <if test="integrationName != null">
+        integration_name = #{integrationName,jdbcType=VARCHAR},
+      </if>
+      <if test="partNames != null">
+        part_names = #{partNames,jdbcType=VARCHAR},
+      </if>
+      <if test="unit != null">
+        unit = #{unit,jdbcType=VARCHAR},
+      </if>
+      <if test="formula != null">
+        formula = #{formula,jdbcType=VARCHAR},
+      </if>
+      <if test="remark != null">
+        remark = #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        `status` = #{status,jdbcType=TINYINT},
+      </if>
+      <if test="createBy != null">
+        create_by = #{createBy,jdbcType=BIGINT},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateBy != null">
+        update_by = #{updateBy,jdbcType=BIGINT},
+      </if>
+      <if test="updateTime != null">
+        update_time = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="delFlag != null">
+        del_flag = #{delFlag,jdbcType=TINYINT},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsIntegration">
+    <!--@mbg.generated-->
+    update kws_integration
+    set integration_name = #{integrationName,jdbcType=VARCHAR},
+      part_names = #{partNames,jdbcType=VARCHAR},
+      unit = #{unit,jdbcType=VARCHAR},
+      formula = #{formula,jdbcType=VARCHAR},
+      remark = #{remark,jdbcType=VARCHAR},
+      `status` = #{status,jdbcType=TINYINT},
+      create_by = #{createBy,jdbcType=BIGINT},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      update_by = #{updateBy,jdbcType=BIGINT},
+      update_time = #{updateTime,jdbcType=TIMESTAMP},
+      del_flag = #{delFlag,jdbcType=TINYINT}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+</mapper>