【代码评审】IoT:场景联动 review

This commit is contained in:
YunaiV 2025-03-23 09:41:05 +08:00
parent 35dd91d6c9
commit 2f9d760327
9 changed files with 18 additions and 8 deletions

View File

@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
// TODO @芋艿规则场景 要不要统一改成 场景联动
@Tag(name = "管理后台 - IoT 规则场景")
@RestController
@RequestMapping("/iot/rule-scene")

View File

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.iot.controller.admin.rule.vo.scene;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -24,6 +26,7 @@ public class IotRuleScenePageReqVO extends PageParam {
private String description;
@Schema(description = "场景状态", example = "1")
@InEnum(CommonStatusEnum.class)
private Integer status;
@Schema(description = "创建时间")

View File

@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataBridgeDO;
import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneActionTypeEnum;
import lombok.Data;
// TODO @puhui999这个要不内嵌到 IoTRuleSceneDO 里面
/**
* 执行器配置
*

View File

@ -9,6 +9,7 @@ import lombok.Data;
import java.util.List;
import java.util.Map;
// TODO @puhui999这个要不内嵌到 IoTRuleSceneDO 里面
/**
* 执行设备控制
*

View File

@ -6,6 +6,7 @@ import lombok.Data;
import java.util.List;
// TODO @puhui999这个要不内嵌到 IoTRuleSceneDO 里面
/**
* 触发条件
*

View File

@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO;
import cn.iocoder.yudao.module.iot.enums.rule.IotRuleSceneTriggerConditionParameterOperatorEnum;
import lombok.Data;
// TODO @puhui999这个要不内嵌到 IoTRuleSceneDO 里面
/**
* 触发条件参数
*

View File

@ -7,6 +7,7 @@ import lombok.Data;
import java.util.List;
// TODO @puhui999这个要不内嵌到 IoTRuleSceneDO 里面
/**
* 触发器配置
*

View File

@ -61,6 +61,7 @@ public class IotThingModelController {
return success(BeanUtils.toBean(thingModel, IotThingModelRespVO.class));
}
// TODO @puhui999要不叫 get-tsl去掉 product-id后续
@GetMapping("/tsl-by-product-id")
@Operation(summary = "获得产品物模型 TSL")
@Parameter(name = "productId", description = "产品 ID", required = true, example = "1024")
@ -69,7 +70,6 @@ public class IotThingModelController {
return success(thingModelService.getThingModelTslByProductId(productId));
}
// TODO @puhui @supergetThingModelListByProductId getThingModelListByProductId 可以融合么
@GetMapping("/list")
@Operation(summary = "获得产品物模型列表")
@PreAuthorize("@ss.hasPermission('iot:thing-model:query')")

View File

@ -151,26 +151,27 @@ public class IotThingModelServiceImpl implements IotThingModelService {
return thingModelMapper.selectList(reqVO);
}
// TODO @puhui999这个转换放在 controller 貌似也行
@Override
public IotThingModelTSLRespVO getThingModelTslByProductId(Long productId) {
IotThingModelTSLRespVO tslRespVO = new IotThingModelTSLRespVO();
// 1. 获得产品所有物模型定义
List<IotThingModelDO> thingModelList = thingModelMapper.selectListByProductId(productId);
if (CollUtil.isEmpty(thingModelList)) {
List<IotThingModelDO> thingModels = thingModelMapper.selectListByProductId(productId);
if (CollUtil.isEmpty(thingModels)) {
return tslRespVO;
}
// 2.1 设置公共部分参数
IotThingModelDO thingModel = thingModelList.get(0);
IotThingModelDO thingModel = thingModels.get(0);
tslRespVO.setProductId(thingModel.getProductId()).setProductKey(thingModel.getProductKey());
// 2.2 处理属性列表
tslRespVO.setProperties(convertList(filterList(thingModelList, item ->
tslRespVO.setProperties(convertList(filterList(thingModels, item ->
ObjUtil.equal(IotThingModelTypeEnum.PROPERTY.getType(), item.getType())), IotThingModelDO::getProperty));
// 2.3 处理服务列表
tslRespVO.setServices(convertList(filterList(thingModelList, item ->
tslRespVO.setServices(convertList(filterList(thingModels, item ->
ObjUtil.equal(IotThingModelTypeEnum.SERVICE.getType(), item.getType())), IotThingModelDO::getService));
// 2.4 处理事件列表
tslRespVO.setEvents(convertList(filterList(thingModelList, item ->
tslRespVO.setEvents(convertList(filterList(thingModels, item ->
ObjUtil.equal(IotThingModelTypeEnum.EVENT.getType(), item.getType())), IotThingModelDO::getEvent));
return tslRespVO;
}