|
|
|
@ -433,6 +433,26 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
|
|
|
|
|
String databaseName = TdEngineConstants.getDatabaseName();
|
|
|
|
|
|
|
|
|
|
List<HwDevice> hwDevices = hwDeviceMapper.selectHwDeviceListByMonitor(queryHwDevice);
|
|
|
|
|
|
|
|
|
|
/* 获取该监控单元节点下的所有子孙节点的设备 */
|
|
|
|
|
//获取所有监控单元
|
|
|
|
|
List<HwMonitorUnit> hwMonitorUnits = hwMonitorUnitMapper.selectHwMonitorUnitList(new HwMonitorUnit());
|
|
|
|
|
Long targetNodeId = queryHwDevice.getMonitorUnitId();//目标节点,即父节点ID
|
|
|
|
|
//TODO(zangch,2024.10.16):在hwDevices拼接子孙节点的设备列表,数据库样本少未完全验证性能和有效性
|
|
|
|
|
//调用递归方法
|
|
|
|
|
List<HwMonitorUnit> descendants = getAllHwMonitorUnits(hwMonitorUnits,targetNodeId);
|
|
|
|
|
// 遍历所有监控单元
|
|
|
|
|
for (HwMonitorUnit hwMonitorUnit : descendants){
|
|
|
|
|
// 创建设备对象
|
|
|
|
|
HwDevice hwMonitorUnitDevice = new HwDevice();
|
|
|
|
|
// 设置监控单元ID
|
|
|
|
|
hwMonitorUnitDevice.setMonitorUnitId(hwMonitorUnit.getMonitorUnitId());
|
|
|
|
|
// 根据监控单元ID查询设备列表
|
|
|
|
|
List<HwDevice> hwDevicesByMonitor = hwDeviceMapper.selectHwDeviceListByMonitor(hwMonitorUnitDevice);
|
|
|
|
|
// 将查询到的设备列表添加到总列表中
|
|
|
|
|
hwDevices.addAll(hwDevicesByMonitor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hwDevices.size()>0){
|
|
|
|
|
hwDevices.forEach(hwDevice -> {
|
|
|
|
|
Long deviceId = hwDevice.getDeviceId();
|
|
|
|
@ -548,6 +568,26 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
|
|
|
|
|
return devicesMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO(zangch,2024.10.16):递归获取所有子孙节点,数据库数据太少没办法验证是否完全有效
|
|
|
|
|
/* 根据节点ID获取所有子孙节点*/
|
|
|
|
|
private List<HwMonitorUnit> getAllHwMonitorUnits(List<HwMonitorUnit> hwMonitorUnits,Long nodeId){
|
|
|
|
|
// 创建一个空的列表,用于存储所有子节点
|
|
|
|
|
List<HwMonitorUnit> hwMonitorUnitList = new ArrayList<>();
|
|
|
|
|
// 遍历所有节点
|
|
|
|
|
for(HwMonitorUnit node :hwMonitorUnits){
|
|
|
|
|
// 如果当前节点的父节点ID等于传入的节点ID
|
|
|
|
|
if (node.getParentId().equals(nodeId)){
|
|
|
|
|
// 当前节点是直接子节点,加入结果集并继续寻找其子孙节点
|
|
|
|
|
hwMonitorUnitList.add(node);
|
|
|
|
|
// 递归调用方法,获取当前节点的所有子孙节点
|
|
|
|
|
hwMonitorUnitList.addAll(getAllHwMonitorUnits(hwMonitorUnits, node.getMonitorUnitId()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 返回所有子节点
|
|
|
|
|
return hwMonitorUnitList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询设备信息列表,join监控单元、设备模型等表
|
|
|
|
|
*
|
|
|
|
|