Commit f6232cf43301c8680c244d7e9a6bac96567d59da
1 parent
b167b419
fix:【iot 物联网】增强 jdk8 的兼容性
Showing
2 changed files
with
9 additions
and
5 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotDeviceControlSceneRuleAction.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.service.rule.scene.action; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.hutool.core.map.MapUtil; | |
| 4 | 5 | import cn.hutool.core.util.StrUtil; |
| 5 | 6 | import cn.iocoder.yudao.module.iot.core.enums.IotDeviceMessageMethodEnum; |
| 6 | 7 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| ... | ... | @@ -126,7 +127,7 @@ public class IotDeviceControlSceneRuleAction implements IotSceneRuleAction { |
| 126 | 127 | private IotDeviceMessage buildPropertySetMessage(IotSceneRuleDO.Action actionConfig, IotDeviceDO device) { |
| 127 | 128 | try { |
| 128 | 129 | // 属性设置参数格式: {"properties": {"identifier": value}} |
| 129 | - Object params = Map.of("properties", Map.of(actionConfig.getIdentifier(), actionConfig.getParams())); | |
| 130 | + Object params = MapUtil.of("properties", MapUtil.of(actionConfig.getIdentifier(), actionConfig.getParams())); | |
| 130 | 131 | return IotDeviceMessage.requestOf(IotDeviceMessageMethodEnum.PROPERTY_SET.getMethod(), params); |
| 131 | 132 | } catch (Exception e) { |
| 132 | 133 | log.error("[buildPropertySetMessage][构建属性设置消息异常]", e); | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/rule/scene/action/IotDeviceServiceInvokeSceneRuleAction.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.service.rule.scene.action; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.hutool.core.map.MapUtil; | |
| 4 | 5 | import cn.hutool.core.util.StrUtil; |
| 5 | 6 | import cn.iocoder.yudao.module.iot.core.enums.IotDeviceMessageMethodEnum; |
| 6 | 7 | import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage; |
| ... | ... | @@ -13,6 +14,8 @@ import jakarta.annotation.Resource; |
| 13 | 14 | import lombok.extern.slf4j.Slf4j; |
| 14 | 15 | import org.springframework.stereotype.Component; |
| 15 | 16 | |
| 17 | +import java.util.Collections; | |
| 18 | +import java.util.HashMap; | |
| 16 | 19 | import java.util.List; |
| 17 | 20 | import java.util.Map; |
| 18 | 21 | |
| ... | ... | @@ -126,10 +129,10 @@ public class IotDeviceServiceInvokeSceneRuleAction implements IotSceneRuleAction |
| 126 | 129 | private IotDeviceMessage buildServiceInvokeMessage(IotSceneRuleDO.Action actionConfig, IotDeviceDO device) { |
| 127 | 130 | try { |
| 128 | 131 | // 服务调用参数格式: {"identifier": "serviceId", "params": {...}} |
| 129 | - Object params = Map.of( | |
| 130 | - "identifier", actionConfig.getIdentifier(), | |
| 131 | - "params", actionConfig.getParams() != null ? actionConfig.getParams() : Map.of() | |
| 132 | - ); | |
| 132 | + Object params = MapUtil.builder() | |
| 133 | + .put("identifier", actionConfig.getIdentifier()) | |
| 134 | + .put("params", actionConfig.getParams() != null ? actionConfig.getParams() : Collections.emptyMap()) | |
| 135 | + .build(); | |
| 133 | 136 | return IotDeviceMessage.requestOf(IotDeviceMessageMethodEnum.SERVICE_INVOKE.getMethod(), params); |
| 134 | 137 | } catch (Exception e) { |
| 135 | 138 | log.error("[buildServiceInvokeMessage][构建服务调用消息异常]", e); | ... | ... |