From a2a8908f2d9d4e19201423ff58ee23c65a8df670 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期六, 29 八月 2026 20:51:10 +0800
Subject: [PATCH] 实现测试原子开始接收
---
ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 51 insertions(+), 1 deletions(-)
diff --git a/ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml
index a313720..d19302b 100644
--- a/ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml
@@ -18,6 +18,7 @@
<result property="monitorTimeoutMinutes" column="monitor_timeout_minutes" />
<result property="startedAtUtc" column="started_at_utc" />
<result property="endedAtUtc" column="ended_at_utc" />
+ <result property="runtimeAttach" column="runtime_attach" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
@@ -115,7 +116,9 @@
t.test_status, t.reception_status, t.monitor_timeout_minutes,
t.started_at_utc, t.ended_at_utc, t.del_flag,
t.create_by, t.create_time, t.update_by, t.update_time, t.remark,
- (select count(1) from t_test_battery b where b.test_id = t.test_id and b.del_flag = 0) battery_count
+ (select count(1) from t_test_battery b where b.test_id = t.test_id and b.del_flag = 0) battery_count,
+ exists (select 1 from t_test_reception_interval ri where ri.test_id = t.test_id
+ and ri.boundary_note like '运行中接入%') runtime_attach
from t_test t
left join sys_user creator on creator.user_id = t.creator_id and creator.del_flag = '0'
left join sys_user principal on principal.user_id = t.principal_id and principal.del_flag = '0'
@@ -343,4 +346,51 @@
<choose><when test="newValue != null">cast(#{newValue} as json)</when><otherwise>null</otherwise></choose>,
uuid())
</insert>
+
+ <select id="selectReceptionChannelForUpdate" parameterType="Long" resultType="com.ruoyi.system.domain.TDetectionChannel">
+ select channel_id, adapter_id, cabinet_id, devtype, devid, subdevid, chlid, display_no,
+ online_status, work_status, last_seen_at_utc, status
+ from t_detection_channel channel_fact
+ join t_detection_cabinet cabinet on cabinet.cabinet_id = channel_fact.cabinet_id
+ where channel_fact.channel_id = #{channelId}
+ and channel_fact.del_flag = 0 and channel_fact.status = '0'
+ and cabinet.del_flag = 0 and cabinet.status = '0'
+ and cabinet.registration_status = 'REGISTERED'
+ for update
+ </select>
+ <select id="selectChannelLeaseForUpdate" parameterType="Long" resultMap="TTestBindingResultMap">
+ select binding.binding_id, binding.test_id, binding.battery_relation_id, binding.channel_id,
+ binding.claim_status
+ from t_channel_lease lease
+ join t_test_channel_binding binding on binding.binding_id = lease.binding_id
+ where lease.channel_id = #{channelId}
+ for update
+ </select>
+ <insert id="insertChannelLease">
+ insert into t_channel_lease(channel_id, test_id, binding_id, acquired_by, acquired_at_utc)
+ values(#{channelId}, #{testId}, #{bindingId}, #{acquiredBy}, #{acquiredAtUtc})
+ </insert>
+ <insert id="insertCollectorChannelLease">
+ insert into t_collector_channel_lease(collector_id, channel_code, test_id, binding_id, acquired_by, acquired_at_utc)
+ values(#{collectorId}, #{channelCode}, #{testId}, #{bindingId}, #{acquiredBy}, #{acquiredAtUtc})
+ </insert>
+ <select id="collectorOnline" resultType="boolean">
+ select count(1) > 0 from t_collector
+ where collector_id = #{collectorId} and status = '0' and del_flag = 0
+ and upper(online_status) in ('ONLINE', '1')
+ </select>
+ <update id="updateReceptionStarted">
+ update t_test
+ set test_status = 'RUNNING', reception_status = 'RECEIVING',
+ started_at_utc = coalesce(started_at_utc, #{startedAtUtc}),
+ update_by = #{updateBy}, update_time = #{startedAtUtc}
+ where test_id = #{testId} and reception_status = 'NOT_STARTED' and del_flag = 0
+ </update>
+ <insert id="insertReceptionInterval" parameterType="com.ruoyi.system.domain.TTestReceptionInterval" useGeneratedKeys="true" keyProperty="intervalId">
+ insert into t_test_reception_interval
+ (test_id, binding_id, source_type, source_id, source_channel_code, action_at_utc,
+ start_boundary_at_utc, boundary_note, interval_status)
+ values(#{testId}, #{bindingId}, #{sourceType}, #{sourceId}, #{sourceChannelCode}, #{actionAtUtc},
+ #{startBoundaryAtUtc}, #{boundaryNote}, #{intervalStatus})
+ </insert>
</mapper>
--
Gitblit v1.7.1