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/java/com/ruoyi/system/service/impl/TestBackfillServiceImpl.java |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestBackfillServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestBackfillServiceImpl.java
index 8e725bf..7f85409 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestBackfillServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestBackfillServiceImpl.java
@@ -190,6 +190,15 @@
         byte[] hash = hash(sample.sequenceId() + "|" + sample.stepNo() + "|" + sample.cycleNo() + "|"
                 + sample.stepType() + "|" + sample.deviceTimeRaw() + "|" + sample.voltageV() + "|"
                 + sample.currentA() + "|" + sample.capacityAh() + "|" + sample.energyWh());
+        String testScoped = mapper.selectTestSampleContentHash(test.getTestId(), binding.getChannelId(),
+                sample.sequenceId());
+        if (testScoped != null)
+        {
+            if (!testScoped.equalsIgnoreCase(HexFormat.of().formatHex(hash)))
+                mapper.insertBackfillConflict(test.getTestId(), binding.getChannelId(),
+                        "测试内采样内容冲突 seqid=" + sample.sequenceId());
+            return;
+        }
         String old = mapper.selectSampleContentHash(binding.getChannelId(), btsTestId, sample.sequenceId());
         if (old != null && !old.equalsIgnoreCase(HexFormat.of().formatHex(hash)))
         {
@@ -199,7 +208,8 @@
         }
         mapper.insertBtsSample(test.getTestId(), binding.getBindingId(), binding.getChannelId(),
                 intervalId(intervals, sample.deviceTime()), btsTestId, sample.sequenceId(), Date.from(sample.deviceTime()),
-                sample.deviceTimeRaw(), new Date(), sample.cycleNo(), sample.stepNo(), sample.stepType(), sample.testTimeMs(),
+                sample.deviceTimeRaw(), new Date(), sample.cycleNo(), sample.stepNo(), sample.stepType(),
+                stepNameForType(sample.stepType()), sample.testTimeMs(),
                 sample.voltageV(), sample.currentA(), sample.capacityAh(), sample.energyWh(), hash);
         Long sampleId = mapper.selectBtsSampleId(binding.getChannelId(), btsTestId, sample.sequenceId());
         if (sampleId != null)
@@ -255,6 +265,18 @@
                 Date.from(record.serverReceivedAt()), record.metricCode(), record.value(), record.unit(), hash);
     }
 
+    /** BTS download 协议只提供类型码;演示协议按已确认的类型语义补出名称。 */
+    private String stepNameForType(String stepType)
+    {
+        return switch (stepType == null ? "" : stepType.toLowerCase(java.util.Locale.ROOT))
+        {
+            case "cc" -> "恒流充电";
+            case "dc" -> "恒流放电";
+            case "rest" -> "搁置";
+            default -> stepType;
+        };
+    }
+
     private boolean checkIntegrity(TTest test, Date checkedAt)
     {
         // 序号只在同一来源、同一接收区间内比较;区间边界和暂停间隔不构成缺口。

--
Gitblit v1.7.1