feat:【IoT 产品】产品的协议,改成 codec 字段
This commit is contained in:
parent
6488d5bcaa
commit
b06556da2d
|
@ -10,12 +10,9 @@ public class DictTypeConstants {
|
||||||
public static final String PRODUCT_STATUS = "iot_product_status";
|
public static final String PRODUCT_STATUS = "iot_product_status";
|
||||||
public static final String PRODUCT_DEVICE_TYPE = "iot_product_device_type";
|
public static final String PRODUCT_DEVICE_TYPE = "iot_product_device_type";
|
||||||
public static final String NET_TYPE = "iot_net_type";
|
public static final String NET_TYPE = "iot_net_type";
|
||||||
public static final String PROTOCOL_TYPE = "iot_protocol_type";
|
public static final String CODEC_TYPE = "iot_codec_type";
|
||||||
public static final String DATA_FORMAT = "iot_data_format";
|
|
||||||
public static final String VALIDATE_TYPE = "iot_validate_type";
|
|
||||||
|
|
||||||
public static final String DEVICE_STATE = "iot_device_state";
|
public static final String DEVICE_STATE = "iot_device_state";
|
||||||
|
|
||||||
public static final String CODEC_TYPE = "iot_codec_type";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.iot.enums.product;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 产品数据格式枚举类
|
|
||||||
*
|
|
||||||
* @author ahh
|
|
||||||
* @see <a href="https://help.aliyun.com/zh/iot/user-guide/message-parsing">阿里云 - 什么是消息解析</a>
|
|
||||||
*/
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum IotDataFormatEnum implements ArrayValuable<Integer> {
|
|
||||||
|
|
||||||
JSON(0, "标准数据格式(JSON)"),
|
|
||||||
CUSTOMIZE(1, "透传/自定义");
|
|
||||||
|
|
||||||
public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotDataFormatEnum::getType).toArray(Integer[]::new);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类型
|
|
||||||
*/
|
|
||||||
private final Integer type;
|
|
||||||
/**
|
|
||||||
* 描述
|
|
||||||
*/
|
|
||||||
private final String description;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer[] array() {
|
|
||||||
return ARRAYS;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.iot.enums.product;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IoT 接入网关协议枚举类
|
|
||||||
*
|
|
||||||
* @author ahh
|
|
||||||
*/
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum IotProtocolTypeEnum implements ArrayValuable<Integer> {
|
|
||||||
|
|
||||||
CUSTOM(0, "自定义"),
|
|
||||||
MODBUS(1, "Modbus"),
|
|
||||||
OPC_UA(2, "OPC UA"),
|
|
||||||
ZIGBEE(3, "ZigBee"),
|
|
||||||
BLE(4, "BLE");
|
|
||||||
|
|
||||||
public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotProtocolTypeEnum::getType).toArray(Integer[]::new);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类型
|
|
||||||
*/
|
|
||||||
private final Integer type;
|
|
||||||
/**
|
|
||||||
* 描述
|
|
||||||
*/
|
|
||||||
private final String description;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer[] array() {
|
|
||||||
return ARRAYS;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.iot.enums.product;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IoT 数据校验级别枚举类
|
|
||||||
*
|
|
||||||
* @author ahh
|
|
||||||
*/
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
public enum IotValidateTypeEnum implements ArrayValuable<Integer> {
|
|
||||||
|
|
||||||
WEAK(0, "弱校验"),
|
|
||||||
NONE(1, "免校验");
|
|
||||||
|
|
||||||
public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotValidateTypeEnum::getType).toArray(Integer[]::new);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 类型
|
|
||||||
*/
|
|
||||||
private final Integer type;
|
|
||||||
/**
|
|
||||||
* 描述
|
|
||||||
*/
|
|
||||||
private final String description;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer[] array() {
|
|
||||||
return ARRAYS;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -61,24 +61,10 @@ public class IotProductRespVO {
|
||||||
@DictFormat(DictTypeConstants.NET_TYPE)
|
@DictFormat(DictTypeConstants.NET_TYPE)
|
||||||
private Integer netType;
|
private Integer netType;
|
||||||
|
|
||||||
@Schema(description = "接入网关协议", example = "2")
|
@Schema(description = "数据格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||||
@ExcelProperty(value = "接入网关协议", converter = DictConvert.class)
|
|
||||||
@DictFormat(DictTypeConstants.PROTOCOL_TYPE)
|
|
||||||
private Integer protocolType;
|
|
||||||
|
|
||||||
@Schema(description = "协议编号(脚本解析 id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "13177")
|
|
||||||
@ExcelProperty("协议编号(脚本解析 id)")
|
|
||||||
private Long protocolId;
|
|
||||||
|
|
||||||
@Schema(description = "数据格式")
|
|
||||||
@ExcelProperty(value = "数据格式", converter = DictConvert.class)
|
@ExcelProperty(value = "数据格式", converter = DictConvert.class)
|
||||||
@DictFormat(DictTypeConstants.DATA_FORMAT)
|
@DictFormat(DictTypeConstants.CODEC_TYPE)
|
||||||
private Integer dataFormat;
|
private String codecType;
|
||||||
|
|
||||||
@Schema(description = "数据校验级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
|
||||||
@ExcelProperty(value = "数据校验级别", converter = DictConvert.class)
|
|
||||||
@DictFormat(DictTypeConstants.VALIDATE_TYPE)
|
|
||||||
private Integer validateType;
|
|
||||||
|
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@ExcelProperty("创建时间")
|
@ExcelProperty("创建时间")
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package cn.iocoder.yudao.module.iot.controller.admin.product.vo.product;
|
package cn.iocoder.yudao.module.iot.controller.admin.product.vo.product;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
import cn.iocoder.yudao.module.iot.enums.product.*;
|
import cn.iocoder.yudao.module.iot.enums.product.IotNetTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.iot.enums.product.IotProductDeviceTypeEnum;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
@ -43,18 +44,8 @@ public class IotProductSaveReqVO {
|
||||||
@InEnum(value = IotNetTypeEnum.class, message = "联网方式必须是 {value}")
|
@InEnum(value = IotNetTypeEnum.class, message = "联网方式必须是 {value}")
|
||||||
private Integer netType;
|
private Integer netType;
|
||||||
|
|
||||||
@Schema(description = "接入网关协议", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
@Schema(description = "数据格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||||
@InEnum(value = IotProtocolTypeEnum.class, message = "接入网关协议必须是 {value}")
|
@NotEmpty(message = "数据格式不能为空")
|
||||||
private Integer protocolType;
|
private String codecType;
|
||||||
|
|
||||||
@Schema(description = "数据格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
|
||||||
@InEnum(value = IotDataFormatEnum.class, message = "数据格式必须是 {value}")
|
|
||||||
@NotNull(message = "数据格式不能为空")
|
|
||||||
private Integer dataFormat;
|
|
||||||
|
|
||||||
@Schema(description = "数据校验级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
|
||||||
@InEnum(value = IotValidateTypeEnum.class, message = "数据校验级别必须是 {value}")
|
|
||||||
@NotNull(message = "数据校验级别不能为空")
|
|
||||||
private Integer validateType;
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -71,34 +71,12 @@ public class IotProductDO extends TenantBaseDO {
|
||||||
private Integer netType;
|
private Integer netType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编解码器类型
|
* 数据格式(编解码器类型)
|
||||||
*
|
* <p>
|
||||||
* 字典 {@link cn.iocoder.yudao.module.iot.enums.DictTypeConstants#CODEC_TYPE}
|
* 字典 {@link cn.iocoder.yudao.module.iot.enums.DictTypeConstants#CODEC_TYPE}
|
||||||
|
*
|
||||||
|
* 目的:用于 gateway-server 解析消息格式
|
||||||
*/
|
*/
|
||||||
private String codecType;
|
private String codecType;
|
||||||
/**
|
|
||||||
* 接入网关协议
|
|
||||||
* <p>
|
|
||||||
* 枚举 {@link cn.iocoder.yudao.module.iot.enums.product.IotProtocolTypeEnum}
|
|
||||||
*/
|
|
||||||
private Integer protocolType;
|
|
||||||
/**
|
|
||||||
* 协议编号
|
|
||||||
* <p>
|
|
||||||
* TODO 外键:后续加
|
|
||||||
*/
|
|
||||||
private Long protocolId;
|
|
||||||
/**
|
|
||||||
* 数据格式
|
|
||||||
* <p>
|
|
||||||
* 枚举 {@link cn.iocoder.yudao.module.iot.enums.product.IotDataFormatEnum}
|
|
||||||
*/
|
|
||||||
private Integer dataFormat;
|
|
||||||
/**
|
|
||||||
* 数据校验级别
|
|
||||||
* <p>
|
|
||||||
* 枚举 {@link cn.iocoder.yudao.module.iot.enums.product.IotValidateTypeEnum}
|
|
||||||
*/
|
|
||||||
private Integer validateType;
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -26,7 +26,7 @@ public interface IotDeviceMessageCodec {
|
||||||
IotDeviceMessage decode(byte[] bytes);
|
IotDeviceMessage decode(byte[] bytes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 类型
|
* @return 数据格式(编码器类型)
|
||||||
*/
|
*/
|
||||||
String type();
|
String type();
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class IotAlinkDeviceMessageCodec implements IotDeviceMessageCodec {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String type() {
|
public String type() {
|
||||||
return "alink";
|
return "Alink";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue