|
|
@@ -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);
|