From d61c013599a1a4e09cadfe80cdf872f263737c9c Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期二, 01 九月 2026 13:19:16 +0800
Subject: [PATCH] 修正检测柜测试方案实时事实
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTestLiveServiceImpl.java | 32 +++++++++++++++++++++++++++++++-
1 files changed, 31 insertions(+), 1 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 8433e22..3a360d1 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
@@ -27,6 +27,8 @@
import com.ruoyi.system.domain.TTestCollectorExceptionInterval;
import com.ruoyi.system.mapper.TTestMapper;
import com.ruoyi.system.service.ITestLiveService;
+import com.ruoyi.system.service.ITestLiveService.TestPlanRow;
+import com.ruoyi.system.service.ITestLiveService.TestPlanSnapshot;
import com.ruoyi.system.service.ITTestService;
/** 将设备最新快照转换为测试视角,并托管 SSE 连接生命周期。 */
@@ -90,8 +92,31 @@
if (persistedIntegrity != null) integrity.addAll(persistedIntegrity);
List<com.ruoyi.system.domain.TTestIntegrityIssue> persistedExceptions = testMapper.selectTestExceptionFacts(testId);
if (persistedExceptions != null) integrity.addAll(persistedExceptions);
+ TestPlanSnapshot testPlan = detectorTestPlan(test);
return new LiveState(testId, testStatus, test.getReceptionStatus(), Instant.now(), sources, exceptions,
- integrity == null ? List.of() : integrity);
+ integrity == null ? List.of() : integrity, testPlan);
+ }
+
+ private TestPlanSnapshot detectorTestPlan(TTest test)
+ {
+ if (test.getBatteries() == null) return null;
+ for (TTestBattery battery : test.getBatteries())
+ {
+ if (battery.getBinding() == null || battery.getBinding().getDevid() == null
+ || battery.getBinding().getChlid() == null) continue;
+ try
+ {
+ var source = simulator.btsTest(battery.getBinding().getDevid(), battery.getBinding().getChlid());
+ List<TestPlanRow> rows = source.rows().stream()
+ .map(row -> new TestPlanRow(row.rowType(), row.stepNo(), row.stepName(), row.durationSeconds(),
+ row.voltageV(), row.executionStatus(), row.cycleCount(), row.recordCount()))
+ .toList();
+ return new TestPlanSnapshot(source.currentCycleNo(), source.currentStepNo(),
+ source.plannedCycleCount(), rows);
+ }
+ catch (IllegalArgumentException ignored) { /* 登记设备尚未被开发模拟器提供时保持无方案事实。 */ }
+ }
+ return null;
}
private LiveSource snapshotFor(Long testId, LiveSource fresh, boolean freeze)
@@ -165,6 +190,11 @@
if (channel.latestSnapshot() == null) return value;
value.put("source", "检测柜");
value.put("observedAt", channel.latestSnapshot().receivedAt());
+ // 实时方案需要设备当前循环和实际工步;这些字段只用于快照展示,不形成历史采集事实。
+ value.put("cycleNo", channel.latestSnapshot().cycleNo());
+ value.put("stepNo", channel.latestSnapshot().stepNo());
+ value.put("stepType", channel.latestSnapshot().stepType());
+ value.put("totalTimeSeconds", channel.latestSnapshot().totalTimeSeconds());
value.put("measurements", channel.latestSnapshot().measurements().entrySet().stream().map(entry -> {
Measurement measurement = entry.getValue();
return Map.of("metricCode", entry.getKey(), "value", measurement.value(), "unit", measurement.unit());
--
Gitblit v1.7.1