From bc9a169ce3648467136a279d167f72c4fbab9595 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期六, 05 九月 2026 00:53:48 +0800
Subject: [PATCH] 完成设备发现登记与状态事实
---
ruoyi-system/src/main/resources/mapper/system/TCollectorMapper.xml | 45 +++++++++++++++++++++++++++++++++++----------
1 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/ruoyi-system/src/main/resources/mapper/system/TCollectorMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TCollectorMapper.xml
index 70e19b1..fcf60f7 100644
--- a/ruoyi-system/src/main/resources/mapper/system/TCollectorMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/TCollectorMapper.xml
@@ -6,6 +6,7 @@
<resultMap type="TCollector" id="TCollectorResult">
<id property="collectorId" column="collector_id" />
+ <result property="adapterId" column="adapter_id" />
<result property="collectorCode" column="collector_code" />
<result property="ipAddress" column="ip_address" />
<result property="macAddress" column="mac_address" />
@@ -16,7 +17,7 @@
<result property="onlineStatus" column="online_status" />
<result property="testStatus" column="test_status" />
<result property="currentTest" column="current_test" />
- <result property="currentSampleName" column="current_sample_name" />
+ <result property="lastSeenAtUtc" column="last_seen_at_utc" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
@@ -27,11 +28,27 @@
</resultMap>
<sql id="selectCollectorVo">
- select collector_id, collector_code, ip_address, mac_address, collector_name,
- manufacturer, model, channel_count, online_status, test_status,
- current_test, current_sample_name, status, del_flag, create_by,
- create_time, update_by, update_time, remark
- from t_collector
+ select c.collector_id, c.collector_code, c.adapter_id, c.ip_address, c.mac_address, c.collector_name,
+ c.manufacturer, c.model, c.channel_count,
+ case when upper(c.online_status) = 'ONLINE' or c.online_status = '1' then '1' else '0' end as online_status,
+ c.last_seen_at_utc,
+ case when exists (
+ select 1 from t_test_collector_channel mapping
+ join t_test test_fact on test_fact.test_id = mapping.test_id
+ where mapping.collector_id = c.collector_id
+ and test_fact.del_flag = 0
+ and test_fact.test_status in ('RUNNING', 'PAUSED')
+ ) then '1' else '0' end as test_status,
+ case when exists (
+ select 1 from t_test_collector_channel mapping
+ join t_test test_fact on test_fact.test_id = mapping.test_id
+ where mapping.collector_id = c.collector_id
+ and test_fact.del_flag = 0
+ and test_fact.test_status in ('RUNNING', 'PAUSED')
+ ) then '待确认' else null end as current_test,
+ c.status, c.del_flag, c.create_by,
+ c.create_time, c.update_by, c.update_time, c.remark
+ from t_collector c
</sql>
<select id="selectCollectorById" parameterType="Long" resultMap="TCollectorResult">
@@ -60,7 +77,13 @@
and online_status = #{onlineStatus}
</if>
<if test="testStatus != null and testStatus != ''">
- and test_status = #{testStatus}
+ and (case when exists (
+ select 1 from t_test_collector_channel mapping
+ join t_test test_fact on test_fact.test_id = mapping.test_id
+ where mapping.collector_id = c.collector_id
+ and test_fact.del_flag = 0
+ and test_fact.test_status in ('RUNNING', 'PAUSED')
+ ) then '1' else '0' end) = #{testStatus}
</if>
<if test="status != null and status != ''">
and status = #{status}
@@ -92,17 +115,19 @@
<insert id="insertCollector" parameterType="TCollector" useGeneratedKeys="true" keyProperty="collectorId">
insert into t_collector
(collector_code, ip_address, mac_address, collector_name, manufacturer, model,
- channel_count, online_status, test_status, current_test, current_sample_name,
+ channel_count, online_status, last_seen_at_utc,
status, del_flag, create_by, create_time, remark)
values
(#{collectorCode}, #{ipAddress}, #{macAddress}, #{collectorName}, #{manufacturer}, #{model},
- #{channelCount}, #{onlineStatus}, #{testStatus}, #{currentTest}, #{currentSampleName},
+ #{channelCount}, case when #{onlineStatus} in ('1', 'ONLINE') then 'ONLINE' else 'OFFLINE' end,
+ #{lastSeenAtUtc},
#{status}, #{delFlag}, #{createBy}, #{createTime}, #{remark})
</insert>
<update id="updateRegisteredObservation">
update t_collector
- set online_status = #{onlineStatus}, update_time = sysdate()
+ set online_status = case when #{onlineStatus} in ('1', 'ONLINE') then 'ONLINE' else 'OFFLINE' end,
+ last_seen_at_utc = utc_timestamp(3), update_time = sysdate()
where collector_code = #{collectorCode} and del_flag = 0
</update>
--
Gitblit v1.7.1