Преглед изворни кода

Merge branch 'dev' into sky_v2

15928045575 пре 2 година
родитељ
комит
8242309f74
33 измењених фајлова са 913 додато и 399 уклоњено
  1. 0 12
      slope-common/slope-common-core/src/main/java/com/sckw/core/exception/GlobalSystemExceptionHandler.java
  2. 0 29
      slope-common/slope-common-core/src/main/java/com/sckw/core/exception/NotLoginException.java
  3. 0 25
      slope-common/slope-common-core/src/main/java/com/sckw/core/exception/TranslateException.java
  4. 1 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/SlopeDetectionApplication.java
  5. 39 39
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/MqSendMessageGateWay.java
  6. 211 211
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/MqttConfig.java
  7. 40 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/dateSource/MyDataSourceConfig.java
  8. 73 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/dateSource/MysqlServerConfig.java
  9. 71 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/dateSource/TDengineServerConfig.java
  10. 39 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/mqtt/MqSendMessageGateWay.java
  11. 211 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/mqtt/MqttConfig.java
  12. 25 7
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/consumer/MqttDeviceCallbackHandler.java
  13. 3 3
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ReportTemplateController.java
  14. 3 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/TdengineDemoController.java
  15. 11 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ThresholdController.java
  16. 3 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/tdengine/DevicesMapper.java
  17. 1 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/tdengine/SlopeDataMapper.java
  18. 12 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/IsEnableDTO.java
  19. 2 4
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/ProjectUpdateDTO.java
  20. 21 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/ProjectAndDeviceParam.java
  21. 36 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ProjectAndDeviceVo.java
  22. 3 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ProjectVo.java
  23. 5 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ReportStatementVO.java
  24. 16 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ThresholdLogDetailVO.java
  25. 3 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/KwsAlarmService.java
  26. 15 12
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ReportTemplateService.java
  27. 2 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/TdengineService.java
  28. 30 4
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java
  29. 3 1
      slope-modules/slope-detection/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  30. 24 24
      slope-modules/slope-detection/src/main/resources/bootstrap-lfdc.yml
  31. 7 21
      slope-modules/slope-detection/src/main/resources/bootstrap-local.yml
  32. 1 0
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsProjectMapper.xml
  33. 2 1
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsReportTemplateMapper.xml

+ 0 - 12
slope-common/slope-common-core/src/main/java/com/sckw/core/exception/GlobalSystemExceptionHandler.java

@@ -63,18 +63,6 @@ public class GlobalSystemExceptionHandler {
     }
 
 
-    /**
-     * NotLoginException处理
-     *
-     * @param ex
-     * @return
-     */
-    @ResponseBody
-    @ExceptionHandler(NotLoginException.class)
-    public HttpResult notLoginException(NotLoginException ex) {
-        log.error("用户未登录, message={}, param={}", ex.getMsg(), ex.getParam());
-        return HttpResult.error(HttpStatus.TOKEN_INVALID_CODE, HttpStatus.UN_LOGIN_MESSAGE, ex.getMessage());
-    }
 
     @ResponseBody
     @ExceptionHandler(MissingServletRequestParameterException.class)

+ 0 - 29
slope-common/slope-common-core/src/main/java/com/sckw/core/exception/NotLoginException.java

@@ -1,29 +0,0 @@
-package com.sckw.core.exception;
-
-import lombok.Getter;
-
-/**
- * @Author yzc
- * @Description 未登陆异常
- * @createTime 2023年06月08日 10:05:00
- */
-@Getter
-public class NotLoginException extends  RuntimeException {
-
-    /**
-     * 异常信息
-    **/
-    private String msg;
-    private Object[] param;
-
-    public NotLoginException(String msg) {
-        super(msg);
-        this.msg = msg;
-    }
-    public NotLoginException(String msg, Object... param){
-        super(msg);
-        this.msg = msg;
-        this.param=param;
-    }
-
-}

+ 0 - 25
slope-common/slope-common-core/src/main/java/com/sckw/core/exception/TranslateException.java

@@ -1,25 +0,0 @@
-package com.sckw.core.exception;
-
-import lombok.Getter;
-
-/**
- *
- * 翻译失败时的异常
- *
- *
- * @author lfdc
- * @version v1
- * @create 2020-12-01 11:53:03
- * @copyright
- */
-@Getter
-public class TranslateException extends RuntimeException {
-
-    public TranslateException(String msg) {
-        super(msg);
-    }
-
-    public TranslateException(String msg, Throwable e) {
-        super(msg, e);
-    }
-}

+ 1 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/SlopeDetectionApplication.java

@@ -2,7 +2,6 @@ package com.sckw.slope.detection;
 
 import com.sckw.remote.annotation.SckwRemoteApplication;
 import com.sckw.startup.annotation.SckwCloudApplication;
