From c2dd019c1fddaeae412e2b6f44fb86ff0dc635d4 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期三, 02 九月 2026 22:08:16 +0800
Subject: [PATCH] 实现主动轮询完整实时快照
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestDataQueryServiceImpl.java | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestDataQueryServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestDataQueryServiceImpl.java
index 910777b..06ee3c8 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestDataQueryServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestDataQueryServiceImpl.java
@@ -37,10 +37,15 @@
{
requireTest(testId);
List<Map<String, Object>> source = new java.util.ArrayList<>();
- List<Map<String, Object>> cabinet = mapper.selectPersistedRecords(testId);
- List<Map<String, Object>> collector = mapper.selectPersistedCollectorRecords(testId);
- if (cabinet != null) source.addAll(cabinet);
- if (collector != null) source.addAll(collector);
+ List<Map<String, Object>> snapshots = mapper.selectPersistedRealtimeSnapshots(testId);
+ if (snapshots != null && !snapshots.isEmpty()) source.addAll(snapshots);
+ else {
+ // 迁移完成前兼容旧数据;新采集只从统一快照读取。
+ List<Map<String, Object>> cabinet = mapper.selectPersistedRecords(testId);
+ List<Map<String, Object>> collector = mapper.selectPersistedCollectorRecords(testId);
+ if (cabinet != null) source.addAll(cabinet);
+ if (collector != null) source.addAll(collector);
+ }
List<Map<String, Object>> effective = applyEffectiveData(testId, "REALTIME", source);
attachCollectorStepContext(effective);
return effective;
@@ -111,6 +116,8 @@
private String stableIdentity(String dataType, Map<String, Object> row)
{
+ if ("REALTIME".equals(dataType) && "SNAPSHOT".equals(String.valueOf(row.get("sourceType"))))
+ return String.valueOf(row.getOrDefault("stableIdentity", "snapshot:" + value(row, "snapshotId")));
if ("REALTIME".equals(dataType) && "COLLECTOR".equals(String.valueOf(row.get("sourceType"))))
return String.join(":", "collector", identityPart(row, "collectorId"),
identityPart(row, "channelCode"), value(row, "sequenceId"), identityPart(row, "metricCode"));
--
Gitblit v1.7.1