From 5aeff3d815c360de0d1b00fca2a6c4323b600e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B0=8F=E4=BA=91?= Date: Wed, 11 Feb 2026 11:17:50 +0800 Subject: [PATCH] xx --- .../machine/instruction/CallbackConfig.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/ruoyi/device/domain/impl/machine/instruction/CallbackConfig.java b/src/main/java/com/ruoyi/device/domain/impl/machine/instruction/CallbackConfig.java index e3c870b..7835068 100644 --- a/src/main/java/com/ruoyi/device/domain/impl/machine/instruction/CallbackConfig.java +++ b/src/main/java/com/ruoyi/device/domain/impl/machine/instruction/CallbackConfig.java @@ -102,7 +102,31 @@ public class CallbackConfig { // 检查业务字段是否匹配 Object fieldValue = extractFieldValue(messageBody, fieldPath); - return expectedValue == null || expectedValue.equals(fieldValue); + return expectedValue == null || flexibleEquals(expectedValue, fieldValue); + } + + /** + * 灵活的相等性比较,支持字符串和数字之间的自动转换 + * 例如:flexibleEquals("2", 2) 返回 true + */ + private boolean flexibleEquals(Object expected, Object actual) { + if (expected == null && actual == null) { + return true; + } + if (expected == null || actual == null) { + return false; + } + + // 如果类型相同,直接比较 + if (expected.equals(actual)) { + return true; + } + + // 尝试将两者都转换为字符串进行比较 + String expectedStr = String.valueOf(expected); + String actualStr = String.valueOf(actual); + + return expectedStr.equals(actualStr); } /**