-
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 
@@ -14,6 +13,7 @@ import org.springframework.boot.SpringApplication;
 @SckwRemoteApplication
 @SckwCloudApplication
 @MapperScan("com.sckw.slope.detection.dao.*")
+//@EnableConfigurationProperties(DataSource.class)
 public class SlopeDetectionApplication {
     public static void main(String[] args) {
         SpringApplication.run(SlopeDetectionApplication.class, args);

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

@@ -1,39 +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);
-}
+//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);
+//}

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

@@ -1,211 +1,211 @@
-package com.sckw.slope.detection.common.config;
-
-import com.sckw.slope.detection.consumer.MqttCallbackHandler;
-import com.sckw.slope.detection.consumer.mqApi.MqttApiHandler;
-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 MqttApiHandler mqttApiHandler;
-
-
-    /**
-     * 新建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;
-    }
-
-    @Autowired
-    private MqttCallbackHandler mqttCallbackHandler;
-    /**
-     * 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);
-            mqttApiHandler.handle(topic, payload);
-        };
-    }
-}
+//package com.sckw.slope.detection.common.config;
+//
+//import com.sckw.slope.detection.consumer.MqttCallbackHandler;
+//import com.sckw.slope.detection.consumer.mqApi.MqttApiHandler;
+//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 MqttApiHandler mqttApiHandler;
+//
+//
+//    /**
+//     * 新建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;
+//    }
+//
+//    @Autowired
+//    private MqttCallbackHandler mqttCallbackHandler;
+//    /**
+//     * 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);
+//            mqttApiHandler.handle(topic, payload);
+//        };
+//    }
+//}

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

@@ -0,0 +1,40 @@
+//package com.sckw.slope.detection.common.config.dateSource;
+//
+//import com.zaxxer.hikari.HikariDataSource;
+//import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
+//import org.springframework.boot.context.properties.ConfigurationProperties;
+//import org.springframework.boot.jdbc.DataSourceBuilder;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.context.annotation.Primary;
+//
+//import javax.sql.DataSource;
+//
+///**
+// * @author lfdc
+// * @description
+// * @date 2023-11-19 10:11:29
+// */
+//
+//@Configuration
+//public class MyDataSourceConfig {
+//    @ConfigurationProperties(prefix = "spring.datasource")
+//    @Primary
+//    @Bean
+//    public DataSource dataSource(DataSourceProperties properties){
+////        return DataSourceBuilder.create(properties.getClassLoader())
+////                .type(HikariDataSource.class)
+////                .driverClassName(properties.determineDriverClassName())
+////                .url(properties.determineUrl())
+////                .username(properties.determineUsername())
+////                .password(properties.determinePassword())
+////                .build();
+//        return DataSourceBuilder.create(properties.getClassLoader())
+//                .type(HikariDataSource.class)
+//                .driverClassName(properties.determineDriverClassName())
+//                .url(properties.determineUrl())
+//                .username(properties.determineUsername())
+//                .password(properties.determinePassword())
+//                .build();
+//    }
+//}

+ 73 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/dateSource/MysqlServerConfig.java

@@ -0,0 +1,73 @@
+//package com.sckw.slope.detection.common.config.dateSource;
+//
+//import com.baomidou.mybatisplus.annotation.DbType;
+//import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+//import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+//import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
+//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.boot.jdbc.DataSourceBuilder;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.context.annotation.Primary;
+//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+//
+//import javax.sql.DataSource;
+//import java.util.Collections;
+//
+///**
+// * @author lfdc
+// * @description mysql配置类
+// * @date 2023-11-19 10:11:19
+// */
+//@Configuration
+//@MapperScan(basePackages = {"com.sckw.slope.detection.dao.mysql"}, sqlSessionTemplateRef  = "mysqlSqlSessionTemplate")
+//public class MysqlServerConfig {
+//    @Autowired
+//    private PaginationInnerInterceptor paginationInnerInterceptor;
+//
+//    private static final String MAPPER_LOCATION = "classpath:mapper/mysql/*.xml";
+//    @Bean(name = "mysqlDataSource")
+//    @ConfigurationProperties(prefix = "spring.datasource.master")
+//    @Primary
+//    public DataSource mysqlDataSource() {
+//        return DataSourceBuilder.create().build();
+//    }
+//
+//    @Bean(name = "mysqlSqlSessionFactory")
+//    @Primary
+//    public SqlSessionFactory mysqlSqlSessionFactory(@Qualifier("mysqlDataSource") DataSource dataSource) throws Exception {
+//        //注意这里一定要用MybatisSqlSessionFactoryBean,如果用SqlSessionFactory,配置无效
+//        MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
+//        bean.setDataSource(dataSource);
+//        bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(MAPPER_LOCATION));
+//
+//        //不在这里注入分页插件,会失效,(MyBatisPlusConfig只负责注册分页插件)
+//        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
+//        paginationInnerInterceptor.setMaxLimit(-1L);
+//        paginationInnerInterceptor.setDbType(DbType.MYSQL);
+//        // 开启 count 的 join 优化,只针对部分 left join
+//        paginationInnerInterceptor.setOptimizeJoin(true);
+//        mybatisPlusInterceptor.setInterceptors(Collections.singletonList(paginationInnerInterceptor));
+//        bean.setPlugins(mybatisPlusInterceptor);
+//
+//        return bean.getObject();
+//    }
+//
+//    @Bean(name = "mysqlTransactionManager")
+//    @Primary
+//    public DataSourceTransactionManager mysqlTransactionManager(@Qualifier("mysqlDataSource") DataSource dataSource) {
+//        return new DataSourceTransactionManager(dataSource);
+//    }
+//
+//    @Bean(name = "mysqlSqlSessionTemplate")
+//    @Primary
+//    public SqlSessionTemplate mysqlSqlSessionTemplate(@Qualifier("mysqlSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
+//        return new SqlSessionTemplate(sqlSessionFactory);
+//    }
+//}

