From a15a8cfd7b01ce4bba6fe9fd876f6704ca23a12d Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期二, 07 一月 2025 16:40:32 +0800 Subject: [PATCH] 1、取水口用水日统计表中增加金额、次数字段; 2、优化或重写“累计流量超过指定值的取水口”、“累计流量低于指定值的取水口”、“指定时间段内用水量超过指定值的取水口”、“指定时间段内消费金额超过指定值的取水口”几个统计查询; 3、改“指定时间段内用水时长超过指定值的取水口”为“指定时间段内用水次数超过指定值的取水口” --- pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/workOrder/mqtt/TestController.java | 31 ++++++++++++++++++++++++++----- 1 files changed, 26 insertions(+), 5 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/workOrder/mqtt/TestController.java b/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/workOrder/mqtt/TestController.java index b2f3c37..0a6a028 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/workOrder/mqtt/TestController.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-app/src/main/java/com/dy/pipIrrApp/workOrder/mqtt/TestController.java @@ -2,6 +2,7 @@ import lombok.extern.slf4j.Slf4j; import org.eclipse.paho.client.mqttv3.MqttClient; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -18,17 +19,30 @@ @RestController @RequestMapping(path = "mqtt") public class TestController { + + @Value("${mqtt.broker}") + private String broker; + + @Value("${mqtt.username}") + private String username; + + @Value("${mqtt.password}") + private String password; + + @Value("${mqtt.topic}") + private String topic; + + @Value("${mqtt.qos}") + private Integer qos; + @GetMapping("/mqtt/{msg}") public String testSendMqttMsg(@PathVariable("msg") String msg){ log.info("娑堟伅鍐呭锛歿}.", msg); - MqttClient mqttClient = MqttClientConnectorPool.connectMQTT(); + MqttClient mqttClient = MqttClientConnectorPool.connectMQTT(broker, username, password); MqttMsgSender sender = new MqttMsgSender(); - String content = "{" + " \"deviceNo\": \"" + msg + "\"," + " \"val\": 232.5" + "}"; - - String topic = "workOrder"; - int qos = 1; + String content = "{" + " \"message\": \"" + msg + "\"," + " \"val\": 100.00" + "}"; if (null != mqttClient){ sender.sendMessage(mqttClient, topic, content, qos); @@ -38,4 +52,11 @@ } return "鎴愬姛锛�"; } + + @GetMapping("/receive") + public String receiveMsg() { + MqttMsgSubscriber subscriber = new MqttMsgSubscriber(); + subscriber.readSubscribeTopicMessage(); + return "success"; + } } -- Gitblit v1.8.0