Pre Merge pull request !1306 from puhui999/iot
This commit is contained in:
commit
340173702d
|
@ -185,4 +185,12 @@ public class IotDeviceController {
|
|||
return success(deviceService.getMqttConnectionParams(deviceId));
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("/list-by-product-key-and-names")
|
||||
@Operation(summary = "通过产品标识和设备名称列表获取设备")
|
||||
@PreAuthorize("@ss.hasPermission('iot:device:query')")
|
||||
public CommonResult<List<IotDeviceRespVO>> getDevicesByProductKeyAndNames(@Valid IotDeviceByProductKeyAndNamesReqVO reqVO) {
|
||||
List<IotDeviceDO> devices = deviceService.getDevicesByProductKeyAndNames(reqVO.getProductKey(), reqVO.getDeviceNames());
|
||||
return success(BeanUtils.toBean(devices, IotDeviceRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package cn.iocoder.yudao.module.iot.controller.admin.device.vo.device;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 通过产品标识和设备名称列表获取设备 Request VO")
|
||||
@Data
|
||||
public class IotDeviceByProductKeyAndNamesReqVO {
|
||||
|
||||
@Schema(description = "产品标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "1de24640dfe")
|
||||
@NotBlank(message = "产品标识不能为空")
|
||||
private String productKey;
|
||||
|
||||
@Schema(description = "设备名称列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "device001,device002")
|
||||
@NotEmpty(message = "设备名称列表不能为空")
|
||||
private List<String> deviceNames;
|
||||
|
||||
}
|
|
@ -93,6 +93,21 @@ public class IotProductController {
|
|||
}));
|
||||
}
|
||||
|
||||
@GetMapping("/get-by-key")
|
||||
@Operation(summary = "通过 ProductKey 获得产品")
|
||||
@Parameter(name = "productKey", description = "产品Key", required = true, example = "abc123")
|
||||
@PreAuthorize("@ss.hasPermission('iot:product:query')")
|
||||
public CommonResult<IotProductRespVO> getProductByKey(@RequestParam("productKey") String productKey) {
|
||||
IotProductDO product = productService.getProductByProductKey(productKey);
|
||||
// 拼接数据
|
||||
IotProductCategoryDO category = categoryService.getProductCategory(product.getCategoryId());
|
||||
return success(BeanUtils.toBean(product, IotProductRespVO.class, bean -> {
|
||||
if (category != null) {
|
||||
bean.setCategoryName(category.getName());
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得产品分页")
|
||||
@PreAuthorize("@ss.hasPermission('iot:product:query')")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cn.iocoder.yudao.module.iot.controller.admin.rule;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
@ -17,7 +18,10 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
|
||||
@Tag(name = "管理后台 - IoT 数据桥梁")
|
||||
@RestController
|
||||
|
@ -69,4 +73,12 @@ public class IotDataBridgeController {
|
|||
return success(BeanUtils.toBean(pageResult, IotDataBridgeRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping("/simple-list")
|
||||
@Operation(summary = "获取数据桥梁的精简信息列表", description = "主要用于前端的下拉选项")
|
||||
public CommonResult<List<IotDataBridgeRespVO>> getSimpleDataBridgeList() {
|
||||
List<IotDataBridgeDO> list = dataBridgeService.getDataBridgeList(CommonStatusEnum.ENABLE.getStatus());
|
||||
return success(convertList(list, dataBridge -> // 只返回 id、name 字段
|
||||
new IotDataBridgeRespVO().setId(dataBridge.getId()).setName(dataBridge.getName())));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -144,8 +144,16 @@ public class IotRuleSceneDO extends TenantBaseDO {
|
|||
@Data
|
||||
public static class TriggerConditionParameter {
|
||||
|
||||
// TODO @芋艿: identifier0 存事件和服务的 identifier 属性的情况 identifier0 就为 null 解决前端回显问题
|
||||
/**
|
||||
* 标识符(属性、事件、服务)
|
||||
* 标识符(事件、服务)
|
||||
*
|
||||
* 关联 {@link IotThingModelDO#getIdentifier()}
|
||||
*/
|
||||
private String identifier0;
|
||||
|
||||
/**
|
||||
* 标识符(属性)
|
||||
*
|
||||
* 关联 {@link IotThingModelDO#getIdentifier()}
|
||||
*/
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -77,6 +78,12 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
|
|||
.geIfPresent(IotDeviceDO::getCreateTime, createTime));
|
||||
}
|
||||
|
||||
default List<IotDeviceDO> selectByProductKeyAndDeviceNames(String productKey, Collection<String> deviceNames) {
|
||||
return selectList(new LambdaQueryWrapperX<IotDeviceDO>()
|
||||
.eq(IotDeviceDO::getProductKey, productKey)
|
||||
.in(IotDeviceDO::getDeviceName, deviceNames));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定产品下各状态的设备数量
|
||||
*
|
||||
|
@ -93,4 +100,4 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
|
|||
*/
|
||||
List<Map<String, Object>> selectDeviceCountGroupByState();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBr
|
|||
import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataBridgeDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* IoT 数据桥梁 Mapper
|
||||
*
|
||||
|
@ -23,4 +25,10 @@ public interface IotDataBridgeMapper extends BaseMapperX<IotDataBridgeDO> {
|
|||
.orderByDesc(IotDataBridgeDO::getId));
|
||||
}
|
||||
|
||||
default List<IotDataBridgeDO> selectList(Integer status) {
|
||||
return selectList(new LambdaQueryWrapperX<IotDataBridgeDO>()
|
||||
.eqIfPresent(IotDataBridgeDO::getStatus, status)
|
||||
.orderByDesc(IotDataBridgeDO::getId));
|
||||
}
|
||||
|
||||
}
|
|
@ -219,4 +219,13 @@ public interface IotDeviceService {
|
|||
*/
|
||||
Map<Integer, Long> getDeviceCountMapByState();
|
||||
|
||||
}
|
||||
/**
|
||||
* 通过产品标识和设备名称列表获取设备列表
|
||||
*
|
||||
* @param productKey 产品标识
|
||||
* @param deviceNames 设备名称列表
|
||||
* @return 设备列表
|
||||
*/
|
||||
List<IotDeviceDO> getDevicesByProductKeyAndNames(String productKey, List<String> deviceNames);
|
||||
|
||||
}
|
||||
|
|
|
@ -451,4 +451,12 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
|||
));
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public List<IotDeviceDO> getDevicesByProductKeyAndNames(String productKey, List<String> deviceNames) {
|
||||
if (StrUtil.isBlank(productKey) || CollUtil.isEmpty(deviceNames)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return deviceMapper.selectByProductKeyAndDeviceNames(productKey, deviceNames);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import cn.iocoder.yudao.module.iot.controller.admin.rule.vo.databridge.IotDataBr
|
|||
import cn.iocoder.yudao.module.iot.dal.dataobject.rule.IotDataBridgeDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* IoT 数据桥梁 Service 接口
|
||||
*
|
||||
|
@ -51,4 +53,12 @@ public interface IotDataBridgeService {
|
|||
*/
|
||||
PageResult<IotDataBridgeDO> getDataBridgePage(IotDataBridgePageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
/**
|
||||
* 获取数据桥梁列表
|
||||
*
|
||||
* @param status 状态,如果为空,则不进行筛选
|
||||
* @return 数据桥梁列表
|
||||
*/
|
||||
List<IotDataBridgeDO> getDataBridgeList(Integer status);
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ import jakarta.annotation.Resource;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.DATA_BRIDGE_NOT_EXISTS;
|
||||
|
||||
|
@ -67,4 +69,9 @@ public class IotDataBridgeServiceImpl implements IotDataBridgeService {
|
|||
return dataBridgeMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public List<IotDataBridgeDO> getDataBridgeList(Integer status) {
|
||||
return dataBridgeMapper.selectList(status);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue