From 78f53edb9542a83d9579714cf4e1e8133fc89ee9 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期六, 05 九月 2026 19:24:13 +0800
Subject: [PATCH] 修复接收中设备离线异常的记录与展示

---
 battery-business/src/main/java/com/battery/business/service/impl/TestWarningExceptionService.java |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/battery-business/src/main/java/com/battery/business/service/impl/TestWarningExceptionService.java b/battery-business/src/main/java/com/battery/business/service/impl/TestWarningExceptionService.java
index 3a6d632..89718d7 100644
--- a/battery-business/src/main/java/com/battery/business/service/impl/TestWarningExceptionService.java
+++ b/battery-business/src/main/java/com/battery/business/service/impl/TestWarningExceptionService.java
@@ -10,11 +10,19 @@
 import com.battery.business.domain.TTestWarningThreshold;
 import com.battery.business.mapper.TTestMapper;
 
-/** 对成功接收的测量值执行测试阈值判断;设备状态和缺失数据不经过此服务。 */
+/** 分别记录测量超限与接收中的离线事实;缺失测量不参与阈值判断。 */
 @Service
 public class TestWarningExceptionService {
     private final TTestMapper mapper;
     public TestWarningExceptionService(TTestMapper mapper) { this.mapper = mapper; }
+    /** 调用方须持有测试事务锁;仅在接收中记录当前绑定来源的离线事实。 */
+    public void recordOfflineSources(TTest test, Date occurredAt) {
+        if (test == null || !"RUNNING".equals(test.getTestStatus()) || !"RECEIVING".equals(test.getReceptionStatus())) return;
+        for (var source : mapper.selectOfflineTestSources(test.getTestId())) {
+            mapper.upsertOfflineException(test.getTestId(), source.sourceType(), source.sourceIdentity(), occurredAt);
+        }
+    }
+
     /** 仅对成功接收的非空测量值判定阈值,并聚合更新开放异常及规则快照。 */
     public void evaluate(TTest test, String sourceType, String sourceIdentity, String metricCode, BigDecimal value, String unit, Date occurredAt) {
         if (value == null || test == null || test.getThresholds() == null) return;

--
Gitblit v1.7.1