From acfb83068486766f63284b479d30f78e3ec17dca Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期六, 05 九月 2026 02:24:48 +0800
Subject: [PATCH] 完成测试生命周期与接收边界

---
 ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml |   27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml
index 115e96e..999f31d 100644
--- a/ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml
@@ -17,6 +17,7 @@
         <result property="receptionStatus" column="reception_status" />
         <result property="monitorTimeoutMinutes" column="monitor_timeout_minutes" />
         <result property="startedAtUtc" column="started_at_utc" />
+        <result property="receptionBoundaryAtUtc" column="reception_boundary_at_utc" />
         <result property="endedAtUtc" column="ended_at_utc" />
         <result property="runtimeAttach" column="runtime_attach" />
         <result property="delFlag" column="del_flag" />
@@ -133,7 +134,7 @@
                t.test_type_id, ty.test_type_name, t.test_purpose,
                t.test_status,
                t.reception_status, t.monitor_timeout_minutes,
-               t.started_at_utc, t.ended_at_utc, t.del_flag,
+               t.started_at_utc, t.reception_boundary_at_utc, t.ended_at_utc, t.del_flag,
                t.create_by, t.create_time, t.update_by, t.update_time, t.remark,
                cast(t.logic_step_mappings_json as char) logic_step_mappings_json,
                cast(t.console_detail_json as char) console_detail_json,
@@ -241,11 +242,12 @@
         set test_name = #{testName}, principal_id = #{principalId}, test_type_id = #{testTypeId},
             test_purpose = #{testPurpose}, monitor_timeout_minutes = #{monitorTimeoutMinutes},
             remark = #{remark}, update_by = #{updateBy}, update_time = #{updateTime}
-        where test_id = #{testId} and reception_status = 'NOT_STARTED' and del_flag = 0
+        where test_id = #{testId} and test_status = 'WAITING' and reception_status = 'NOT_STARTED' and del_flag = 0
     </update>
 
     <delete id="deleteTestById">
-        delete from t_test where test_id = #{testId} and reception_status = 'NOT_STARTED' and del_flag = 0
+        delete from t_test
+        where test_id = #{testId} and test_status = 'WAITING' and reception_status = 'NOT_STARTED' and del_flag = 0
     </delete>
 
     <delete id="deleteTestBindingsByTestId">delete from t_test_channel_binding where test_id = #{testId}</delete>
@@ -349,7 +351,9 @@
         where exception_id=#{exceptionId} and exception_status='OPEN'
     </update>
     <select id="selectReceivingTestIds" resultType="long">
-        select test_id from t_test where del_flag = 0 and reception_status = 'RECEIVING' order by test_id
+        select test_id from t_test
+        where del_flag = 0 and test_status = 'RUNNING' and reception_status = 'RECEIVING'
+        order by test_id
     </select>
     <insert id="insertRealtimeSnapshot">
         insert ignore into t_test_realtime_snapshot
@@ -685,24 +689,29 @@
         update t_test
         set test_status = 'RUNNING', reception_status = 'RECEIVING',
             started_at_utc = coalesce(started_at_utc, #{startedAtUtc}),
+            reception_boundary_at_utc = #{startedAtUtc},
             update_by = #{updateBy}, update_time = #{startedAtUtc}
-        where test_id = #{testId} and reception_status = 'NOT_STARTED' and del_flag = 0
+        where test_id = #{testId} and test_status = 'WAITING' and reception_status = 'NOT_STARTED' and del_flag = 0
     </update>
     <update id="updateReceptionPaused">
         update t_test
         set test_status = 'PAUSED', reception_status = 'PAUSED', update_by = #{updateBy}, update_time = #{updatedAtUtc}
-        where test_id = #{testId} and reception_status = 'RECEIVING' and del_flag = 0
+        where test_id = #{testId} and test_status = 'RUNNING' and reception_status = 'RECEIVING' and del_flag = 0
     </update>
     <update id="updateReceptionResumed">
         update t_test
-        set test_status = 'RUNNING', reception_status = 'RECEIVING', update_by = #{updateBy}, update_time = #{updatedAtUtc}
-        where test_id = #{testId} and reception_status = 'PAUSED' and del_flag = 0
+        set test_status = 'RUNNING', reception_status = 'RECEIVING',
+            reception_boundary_at_utc = #{updatedAtUtc}, update_by = #{updateBy}, update_time = #{updatedAtUtc}
+        where test_id = #{testId} and test_status = 'PAUSED' and reception_status = 'PAUSED' and del_flag = 0
     </update>
     <update id="updateReceptionStopped">
         update t_test
         set test_status = 'COMPLETED', reception_status = 'ENDED', ended_at_utc = #{endedAtUtc},
             update_by = #{updateBy}, update_time = #{endedAtUtc}
-        where test_id = #{testId} and reception_status in ('RECEIVING', 'PAUSED') and del_flag = 0
+        where test_id = #{testId}
+          and ((test_status = 'RUNNING' and reception_status = 'RECEIVING')
+            or (test_status = 'PAUSED' and reception_status = 'PAUSED'))
+          and del_flag = 0
     </update>
 
     <resultMap id="TTestDataOverrideResultMap" type="com.ruoyi.system.domain.TTestDataOverride">

--
Gitblit v1.7.1