Commit 95067fd6c60da1f3d511bdaafc6100c4bf0e3593
1 parent
92de5b1f
【代码评审】IoT:评审 ThingModel 的实现
Showing
6 changed files
with
16 additions
and
21 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/device/vo/device/IotDevicePageReqVO.java
| ... | ... | @@ -6,13 +6,9 @@ import cn.iocoder.yudao.module.iot.enums.device.IotDeviceStatusEnum; |
| 6 | 6 | import cn.iocoder.yudao.module.iot.enums.product.IotProductDeviceTypeEnum; |
| 7 | 7 | import io.swagger.v3.oas.annotations.media.Schema; |
| 8 | 8 | import lombok.Data; |
| 9 | -import lombok.EqualsAndHashCode; | |
| 10 | -import lombok.ToString; | |
| 11 | 9 | |
| 12 | 10 | @Schema(description = "管理后台 - IoT 设备分页 Request VO") |
| 13 | 11 | @Data |
| 14 | -@EqualsAndHashCode(callSuper = true) | |
| 15 | -@ToString(callSuper = true) | |
| 16 | 12 | public class IotDevicePageReqVO extends PageParam { |
| 17 | 13 | |
| 18 | 14 | @Schema(description = "设备名称", example = "王五") | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/dataType/ThingModelArgument.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.dataType; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelProperty; |
| 4 | -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelProperty; | |
| 5 | 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 6 | 5 | import lombok.Data; |
| 7 | 6 | |
| 8 | 7 | @Data |
| 9 | 8 | @JsonIgnoreProperties(ignoreUnknown = true) |
| 10 | -public class ThinkModelArgument { | |
| 9 | +public class ThingModelArgument { | |
| 11 | 10 | |
| 12 | 11 | public static final String DIRECTION_INPUT = "input"; |
| 13 | 12 | public static final String DIRECTION_OUTPUT = "output"; | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/tdengine/TdThinkModelMessageMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.dal.tdengine; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; |
| 4 | -import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdTableDO; | |
| 5 | 4 | import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThinkModelMessageDO; |
| 6 | 5 | import com.baomidou.dynamic.datasource.annotation.DS; |
| 7 | 6 | import org.apache.ibatis.annotations.Mapper; | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/IotProductServiceImpl.java
| ... | ... | @@ -7,8 +7,8 @@ import cn.iocoder.yudao.module.iot.controller.admin.product.vo.product.IotProduc |
| 7 | 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; |
| 8 | 8 | import cn.iocoder.yudao.module.iot.dal.mysql.product.IotProductMapper; |
| 9 | 9 | import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum; |
| 10 | -import cn.iocoder.yudao.module.iot.service.tdengine.IotThinkModelMessageService; | |
| 11 | -import cn.iocoder.yudao.module.iot.service.thinkmodel.IotProductThinkModelService; | |
| 10 | +import cn.iocoder.yudao.module.iot.service.tdengine.IotThingModelMessageService; | |
| 11 | +import cn.iocoder.yudao.module.iot.service.thingmodel.IotProductThingModelService; | |
| 12 | 12 | import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
| 13 | 13 | import jakarta.annotation.Resource; |
| 14 | 14 | import org.springframework.context.annotation.Lazy; |
| ... | ... | @@ -35,10 +35,10 @@ public class IotProductServiceImpl implements IotProductService { |
| 35 | 35 | |
| 36 | 36 | @Resource |
| 37 | 37 | @Lazy // 延迟加载,解决循环依赖 |
| 38 | - private IotProductThinkModelService thinkModelFunctionService; | |
| 38 | + private IotProductThingModelService thingModelFunctionService; | |
| 39 | 39 | @Resource |
| 40 | 40 | @Lazy // 延迟加载,解决循环依赖 |
| 41 | - private IotThinkModelMessageService thinkModelMessageService; | |
| 41 | + private IotThingModelMessageService thingModelMessageService; | |
| 42 | 42 | |
| 43 | 43 | @Override |
| 44 | 44 | public Long createProduct(IotProductSaveReqVO createReqVO) { |
| ... | ... | @@ -119,9 +119,9 @@ public class IotProductServiceImpl implements IotProductService { |
| 119 | 119 | // 3. 产品是发布状态 |
| 120 | 120 | if (Objects.equals(status, IotProductStatusEnum.PUBLISHED.getStatus())) { |
| 121 | 121 | // 3.1 创建产品超级表数据模型 |
| 122 | - thinkModelFunctionService.createSuperTableDataModel(id); | |
| 122 | + thingModelFunctionService.createSuperTableDataModel(id); | |
| 123 | 123 | // 3.2 创建物模型日志超级表数据模型 |
| 124 | - thinkModelMessageService.createSuperTable(id); | |
| 124 | + thingModelMessageService.createSuperTable(id); | |
| 125 | 125 | } |
| 126 | 126 | productMapper.updateById(updateObj); |
| 127 | 127 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotThingModelMessageService.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.service.tdengine; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; |
| 4 | -import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThinkModelMessage; | |
| 4 | +import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage; | |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * 物模型消息 Service |
| ... | ... | @@ -14,7 +14,7 @@ public interface IotThingModelMessageService { |
| 14 | 14 | * @param device 设备 |
| 15 | 15 | * @param thingModelMessage 物模型消息 |
| 16 | 16 | */ |
| 17 | - void saveThinkModelMessage(IotDeviceDO device, ThinkModelMessage thingModelMessage); | |
| 17 | + void saveThingModelMessage(IotDeviceDO device, ThingModelMessage thingModelMessage); | |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * 创建物模型消息日志超级表 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotThingModelMessageServiceImpl.java
| ... | ... | @@ -14,7 +14,6 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage; |
| 14 | 14 | import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotProductThingModelDO; |
| 15 | 15 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; |
| 16 | 16 | import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.*; |
| 17 | -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodel.IotProductThinkModelDO; | |
| 18 | 17 | import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO; |
| 19 | 18 | import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDDLMapper; |
| 20 | 19 | import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper; |
| ... | ... | @@ -25,7 +24,6 @@ import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum |
| 25 | 24 | import cn.iocoder.yudao.module.iot.service.device.IotDeviceService; |
| 26 | 25 | import cn.iocoder.yudao.module.iot.service.thingmodel.IotProductThingModelService; |
| 27 | 26 | import cn.iocoder.yudao.module.iot.service.product.IotProductService; |
| 28 | -import cn.iocoder.yudao.module.iot.service.thinkmodel.IotProductThinkModelService; | |
| 29 | 27 | import cn.iocoder.yudao.module.iot.util.IotTdDatabaseUtils; |
| 30 | 28 | import jakarta.annotation.Resource; |
| 31 | 29 | import lombok.extern.slf4j.Slf4j; |
| ... | ... | @@ -112,6 +110,8 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ |
| 112 | 110 | private List<IotProductThingModelDO> getValidThingModelList(String productKey) { |
| 113 | 111 | return filterList(iotProductThingModelService.getProductThingModelListByProductKey(productKey), |
| 114 | 112 | thingModel -> IotProductThingModelTypeEnum.PROPERTY.getType().equals(thingModel.getType())); |
| 113 | + } | |
| 114 | + | |
| 115 | 115 | @Override |
| 116 | 116 | @TenantIgnore |
| 117 | 117 | public void createSuperTable(Long productId) { |
| ... | ... | @@ -128,11 +128,12 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ |
| 128 | 128 | .setSuperTableName(superTableName)); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - private List<IotProductThinkModelDO> getValidFunctionList(String productKey) { | |
| 132 | - return iotProductThinkModelService | |
| 133 | - .getProductThinkModelListByProductKey(productKey) | |
| 131 | + private List<IotProductThingModelDO> getValidFunctionList(String productKey) { | |
| 132 | + // TODO @puhui999:使用 convertList 会好点哈 | |
| 133 | + return iotProductThingModelService | |
| 134 | + .getProductThingModelListByProductKey(productKey) | |
| 134 | 135 | .stream() |
| 135 | - .filter(function -> IotProductThinkModelTypeEnum.PROPERTY.getType().equals(function.getType())) | |
| 136 | + .filter(function -> IotProductThingModelTypeEnum.PROPERTY.getType().equals(function.getType())) | |
| 136 | 137 | .toList(); |
| 137 | 138 | } |
| 138 | 139 | ... | ... |