yeg
2026-09-03 f3f54c6ee9b9485429cb9f1d2a6cdcedc41aaaab
修正工步终止电压取值口径

按设备时间最后一条成功采样计算当前工步终止电压,并添加查询契约测试。
2个文件已修改
21 ■■■■■ 已修改文件
ruoyi-admin/src/test/java/com/ruoyi/config/TestPersistedDataQueryContractTest.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TTestMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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()
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,