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

1.阈值新增设备数据查询
2.暂时屏蔽mqtt

lengfaqiang пре 2 година
родитељ
комит
2dbffb1e68
14 измењених фајлова са 399 додато и 293 уклоњено
  1. 39 39
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/mqtt/MqSendMessageGateWay.java
  2. 211 211
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/mqtt/MqttConfig.java
  3. 3 3
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ReportTemplateController.java
  4. 11 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ThresholdController.java
  5. 5 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/IsEnableDTO.java
  6. 2 4
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/ProjectUpdateDTO.java
  7. 21 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/ProjectAndDeviceParam.java
  8. 36 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ProjectAndDeviceVo.java
  9. 3 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ProjectVo.java
  10. 5 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ReportStatementVO.java
  11. 8 7
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ReportTemplateService.java
  12. 30 4
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java
  13. 24 24
      slope-modules/slope-detection/src/main/resources/bootstrap-lfdc.yml
  14. 1 0
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsProjectMapper.xml

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

@@ -1,39 +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);
-}
+//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 - 211
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/common/config/mqtt/MqttConfig.java

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

+ 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);
         return reportTemplateService.update(reportTemplateUpdateDTO, request);
     }
     }
 
 
-    @Log(description = "模版启用")
+    @Log(description = "模版启用/模版禁用")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     //@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) {
     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);
         return reportTemplateService.enable(isEnable, request);
     }
     }
 
 

+ 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.core.web.response.HttpResult;
 import com.sckw.slope.detection.model.dto.DeleteThresholdDTO;
 import com.sckw.slope.detection.model.dto.DeleteThresholdDTO;
 import com.sckw.slope.detection.model.dto.ThresholdConfigurationDTO;
 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.ThresholdDetailQuery;
 import com.sckw.slope.detection.model.param.ThresholdQuery;
 import com.sckw.slope.detection.model.param.ThresholdQuery;
 import com.sckw.slope.detection.service.ThresholdService;
 import com.sckw.slope.detection.service.ThresholdService;
@@ -38,6 +39,16 @@ public class ThresholdController {
         return HttpResult.ok(thresholdService.select(thresholdQuery, request));
         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 = "阈值详情")
     @Log(description = "阈值详情")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "阈值详情", value = "/detail", method = RequestMethod.POST)
     @RequestMapping(name = "阈值详情", value = "/detail", method = RequestMethod.POST)

+ 5 - 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;
 package com.sckw.slope.detection.model.dto;
 
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.gson.annotations.SerializedName;
 import lombok.Data;
 import lombok.Data;
 
 
 /**
 /**
@@ -17,5 +19,7 @@ public class IsEnableDTO {
     /**
     /**
      * 是否启用  0 启用 1禁用
      * 是否启用  0 启用 1禁用
      */
      */
-    private boolean flag;
+    @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;
 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 lombok.Data;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
@@ -99,5 +96,6 @@ public class ProjectUpdateDTO implements Serializable {
     /**
     /**
      * 备注
      * 备注
      */
      */
+    @Max(value = 200, message = "请输入不超过{value}个字符")
     private String remark;
     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;
 package com.sckw.slope.detection.model.vo;
 
 
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.Data;
 
 
 import java.io.Serializable;
 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;
     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;
     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 status;
+
+    /**
+     * 状态
+     */
+    private String statusLabel;
     /**
     /**
      * 报表名称
      * 报表名称
      */
      */

+ 8 - 7
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ReportTemplateService.java

@@ -156,9 +156,10 @@ public class ReportTemplateService {
     @Transactional
     @Transactional
     public HttpResult enable(IsEnableDTO isEnable, HttpServletRequest request) {
     public HttpResult enable(IsEnableDTO isEnable, HttpServletRequest request) {
         HeaderData headerData = commonService.getHeaderData(request);
         HeaderData headerData = commonService.getHeaderData(request);
-        Integer 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());
         Long templateId = Long.parseLong(isEnable.getId());
         KwsReportTemplate template = reportTemplateMapper.selectOne(new LambdaQueryWrapper<KwsReportTemplate>()
         KwsReportTemplate template = reportTemplateMapper.selectOne(new LambdaQueryWrapper<KwsReportTemplate>()
@@ -178,9 +179,9 @@ public class ReportTemplateService {
         Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
         Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
         logMap.put("projectName", project.getName());
         logMap.put("projectName", project.getName());
         logMap.put("templateName", template.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 ?
         commonService.insertLog(messageLogEnum, headerData, logMap, headerData.getUpdateBy() == null ?
                 null : Long.parseLong(headerData.getUpdateBy()));
                 null : Long.parseLong(headerData.getUpdateBy()));
@@ -205,7 +206,7 @@ public class ReportTemplateService {
         }
         }
         Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.THRESHOLD_TYPE);
         Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.THRESHOLD_TYPE);
         for (ReportStatementVO reportStatementVO : list) {
         for (ReportStatementVO reportStatementVO : list) {
-            reportStatementVO.setStatus(ReportEnum.getDescription(reportStatementVO.getStatus()));
+            reportStatementVO.setStatusLabel(ReportEnum.getDescription(reportStatementVO.getStatus()));
             reportStatementVO.setReportType(ReportTypeEnum.getDescription(reportStatementVO.getReportType()));
             reportStatementVO.setReportType(ReportTypeEnum.getDescription(reportStatementVO.getReportType()));
             reportStatementVO.setProjectName(map.get(Long.parseLong(reportStatementVO.getProjectId())));
             reportStatementVO.setProjectName(map.get(Long.parseLong(reportStatementVO.getProjectId())));
             reportStatementVO.setTabulationTime(dictByDictCode == null ? reportStatementVO.getTabulationTime() :
             reportStatementVO.setTabulationTime(dictByDictCode == null ? reportStatementVO.getTabulationTime() :

+ 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.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.dao.mysql.*;
 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.dto.*;
+import com.sckw.slope.detection.model.param.ProjectAndDeviceParam;
 import com.sckw.slope.detection.model.param.ThresholdDetailQuery;
 import com.sckw.slope.detection.model.param.ThresholdDetailQuery;
 import com.sckw.slope.detection.model.param.ThresholdQuery;
 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.model.vo.ThresholdDetailVO;
 import com.sckw.slope.detection.service.repository.KwsThresholdRepository;
 import com.sckw.slope.detection.service.repository.KwsThresholdRepository;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletRequest;
@@ -647,4 +646,31 @@ public class ThresholdService {
         }
         }
         return HttpResult.ok("删除成功");
         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);
+    }
 }
 }

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

@@ -40,30 +40,30 @@ spring:
             group: slope-manage-service
             group: slope-manage-service
             refresh: true
             refresh: true
 ## MQTT##
 ## 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:
 #mqtt:
 #  send:
 #  send:
 #    #完成超时时间
 #    #完成超时时间

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