【功能新增】IoT: 通过产品标识和设备名称列表获取设备列表
This commit is contained in:
parent
b3dcd7b133
commit
5a66037725
|
@ -185,4 +185,12 @@ public class IotDeviceController {
|
||||||
return success(deviceService.getMqttConnectionParams(deviceId));
|
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;
|
||||||
|
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -77,6 +78,12 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
|
||||||
.geIfPresent(IotDeviceDO::getCreateTime, createTime));
|
.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();
|
List<Map<String, Object>> selectDeviceCountGroupByState();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,4 +219,13 @@ public interface IotDeviceService {
|
||||||
*/
|
*/
|
||||||
Map<Integer, Long> getDeviceCountMapByState();
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue