From f3f54c6ee9b9485429cb9f1d2a6cdcedc41aaaab Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期四, 03 九月 2026 15:01:58 +0800
Subject: [PATCH] 修正工步终止电压取值口径

---
 ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml |   12 +++++++++++-
 1 files changed, 11 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 bb0eee7..3c7a660 100644
--- a/ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml
@@ -411,7 +411,17 @@
                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,
+               <!-- 工步终止电压按设备时间最后成功采样取值;同一时刻以采样主键稳定排序。 -->
+               (select latest.voltage_v
+                  from t_test_sample latest
+                 where latest.test_id = sample.test_id
+                   and latest.binding_id = sample.binding_id
+                   and latest.cycle_no = sample.cycle_no
+                   and latest.step_no = sample.step_no
+                   and latest.step_type &lt;=&gt; sample.step_type
+                   and latest.step_name &lt;=&gt; sample.step_name
+                 order by latest.device_time_utc desc, latest.sample_id desc
+                 limit 1) 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.adapter_id adapterId, channel.adapter_code adapterCode, channel.devtype devtype,

--
Gitblit v1.7.1