【功能新增】IoT:设备拓扑图的添加

This commit is contained in:
YunaiV
2025-02-08 21:44:49 +08:00
parent 4254c06c37
commit bc9b3715b1
17 changed files with 161 additions and 18 deletions

View File

@@ -62,6 +62,15 @@ public interface IotDeviceUpstreamApi {
@PostMapping(PREFIX + "/register-sub")
CommonResult<Boolean> registerSubDevice(@Valid @RequestBody IotDeviceRegisterSubReqDTO registerReqDTO);
// TODO @芋艿:这个需要 plugins 接入下
/**
* 注册设备拓扑
*
* @param addReqDTO 注册设备拓扑 DTO
*/
@PostMapping(PREFIX + "/add-topology")
CommonResult<Boolean> addDeviceTopology(@Valid @RequestBody IotDeviceTopologyAddReqDTO addReqDTO);
// ========== 插件相关 ==========
/**

View File

@@ -7,6 +7,8 @@ import java.util.Map;
/**
* IoT 设备【事件】上报 Request DTO
*
* @author 芋道源码
*/
@Data
public class IotDeviceEventReportReqDTO extends IotDeviceUpstreamAbstractReqDTO {

View File

@@ -7,6 +7,8 @@ import java.util.Map;
/**
* IoT 设备【属性】上报 Request DTO
*
* @author 芋道源码
*/
@Data
public class IotDevicePropertyReportReqDTO extends IotDeviceUpstreamAbstractReqDTO {

View File

@@ -13,6 +13,7 @@ import java.util.List;
@Data
public class IotDeviceRegisterSubReqDTO extends IotDeviceUpstreamAbstractReqDTO {
// TODO @芋艿:看看要不要优化命名
/**
* 子设备数组
*/

View File

@@ -7,6 +7,8 @@ import lombok.Data;
/**
* IoT 设备【状态】更新 Request DTO
*
* @author 芋道源码
*/
@Data
public class IotDeviceStateUpdateReqDTO extends IotDeviceUpstreamAbstractReqDTO {

View File

@@ -0,0 +1,43 @@
package cn.iocoder.yudao.module.iot.api.device.dto.control.upstream;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import java.util.List;
/**
* IoT 设备【拓扑】添加 Request DTO
*/
@Data
public class IotDeviceTopologyAddReqDTO extends IotDeviceUpstreamAbstractReqDTO {
// TODO @芋艿:看看要不要优化命名
/**
* 子设备数组
*/
@NotEmpty(message = "子设备不能为空")
private List<IotDeviceRegisterSubReqDTO.Device> params;
/**
* 设备信息
*/
@Data
public static class Device {
/**
* 产品标识
*/
@NotEmpty(message = "产品标识不能为空")
private String productKey;
/**
* 设备名称
*/
@NotEmpty(message = "设备名称不能为空")
private String deviceName;
// TODO @芋艿:阿里云还有 sign 签名
}
}

View File

@@ -30,7 +30,10 @@ public enum IotDeviceMessageIdentifierEnum {
REGISTER_REGISTER("register"), // 上行
REGISTER_REGISTER_SUB("register_sub"), // 上行
REGISTER_UNREGISTER_SUB("unregister_sub"),; // 下行
REGISTER_UNREGISTER_SUB("unregister_sub"), // 下行
TOPOLOGY_ADD("topology_add"), // 下行;
;
/**
* 标志符

View File

@@ -19,7 +19,8 @@ public enum IotDeviceMessageTypeEnum implements ArrayValuable<String> {
SERVICE("service"), // 设备服务:可参考 https://help.aliyun.com/zh/iot/user-guide/device-properties-events-and-services 设备属性、事件、服务
CONFIG("config"), // 设备配置:可参考 https://help.aliyun.com/zh/iot/user-guide/remote-configuration-1 远程配置
OTA("ota"), // 设备 OTA可参考 https://help.aliyun.com/zh/iot/user-guide/ota-update OTA 升级
REGISTER("register"),; // 设备注册:可参考 https://help.aliyun.com/zh/iot/user-guide/register-devices 设备身份注册
REGISTER("register"), // 设备注册:可参考 https://help.aliyun.com/zh/iot/user-guide/register-devices 设备身份注册
TOPOLOGY("topology"),; // 设备拓扑:可参考 https://help.aliyun.com/zh/iot/user-guide/manage-topological-relationships 设备拓扑
public static final String[] ARRAYS = Arrays.stream(values()).map(IotDeviceMessageTypeEnum::getType).toArray(String[]::new);