feat:【IoT 物联网】设备消息查询时,增加 pair 查询

This commit is contained in:
YunaiV
2025-06-19 23:33:16 +08:00
parent e9c5464aac
commit f5c2ee2ae5
16 changed files with 214 additions and 25 deletions

View File

@@ -32,6 +32,10 @@ public enum IotDeviceMessageMethodEnum implements ArrayValuable<String> {
EVENT_POST("thing.event.post", "事件上报", true),
// ========== 设备服务调用 ==========
SERVICE_INVOKE("thing.service.invoke", "服务调用", false),
;
public static final String[] ARRAYS = Arrays.stream(values()).map(IotDeviceMessageMethodEnum::getMethod)

View File

@@ -1,11 +1,15 @@
package cn.iocoder.yudao.module.iot.core.util;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.system.SystemUtil;
import cn.iocoder.yudao.module.iot.core.enums.IotDeviceMessageMethodEnum;
import cn.iocoder.yudao.module.iot.core.mq.message.IotDeviceMessage;
import java.util.Map;
/**
* IoT 设备【消息】的工具类
*
@@ -43,6 +47,23 @@ public class IotDeviceMessageUtils {
return message.getCode() != null;
}
/**
* 提取消息中的标识符
*
* @param message 消息
* @return 标识符
*/
@SuppressWarnings("unchecked")
public static String getIdentifier(IotDeviceMessage message) {
if (StrUtil.equalsAny(message.getMethod(), IotDeviceMessageMethodEnum.EVENT_POST.getMethod(),
message.getMethod(), IotDeviceMessageMethodEnum.SERVICE_INVOKE.getMethod())
&& message.getParams() != null) {
Map<String, Object> params = (Map<String, Object>) message.getParams();
return MapUtil.getStr(params, "identifier");
}
return null;
}
// ========== Topic 相关 ==========
public static String buildMessageBusGatewayDeviceMessageTopic(String serverId) {