Bläddra i källkod

fix:【iot 物联网】增强 jdk8 的兼容性

YunaiV 8 månader sedan
förälder
incheckning
f6232cf433

+ 2 - 1
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotDeviceControlSceneRuleAction.java

@@ -1,6 +1,7 @@
 package cn.iocoder.yudao.module.iot.service.rule.scene.action;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.module.iot.core.enums.IotDeviceMessageMethodEnum;
 import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage;
@@ -126,7 +127,7 @@ public class IotDeviceControlSceneRuleAction implements IotSceneRuleAction {
     private IotDeviceMessage buildPropertySetMessage(IotSceneRuleDO.Action actionConfig, IotDeviceDO device) {
         try {
             // 属性设置参数格式: {"properties": {"identifier": value}}
-            Object params = Map.of("properties", Map.of(actionConfig.getIdentifier(), actionConfig.getParams()));
+            Object params = MapUtil.of("properties", MapUtil.of(actionConfig.getIdentifier(), actionConfig.getParams()));
             return IotDeviceMessage.requestOf(IotDeviceMessageMethodEnum.PROPERTY_SET.getMethod(), params);
         } catch (Exception e) {
             log.error("[buildPropertySetMessage][构建属性设置消息异常]", e);

+ 7 - 4
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotDeviceServiceInvokeSceneRuleAction.java

@@ -1,6 +1,7 @@
 package cn.iocoder.yudao.module.iot.service.rule.scene.action;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.module.iot.core.enums.IotDeviceMessageMethodEnum;
 import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage;
@@ -13,6 +14,8 @@ import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -126,10 +129,10 @@ public class IotDeviceServiceInvokeSceneRuleAction implements IotSceneRuleAction
     private IotDeviceMessage buildServiceInvokeMessage(IotSceneRuleDO.Action actionConfig, IotDeviceDO device) {
         try {
             // 服务调用参数格式: {"identifier": "serviceId", "params": {...}}
-            Object params = Map.of(
-                    "identifier", actionConfig.getIdentifier(),
-                    "params", actionConfig.getParams() != null ? actionConfig.getParams() : Map.of()
-            );
+            Object params = MapUtil.builder()
+                    .put("identifier", actionConfig.getIdentifier())
+                    .put("params", actionConfig.getParams() != null ? actionConfig.getParams() : Collections.emptyMap())
+                    .build();
             return IotDeviceMessage.requestOf(IotDeviceMessageMethodEnum.SERVICE_INVOKE.getMethod(), params);
         } catch (Exception e) {
             log.error("[buildServiceInvokeMessage][构建服务调用消息异常]", e);