Commit b06556da2d053e39ba3e1f82958984bcd6f39cce
1 parent
6488d5bc
feat:【IoT 产品】产品的协议,改成 codec 字段
Showing
9 changed files
with
15 additions
and
178 deletions
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/DictTypeConstants.java
| ... | ... | @@ -10,12 +10,9 @@ public class DictTypeConstants { |
| 10 | 10 | public static final String PRODUCT_STATUS = "iot_product_status"; |
| 11 | 11 | public static final String PRODUCT_DEVICE_TYPE = "iot_product_device_type"; |
| 12 | 12 | public static final String NET_TYPE = "iot_net_type"; |
| 13 | - public static final String PROTOCOL_TYPE = "iot_protocol_type"; | |
| 14 | - public static final String DATA_FORMAT = "iot_data_format"; | |
| 15 | - public static final String VALIDATE_TYPE = "iot_validate_type"; | |
| 13 | + public static final String CODEC_TYPE = "iot_codec_type"; | |
| 16 | 14 | |
| 17 | 15 | public static final String DEVICE_STATE = "iot_device_state"; |
| 18 | 16 | |
| 19 | - public static final String CODEC_TYPE = "iot_codec_type"; | |
| 20 | 17 | |
| 21 | 18 | } | ... | ... |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotDataFormatEnum.java deleted
| 1 | -package cn.iocoder.yudao.module.iot.enums.product; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.core.ArrayValuable; | |
| 4 | -import lombok.AllArgsConstructor; | |
| 5 | -import lombok.Getter; | |
| 6 | - | |
| 7 | -import java.util.Arrays; | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * 产品数据格式枚举类 | |
| 11 | - * | |
| 12 | - * @author ahh | |
| 13 | - * @see <a href="https://help.aliyun.com/zh/iot/user-guide/message-parsing">阿里云 - 什么是消息解析</a> | |
| 14 | - */ | |
| 15 | -@AllArgsConstructor | |
| 16 | -@Getter | |
| 17 | -public enum IotDataFormatEnum implements ArrayValuable<Integer> { | |
| 18 | - | |
| 19 | - JSON(0, "标准数据格式(JSON)"), | |
| 20 | - CUSTOMIZE(1, "透传/自定义"); | |
| 21 | - | |
| 22 | - public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotDataFormatEnum::getType).toArray(Integer[]::new); | |
| 23 | - | |
| 24 | - /** | |
| 25 | - * 类型 | |
| 26 | - */ | |
| 27 | - private final Integer type; | |
| 28 | - /** | |
| 29 | - * 描述 | |
| 30 | - */ | |
| 31 | - private final String description; | |
| 32 | - | |
| 33 | - @Override | |
| 34 | - public Integer[] array() { | |
| 35 | - return ARRAYS; | |
| 36 | - } | |
| 37 | - | |
| 38 | -} |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProtocolTypeEnum.java deleted
| 1 | -package cn.iocoder.yudao.module.iot.enums.product; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.core.ArrayValuable; | |
| 4 | -import lombok.AllArgsConstructor; | |
| 5 | -import lombok.Getter; | |
| 6 | - | |
| 7 | -import java.util.Arrays; | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * IoT 接入网关协议枚举类 | |
| 11 | - * | |
| 12 | - * @author ahh | |
| 13 | - */ | |
| 14 | -@AllArgsConstructor | |
| 15 | -@Getter | |
| 16 | -public enum IotProtocolTypeEnum implements ArrayValuable<Integer> { | |
| 17 | - | |
| 18 | - CUSTOM(0, "自定义"), | |
| 19 | - MODBUS(1, "Modbus"), | |
| 20 | - OPC_UA(2, "OPC UA"), | |
| 21 | - ZIGBEE(3, "ZigBee"), | |
| 22 | - BLE(4, "BLE"); | |
| 23 | - | |
| 24 | - public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotProtocolTypeEnum::getType).toArray(Integer[]::new); | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * 类型 | |
| 28 | - */ | |
| 29 | - private final Integer type; | |
| 30 | - /** | |
| 31 | - * 描述 | |
| 32 | - */ | |
| 33 | - private final String description; | |
| 34 | - | |
| 35 | - @Override | |
| 36 | - public Integer[] array() { | |
| 37 | - return ARRAYS; | |
| 38 | - } | |
| 39 | - | |
| 40 | -} |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotValidateTypeEnum.java deleted
| 1 | -package cn.iocoder.yudao.module.iot.enums.product; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.core.ArrayValuable; | |
| 4 | -import lombok.AllArgsConstructor; | |
| 5 | -import lombok.Getter; | |
| 6 | - | |
| 7 | -import java.util.Arrays; | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * IoT 数据校验级别枚举类 | |
| 11 | - * | |
| 12 | - * @author ahh | |
| 13 | - */ | |
| 14 | -@AllArgsConstructor | |
| 15 | -@Getter | |
| 16 | -public enum IotValidateTypeEnum implements ArrayValuable<Integer> { | |
| 17 | - | |
| 18 | - WEAK(0, "弱校验"), | |
| 19 | - NONE(1, "免校验"); | |
| 20 | - | |
| 21 | - public static final Integer[] ARRAYS = Arrays.stream(values()).map(IotValidateTypeEnum::getType).toArray(Integer[]::new); | |
| 22 | - | |
| 23 | - /** | |
| 24 | - * 类型 | |
| 25 | - */ | |
| 26 | - private final Integer type; | |
| 27 | - /** | |
| 28 | - * 描述 | |
| 29 | - */ | |
| 30 | - private final String description; | |
| 31 | - | |
| 32 | - @Override | |
| 33 | - public Integer[] array() { | |
| 34 | - return ARRAYS; | |
| 35 | - } | |
| 36 | - | |
| 37 | -} |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/product/IotProductRespVO.java
| ... | ... | @@ -61,24 +61,10 @@ public class IotProductRespVO { |
| 61 | 61 | @DictFormat(DictTypeConstants.NET_TYPE) |
| 62 | 62 | private Integer netType; |
| 63 | 63 | |
| 64 | - @Schema(description = "接入网关协议", example = "2") | |
| 65 | - @ExcelProperty(value = "接入网关协议", converter = DictConvert.class) | |
| 66 | - @DictFormat(DictTypeConstants.PROTOCOL_TYPE) | |
| 67 | - private Integer protocolType; | |
| 68 | - | |
| 69 | - @Schema(description = "协议编号(脚本解析 id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "13177") | |
| 70 | - @ExcelProperty("协议编号(脚本解析 id)") | |
| 71 | - private Long protocolId; | |
| 72 | - | |
| 73 | - @Schema(description = "数据格式") | |
| 64 | + @Schema(description = "数据格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 74 | 65 | @ExcelProperty(value = "数据格式", converter = DictConvert.class) |
| 75 | - @DictFormat(DictTypeConstants.DATA_FORMAT) | |
| 76 | - private Integer dataFormat; | |
| 77 | - | |
| 78 | - @Schema(description = "数据校验级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 79 | - @ExcelProperty(value = "数据校验级别", converter = DictConvert.class) | |
| 80 | - @DictFormat(DictTypeConstants.VALIDATE_TYPE) | |
| 81 | - private Integer validateType; | |
| 66 | + @DictFormat(DictTypeConstants.CODEC_TYPE) | |
| 67 | + private String codecType; | |
| 82 | 68 | |
| 83 | 69 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 84 | 70 | @ExcelProperty("创建时间") | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/product/IotProductSaveReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.controller.admin.product.vo.product; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | -import cn.iocoder.yudao.module.iot.enums.product.*; | |
| 4 | +import cn.iocoder.yudao.module.iot.enums.product.IotNetTypeEnum; | |
| 5 | +import cn.iocoder.yudao.module.iot.enums.product.IotProductDeviceTypeEnum; | |
| 5 | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | 7 | import jakarta.validation.constraints.NotEmpty; |
| 7 | 8 | import jakarta.validation.constraints.NotNull; |
| ... | ... | @@ -43,18 +44,8 @@ public class IotProductSaveReqVO { |
| 43 | 44 | @InEnum(value = IotNetTypeEnum.class, message = "联网方式必须是 {value}") |
| 44 | 45 | private Integer netType; |
| 45 | 46 | |
| 46 | - @Schema(description = "接入网关协议", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | |
| 47 | - @InEnum(value = IotProtocolTypeEnum.class, message = "接入网关协议必须是 {value}") | |
| 48 | - private Integer protocolType; | |
| 49 | - | |
| 50 | - @Schema(description = "数据格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | |
| 51 | - @InEnum(value = IotDataFormatEnum.class, message = "数据格式必须是 {value}") | |
| 52 | - @NotNull(message = "数据格式不能为空") | |
| 53 | - private Integer dataFormat; | |
| 54 | - | |
| 55 | - @Schema(description = "数据校验级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | |
| 56 | - @InEnum(value = IotValidateTypeEnum.class, message = "数据校验级别必须是 {value}") | |
| 57 | - @NotNull(message = "数据校验级别不能为空") | |
| 58 | - private Integer validateType; | |
| 47 | + @Schema(description = "数据格式", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 48 | + @NotEmpty(message = "数据格式不能为空") | |
| 49 | + private String codecType; | |
| 59 | 50 | |
| 60 | 51 | } |
| 61 | 52 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/product/IotProductDO.java
| ... | ... | @@ -71,34 +71,12 @@ public class IotProductDO extends TenantBaseDO { |
| 71 | 71 | private Integer netType; |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | - * 编解码器类型 | |
| 75 | - * | |
| 74 | + * 数据格式(编解码器类型) | |
| 75 | + * <p> | |
| 76 | 76 | * 字典 {@link cn.iocoder.yudao.module.iot.enums.DictTypeConstants#CODEC_TYPE} |
| 77 | + * | |
| 78 | + * 目的:用于 gateway-server 解析消息格式 | |
| 77 | 79 | */ |
| 78 | 80 | private String codecType; |
| 79 | - /** | |
| 80 | - * 接入网关协议 | |
| 81 | - * <p> | |
| 82 | - * 枚举 {@link cn.iocoder.yudao.module.iot.enums.product.IotProtocolTypeEnum} | |
| 83 | - */ | |
| 84 | - private Integer protocolType; | |
| 85 | - /** | |
| 86 | - * 协议编号 | |
| 87 | - * <p> | |
| 88 | - * TODO 外键:后续加 | |
| 89 | - */ | |
| 90 | - private Long protocolId; | |
| 91 | - /** | |
| 92 | - * 数据格式 | |
| 93 | - * <p> | |
| 94 | - * 枚举 {@link cn.iocoder.yudao.module.iot.enums.product.IotDataFormatEnum} | |
| 95 | - */ | |
| 96 | - private Integer dataFormat; | |
| 97 | - /** | |
| 98 | - * 数据校验级别 | |
| 99 | - * <p> | |
| 100 | - * 枚举 {@link cn.iocoder.yudao.module.iot.enums.product.IotValidateTypeEnum} | |
| 101 | - */ | |
| 102 | - private Integer validateType; | |
| 103 | 81 | |
| 104 | 82 | } |
| 105 | 83 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/codec/IotDeviceMessageCodec.java
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/codec/alink/IotAlinkDeviceMessageCodec.java