From 07d3e4aa6478fe61edb271d80cbc61d037e6f409 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期六, 05 九月 2026 11:45:36 +0800
Subject: [PATCH] 对齐控制台时间与扩展测量响应
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTestLiveServiceImpl.java | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTestLiveServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTestLiveServiceImpl.java
index 02cd9b9..34cf5e1 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTestLiveServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTestLiveServiceImpl.java
@@ -78,7 +78,7 @@
}
String testStatus = test.getTestStatus();
TestPlanSnapshot testPlan = detectorTestPlan(test);
- return new LiveState(testId, testStatus, test.getReceptionStatus(), Instant.now(), sources, exceptions, testPlan);
+ return new LiveState(testId, testStatus, test.getReceptionStatus(), Instant.now().toEpochMilli(), sources, exceptions, testPlan);
}
private TestPlanSnapshot detectorTestPlan(TTest test)
@@ -181,7 +181,7 @@
Map<String, Object> value = new LinkedHashMap<>();
if (channel.latestSnapshot() == null) return value;
value.put("source", "检测柜");
- value.put("observedAt", channel.latestSnapshot().receivedAt());
+ value.put("observedAt", channel.latestSnapshot().receivedAt().toEpochMilli());
// BTS 核心采样字段是快照的一等事实,不能只依赖动态 measurements 展示。
value.put("currentA", channel.latestSnapshot().currentA());
value.put("voltageV", channel.latestSnapshot().voltageV());
@@ -214,10 +214,19 @@
{
Map<String, Object> value = new LinkedHashMap<>();
value.put("source", "采集器"); value.put("sampleIntervalMs", collector.sampleIntervalMs());
- value.put("measurements", collector.latestMeasurements());
+ value.put("measurements", collector.latestMeasurements().stream().map(item -> {
+ Map<String, Object> measurement = new LinkedHashMap<>();
+ measurement.put("metricCode", item.metricCode());
+ measurement.put("channelCode", item.channelCode());
+ measurement.put("value", item.value());
+ measurement.put("unit", item.unit());
+ measurement.put("deviceTime", item.deviceTime().toEpochMilli());
+ measurement.put("serverReceivedAt", item.serverReceivedAt().toEpochMilli());
+ return measurement;
+ }).toList());
value.put("units", collector.latestMeasurements().stream().map(item -> item.unit()).distinct().toList());
collector.latestMeasurements().stream().map(item -> item.serverReceivedAt()).max(Instant::compareTo)
- .ifPresent(observedAt -> value.put("observedAt", observedAt));
+ .ifPresent(observedAt -> value.put("observedAt", observedAt.toEpochMilli()));
return new LiveSource("COLLECTOR", (long) collector.collectorId(), battery.getBatteryNo(),
collector.online() ? "ONLINE" : "OFFLINE", collector.online() ? value : Map.of());
}
--
Gitblit v1.7.1