reactor:【IoT 物联网】清理 yudao-module-iot-api

This commit is contained in:
YunaiV
2025-06-26 23:39:29 +08:00
parent 456423b5aa
commit 0faee76ffd
45 changed files with 123 additions and 248 deletions

View File

@@ -19,10 +19,6 @@ public enum IotDeviceMessageMethodEnum implements ArrayValuable<String> {
// ========== 设备状态 ==========
// TODO @芋艿要合并下thing.state.update
STATE_ONLINE("thing.state.online", "设备上线", true),
STATE_OFFLINE("thing.state.offline", "设备下线", true),
STATE_UPDATE("thing.state.update", "设备状态更新", true),
// ========== 设备属性 ==========
@@ -52,7 +48,7 @@ public enum IotDeviceMessageMethodEnum implements ArrayValuable<String> {
/**
* 不进行 reply 回复的方法集合
*/
public static final Set<String> REPLY_DISABLED = Set.of(STATE_ONLINE.getMethod(), STATE_OFFLINE.getMethod());
public static final Set<String> REPLY_DISABLED = Set.of(STATE_UPDATE.getMethod());
private final String method;

View File

@@ -1,7 +1,9 @@
package cn.iocoder.yudao.module.iot.core.mq.message;
import cn.hutool.core.map.MapUtil;
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
import cn.iocoder.yudao.module.iot.core.enums.IotDeviceMessageMethodEnum;
import cn.iocoder.yudao.module.iot.core.enums.IotDeviceStateEnum;
import cn.iocoder.yudao.module.iot.core.util.IotDeviceMessageUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
@@ -128,12 +130,14 @@ public class IotDeviceMessage {
// ========== 核心方法:在 of 基础方法之上,添加对应 method ==========
public static IotDeviceMessage buildStateOnline() {
return requestOf(IotDeviceMessageMethodEnum.STATE_ONLINE.getMethod());
public static IotDeviceMessage buildStateUpdateOnline() {
return requestOf(IotDeviceMessageMethodEnum.STATE_UPDATE.getMethod(),
MapUtil.of("state", IotDeviceStateEnum.ONLINE.getState()));
}
public static IotDeviceMessage buildStateOffline() {
return requestOf(IotDeviceMessageMethodEnum.STATE_OFFLINE.getMethod());
return requestOf(IotDeviceMessageMethodEnum.STATE_UPDATE.getMethod(),
MapUtil.of("state", IotDeviceStateEnum.OFFLINE.getState()));
}
}

View File

@@ -55,11 +55,16 @@ public class IotDeviceMessageUtils {
*/
@SuppressWarnings("unchecked")
public static String getIdentifier(IotDeviceMessage message) {
if (message.getParams() == null) {
return null;
}
if (StrUtil.equalsAny(message.getMethod(), IotDeviceMessageMethodEnum.EVENT_POST.getMethod(),
message.getMethod(), IotDeviceMessageMethodEnum.SERVICE_INVOKE.getMethod())
&& message.getParams() != null) {
IotDeviceMessageMethodEnum.SERVICE_INVOKE.getMethod())) {
Map<String, Object> params = (Map<String, Object>) message.getParams();
return MapUtil.getStr(params, "identifier");
} else if (StrUtil.equalsAny(message.getMethod(), IotDeviceMessageMethodEnum.STATE_UPDATE.getMethod())) {
Map<String, Object> params = (Map<String, Object>) message.getParams();
return MapUtil.getStr(params, "state");
}
return null;
}