Commit e01d03eefb3fbe5d50fb67c44384bb7f6c88162c
1 parent
f5803832
【代码评审】IoT:物模型日志
Showing
4 changed files
with
12 additions
and
19 deletions
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ErrorCodeConstants.java
| ... | ... | @@ -14,7 +14,6 @@ public interface ErrorCodeConstants { |
| 14 | 14 | ErrorCode PRODUCT_KEY_EXISTS = new ErrorCode(1_050_001_001, "产品标识已经存在"); |
| 15 | 15 | ErrorCode PRODUCT_STATUS_NOT_DELETE = new ErrorCode(1_050_001_002, "产品状是发布状态,不允许删除"); |
| 16 | 16 | ErrorCode PRODUCT_STATUS_NOT_ALLOW_THING_MODEL = new ErrorCode(1_050_001_003, "产品状是发布状态,不允许操作物模型"); |
| 17 | - ErrorCode PRODUCT_DEVICE_NOT_EXISTS = new ErrorCode(1_050_001_004, "产品设备类型不存在"); | |
| 18 | 17 | |
| 19 | 18 | // ========== 产品物模型 1-050-002-000 ============ |
| 20 | 19 | ErrorCode THING_MODEL_NOT_EXISTS = new ErrorCode(1_050_002_000, "产品物模型不存在"); | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/mq/consumer/simulatesend/SimulateSendConsumer.java
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/util/IotTdDatabaseUtils.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.util; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.lang.Assert; | |
| 3 | 4 | import cn.hutool.core.util.StrUtil; |
| 4 | 5 | import cn.iocoder.yudao.module.iot.enums.IotConstants; |
| 5 | 6 | import cn.iocoder.yudao.module.iot.enums.product.IotProductDeviceTypeEnum; |
| 6 | -import org.springframework.beans.factory.annotation.Value; | |
| 7 | -import org.springframework.stereotype.Component; | |
| 8 | - | |
| 9 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 10 | -import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.PRODUCT_DEVICE_NOT_EXISTS; | |
| 11 | 7 | |
| 12 | 8 | // TODO @芋艿:可能要思索下,有没更好的处理方式 |
| 13 | 9 | // TODO @芋艿:怎么改成无状态 |
| ... | ... | @@ -34,20 +30,17 @@ public class IotTdDatabaseUtils { |
| 34 | 30 | * @return 产品超级表表名 |
| 35 | 31 | */ |
| 36 | 32 | public static String getProductSuperTableName(Integer deviceType, String productKey) { |
| 37 | - // TODO @alwayssuper:枚举字段,不要 1、2、3;不符合预期,抛出异常 | |
| 38 | - if (deviceType == null) { | |
| 39 | - throw exception(PRODUCT_DEVICE_NOT_EXISTS); | |
| 40 | - } | |
| 33 | + Assert.notNull(deviceType, "deviceType 不能为空"); | |
| 41 | 34 | if (IotProductDeviceTypeEnum.GATEWAY_SUB.getType().equals(deviceType)) { |
| 42 | 35 | return String.format(IotConstants.GATEWAY_SUB_STABLE_NAME_FORMAT, productKey).toLowerCase(); |
| 43 | - } else if (IotProductDeviceTypeEnum.GATEWAY.getType().equals(deviceType)) { | |
| 36 | + } | |
| 37 | + if (IotProductDeviceTypeEnum.GATEWAY.getType().equals(deviceType)) { | |
| 44 | 38 | return String.format(IotConstants.GATEWAY_STABLE_NAME_FORMAT, productKey).toLowerCase(); |
| 45 | - } else if (IotProductDeviceTypeEnum.DIRECT.getType().equals(deviceType)){ | |
| 46 | - return String.format(IotConstants.DEVICE_STABLE_NAME_FORMAT, productKey).toLowerCase(); | |
| 47 | 39 | } |
| 48 | - else{ | |
| 49 | - throw exception(PRODUCT_DEVICE_NOT_EXISTS); | |
| 40 | + if (IotProductDeviceTypeEnum.DIRECT.getType().equals(deviceType)){ | |
| 41 | + return String.format(IotConstants.DEVICE_STABLE_NAME_FORMAT, productKey).toLowerCase(); | |
| 50 | 42 | } |
| 43 | + throw new IllegalArgumentException("deviceType 不正确"); | |
| 51 | 44 | } |
| 52 | 45 | |
| 53 | 46 | /** |
| ... | ... | @@ -58,7 +51,6 @@ public class IotTdDatabaseUtils { |
| 58 | 51 | * |
| 59 | 52 | */ |
| 60 | 53 | public static String getThingModelMessageSuperTableName(String productKey) { |
| 61 | - // TODO @alwayssuper:是不是应该 + 拼接就好,不用 format | |
| 62 | 54 | return "thing_model_message_" + productKey.toLowerCase(); |
| 63 | 55 | } |
| 64 | 56 | |
| ... | ... | @@ -70,7 +62,8 @@ public class IotTdDatabaseUtils { |
| 70 | 62 | * @return 物模型日志设备表名 |
| 71 | 63 | */ |
| 72 | 64 | public static String getThingModelMessageDeviceTableName(String productKey, String deviceName) { |
| 73 | - return String.format(IotConstants.THING_MODEL_MESSAGE_TABLE_NAME_FORMAT, productKey.toLowerCase(), deviceName.toLowerCase()); | |
| 65 | + return String.format(IotConstants.THING_MODEL_MESSAGE_TABLE_NAME_FORMAT, | |
| 66 | + productKey.toLowerCase(), deviceName.toLowerCase()); | |
| 74 | 67 | } |
| 75 | 68 | |
| 76 | 69 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/tdengine/TdThinkModelMessageMapper.xml
| ... | ... | @@ -5,7 +5,6 @@ |
| 5 | 5 | <mapper namespace="cn.iocoder.yudao.module.iot.dal.tdengine.TdThingModelMessageMapper"> |
| 6 | 6 | |
| 7 | 7 | <!-- 创建物模型消息日志超级表 --> |
| 8 | - <!-- TODO @芋艿:捉摸下字段,特别是 sys、ts 这种缩写 --> | |
| 9 | 8 | <update id="createSuperTable"> |
| 10 | 9 | CREATE STABLE ${dataBaseName}.${superTableName}( |
| 11 | 10 | ts TIMESTAMP, | ... | ... |