+ 71 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/dateSource/TDengineServerConfig.java

@@ -0,0 +1,71 @@
+//package com.sckw.slope.detection.common.config.dateSource;
+//
+//import com.baomidou.mybatisplus.annotation.DbType;
+//import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+//import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+//import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
+//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.boot.jdbc.DataSourceBuilder;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+//
+//import javax.sql.DataSource;
+//import java.util.Collections;
+//
+///**
+// * @author lfdc
+// * @description TDengine配置类
+// * @date 2023-11-19 10:11:24
+// */
+//@Configuration
+//@MapperScan(basePackages = "com.sckw.slope.detection.dao.tdengine", sqlSessionTemplateRef = "tdengineSqlSessionTemplate")
+//
+//public class TDengineServerConfig {
+//    @Autowired
+//    private PaginationInnerInterceptor paginationInnerInterceptor;
+//
+//    private static final String MAPPER_LOCATION = "classpath:mapper/tdengine/*.xml";
+//
+//    @Bean(name = "tdengineDataSource")
+//    @ConfigurationProperties(prefix = "spring.datasource.td")
+//    public DataSource tdengineDataSource() {
+//        return DataSourceBuilder.create().build();
+//    }
+//
+//    @Bean(name = "tdengineSqlSessionFactory")
+//    public SqlSessionFactory tdengineSqlSessionFactory(@Qualifier("tdengineDataSource") DataSource dataSource) throws Exception {
+//        MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
+//        bean.setDataSource(dataSource);
+//        bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(MAPPER_LOCATION));
+//
+//        //不在这里注入分页插件,会失效,(MyBatisPlusConfig只负责注册分页插件)
+//        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
+//        paginationInnerInterceptor.setMaxLimit(-1L);
+//        paginationInnerInterceptor.setDbType(DbType.TDENGINE);
+//        // 开启 count 的 join 优化,只针对部分 left join
+//        paginationInnerInterceptor.setOptimizeJoin(true);
+//        mybatisPlusInterceptor.setInterceptors(Collections.singletonList(paginationInnerInterceptor));
+//        bean.setPlugins(mybatisPlusInterceptor);
+//
+//        return bean.getObject();
+//    }
+//
+//    @Bean(name = "tdengineTransactionManager")
+//    public DataSourceTransactionManager tdengineTransactionManager(@Qualifier("tdengineDataSource") DataSource dataSource) {
+//        return new DataSourceTransactionManager(dataSource);
+//    }
+//
+//
+//    @Bean(name = "tdengineSqlSessionTemplate")
+//    public SqlSessionTemplate tdengineSqlSessionTemplate(@Qualifier("tdengineSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
+//        return new SqlSessionTemplate(sqlSessionFactory);
+//    }
+//
+//}

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

@@ -0,0 +1,39 @@
+//package com.sckw.slope.detection.common.config.mqtt;
+//
+//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);
+//}

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

@@ -0,0 +1,211 @@
+//package com.sckw.slope.detection.common.config.mqtt;
+//
+//import com.sckw.slope.detection.consumer.MqttCallbackHandler;
+//import com.sckw.slope.detection.consumer.mqApi.MqttApiHandler;
+//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 MqttApiHandler mqttApiHandler;
+//
+//
+//    /**
+//     * 新建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 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;
+//    }
+//
+//    @Autowired
+//    private MqttCallbackHandler mqttCallbackHandler;
+//    /**
+//     * 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);
+//            mqttApiHandler.handle(topic, payload);
+//        };
+//    }
+//}

+ 25 - 7
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/consumer/MqttDeviceCallbackHandler.java

@@ -1,6 +1,7 @@
 package com.sckw.slope.detection.consumer;
 
 import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckw.core.model.constant.NumberConstant;
 import com.sckw.core.model.enums.DictEnum;
