From 6c38637d89f346a660618558451f2dd7286dc7a5 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期一, 31 八月 2026 22:51:54 +0800
Subject: [PATCH] 补齐检测柜模拟器完整 Excel 数据生命周期

---
 ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TDetectionCabinetServiceImplTest.java |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TDetectionCabinetServiceImplTest.java b/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TDetectionCabinetServiceImplTest.java
index 9207f29..bc39408 100644
--- a/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TDetectionCabinetServiceImplTest.java
+++ b/ruoyi-admin/src/test/java/com/ruoyi/system/service/impl/TDetectionCabinetServiceImplTest.java
@@ -168,6 +168,24 @@
         }
     }
 
+    /** 验证旧登记记录缺少厂商身份时仍可按稳定设备编码同步并补齐身份。 */
+    @Test
+    void registeredObservationSqlShouldRepairLegacyVendorIdentity() throws IOException
+    {
+        try (InputStream input = getClass().getResourceAsStream(
+                "/mapper/system/TDetectionCabinetMapper.xml"))
+        {
+            assertNotNull(input);
+            String mapperXml = new String(input.readAllBytes(), StandardCharsets.UTF_8);
+            int start = mapperXml.indexOf("<update id=\"updateRegisteredCabinetObservation\"");
+            int end = mapperXml.indexOf("</update>", start);
+            String updateSql = mapperXml.substring(start, end);
+
+            assertTrue(updateSql.contains("vendor_device_type = coalesce(vendor_device_type, #{devtype})"));
+            assertTrue(updateSql.contains("cabinet_code = concat(#{adapterCode}, '-', #{devtype}, '-', #{devid})"));
+        }
+    }
+
     private String sqlFragment(String mapperXml, String id)
     {
         int start = mapperXml.indexOf("<sql id=\"" + id + "\"");

--
Gitblit v1.7.1