From 55f76c22bf289fe11f00dbc4048f853f922a0ab6 Mon Sep 17 00:00:00 2001 From: andy <1042025947@qq.com> Date: Thu, 5 Feb 2026 16:52:15 +0800 Subject: [PATCH] =?UTF-8?q?mqtt=E7=9B=B8=E5=85=B3=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 46 ++++--------------- .../hd/core/dtos/system/MessageMqttDTO.java | 4 ++ .../hd/core/entity/system/MessageMqtt.java | 5 +- .../controller/MqttLogController.java | 43 +++++++++++++++++ .../hd/webserver/mqtt/MessageTopic.java | 2 + .../webserver/service/MessageMqttService.java | 6 +++ .../service/impl/MessageMqttServiceImpl.java | 12 ++++- .../resources/mapper/MessageMqttMapper.xml | 2 +- 8 files changed, 78 insertions(+), 42 deletions(-) create mode 100644 web-server/src/main/java/com/evotech/hd/webserver/controller/MqttLogController.java diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 8c8d42a..d8ce25b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,42 +5,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + diff --git a/commoms/core/src/main/java/com/evotech/hd/core/dtos/system/MessageMqttDTO.java b/commoms/core/src/main/java/com/evotech/hd/core/dtos/system/MessageMqttDTO.java index c35a0b1..eac9198 100644 --- a/commoms/core/src/main/java/com/evotech/hd/core/dtos/system/MessageMqttDTO.java +++ b/commoms/core/src/main/java/com/evotech/hd/core/dtos/system/MessageMqttDTO.java @@ -32,9 +32,13 @@ public class MessageMqttDTO extends BaseDTO { @ApiModelProperty("传送方向") private String direction; + @ApiModelProperty("通讯方式") + private String requestMethod; + @ApiModelProperty("消息ID") private String messageId; + @ApiModelProperty("qos") private Integer qos; diff --git a/commoms/core/src/main/java/com/evotech/hd/core/entity/system/MessageMqtt.java b/commoms/core/src/main/java/com/evotech/hd/core/entity/system/MessageMqtt.java index a6937b4..cf4e5b5 100644 --- a/commoms/core/src/main/java/com/evotech/hd/core/entity/system/MessageMqtt.java +++ b/commoms/core/src/main/java/com/evotech/hd/core/entity/system/MessageMqtt.java @@ -18,6 +18,8 @@ public class MessageMqtt extends BaseEntity { private String direction; + private String requestMethod; + private String messageId; private Integer qos; @@ -34,10 +36,11 @@ public class MessageMqtt extends BaseEntity { public MessageMqtt() { } - public MessageMqtt(String stationCode, String direction, String type, String messageFunction) { + public MessageMqtt(String stationCode, String direction, String type, String messageFunction, String requestMethod) { this.stationCode = stationCode; this.direction = direction; this.type = type; this.messageFunction = messageFunction; + this.requestMethod = requestMethod; } } diff --git a/web-server/src/main/java/com/evotech/hd/webserver/controller/MqttLogController.java b/web-server/src/main/java/com/evotech/hd/webserver/controller/MqttLogController.java new file mode 100644 index 0000000..a6991ee --- /dev/null +++ b/web-server/src/main/java/com/evotech/hd/webserver/controller/MqttLogController.java @@ -0,0 +1,43 @@ +package com.evotech.hd.webserver.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.evotech.hd.core.dtos.RequestParams; +import com.evotech.hd.core.dtos.Result; +import com.evotech.hd.core.dtos.system.MessageMqttDTO; +import com.evotech.hd.webserver.logging.annotation.ApiLog; +import com.evotech.hd.webserver.service.MessageMqttService; +import com.evotech.hd.webserver.utils.query.QueryWrapperGenerator; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * MqttLogController + * + * @author andy.shi + * @ClassName:MqttLogController + * @date: 2026年02月05日 16:44 + * @remark: 开发人员联系方式 1042025947@qq.com/微信同步 + */ +@RestController +@RequestMapping("/mqtt/log") +@Api(tags = "MQTT日志管理") +public class MqttLogController { + + @Autowired + MessageMqttService messageMqttService; + + @ApiOperation("订单列表") + @PostMapping("/page/list") + @ApiLog(value = "订单列表") + public Result> pageList(@RequestBody RequestParams params) throws Exception { + QueryWrapper queryWrapper = QueryWrapperGenerator.buildQueryCondition(params.getParams(), MessageMqttDTO.class); + return Result.getInstance().buildIPage(MessageMqttDTO.class).success(messageMqttService.findPageList(new Page(params.getPage().getPage(), params.getPage().getPageSize()), queryWrapper)); + } +} diff --git a/web-server/src/main/java/com/evotech/hd/webserver/mqtt/MessageTopic.java b/web-server/src/main/java/com/evotech/hd/webserver/mqtt/MessageTopic.java index 1f61cce..bfbdee6 100644 --- a/web-server/src/main/java/com/evotech/hd/webserver/mqtt/MessageTopic.java +++ b/web-server/src/main/java/com/evotech/hd/webserver/mqtt/MessageTopic.java @@ -20,6 +20,8 @@ public class MessageTopic implements Serializable { private String messageType; + private String requestMethod; + @Override public String toString() { return businessType + "/" + stationCode + "/" + dataDirection + "/" + messageType; diff --git a/web-server/src/main/java/com/evotech/hd/webserver/service/MessageMqttService.java b/web-server/src/main/java/com/evotech/hd/webserver/service/MessageMqttService.java index cc0969b..d3ebfa3 100644 --- a/web-server/src/main/java/com/evotech/hd/webserver/service/MessageMqttService.java +++ b/web-server/src/main/java/com/evotech/hd/webserver/service/MessageMqttService.java @@ -1,13 +1,19 @@ package com.evotech.hd.webserver.service; import cn.hutool.json.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.evotech.hd.core.dtos.Result; +import com.evotech.hd.core.dtos.system.MessageMqttDTO; import com.evotech.hd.core.entity.system.MessageMqtt; import com.evotech.hd.webserver.mqtt.MessageTopic; public interface MessageMqttService extends IService { + IPage findPageList(Page page, QueryWrapper queryWrapper); + public Result addResultId(String stationCode); public Result update(Integer id, MessageTopic topic, String messageId, int qos, JSONObject jo); diff --git a/web-server/src/main/java/com/evotech/hd/webserver/service/impl/MessageMqttServiceImpl.java b/web-server/src/main/java/com/evotech/hd/webserver/service/impl/MessageMqttServiceImpl.java index b53cbb4..b4bef87 100644 --- a/web-server/src/main/java/com/evotech/hd/webserver/service/impl/MessageMqttServiceImpl.java +++ b/web-server/src/main/java/com/evotech/hd/webserver/service/impl/MessageMqttServiceImpl.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.evotech.hd.core.dtos.Result; import com.evotech.hd.core.dtos.system.LogDTO; +import com.evotech.hd.core.dtos.system.MessageMqttDTO; import com.evotech.hd.core.entity.system.Log; import com.evotech.hd.core.entity.system.MessageMqtt; import com.evotech.hd.webserver.mapper.LogMapper; @@ -16,6 +17,7 @@ import com.evotech.hd.webserver.mqtt.MessageTopic; import com.evotech.hd.webserver.mqtt.MqttMessageHeader; import com.evotech.hd.webserver.service.LogService; import com.evotech.hd.webserver.service.MessageMqttService; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; /** @@ -29,6 +31,12 @@ import org.springframework.stereotype.Service; @Service public class MessageMqttServiceImpl extends ServiceImpl implements MessageMqttService { + @Override + public IPage findPageList(Page page, QueryWrapper queryWrapper) { + queryWrapper.orderByDesc("a.create_time");// 根据预约日期和预约时间段倒序排序 + return getBaseMapper().findPage(page, queryWrapper); + } + @Override public Result addResultId(String stationCode) { MessageMqtt messageMqtt = new MessageMqtt(); @@ -54,8 +62,8 @@ public class MessageMqttServiceImpl extends ServiceImpl - a.station_code,a.direction, a.message_id,a.qos,a.type,a.message_function,a.topic,a.content, + a.station_code,a.direction, a.message_id,a.qos,a.type,a.message_function,a.topic,a.content,request_method,