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 +++++++++++-
ruoyi-admin/src/test/java/com/ruoyi/config/TestPersistedDataQueryContractTest.java | 9 +++++++++
2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/ruoyi-admin/src/test/java/com/ruoyi/config/TestPersistedDataQueryContractTest.java b/ruoyi-admin/src/test/java/com/ruoyi/config/TestPersistedDataQueryContractTest.java
index a4ea8d5..8ddb6e5 100644
--- a/ruoyi-admin/src/test/java/com/ruoyi/config/TestPersistedDataQueryContractTest.java
+++ b/ruoyi-admin/src/test/java/com/ruoyi/config/TestPersistedDataQueryContractTest.java
@@ -24,6 +24,15 @@
}
@Test
+ void stepEndVoltageUsesTheLastDeviceTimeSample()
+ {
+ String mapper = resource("mapper/system/TTestMapper.xml");
+ assertTrue(mapper.contains(") endVoltage"));
+ assertTrue(mapper.contains("order by latest.device_time_utc desc, latest.sample_id desc"));
+ assertTrue(mapper.contains("latest.step_no = sample.step_no"));
+ }
+
+ @Test
void mapperXmlIsWellFormed()
{
try (InputStream stream = TestPersistedDataQueryContractTest.class.getClassLoader()
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 <=> sample.step_type
+ and latest.step_name <=> sample.step_name
+ order by latest.device_time_utc desc, latest.sample_id desc
+ limit 1) endVoltage,
max(case when sample.current_a >= 0 then sample.voltage_v end) chargePeakVoltage,
min(case when sample.current_a < 0 then sample.voltage_v end) dischargeValleyVoltage,
channel.adapter_id adapterId, channel.adapter_code adapterCode, channel.devtype devtype,
--
Gitblit v1.7.1