yeg
2026-08-31 6c38637d89f346a660618558451f2dd7286dc7a5
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 + "\"");