From 96144b97e1761db230c0dc61a837ec55d76210df Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期三, 02 九月 2026 15:50:55 +0800
Subject: [PATCH] 允许离线设备进入接收状态

---
 ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestServiceImplTest.java |   33 ++++++++++++++++++++++++---------
 1 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestServiceImplTest.java b/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestServiceImplTest.java
index 561b2de..32c39ad 100644
--- a/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestServiceImplTest.java
+++ b/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TTestServiceImplTest.java
@@ -383,7 +383,6 @@
         when(testMapper.selectReceptionChannelForUpdate(100L)).thenReturn(channel);
         when(testMapper.countCollectorEnabled(8L)).thenReturn(1);
         when(testMapper.selectCollectorChannelCount(8L)).thenReturn(4);
-        when(testMapper.collectorOnline(8L)).thenReturn(true);
         when(testMapper.updateReceptionStarted(eq(10L), any(), anyBoolean(), eq("operator"))).thenReturn(1);
 
         assertEquals(1, testService.startReception(10L, 7L, "operator"));
@@ -406,7 +405,6 @@
         when(testMapper.selectReceptionChannelForUpdate(100L)).thenReturn(channel);
         when(testMapper.countCollectorEnabled(8L)).thenReturn(1);
         when(testMapper.selectCollectorChannelCount(8L)).thenReturn(4);
-        when(testMapper.collectorOnline(8L)).thenReturn(true);
         when(testMapper.updateReceptionStarted(eq(10L), any(), anyBoolean(), eq("operator"))).thenReturn(1);
 
         assertEquals(1, testService.startReception(10L, 7L, "operator"));
@@ -430,7 +428,6 @@
         when(testMapper.selectReceptionChannelForUpdate(100L)).thenReturn(channel);
         when(testMapper.countCollectorEnabled(8L)).thenReturn(1);
         when(testMapper.selectCollectorChannelCount(8L)).thenReturn(4);
-        when(testMapper.collectorOnline(8L)).thenReturn(true);
         when(testMapper.updateReceptionStarted(eq(10L), any(), anyBoolean(), eq("operator"))).thenReturn(1);
 
         assertEquals(1, testService.startReception(10L, 7L, "operator"));
@@ -438,22 +435,41 @@
     }
 
     @Test
-    void startReceptionShouldRejectOfflineSourceWithoutWritingAnything()
+    void startReceptionShouldAllowOfflineSourcesWithoutBlockingReception()
     {
         TTest current = validTest();
         current.setTestId(10L);
         current.setReceptionStatus("NOT_STARTED");
+        current.getBatteries().get(0).getBinding().setBindingId(30L);
         when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current);
         TDetectionChannel channel = new TDetectionChannel();
         channel.setChannelId(100L);
         channel.setOnlineStatus("OFFLINE");
         when(testMapper.selectReceptionChannelForUpdate(100L)).thenReturn(channel);
+        when(testMapper.countCollectorEnabled(8L)).thenReturn(1);
+        when(testMapper.selectCollectorChannelCount(8L)).thenReturn(4);
+        when(testMapper.updateReceptionStarted(eq(10L), any(), anyBoolean(), eq("operator"))).thenReturn(1);
 
-        ServiceException exception = assertThrows(ServiceException.class,
-                () -> testService.startReception(10L, 7L, "operator"));
+        assertEquals(1, testService.startReception(10L, 7L, "operator"));
+    }
 
-        assertEquals("检测柜通道 100 当前离线或不可观测", exception.getMessage());
-        verify(testMapper, never()).updateReceptionStarted(any(), any(), anyBoolean(), any());
+    @Test
+    void startReceptionShouldAllowOfflineCollectorWithoutBlockingReception()
+    {
+        TTest current = validTest();
+        current.setTestId(10L);
+        current.setReceptionStatus("NOT_STARTED");
+        current.getBatteries().get(0).getBinding().setBindingId(30L);
+        when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current);
+        TDetectionChannel channel = new TDetectionChannel();
+        channel.setChannelId(100L);
+        channel.setOnlineStatus("ONLINE");
+        when(testMapper.selectReceptionChannelForUpdate(100L)).thenReturn(channel);
+        when(testMapper.countCollectorEnabled(8L)).thenReturn(1);
+        when(testMapper.selectCollectorChannelCount(8L)).thenReturn(4);
+        when(testMapper.updateReceptionStarted(eq(10L), any(), anyBoolean(), eq("operator"))).thenReturn(1);
+
+        assertEquals(1, testService.startReception(10L, 7L, "operator"));
     }
 
     @Test
@@ -471,7 +487,6 @@
         channel.setLastSeenAtUtc(Instant.parse("2026-08-29T12:00:00Z"));
         when(testMapper.selectReceptionChannelForUpdate(100L)).thenReturn(channel);
         when(testMapper.countCollectorEnabled(8L)).thenReturn(1);
-        when(testMapper.collectorOnline(8L)).thenReturn(true);
         when(testMapper.selectCollectorChannelCount(8L)).thenReturn(4);
 
         ServiceException exception = assertThrows(ServiceException.class,

--
Gitblit v1.7.1