From 0fcd0642efdff8d4e0584fa991aaea2178bc932b Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期二, 01 九月 2026 22:48:35 +0800
Subject: [PATCH] 测试控制台持续更新

---
 ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml |   70 ++++++++++++++++++++++++++++++++++-
 1 files changed, 68 insertions(+), 2 deletions(-)

diff --git a/ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml
index 1f0e210..4ba5d0a 100644
--- a/ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml
@@ -367,6 +367,67 @@
         where test_id = #{testId}
         order by source_type, source_id, source_channel_code, start_boundary_at_utc, interval_id
     </select>
+    <select id="selectReceivingTestIds" resultType="long">
+        select test_id from t_test where del_flag = 0 and reception_status = 'RECEIVING' order by test_id
+    </select>
+    <select id="selectPersistedRecords" resultType="map">
+        select sample.sample_id id,
+               concat('RD-', channel.devid, '-', channel.chlid, '-', lpad(sample.seq_id, 6, '0')) recordNo,
+               battery.battery_no batteryNo, sample.cycle_no cycleNo, sample.step_no stepNo,
+               coalesce(sample.step_name, sample.step_type) stepName, sample.step_type stepType, sample.seq_id sequenceId,
+               sample.device_time_utc recordedAt, sample.device_time_utc absoluteTime,
+               sample.voltage_v voltage, sample.current_a current, sample.capacity_ah capacity,
+               sample.energy_wh energy, channel.devid deviceId, channel.chlid channelId
+        from t_test_sample sample
+        join t_test_battery battery on battery.relation_id = sample.binding_id and battery.del_flag = 0
+        join t_detection_channel channel on channel.channel_id = sample.channel_id and channel.del_flag = 0
+        where sample.test_id = #{testId}
+        order by sample.device_time_utc desc, sample.seq_id desc, sample.sample_id desc
+    </select>
+    <select id="selectPersistedSteps" resultType="map">
+        select concat('step:', channel.devid, ':', channel.chlid, ':', sample.cycle_no, ':', sample.step_no) id,
+               concat('STEP-', channel.devid, '-', channel.chlid, '-', sample.cycle_no, '-', sample.step_no) recordNo,
+               battery.battery_no batteryNo, sample.cycle_no cycleNo, sample.step_no stepNo,
+               coalesce(sample.step_name, sample.step_type) stepName,
+               sample.step_type stepType, coalesce(sample.step_name, sample.step_type) actualStepLabel,
+               count(*) recordCount,
+               min(sample.device_time_utc) recordedAt, min(sample.device_time_utc) absoluteTime,
+               timestampdiff(second, min(sample.device_time_utc), max(sample.device_time_utc)) stepDuration,
+               max(sample.capacity_ah) capacity, max(sample.energy_wh) energy,
+               min(sample.voltage_v) startVoltage,
+               max(sample.voltage_v) endVoltage,
+               max(case when sample.current_a &gt;= 0 then sample.voltage_v end) chargePeakVoltage,
+               min(case when sample.current_a &lt; 0 then sample.voltage_v end) dischargeValleyVoltage,
+               channel.devid deviceId, channel.chlid channelId
+        from t_test_sample sample
+        join t_test_battery battery on battery.relation_id = sample.binding_id and battery.del_flag = 0
+        join t_detection_channel channel on channel.channel_id = sample.channel_id and channel.del_flag = 0
+        where sample.test_id = #{testId}
+        group by sample.binding_id, battery.battery_no, channel.devid, channel.chlid, sample.cycle_no, sample.step_no,
+                 sample.step_type, sample.step_name
+        order by sample.cycle_no, sample.step_no, battery.battery_no
+    </select>
+    <select id="selectPersistedCycles" resultType="map">
+        select concat('cycle:', channel.devid, ':', channel.chlid, ':', sample.cycle_no) id,
+               concat('CYCLE-', channel.devid, '-', channel.chlid, '-', sample.cycle_no) recordNo,
+               battery.battery_no batteryNo, sample.cycle_no cycleNo, count(*) recordCount,
+               min(sample.device_time_utc) recordedAt, min(sample.device_time_utc) absoluteTime,
+               greatest(max(case when sample.current_a &gt;= 0 then sample.capacity_ah end), 0) chargeCapacity,
+               greatest(max(case when sample.current_a &lt; 0 then sample.capacity_ah end), 0) dischargeCapacity,
+               greatest(max(case when sample.current_a &gt;= 0 then sample.energy_wh end), 0) chargeEnergy,
+               greatest(max(case when sample.current_a &lt; 0 then abs(sample.energy_wh) end), 0) dischargeEnergy,
+               case when max(case when sample.current_a &gt;= 0 then sample.capacity_ah end) &gt; 0
+                    then greatest(max(case when sample.current_a &lt; 0 then sample.capacity_ah end), 0)
+                         / max(case when sample.current_a &gt;= 0 then sample.capacity_ah end) * 100
+                    else 0 end efficiency,
+               channel.devid deviceId, channel.chlid channelId
+        from t_test_sample sample
+        join t_test_battery battery on battery.relation_id = sample.binding_id and battery.del_flag = 0
+        join t_detection_channel channel on channel.channel_id = sample.channel_id and channel.del_flag = 0
+        where sample.test_id = #{testId}
+        group by sample.binding_id, battery.battery_no, channel.devid, channel.chlid, sample.cycle_no
+        order by sample.cycle_no, battery.battery_no
+    </select>
     <select id="selectTestResults" parameterType="TTestResult" resultMap="TTestResultResultMap">
         select result.*, battery.test_id from t_test_result result
         join t_test_battery battery on battery.relation_id = result.relation_id
@@ -559,13 +620,18 @@
         select hex(content_sha256) from t_test_sample
         where channel_id = #{channelId} and bts_test_id = #{btsTestId} and seq_id = #{sequenceId}
     </select>
+    <select id="selectTestSampleContentHash" resultType="string">
+        select hex(content_sha256) from t_test_sample
+        where test_id = #{testId} and channel_id = #{channelId} and seq_id = #{sequenceId}
+        order by sample_id limit 1
+    </select>
     <insert id="insertBtsSample">
         insert ignore into t_test_sample
         (test_id, binding_id, channel_id, reception_interval_id, bts_test_id, seq_id, device_time_utc,
-         device_time_raw, received_at_utc, cycle_no, step_no, step_type, test_time_ms, voltage_v,
+         device_time_raw, received_at_utc, cycle_no, step_no, step_type, step_name, test_time_ms, voltage_v,
          current_a, capacity_ah, energy_wh, content_sha256)
         values (#{testId}, #{bindingId}, #{channelId}, #{intervalId}, #{btsTestId}, #{sequenceId}, #{deviceTimeUtc},
-                #{deviceTimeRaw}, #{receivedAtUtc}, #{cycleNo}, #{stepNo}, #{stepType}, #{testTimeMs}, #{voltageV},
+                #{deviceTimeRaw}, #{receivedAtUtc}, #{cycleNo}, #{stepNo}, #{stepType}, #{stepName}, #{testTimeMs}, #{voltageV},
                 #{currentA}, #{capacityAh}, #{energyWh}, #{contentSha256})
     </insert>
     <insert id="insertBtsMeasurement">

--
Gitblit v1.7.1