From 76cd5948e95ddbde9dd4411b466ee75ba20b562e Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期四, 03 九月 2026 17:28:29 +0800
Subject: [PATCH] 实现测试预警异常管理
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTestLiveServiceImpl.java | 16 +++++++++++++++-
1 files changed, 15 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 2b24d8e..1869330 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
@@ -13,6 +13,7 @@
import java.util.concurrent.TimeUnit;
import jakarta.annotation.PreDestroy;
import org.springframework.stereotype.Service;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import com.ruoyi.device.bts.BtsDevelopmentSimulator;
import com.ruoyi.device.bts.BtsDevelopmentSimulator.CollectorSnapshot;
@@ -26,6 +27,7 @@
import com.ruoyi.system.service.ITestLiveService.TestPlanRow;
import com.ruoyi.system.service.ITestLiveService.TestPlanSnapshot;
import com.ruoyi.system.service.ITTestService;
+import com.ruoyi.system.mapper.TTestMapper;
/** 将设备最新快照转换为测试视角,并托管 SSE 连接生命周期。 */
@Service
@@ -34,11 +36,17 @@
private final ITTestService tests;
private final DeviceDiscoveryCandidateStore candidates;
private final BtsDevelopmentSimulator simulator;
+ private final TTestMapper mapper;
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(2);
+
+ @Autowired
+ public TTestLiveServiceImpl(ITTestService tests, DeviceDiscoveryCandidateStore candidates,
+ BtsDevelopmentSimulator simulator, TTestMapper mapper)
+ { this.tests = tests; this.candidates = candidates; this.simulator = simulator; this.mapper = mapper; }
public TTestLiveServiceImpl(ITTestService tests, DeviceDiscoveryCandidateStore candidates,
BtsDevelopmentSimulator simulator)
- { this.tests = tests; this.candidates = candidates; this.simulator = simulator; }
+ { this(tests, candidates, simulator, null); }
@Override public LiveState current(Long testId)
{
@@ -60,6 +68,12 @@
.map(source -> Map.<String, Object>of("sourceType", source.sourceType(), "sourceId", source.sourceId(),
"batteryNo", source.batteryNo(), "status", source.deviceStatus(), "message", "数据来源当前不可观测"))
.toList());
+ if (mapper != null) {
+ mapper.selectWarningExceptions(testId, "OPEN").forEach(item -> exceptions.add(Map.of(
+ "exceptionId", item.getExceptionId(), "sourceType", item.getSourceType(),
+ "metricCode", item.getMetricCode(), "value", item.getAbnormalValue(), "unit", item.getUnit(),
+ "status", item.getExceptionStatus(), "message", "测试预警异常")));
+ }
String testStatus = test.getTestStatus();
TestPlanSnapshot testPlan = detectorTestPlan(test);
return new LiveState(testId, testStatus, test.getReceptionStatus(), Instant.now(), sources, exceptions, testPlan);
--
Gitblit v1.7.1