@@ -9,7 +10,6 @@ import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.dao.mysql.*;
-import com.sckw.slope.detection.dao.tdengine.DevicesMapper;
 import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
 import com.sckw.slope.detection.model.dos.mysql.*;
 import com.sckw.slope.detection.model.dos.tdengine.Devices;
@@ -26,7 +26,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
@@ -65,7 +64,8 @@ public class MqttDeviceCallbackHandler extends AbstractHandler {
     @Autowired
     HandlerFactory handlerFactory;
 
-    @Transactional
+//    @Transactional
+    @DSTransactional
     public HttpResult handle(String topic, String payload) {
         // 根据topic分别进行消息处理。
         log.info("MqttDeviceCallbackHandler:" + topic + "|" + payload);
@@ -164,9 +164,6 @@ public class MqttDeviceCallbackHandler extends AbstractHandler {
 
     }
 
-    @Autowired
-    DevicesMapper devicesMapper;
-
     private void checkDeviceAlarm(String deviceCode, KwsDevice device, String itemValue, Long ts) {
         try {
             Devices devices = tdengineService.selectLastData(deviceCode);
@@ -231,6 +228,17 @@ public class MqttDeviceCallbackHandler extends AbstractHandler {
             Map<String, Long> minMap = new HashMap<>();
             List<BigDecimal> maxList = new ArrayList<>();
             List<BigDecimal> minList = new ArrayList<>();
+            //添加阈值map
+            for (KwsThreshold kwsThreshold : kwsThresholds) {
+                String max = kwsThreshold.getMax();
+                Long thresholdId = kwsThreshold.getId();
+                String min = kwsThreshold.getMin();
+                Integer level = kwsThreshold.getLevel();
+                maxMap.put(max, level.longValue());
+                maxMap.put(level.toString(), thresholdId.longValue());
+                minMap.put(min, level.longValue());
+                minMap.put(level.toString(), thresholdId.longValue());
+            }
             for (KwsThreshold kwsThreshold : kwsThresholds) {
                 maxList.add(new BigDecimal(kwsThreshold.getMax()));
                 minList.add(new BigDecimal(kwsThreshold.getMin()));
@@ -265,7 +273,7 @@ public class MqttDeviceCallbackHandler extends AbstractHandler {
             map.put("level", "1");
             map.put("thresholdId", "1");
             map.put("flag", "1");
-            if (min != null && max != null) {
+            if (min != null || max != null) {
                 if (max != null) {
                     Long level = maxMap.get(max);
                     Long thresholdId = maxMap.get(level.toString());
@@ -289,6 +297,16 @@ public class MqttDeviceCallbackHandler extends AbstractHandler {
             Map<String, Long> minMap = new HashMap<>();
             List<BigDecimal> maxList = new ArrayList<>();
             List<BigDecimal> minList = new ArrayList<>();
+            for (KwsThreshold kwsThreshold : kwsThresholds) {
+                String max = kwsThreshold.getMax();
+                Long thresholdId = kwsThreshold.getId();
+                String min = kwsThreshold.getMin();
+                Integer level = kwsThreshold.getLevel();
+                maxMap.put(max, level.longValue());
+                maxMap.put(level.toString(), thresholdId.longValue());
+                minMap.put(min, level.longValue());
+                minMap.put(level.toString(), thresholdId.longValue());
+            }
             for (KwsThreshold kwsThreshold : kwsThresholds) {
                 maxList.add(new BigDecimal(kwsThreshold.getMax()));
                 minList.add(new BigDecimal(kwsThreshold.getMin()));

+ 3 - 3
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ReportTemplateController.java

@@ -60,11 +60,11 @@ public class ReportTemplateController {
         return reportTemplateService.update(reportTemplateUpdateDTO, request);
     }
 
-    @Log(description = "模版启用")
+    @Log(description = "模版启用/模版禁用")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
-    @RequestMapping(name = "模版启用", value = "/enable", method = RequestMethod.GET)
+    @RequestMapping(name = "模版启用/模版禁用", value = "/enable", method = RequestMethod.POST)
     public HttpResult enable(@RequestBody @Valid IsEnableDTO isEnable, HttpServletRequest request) {
-        log.info("模版启用 enable param:{}", JSONObject.toJSONString(isEnable));
+        log.info("模版启用/模版禁用 enable param:{}", JSONObject.toJSONString(isEnable));
         return reportTemplateService.enable(isEnable, request);
     }
 

+ 3 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/TdengineDemoController.java

@@ -1,5 +1,6 @@
 package com.sckw.slope.detection.controller;
 
+import com.alibaba.fastjson2.JSONObject;
 import com.sckw.slope.detection.model.dos.tdengine.Devices;
 import com.sckw.slope.detection.service.TdengineService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,7 +29,8 @@ public class TdengineDemoController {
 
     @RequestMapping(value = "/getDevicesDemo", method = RequestMethod.GET)
     public void getDevicesDemo() {
-        Devices devices= tdengineDemoService.selectLastData("f1beaa4b9d85f26f288bb3b8e72a6aa0");
+        Devices devices = tdengineDemoService.selectLastData("f1beaa4b9d85f26f288bb3b8e72a6aa0");
+        System.out.println("devices" + JSONObject.toJSONString(devices));
     }
 
     @RequestMapping(value = "/getTable", method = RequestMethod.GET)

+ 11 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ThresholdController.java

@@ -5,6 +5,7 @@ import com.sckw.core.annotation.Log;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.model.dto.DeleteThresholdDTO;
 import com.sckw.slope.detection.model.dto.ThresholdConfigurationDTO;
+import com.sckw.slope.detection.model.param.ProjectAndDeviceParam;
 import com.sckw.slope.detection.model.param.ThresholdDetailQuery;
 import com.sckw.slope.detection.model.param.ThresholdQuery;
 import com.sckw.slope.detection.service.ThresholdService;
@@ -38,6 +39,16 @@ public class ThresholdController {
         return HttpResult.ok(thresholdService.select(thresholdQuery, request));
     }
 
+
+
+    @Log(description = "项目和设备查询")
+    //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
+    @RequestMapping(name = "项目和设备查询", value = "/getDevice", method = RequestMethod.POST)
+    public HttpResult getDevice(@RequestBody @Valid ProjectAndDeviceParam param , HttpServletRequest request) {
+        log.info("数据总览 getDevice param:{}", JSONObject.toJSONString(param));
+        return thresholdService.getDevice(param);
+    }
+
     @Log(description = "阈值详情")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "阈值详情", value = "/detail", method = RequestMethod.POST)

+ 3 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/tdengine/DevicesMapper.java

@@ -1,6 +1,7 @@
 package com.sckw.slope.detection.dao.tdengine;
 
 import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.slope.detection.model.dos.tdengine.Devices;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -9,8 +10,8 @@ import org.springframework.stereotype.Repository;
 @DS("td")
 @Mapper
 @Repository
-public interface DevicesMapper {
-
+public interface DevicesMapper extends BaseMapper<Devices> {
+    @DS("td")
     Devices selectLastData(@Param("deviceCode") String deviceCode);
 
 }

+ 1 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/tdengine/SlopeDataMapper.java

@@ -38,5 +38,6 @@ public interface SlopeDataMapper extends BaseMapper<SlopeData> {
 
     List<SlopeDataVo> selectListByMasterCount(Integer newPage, Integer pageSize);
 
+    @DS("td")
     SlopeData selectLastData(@Param("deviceCode") String deviceCode);
 }

+ 12 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/IsEnableDTO.java

@@ -1,5 +1,7 @@
 package com.sckw.slope.detection.model.dto;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.gson.annotations.SerializedName;
 import lombok.Data;
 
 /**
@@ -9,6 +11,15 @@ import lombok.Data;
  */
 @Data
 public class IsEnableDTO {
+    /**
+     * 模板id
+     */
     private String id;
-    private boolean flag;
+
+    /**
+     * 是否启用  0 启用 1禁用
+     */
+    @JsonProperty("flag")
+    @SerializedName(value = "flag")
+    private String flag;
 }

+ 2 - 4
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/ProjectUpdateDTO.java

@@ -1,9 +1,6 @@
 package com.sckw.slope.detection.model.dto;
 
-import jakarta.validation.constraints.DecimalMin;
-import jakarta.validation.constraints.Digits;
-import jakarta.validation.constraints.NotBlank;
-import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.*;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -99,5 +96,6 @@ public class ProjectUpdateDTO implements Serializable {
     /**
      * 备注
      */
+    @Max(value = 200, message = "请输入不超过{value}个字符")
     private String remark;
 }

+ 21 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/ProjectAndDeviceParam.java

@@ -0,0 +1,21 @@
+package com.sckw.slope.detection.model.param;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2023-11-19 16:11:32
+ */
+@Data
+public class ProjectAndDeviceParam implements Serializable {
+
+    @NotBlank(message = "项目id不能为空")
+    private String projectId;
+
+    @NotBlank(message = "设备id")
+    private String deviceId;
+}

+ 36 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ProjectAndDeviceVo.java

@@ -0,0 +1,36 @@
+package com.sckw.slope.detection.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author lfdc
+ * @description 项目和设备查询设备数据
+ * @date 2023-11-19 16:11:39
+ */
+@Data
+public class ProjectAndDeviceVo implements Serializable {
+
+    /**
+     * 逻辑经度(测点布设的值)
+     */
+    private String logicLng;
+
+    /**
+     * 逻辑纬度(测点布设的值)
+     */
+    private String logicLat;
+
+    /**
+     * 逻辑海拔(测点布设的值)
+     */
+    private String logicAlt;
+
+    private String deviceId;
+
+    private String deviceName;
+
+    private String projectId;
+    private String projectName;
+}

+ 3 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ProjectVo.java

@@ -1,6 +1,7 @@
 package com.sckw.slope.detection.model.vo;
 
 import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -104,6 +105,7 @@ public class ProjectVo implements Serializable {
     /**
      * 创建时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
     private LocalDateTime createTime;
 
     /**
@@ -114,6 +116,7 @@ public class ProjectVo implements Serializable {
     /**
      * 修改时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
     private LocalDateTime updateTime;
 
     /**

+ 5 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ReportStatementVO.java

@@ -24,6 +24,11 @@ public class ReportStatementVO implements Serializable {
      * 状态
      */
     private String status;
+
+    /**
+     * 状态
+     */
+    private String statusLabel;
     /**
      * 报表名称
      */

+ 16 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ThresholdLogDetailVO.java

@@ -18,6 +18,22 @@ public class ThresholdLogDetailVO implements Serializable {
      * 告警类型
      */
     private String alarmType;
+
+    /**
+     * 设备id
+     */
+    private String deviceId;
+
+    /**
+     * 告警id
+     */
+    private String alarmId;
+
+    /**
+     * 告警id
+     */
+    private String alarmDetailId;
+
     /**
      * 告警等级
      */

+ 3 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/KwsAlarmService.java

@@ -271,6 +271,9 @@ public class KwsAlarmService {
                     .eq(KwsDeviceReference::getItem, itemName)
             );
             if (deviceReference != null) {
+                vo.setAlarmId(kwsAlarm.getId().toString());
+                vo.setAlarmDetailId(id);
+                vo.setDeviceId(deviceId.toString());
                 vo.setItemName(itemName);
                 vo.setCurrentValue(deviceReference.getCurrentValue());
                 vo.setCurrentOffset(deviceReference.getOffset());

+ 15 - 12
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ReportTemplateService.java

@@ -6,6 +6,7 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.NumberConstant;
+import com.sckw.core.model.enums.DictEnum;
 import com.sckw.core.model.enums.MessageLogEnum;
 import com.sckw.core.model.enums.ReportEnum;
 import com.sckw.core.model.enums.ReportTypeEnum;
@@ -18,10 +19,7 @@ import com.sckw.slope.detection.dao.mysql.KwsReportTemplateMapper;
 import com.sckw.slope.detection.model.dos.mysql.KwsProject;
 import com.sckw.slope.detection.model.dos.mysql.KwsReportData;
 import com.sckw.slope.detection.model.dos.mysql.KwsReportTemplate;
-import com.sckw.slope.detection.model.dto.HeaderData;
-import com.sckw.slope.detection.model.dto.IsEnableDTO;
-import com.sckw.slope.detection.model.dto.ReportTemplateAddDTO;
-import com.sckw.slope.detection.model.dto.ReportTemplateUpdateDTO;
+import com.sckw.slope.detection.model.dto.*;
 import com.sckw.slope.detection.model.param.StatementQuery;
 import com.sckw.slope.detection.model.vo.KwsReportTemplateVO;
 import com.sckw.slope.detection.model.vo.ReportStatementVO;
@@ -76,7 +74,7 @@ public class ReportTemplateService {
 //        if (Objects.isNull(status)) {
 //            status = ReportEnum.FORBIDDEN.getStatus();
 //        }
-        String tabulationTime = "";
+//        String tabulationTime = "";
 //        if (ReportTypeEnum.DAY.getStatus().equals(type)) {
 //            tabulationTime = ReportTypeEnum.DAY.getValue();
 //        } else if (ReportTypeEnum.WEEK.getStatus().equals(type)) {
@@ -158,9 +156,10 @@ public class ReportTemplateService {
     @Transactional
     public HttpResult enable(IsEnableDTO isEnable, HttpServletRequest request) {
         HeaderData headerData = commonService.getHeaderData(request);
-        String status = "0";
-        if (!isEnable.isFlag()) {
-            status = "1";
+        Integer status = 1;
+        String flag = isEnable.getFlag();
+        if ("1".equals(flag)){
+            status=0;
         }
         Long templateId = Long.parseLong(isEnable.getId());
         KwsReportTemplate template = reportTemplateMapper.selectOne(new LambdaQueryWrapper<KwsReportTemplate>()
@@ -180,9 +179,9 @@ public class ReportTemplateService {
         Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
         logMap.put("projectName", project.getName());
         logMap.put("templateName", template.getName());
-        MessageLogEnum messageLogEnum = MessageLogEnum.FORBIDDEN_REPORT_TEMPLATE;
-        if (isEnable.isFlag()) {
-            messageLogEnum = MessageLogEnum.FORBIDDEN_REPORT_TEMPLATE;
+        MessageLogEnum messageLogEnum = MessageLogEnum.FORBIDDEN_REPORT_TEMPLATE;;
+        if ("1".equals(flag)) {
+            messageLogEnum = MessageLogEnum.ENABLE_REPORT_TEMPLATE;
         }
         commonService.insertLog(messageLogEnum, headerData, logMap, headerData.getUpdateBy() == null ?
                 null : Long.parseLong(headerData.getUpdateBy()));
@@ -205,10 +204,13 @@ public class ReportTemplateService {
         if (!CollectionUtils.isEmpty(kwsProjects)) {
             map = kwsProjects.stream().collect(Collectors.toMap(KwsProject::getId, KwsProject::getName));
         }
+        Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.THRESHOLD_TYPE);
         for (ReportStatementVO reportStatementVO : list) {
-            reportStatementVO.setStatus(ReportEnum.getDescription(reportStatementVO.getStatus()));
+            reportStatementVO.setStatusLabel(ReportEnum.getDescription(reportStatementVO.getStatus()));
             reportStatementVO.setReportType(ReportTypeEnum.getDescription(reportStatementVO.getReportType()));
             reportStatementVO.setProjectName(map.get(Long.parseLong(reportStatementVO.getProjectId())));
+            reportStatementVO.setTabulationTime(dictByDictCode == null ? reportStatementVO.getTabulationTime() :
+                    (dictByDictCode.get(reportStatementVO.getTabulationTime()) == null ? reportStatementVO.getTabulationTime() : dictByDictCode.get(reportStatementVO.getTabulationTime()).getLabel()));
         }
         return PageRes.build(info, list);
     }
@@ -224,6 +226,7 @@ public class ReportTemplateService {
         reportTemplateMapper.update(null, new LambdaUpdateWrapper<KwsReportTemplate>()
                 .eq(KwsReportTemplate::getId, Long.parseLong(id))
                 .set(KwsReportTemplate::getUpdateTime, LocalDateTime.now())
+                .set(KwsReportTemplate::getDelFlag, NumberConstant.ONE)
                 .set(KwsReportTemplate::getUpdateBy, (headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy())))
                 .set(KwsReportTemplate::getStatus, NumberConstant.ONE)
         );

+ 2 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/TdengineService.java

@@ -28,7 +28,7 @@ public class TdengineService {
     InsTablesMapper insTablesMapper;
 
     @Autowired
-    private DevicesMapper devicesMapper;
+     DevicesMapper devicesMapper;
 
     public void tdengineDemo() {
         List<SlopeDataVo> list = slopeDataMapper.selectAll("6", "7");
@@ -53,6 +53,7 @@ public class TdengineService {
     }
 
     public Devices selectLastData(String deviceCode) {
+        SlopeData slopeData = slopeDataMapper.selectLastData(deviceCode);
         Devices devices = devicesMapper.selectLastData(deviceCode);
         return devices;
     }

+ 30 - 4
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java

@@ -17,13 +17,12 @@ import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.dao.mysql.*;
-import com.sckw.slope.detection.model.dos.mysql.KwsDevice;
-import com.sckw.slope.detection.model.dos.mysql.KwsDeviceReference;
-import com.sckw.slope.detection.model.dos.mysql.KwsProject;
-import com.sckw.slope.detection.model.dos.mysql.KwsThreshold;
+import com.sckw.slope.detection.model.dos.mysql.*;
 import com.sckw.slope.detection.model.dto.*;
+import com.sckw.slope.detection.model.param.ProjectAndDeviceParam;
 import com.sckw.slope.detection.model.param.ThresholdDetailQuery;
 import com.sckw.slope.detection.model.param.ThresholdQuery;
+import com.sckw.slope.detection.model.vo.ProjectAndDeviceVo;
 import com.sckw.slope.detection.model.vo.ThresholdDetailVO;
 import com.sckw.slope.detection.service.repository.KwsThresholdRepository;
 import jakarta.servlet.http.HttpServletRequest;
@@ -647,4 +646,31 @@ public class ThresholdService {
         }
         return HttpResult.ok("删除成功");
     }
+
+    @Autowired
+    KwsProjectAreaMapper projectAreaMapper;
+
+    public HttpResult getDevice(ProjectAndDeviceParam param) {
+        String deviceId = param.getDeviceId();
+        String projectId = param.getProjectId();
+        KwsProject project = projectMapper.selectById(Long.parseLong(projectId));
+        KwsProjectArea area = projectAreaMapper.selectOne(new LambdaQueryWrapper<KwsProjectArea>()
+                .eq(KwsProjectArea::getProjectId, Long.parseLong(projectId))
+                .eq(KwsProjectArea::getDelFlag, 0));
+        if (area != null) {
+
+        }
+        ProjectAndDeviceVo vo = new ProjectAndDeviceVo();
+        KwsDevice kwsDevice = deviceMapper.selectById(Long.parseLong(deviceId));
+        if (kwsDevice != null) {
+            vo.setLogicLng(kwsDevice.getLogicLng());
+            vo.setLogicLat(kwsDevice.getLogicLat());
+            vo.setLogicAlt(kwsDevice.getLogicAlt());
+        }
+        vo.setDeviceId(deviceId);
+        vo.setDeviceName(kwsDevice == null ? null : kwsDevice.getName());
+        vo.setProjectId(projectId);
+        vo.setProjectName(project == null ? null : project.getName());
+        return HttpResult.ok(vo);
+    }
 }

+ 3 - 1
slope-modules/slope-detection/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -1,4 +1,6 @@
 #com.sckw.slope.detection.common.config.MultipleDataSourceConfig
 #com.sckw.slope.detection.consumer.AbstractHandler
 com.sckw.slope.detection.consumer.HandlerFactory
-#com.sckw.slope.detection.consumer.MqttCallbackHandler
+#com.sckw.slope.detection.consumer.MqttCallbackHandler
+#com.sckw.slope.detection.common.config.dateSource.MyDataSourceConfig
+#com.sckw.slope.detection.common.config.dateSource.TDengineServerConfig

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

@@ -40,30 +40,30 @@ spring:
             group: slope-manage-service
             refresh: true
 ## MQTT##
-mqtt:
-  send:
-    #完成超时时间
-    completionTimeout: 3000
-    #通过mqtt发送消息验证所需用户名
-    username: test
-    #通过mqtt发送消息验证所需密码
-    password: test
-    #连接的mqtt地址
-    url: tcp://10.10.10.225
-    #客户端id
-    clientId: mqttx_12411c5c1ec1
-    #推送主题  后面跟着#是监控下面所有的话题
-    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
+#mqtt:
+#  send:
+#    #完成超时时间
+#    completionTimeout: 3000
+#    #通过mqtt发送消息验证所需用户名
+#    username: test
+#    #通过mqtt发送消息验证所需密码
+#    password: test
+#    #连接的mqtt地址
+#    url: tcp://10.10.10.225
+#    #客户端id
+#    clientId: mqttx_12411c5c1ec1
+#    #推送主题  后面跟着#是监控下面所有的话题
+#    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
 #mqtt:
 #  send:
 #    #完成超时时间

+ 7 - 21
slope-modules/slope-detection/src/main/resources/bootstrap-local.yml

@@ -107,25 +107,11 @@ mybatis-plus:
   configuration:
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
-# xxljob任务调度
-xxl:
-  job:
-    admin:
-      #调度中心部署跟地址 [选填]:如调度中心集群部署存在多个地址则用逗号分隔。执行器将会使用该地址进行"执行器心跳注册"和"任务结果回调";为空则关闭自动注册;
-      addresses: http://10.10.10.230:10000/xxl-job-admin
-    #执行器通讯TOKEN [选填]:非空时启用;
-    accessToken: sckw123456...
-    executor:
-      #执行器app的名称,和控制台保持一致
-      appname: xxl-job-executor-example-test
-      #优先使用该地址作为注册地址 为空使用内嵌服务”IP:PORT“ 作为注册地址
-      # address:
-      #执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用;地址信息用于 "执行器注册" 和 "调度中心请求并触发任务";
-      # ip:
-      #执行器端口 小于等于0 自动获取 ,默认 9999 ,配置多个执行器时,需要配置不同的执行器端口
-      port: 10000
-      #执行器日志文件保持地址 ,为空使用默认保存地址
-      logpath: /data/project/xxlJob/example/logs
-      #执行器日志保持天数 -1永久生效
-      logretentiondays: 7
 
+#oss上传
+aliyun:
+  oss:
+    endpoint: oss-cn-chengdu.aliyuncs.com
+    accessKeyId: LTAI5tPEbubCGq5Rdwygbz4Q
+    secret: 7mQLWMaBJeZPRV1SRGogctYGXwppjQ
+    bucket: kaiwu-saas

+ 1 - 0
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsProjectMapper.xml

@@ -60,6 +60,7 @@
         <if test="projectQueryDto.name != null and projectQueryDto.name != ''">
             and name like concat('%', #{projectQueryDto.name}, '%')
         </if>
+        order by  create_time desc
     </select>
 
     <select id="selectDeviceByProjectId" resultType="com.sckw.slope.detection.model.vo.ProjectDeviceVO">

+ 2 - 1
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsReportTemplateMapper.xml

@@ -185,7 +185,8 @@
                type            AS reportType,
                project_id      AS projectId,
                tabulation_time AS tabulationTime,
-               create_time     AS createTime
+               create_time     AS createTime,
+               id              as id
         FROM kws_report_template
         WHERE del_flag = 0
         <if test="query.projectId != null and query.projectId != ''">