From 23c4a7838384d643dfa019ae210ef7aa0baef8c1 Mon Sep 17 00:00:00 2001
From: hongawen <83944980@qq.com>
Date: Fri, 16 Jan 2026 15:14:16 +0800
Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95=E6=94=B9?=
=?UTF-8?q?=E9=80=A0=E7=94=B1mqtt=E5=BC=82=E6=AD=A5=E6=94=B9=E9=80=A0?=
=?UTF-8?q?=E4=B8=BAredis=20list=E5=AE=9E=E7=8E=B0=EF=BC=8CTPS=E6=BB=A1?=
=?UTF-8?q?=E8=B6=B3=EF=BC=9A150-200=E6=9D=A1/=E7=A7=92?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pqs-common/common-oss/pom.xml | 7 +
.../njcn/redis/pojo/enums/RedisKeyEnum.java | 17 +-
.../redis/utils/RedisMessageQueueUtil.java | 66 ++++
.../java/com/njcn/web/config/FeignConfig.java | 3 +
.../njcn/web/service/impl/LogServiceImpl.java | 56 ++-
.../Impl/EventDetailServiceImpl.java | 7 -
.../gateway/config/ResourceServerConfig.java | 25 +-
.../system/consumer/RedisLogConsumer.java | 371 ++++++++++++++++++
.../system/handler/MqttMessageHandler.java | 10 +-
.../system/service/impl/AuditServiceImpl.java | 25 +-
10 files changed, 551 insertions(+), 36 deletions(-)
create mode 100644 pqs-common/common-redis/src/main/java/com/njcn/redis/utils/RedisMessageQueueUtil.java
create mode 100644 pqs-system/system-boot/src/main/java/com/njcn/system/consumer/RedisLogConsumer.java
diff --git a/pqs-common/common-oss/pom.xml b/pqs-common/common-oss/pom.xml
index c31b7a36f..86d8a65be 100644
--- a/pqs-common/common-oss/pom.xml
+++ b/pqs-common/common-oss/pom.xml
@@ -63,6 +63,13 @@
+
+
+ com.aliyun.oss
+ aliyun-sdk-oss
+ 3.18.0
+ false
+
\ No newline at end of file
diff --git a/pqs-common/common-redis/src/main/java/com/njcn/redis/pojo/enums/RedisKeyEnum.java b/pqs-common/common-redis/src/main/java/com/njcn/redis/pojo/enums/RedisKeyEnum.java
index 9b305da0e..0d16c1eec 100644
--- a/pqs-common/common-redis/src/main/java/com/njcn/redis/pojo/enums/RedisKeyEnum.java
+++ b/pqs-common/common-redis/src/main/java/com/njcn/redis/pojo/enums/RedisKeyEnum.java
@@ -45,7 +45,22 @@ public enum RedisKeyEnum {
/**
* 云前置心跳
*/
- CLD_HEART_BEAT_KEY("CLD_HEART_BEAT:", 180L);
+ CLD_HEART_BEAT_KEY("CLD_HEART_BEAT:", 180L),
+
+ /**
+ * 用户日志队列
+ */
+ USER_LOG_QUEUE("USER_LOG_QUEUE", -1L),
+
+ /**
+ * 用户日志邮件推送队列
+ */
+ USER_LOG_EMAIL_QUEUE("USER_LOG_EMAIL_QUEUE", -1L),
+
+ /**
+ * 终端日志
+ */
+ DEVICE_LOG_QUEUE("DEVICE_LOG_QUEUE", -1L);
private final String key;
diff --git a/pqs-common/common-redis/src/main/java/com/njcn/redis/utils/RedisMessageQueueUtil.java b/pqs-common/common-redis/src/main/java/com/njcn/redis/utils/RedisMessageQueueUtil.java
new file mode 100644
index 000000000..5ec6f4454
--- /dev/null
+++ b/pqs-common/common-redis/src/main/java/com/njcn/redis/utils/RedisMessageQueueUtil.java
@@ -0,0 +1,66 @@
+package com.njcn.redis.utils;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Redis 消息队列工具类
+ */
+@Slf4j
+@Component
+@RequiredArgsConstructor
+public class RedisMessageQueueUtil {
+
+ private final RedisTemplate redisTemplate;
+
+ /**
+ * 推送消息到队列(左推)
+ *
+ * @param queueKey 队列Key
+ * @param message 消息内容(JSON字符串)
+ */
+ public void pushMessage(String queueKey, String message) {
+ try {
+ redisTemplate.opsForList().leftPush(queueKey, message);
+ } catch (Exception e) {
+ log.error("推送消息到队列失败,queueKey={}", queueKey, e);
+ throw e;
+ }
+ }
+
+ /**
+ * 阻塞式弹出消息(右弹)
+ *
+ * @param queueKey 队列Key
+ * @param timeout 超时时间(秒)
+ * @return 消息内容,超时返回null
+ */
+ public String popMessage(String queueKey, long timeout) {
+ try {
+ Object result = redisTemplate.opsForList().rightPop(queueKey, timeout, TimeUnit.SECONDS);
+ return result != null ? result.toString() : null;
+ } catch (Exception e) {
+ log.error("弹出消息失败,queueKey={}", queueKey, e);
+ return null;
+ }
+ }
+
+ /**
+ * 获取队列长度(用于监控)
+ *
+ * @param queueKey 队列Key
+ * @return 队列长度
+ */
+ public Long getQueueSize(String queueKey) {
+ try {
+ return redisTemplate.opsForList().size(queueKey);
+ } catch (Exception e) {
+ log.error("获取队列长度失败,queueKey={}", queueKey, e);
+ return 0L;
+ }
+ }
+}
\ No newline at end of file
diff --git a/pqs-common/common-web/src/main/java/com/njcn/web/config/FeignConfig.java b/pqs-common/common-web/src/main/java/com/njcn/web/config/FeignConfig.java
index d8fdfd33e..ec519054b 100644
--- a/pqs-common/common-web/src/main/java/com/njcn/web/config/FeignConfig.java
+++ b/pqs-common/common-web/src/main/java/com/njcn/web/config/FeignConfig.java
@@ -47,6 +47,7 @@ public class FeignConfig {
@Bean
public Decoder feignDecoder() {
return (response, type) -> {
+
String bodyStr = Util.toString(response.body().asReader(Util.UTF_8));
//对结果进行转换
HttpResult