【代码评审】IoT:OTA 的实现

This commit is contained in:
YunaiV
2025-03-16 22:28:10 +08:00
parent 9dfe2f6fdf
commit 8203e074ac
73 changed files with 73 additions and 228 deletions

View File

@@ -6,6 +6,7 @@ import lombok.Data;
import java.util.List;
// TODO @芋艿:从 server => plugin => device 是否有必要?从阿里云 iot 来看,没有这个功能?!
// TODO @芋艿:是不是改成 read 更好?在看看阿里云的 topic 设计
/**
* IoT 设备【属性】获取 Request DTO
*

View File

@@ -4,6 +4,7 @@ import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
// TODO @芋艿:要不要继承 IotDeviceUpstreamAbstractReqDTO
// TODO @芋艿:@haohao后续其它认证的设计
/**
* IoT 认证 Emqx 连接 Request DTO
*

View File

@@ -5,6 +5,7 @@ import lombok.Data;
import java.util.List;
// TODO @芋艿:要写清楚,是来自设备网关,还是设备。
/**
* IoT 设备【拓扑】添加 Request DTO
*/

View File

@@ -1,45 +0,0 @@
package cn.iocoder.yudao.module.iot.enums;
/**
* Iot 常量
*
* @author 芋道源码
*/
public interface IotConstants {
/**
* 获取设备表名
* <p>
* 格式为 device_{productKey}_{deviceName}
*/
String DEVICE_TABLE_NAME_FORMAT = "device_%s_%s";
/**
* 获取产品属性超级表名 - 网关子设备
* <p>
* 格式为 gateway_sub_{productKey}
*/
String GATEWAY_SUB_STABLE_NAME_FORMAT = "gateway_sub_%s";
/**
* 获取产品属性超级表名 - 网关
* <p>
* 格式为 gateway_{productKey}
*/
String GATEWAY_STABLE_NAME_FORMAT = "gateway_%s";
/**
* 获取产品属性超级表名 - 设备
* <p>
* 格式为 device_{productKey}
*/
String DEVICE_STABLE_NAME_FORMAT = "device_%s";
/**
* 获取物模型消息记录设备名
* <p>
* 格式为 thing_model_message_{productKey}_{deviceName}
*/
String THING_MODEL_MESSAGE_TABLE_NAME_FORMAT = "thing_model_message_%s_%s";
}

View File

@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.iot.enums.device;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
// TODO @芋艿:需要添加对应的 DTO以及上下行的链路网关、网关服务、设备等
/**
* IoT 设备消息标识符枚举
*/

View File

