From 8eb62ee0efe77e264cd48b3f1fd835e9b8430318 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期三, 28 十月 2026 15:02:12 +0800
Subject: [PATCH] fix 设备数采

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/collect/MesCollectDataParser.java |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/collect/MesCollectDataParser.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/collect/MesCollectDataParser.java
index 931b38a..2215a08 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/collect/MesCollectDataParser.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/collect/MesCollectDataParser.java
@@ -201,7 +201,32 @@
         return parts.length >= 2 ? parts[parts.length - 2] : null;
     }
 
-    private String extractTopicSuffix(String mqttTopic) {
+    /**
+     * 缃戝叧鏍煎紡鎶ユ枃鎷嗗寘锛氭姤鏂囬灞� key 鏄澶囧悕锛寁alue 鏄璁惧鐨勫睘鎬у瓧鍏搞��
+     *
+     * <p>渚嬪 {"630妗嗙粸鏈�2":{"璁$背":268.3499}} 鎷嗘垚 {630妗嗙粸鏈�2 -> {"璁$背":268.3499}}锛�
+     * 杩炴帴浜嬩欢 {"device":"澶ф媺"} 杩欑被鎵佸钩鎶ユ枃娌℃湁宓屽瀵硅薄锛岃繑鍥炵┖ Map 鐢辫皟鐢ㄦ柟鍙﹁澶勭悊銆�</p>
+     */
+    public Map<String, JsonNode> splitGatewayDevices(JsonNode root) {
+        Map<String, JsonNode> devices = new LinkedHashMap<>();
+        if (root == null || !root.isObject()) {
+            return devices;
+        }
+        root.properties().forEach(entry -> {
+            String deviceCode = StrUtil.trim(entry.getKey());
+            JsonNode data = entry.getValue();
+            if (StrUtil.isBlank(deviceCode) || data == null || !data.isObject()) {
+                return;
+            }
+            devices.put(deviceCode, data);
+        });
+        return devices;
+    }
+
+    /**
+     * 鍙栦富棰樻湯娈典綔涓烘姤鏂囩被鍨嬶紝濡� gateway/attributes -> attributes銆乬ateway/disconnect -> disconnect
+     */
+    public String extractTopicSuffix(String mqttTopic) {
         if (StrUtil.isBlank(mqttTopic)) {
             return null;
         }

--
Gitblit v1.9.3