From 037ab39ac74746e8cfc452b00cb593144bf4d6f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=B5=A9=E6=B5=A9?= <1036606149@qq.com> Date: Sat, 7 Sep 2024 09:45:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/enums/ProductDeviceTypeConstants.java | 13 ------ .../enums/ProductProtocolTypeConstants.java | 13 ------ .../IotDataFormatEnum.java} | 12 +++--- .../iot/enums/product/IotNetTypeEnum.java | 40 ++++++++++++++++++ .../product/IotProductDeviceTypeEnum.java | 38 +++++++++++++++++ .../IotProductStatusEnum.java} | 12 +++--- .../enums/product/IotProtocolTypeEnum.java | 41 +++++++++++++++++++ .../enums/product/IotValidateTypeEnum.java | 38 +++++++++++++++++ .../admin/product/vo/ProductSaveReqVO.java | 9 +++- .../iot/dal/mysql/product/ProductMapper.java | 8 ++-- 10 files changed, 179 insertions(+), 45 deletions(-) delete mode 100644 yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductDeviceTypeConstants.java delete mode 100644 yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductProtocolTypeConstants.java rename yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/{ProductDataFormatEnum.java => product/IotDataFormatEnum.java} (61%) create mode 100644 yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotNetTypeEnum.java create mode 100644 yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductDeviceTypeEnum.java rename yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/{ProductStatusEnum.java => product/IotProductStatusEnum.java} (62%) create mode 100644 yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProtocolTypeEnum.java create mode 100644 yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotValidateTypeEnum.java diff --git a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductDeviceTypeConstants.java b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductDeviceTypeConstants.java deleted file mode 100644 index d44a47102..000000000 --- a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductDeviceTypeConstants.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.iot.enums; - -/** - * 产品设备类型常量 - */ -public interface ProductDeviceTypeConstants { - - // ========== 产品设备类型 ============ - String DEVICE = "device"; // 直连设备 - String GATEWAY = "gateway"; // 网关设备 - String GATEWAY_SUB = "gateway_sub"; // 网关子设备 - -} diff --git a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductProtocolTypeConstants.java b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductProtocolTypeConstants.java deleted file mode 100644 index fe033bf5d..000000000 --- a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductProtocolTypeConstants.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.iot.enums; - -/** - * 产品传输协议类型常量 - */ -public interface ProductProtocolTypeConstants { - - // ========== 产品传输协议类型 ============ - String MQTT = "mqtt"; // MQTT - String COAP = "coap"; // COAP - String HTTP = "http"; // HTTP - String HTTPS = "https"; // HTTPS -} diff --git a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductDataFormatEnum.java b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotDataFormatEnum.java similarity index 61% rename from yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductDataFormatEnum.java rename to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotDataFormatEnum.java index be3470982..4b0f15e05 100644 --- a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductDataFormatEnum.java +++ b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotDataFormatEnum.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.iot.enums; +package cn.iocoder.yudao.module.iot.enums.product; import cn.iocoder.yudao.framework.common.core.IntArrayValuable; import lombok.AllArgsConstructor; @@ -8,14 +8,14 @@ import java.util.Arrays; /** * 产品数据格式枚举类 - * 1. 标准数据格式(JSON)2. 透传/自定义 + * 数据格式, 0: 标准数据格式(JSON), 1: 透传/自定义 */ @AllArgsConstructor @Getter -public enum ProductDataFormatEnum implements IntArrayValuable { +public enum IotDataFormatEnum implements IntArrayValuable { - JSON(1, "标准数据格式(JSON)"), - SCRIPT(2, "透传/自定义"); + JSON(0, "标准数据格式(JSON)"), + CUSTOMIZE(1, "透传/自定义"); /** * 类型 @@ -27,7 +27,7 @@ public enum ProductDataFormatEnum implements IntArrayValuable { */ private final String description; - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductDataFormatEnum::getType).toArray(); + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotDataFormatEnum::getType).toArray(); @Override public int[] array() { diff --git a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotNetTypeEnum.java b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotNetTypeEnum.java new file mode 100644 index 000000000..aef8999be --- /dev/null +++ b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotNetTypeEnum.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.iot.enums.product; + +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * IOT 联网方式枚举类 + * 联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他 + */ +@AllArgsConstructor +@Getter +public enum IotNetTypeEnum implements IntArrayValuable { + + WIFI(0, "Wi-Fi"), + CELLULAR(1, "Cellular"), + ETHERNET(2, "Ethernet"), + OTHER(3, "其他"); + + + /** + * 类型 + */ + private final Integer type; + + /** + * 描述 + */ + private final String description; + + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotNetTypeEnum::getType).toArray(); + + @Override + public int[] array() { + return ARRAYS; + } + +} diff --git a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductDeviceTypeEnum.java b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductDeviceTypeEnum.java new file mode 100644 index 000000000..37ce0b5ad --- /dev/null +++ b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductDeviceTypeEnum.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.module.iot.enums.product; + +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * IOT 产品设备类型 + * 设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备 + */ +@AllArgsConstructor +@Getter +public enum IotProductDeviceTypeEnum implements IntArrayValuable { + + DIRECT(0, "直连设备"), + GATEWAY_CHILD(1, "网关子设备"), + GATEWAY(2, "网关设备"); + + /** + * 类型 + */ + private final Integer type; + + /** + * 描述 + */ + private final String description; + + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotProductDeviceTypeEnum::getType).toArray(); + + @Override + public int[] array() { + return ARRAYS; + } + +} diff --git a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductStatusEnum.java b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductStatusEnum.java similarity index 62% rename from yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductStatusEnum.java rename to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductStatusEnum.java index 94ec21f61..38316371b 100644 --- a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductStatusEnum.java +++ b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductStatusEnum.java @@ -1,19 +1,19 @@ -package cn.iocoder.yudao.module.iot.enums; +package cn.iocoder.yudao.module.iot.enums.product; import cn.iocoder.yudao.framework.common.core.IntArrayValuable; import lombok.AllArgsConstructor; import lombok.Getter; /** - * 产品状态枚举类 - * 禁用 启用 + * IOT 产品状态枚举类 + * 产品状态, 0: 未发布, 1: 已发布 */ @AllArgsConstructor @Getter -public enum ProductStatusEnum implements IntArrayValuable { +public enum IotProductStatusEnum implements IntArrayValuable { - DISABLE(0, "禁用"), - ENABLE(1, "启用"); + UNPUBLISHED(0, "未发布"), + PUBLISHED(1, "已发布"); /** * 类型 diff --git a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProtocolTypeEnum.java b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProtocolTypeEnum.java new file mode 100644 index 000000000..64644b213 --- /dev/null +++ b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProtocolTypeEnum.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.iot.enums.product; + +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * IOT 接入网关协议枚举类 + * 接入网关协议, 0: 自定义, 1: Modbus, 2: OPC UA, 3: ZigBee, 4: BLE + */ +@AllArgsConstructor +@Getter +public enum IotProtocolTypeEnum implements IntArrayValuable { + + CUSTOM(0, "自定义"), + MODBUS(1, "Modbus"), + OPC_UA(2, "OPC UA"), + ZIGBEE(3, "ZigBee"), + BLE(4, "BLE"); + + + /** + * 类型 + */ + private final Integer type; + + /** + * 描述 + */ + private final String description; + + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotProtocolTypeEnum::getType).toArray(); + + @Override + public int[] array() { + return ARRAYS; + } + +} diff --git a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotValidateTypeEnum.java b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotValidateTypeEnum.java new file mode 100644 index 000000000..3b27b0d36 --- /dev/null +++ b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotValidateTypeEnum.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.module.iot.enums.product; + +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * IOT 数据校验级别枚举类 + * 数据校验级别, 0: 弱校验, 1: 免校验 + */ +@AllArgsConstructor +@Getter +public enum IotValidateTypeEnum implements IntArrayValuable { + + WEAK(0, "弱校验"), + NONE(1, "免校验"); + + + /** + * 类型 + */ + private final Integer type; + + /** + * 描述 + */ + private final String description; + + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotValidateTypeEnum::getType).toArray(); + + @Override + public int[] array() { + return ARRAYS; + } + +} diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductSaveReqVO.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductSaveReqVO.java index 9ecf8a2ce..ecbbb03c9 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductSaveReqVO.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductSaveReqVO.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.iot.controller.admin.product.vo; +import cn.iocoder.yudao.framework.common.validation.InEnum; +import cn.iocoder.yudao.module.iot.enums.product.*; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; @@ -20,22 +22,25 @@ public class ProductSaveReqVO { private String name; @Schema(description = "设备类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") + @InEnum(value = IotProductDeviceTypeEnum.class, message = "设备类型必须是 {value}") @NotNull(message = "设备类型不能为空") private Integer deviceType; @Schema(description = "联网方式", requiredMode = Schema.RequiredMode.REQUIRED,example = "0") - @NotNull(message = "联网方式不能为空") + @InEnum(value = IotNetTypeEnum.class, message = "联网方式必须是 {value}") private Integer netType; @Schema(description = "接入网关协议", requiredMode = Schema.RequiredMode.REQUIRED,example = "0") - @NotNull(message = "接入网关协议不能为空") + @InEnum(value = IotProtocolTypeEnum.class, message = "接入网关协议必须是 {value}") private Integer protocolType; @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; diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/product/ProductMapper.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/product/ProductMapper.java index eac366756..b8e80b7a3 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/product/ProductMapper.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/product/ProductMapper.java @@ -1,13 +1,11 @@ package cn.iocoder.yudao.module.iot.dal.mysql.product; -import java.util.*; - import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.iot.controller.admin.product.vo.ProductPageReqVO; import cn.iocoder.yudao.module.iot.dal.dataobject.product.ProductDO; import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.iot.controller.admin.product.vo.*; /** * iot 产品 Mapper @@ -21,7 +19,7 @@ public interface ProductMapper extends BaseMapperX { return selectPage(reqVO, new LambdaQueryWrapperX() .likeIfPresent(ProductDO::getName, reqVO.getName()) .betweenIfPresent(ProductDO::getCreateTime, reqVO.getCreateTime()) - .eqIfPresent(ProductDO::getProductKey, reqVO.getProductKey()) + .likeIfPresent(ProductDO::getProductKey, reqVO.getProductKey()) .eqIfPresent(ProductDO::getProtocolId, reqVO.getProtocolId()) .eqIfPresent(ProductDO::getCategoryId, reqVO.getCategoryId()) .eqIfPresent(ProductDO::getDescription, reqVO.getDescription())