From 7a4f9541331bef779a506b38a27ed5c3373c0bec Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 15 五月 2025 13:53:22 +0800
Subject: [PATCH] 开发二级等保功能及心跳消息队列修改

---
 ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/tools/MessageUtil.java |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/tools/MessageUtil.java b/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/tools/MessageUtil.java
index bd592d8..caab60d 100644
--- a/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/tools/MessageUtil.java
+++ b/ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/tools/MessageUtil.java
@@ -7,7 +7,11 @@
 import com.ruoyi.integration.mongodb.service.*;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.concurrent.TimeUnit;
 
 @Slf4j
 @Component
@@ -57,6 +61,8 @@
     private PlatformRemoteUpdateService platformRemoteUpdateService;
     @Autowired
     private QrCodeDeliveryService qrCodeDeliveryService;
+    @Resource
+    private RedisTemplate redisTemplate;
 
     /**
      * 登录认证应答
@@ -76,7 +82,9 @@
      */
     public JSONObject pong(Pong pong){
         log.info("心跳包应答:{}", pong);
-        pongService.create(pong);
+//        pongService.create(pong);
+        //存储缓存中,5分钟有效
+        redisTemplate.opsForValue().set("pong:" + pong.getCharging_pile_code() + pong.getCharging_gun_code(), pong, 5, TimeUnit.MINUTES);
         return  getMessageJsonString(pong, ServiceIdMenu.PONG.getValue());
     }
 
@@ -289,6 +297,7 @@
     public JSONObject getMessageJsonString(Object object, String serviceId){
         JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(object));
         jsonObject.put("service_id", serviceId);
+        log.info("发送数据service_id:{},发送内容:{}",serviceId,jsonObject);
         return jsonObject;
     }
 }

--
Gitblit v1.7.1