@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.iot.enums.plugin;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.Arrays;
@@ -10,6 +11,7 @@ import java.util.Arrays;
*
* @author haohao
*/
@RequiredArgsConstructor
@Getter
public enum IotPluginDeployTypeEnum implements ArrayValuable<Integer> {
@@ -22,24 +24,11 @@ public enum IotPluginDeployTypeEnum implements ArrayValuable<Integer> {
* 部署方式
*/
private final Integer deployType;
/**
* 部署方式名
*/
private final String name;
IotPluginDeployTypeEnum(Integer deployType, String name) {
this.deployType = deployType;
this.name = name;
}
public static IotPluginDeployTypeEnum valueOf(Integer deployType) {
return Arrays.stream(values())
.filter(value -> value.getDeployType().equals(deployType))
.findFirst()
.orElse(null);
}
@Override
public Integer[] array() {
return ARRAYS;

View File

@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.iot.enums.plugin;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.Arrays;
@@ -10,6 +11,7 @@ import java.util.Arrays;
*
* @author haohao
*/
@RequiredArgsConstructor
@Getter
public enum IotPluginStatusEnum implements ArrayValuable<Integer> {
@@ -22,35 +24,14 @@ public enum IotPluginStatusEnum implements ArrayValuable<Integer> {
* 状态
*/
private final Integer status;
/**
* 状态名
*/
private final String name;
IotPluginStatusEnum(Integer status, String name) {
this.status = status;
this.name = name;
}
public static IotPluginStatusEnum fromState(Integer state) {
return Arrays.stream(values())
.filter(value -> value.getStatus().equals(state))
.findFirst()
.orElse(null);
}
@Override
public Integer[] array() {
return ARRAYS;
}
public static boolean isValidState(Integer state) {
return fromState(state) != null;
}
public static boolean contains(Integer status) {
return Arrays.stream(values()).anyMatch(e -> e.getStatus().equals(status));
}
}

View File

@@ -24,7 +24,6 @@ public enum IotPluginTypeEnum implements ArrayValuable<Integer> {
* 类型
*/
private final Integer type;
/**
* 类型名
*/
@@ -35,15 +34,4 @@ public enum IotPluginTypeEnum implements ArrayValuable<Integer> {
return ARRAYS;
}
public static IotPluginTypeEnum fromType(Integer type) {
return Arrays.stream(values())
.filter(value -> value.getType().equals(type))
.findFirst()
.orElse(null);
}
public static boolean isValidType(Integer type) {
return fromType(type) != null;
}
}

View File

@@ -7,7 +7,7 @@ import lombok.Getter;
import java.util.Arrays;
/**
* IOT 联网方式枚举类
* IoT 联网方式枚举类
*
* @author ahh
*/

View File

@@ -7,7 +7,7 @@ import lombok.Getter;
import java.util.Arrays;
/**
* IOT 产品的设备类型
* IoT 产品的设备类型
*
* @author ahh
*/

View File

@@ -7,7 +7,7 @@ import lombok.Getter;
import java.util.Arrays;
/**
* IOT 产品的状态枚举类
* IoT 产品的状态枚举类
*
* @author ahh
*/

View File

@@ -7,7 +7,7 @@ import lombok.Getter;
import java.util.Arrays;
/**
* IOT 接入网关协议枚举类
* IoT 接入网关协议枚举类
*
* @author ahh
*/

View File

@@ -7,7 +7,7 @@ import lombok.Getter;
import java.util.Arrays;
/**
* IOT 数据校验级别枚举类
* IoT 数据校验级别枚举类
*
* @author ahh
*/

View File

@@ -7,7 +7,7 @@ import lombok.RequiredArgsConstructor;
import java.util.Arrays;
/**
* Iot 告警配置的接收方式枚举
* IoT 告警配置的接收方式枚举
*
* @author 芋道源码
*/

View File

@@ -7,7 +7,7 @@ import lombok.RequiredArgsConstructor;
import java.util.Arrays;
/**
* Iot 数据桥接的方向枚举
* IoT 数据桥接的方向枚举
*
* @author 芋道源码
*/

View File

@@ -7,7 +7,7 @@ import lombok.RequiredArgsConstructor;
import java.util.Arrays;
/**
* Iot 数据桥接的类型枚举
* IoT 数据桥接的类型枚举
*
* @author 芋道源码
*/

View File

@@ -7,7 +7,7 @@ import lombok.RequiredArgsConstructor;
import java.util.Arrays;
/**
* Iot 规则场景的触发类型枚举
* IoT 规则场景的触发类型枚举
*
* 设备触发,定时触发
*/

View File

@@ -8,7 +8,7 @@ import lombok.RequiredArgsConstructor;
import java.util.Arrays;
/**
* Iot 场景触发条件参数的操作符枚举
* IoT 场景触发条件参数的操作符枚举
*
* @author 芋道源码
*/

View File

@@ -7,7 +7,7 @@ import lombok.RequiredArgsConstructor;
import java.util.Arrays;
/**
* Iot 场景流转的触发类型枚举
* IoT 场景流转的触发类型枚举
*
* @author 芋道源码
*/

View File

@@ -7,7 +7,7 @@ import lombok.Getter;
import java.util.Arrays;
/**
* IOT 产品物模型属性读取类型枚举
* IoT 产品物模型属性读取类型枚举
*
* @author ahh
*/

View File

@@ -8,7 +8,7 @@ import java.util.Arrays;
/**
* IOT 产品物模型参数是输入参数还是输出参数枚举
* IoT 产品物模型参数是输入参数还是输出参数枚举
*
* @author HUIHUI
*/

View File

@@ -7,7 +7,7 @@ import lombok.Getter;
import java.util.Arrays;
/**
* IOT 产品物模型服务调用方式枚举
* IoT 产品物模型服务调用方式枚举
*
* @author HUIHUI
*/

View File

@@ -7,7 +7,7 @@ import lombok.Getter;
import java.util.Arrays;
/**
* IOT 产品物模型事件类型枚举
* IoT 产品物模型事件类型枚举
*
* @author HUIHUI
*/

View File

@@ -7,7 +7,7 @@ import lombok.Getter;
import java.util.Arrays;
/**
* IOT 产品功能(物模型)类型枚举类
* IoT 产品功能(物模型)类型枚举类
*
* @author ahh
*/
@@ -30,15 +30,6 @@ public enum IotThingModelTypeEnum implements ArrayValuable<Integer> {
*/
private final String description;
public static IotThingModelTypeEnum valueOfType(Integer type) {
for (IotThingModelTypeEnum value : values()) {
if (value.getType().equals(type)) {
return value;
}
}
return null;
}
@Override
public Integer[] array() {
return ARRAYS;