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