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

---
 ruoyi-admin/src/test/java/com/battery/business/service/impl/TestWarningExceptionServiceTest.java |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/ruoyi-admin/src/test/java/com/battery/business/service/impl/TestWarningExceptionServiceTest.java b/ruoyi-admin/src/test/java/com/battery/business/service/impl/TestWarningExceptionServiceTest.java
index 558fd2c..84188d9 100644
--- a/ruoyi-admin/src/test/java/com/battery/business/service/impl/TestWarningExceptionServiceTest.java
+++ b/ruoyi-admin/src/test/java/com/battery/business/service/impl/TestWarningExceptionServiceTest.java
@@ -13,9 +13,33 @@
 import com.battery.business.domain.TTestWarningThreshold;
 import com.battery.business.mapper.TTestMapper;
 
-/** 测试预警仅由成功接收测量值触发,并通过持久层原子聚合。 */
+/** 阈值异常与接收中的离线异常分别判定,并通过持久层原子聚合。 */
 class TestWarningExceptionServiceTest {
     @Test
+    void recordsOfflineSourcesOnlyWhileReceivingWithoutInventingMeasurements() {
+        TTestMapper mapper = mock(TTestMapper.class);
+        var service = new TestWarningExceptionService(mapper);
+        TTest test = new TTest();
+        test.setTestId(1L);
+        test.setTestStatus("RUNNING");
+        test.setReceptionStatus("RECEIVING");
+        Date now = new Date();
+        when(mapper.selectOfflineTestSources(1L)).thenReturn(List.of(
+                new com.battery.business.domain.vo.OfflineTestSource("CABINET_CHANNEL", "sim:22:1:1:1"),
+                new com.battery.business.domain.vo.OfflineTestSource("COLLECTOR", "9")));
+
+        service.recordOfflineSources(test, now);
+        verify(mapper).upsertOfflineException(1L, "CABINET_CHANNEL", "sim:22:1:1:1", now);
+        verify(mapper).upsertOfflineException(1L, "COLLECTOR", "9", now);
+        clearInvocations(mapper);
+        for (String state : List.of("PAUSED", "ENDED", "NOT_STARTED")) {
+            test.setReceptionStatus(state);
+            service.recordOfflineSources(test, now);
+        }
+        verifyNoInteractions(mapper);
+    }
+
+    @Test
     void evaluatesOnlyOutOfRangeValues() {
         TTestMapper mapper = mock(TTestMapper.class);
         TestWarningExceptionService service = new TestWarningExceptionService(mapper);

--
Gitblit v1.7.1