|
|
|
|
@ -263,7 +263,7 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
|
|
OrganizationListReqVO organizationListReqVO = new OrganizationListReqVO();
|
|
|
|
|
List<OrganizationDO> organizationDOS = getOrganizationList(organizationListReqVO);
|
|
|
|
|
List<OrganizationRespVO> organizationRespVOS = buildVOList(organizationDOS);
|
|
|
|
|
if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isEmpty(organizationRespVOS)) {
|
|
|
|
|
if (organizationRespVOS.isEmpty()) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -306,19 +306,171 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
|
|
.filter(param -> param.getDeviceId() != null)
|
|
|
|
|
.collect(Collectors.groupingBy(DeviceContactModelDO::getDeviceId));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取产线与父节点的映射关系
|
|
|
|
|
Map<Long, Long> lineParentIdMap = organizationRespVOS.stream()
|
|
|
|
|
.collect(Collectors.toMap(
|
|
|
|
|
OrganizationRespVO::getId,
|
|
|
|
|
line -> line.getParentId() != null ? line.getParentId() : 0L, // 如果父节点为空,使用默认值0
|
|
|
|
|
(existing, replacement) -> existing
|
|
|
|
|
));
|
|
|
|
|
// 构建产线ID到产线对象的映射
|
|
|
|
|
Map<Long, OrganizationRespVO> lineMap = organizationRespVOS.stream()
|
|
|
|
|
.collect(Collectors.toMap(OrganizationRespVO::getId, Function.identity()));
|
|
|
|
|
|
|
|
|
|
// 获取所有匹配的产线(包括下级匹配的)
|
|
|
|
|
List<OrganizationRespVO> matchedLines = getMatchedLinesWithAncestors(
|
|
|
|
|
organizationRespVOS, keyword, allDevices, paramsByDeviceId, lineParentIdMap, lineMap
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 7. 构建树结构
|
|
|
|
|
return buildTreeStructureWithKeyword(organizationRespVOS, devicesByLineId, paramsByDeviceId,keyword);
|
|
|
|
|
return buildTreeStructureWithKeyword(matchedLines, devicesByLineId, paramsByDeviceId,keyword,lineParentIdMap);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<OrganizationRespVO> getMatchedLinesWithAncestors(
|
|
|
|
|
List<OrganizationRespVO> allLines,
|
|
|
|
|
String keyword,
|
|
|
|
|
List<DeviceDO> allDevices,
|
|
|
|
|
Map<Long, List<DeviceContactModelDO>> paramsByDeviceId,
|
|
|
|
|
Map<Long, Long> lineParentIdMap,
|
|
|
|
|
Map<Long, OrganizationRespVO> lineMap) {
|
|
|
|
|
|
|
|
|
|
boolean hasKeyword = StringUtils.isNotBlank(keyword);
|
|
|
|
|
String lowerKeyword = hasKeyword ? keyword.toLowerCase() : "";
|
|
|
|
|
|
|
|
|
|
// 存储最终要包含的产线ID
|
|
|
|
|
Set<Long> lineIdsToInclude = new HashSet<>();
|
|
|
|
|
|
|
|
|
|
// 1. 首先找出直接匹配的产线
|
|
|
|
|
for (OrganizationRespVO line : allLines) {
|
|
|
|
|
boolean lineMatch = !hasKeyword ||
|
|
|
|
|
(line.getName() != null && line.getName().toLowerCase().contains(lowerKeyword));
|
|
|
|
|
|
|
|
|
|
if (lineMatch) {
|
|
|
|
|
// 添加到结果集
|
|
|
|
|
lineIdsToInclude.add(line.getId());
|
|
|
|
|
// 向上查找所有父级节点
|
|
|
|
|
addAllAncestors(line.getId(), lineParentIdMap, lineMap, lineIdsToInclude);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2. 查找设备匹配的产线
|
|
|
|
|
if (hasKeyword) {
|
|
|
|
|
for (DeviceDO device : allDevices) {
|
|
|
|
|
boolean deviceMatch = device.getDeviceName() != null &&
|
|
|
|
|
device.getDeviceName().toLowerCase().contains(lowerKeyword);
|
|
|
|
|
|
|
|
|
|
if (deviceMatch) {
|
|
|
|
|
// 找到这个设备所属的产线
|
|
|
|
|
for (OrganizationRespVO line : allLines) {
|
|
|
|
|
if (line.getMachineId() != null && line.getMachineId().equals(device.getId())) {
|
|
|
|
|
lineIdsToInclude.add(line.getId());
|
|
|
|
|
addAllAncestors(line.getId(), lineParentIdMap, lineMap, lineIdsToInclude);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3. 查找参数匹配的产线
|
|
|
|
|
if (hasKeyword) {
|
|
|
|
|
for (Map.Entry<Long, List<DeviceContactModelDO>> entry : paramsByDeviceId.entrySet()) {
|
|
|
|
|
Long deviceId = entry.getKey();
|
|
|
|
|
List<DeviceContactModelDO> params = entry.getValue();
|
|
|
|
|
|
|
|
|
|
boolean hasMatchingParam = params.stream()
|
|
|
|
|
.anyMatch(param -> param.getAttributeName() != null &&
|
|
|
|
|
param.getAttributeName().toLowerCase().contains(lowerKeyword));
|
|
|
|
|
|
|
|
|
|
if (hasMatchingParam) {
|
|
|
|
|
// 找到这个设备所属的产线
|
|
|
|
|
for (OrganizationRespVO line : allLines) {
|
|
|
|
|
if (line.getMachineId() != null && line.getMachineId().equals(deviceId)) {
|
|
|
|
|
lineIdsToInclude.add(line.getId());
|
|
|
|
|
addAllAncestors(line.getId(), lineParentIdMap, lineMap, lineIdsToInclude);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果没有关键词,返回所有产线
|
|
|
|
|
if (!hasKeyword) {
|
|
|
|
|
return allLines;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 只返回需要包含的产线
|
|
|
|
|
return allLines.stream()
|
|
|
|
|
.filter(line -> lineIdsToInclude.contains(line.getId()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addAllAncestors(Long lineId,
|
|
|
|
|
Map<Long, Long> lineParentIdMap,
|
|
|
|
|
Map<Long, OrganizationRespVO> lineMap,
|
|
|
|
|
Set<Long> lineIdsToInclude) {
|
|
|
|
|
Long currentParentId = lineParentIdMap.get(lineId);
|
|
|
|
|
|
|
|
|
|
// 递归向上查找所有父级节点
|
|
|
|
|
while (currentParentId != null && currentParentId != 0L) {
|
|
|
|
|
lineIdsToInclude.add(currentParentId);
|
|
|
|
|
|
|
|
|
|
// 继续向上查找
|
|
|
|
|
currentParentId = lineParentIdMap.get(currentParentId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<LineAnalysisTreeDTO.LineNode> buildTreeStructureWithKeyword(List<OrganizationRespVO> lines,
|
|
|
|
|
Map<Long, List<DeviceDO>> devicesByLineId,
|
|
|
|
|
Map<Long, List<DeviceContactModelDO>> paramsByDeviceId,
|
|
|
|
|
String keyword) {
|
|
|
|
|
String keyword,
|
|
|
|
|
Map<Long, Long> lineParentIdMap) {
|
|
|
|
|
|
|
|
|
|
// 统一处理关键词
|
|
|
|
|
boolean hasKeyword = StringUtils.isNotBlank(keyword);
|
|
|
|
|
String lowerKeyword = hasKeyword ? keyword.toLowerCase() : "";
|
|
|
|
|
|
|
|
|
|
// 如果lines已经过滤过,这里不再需要复杂的匹配判断
|
|
|
|
|
if (!hasKeyword) {
|
|
|
|
|
// 没有关键词时,返回完整的树结构
|
|
|
|
|
return lines.stream().map(line -> {
|
|
|
|
|
Long parentId = lineParentIdMap.getOrDefault(line.getId(), 0L);
|
|
|
|
|
|
|
|
|
|
// 获取该产线的设备
|
|
|
|
|
List<DeviceDO> lineDevices = devicesByLineId.getOrDefault(line.getId(), new ArrayList<>());
|
|
|
|
|
|
|
|
|
|
// 构建设备节点(显示所有设备和参数)
|
|
|
|
|
List<LineAnalysisTreeDTO.EquipmentNode> equipmentNodes = lineDevices.stream()
|
|
|
|
|
.map(device -> {
|
|
|
|
|
List<DeviceContactModelDO> deviceParams = paramsByDeviceId.getOrDefault(device.getId(), new ArrayList<>());
|
|
|
|
|
|
|
|
|
|
List<LineAnalysisTreeDTO.ParameterNode> parameterNodes = deviceParams.stream()
|
|
|
|
|
.map(this::buildParameterNode)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
return LineAnalysisTreeDTO.EquipmentNode.builder()
|
|
|
|
|
.id(device.getId())
|
|
|
|
|
.name(device.getDeviceName())
|
|
|
|
|
.parameters(parameterNodes)
|
|
|
|
|
.build();
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
return LineAnalysisTreeDTO.LineNode.builder()
|
|
|
|
|
.id(line.getId())
|
|
|
|
|
.name(line.getName())
|
|
|
|
|
.parentId(parentId)
|
|
|
|
|
.equipments(equipmentNodes)
|
|
|
|
|
.build();
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 有关键词时,lines已经包含了匹配的产线及其父级产线
|
|
|
|
|
// 但我们仍然需要根据关键词过滤设备和参数
|
|
|
|
|
|
|
|
|
|
// 记录匹配情况
|
|
|
|
|
Map<Long, Boolean> lineMatchedMap = new HashMap<>();
|
|
|
|
|
Map<Long, Boolean> deviceMatchedMap = new HashMap<>();
|
|
|
|
|
@ -326,17 +478,16 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
|
|
// 第一遍:分析匹配情况
|
|
|
|
|
for (OrganizationRespVO line : lines) {
|
|
|
|
|
// 产线是否匹配
|
|
|
|
|
boolean lineMatch = !hasKeyword ||
|
|
|
|
|
(line.getName() != null && line.getName().toLowerCase().contains(lowerKeyword));
|
|
|
|
|
boolean lineMatch = line.getName() != null &&
|
|
|
|
|
line.getName().toLowerCase().contains(lowerKeyword);
|
|
|
|
|
lineMatchedMap.put(line.getId(), lineMatch);
|
|
|
|
|
|
|
|
|
|
// 检查该产线的设备
|
|
|
|
|
List<DeviceDO> lineDevices = devicesByLineId.getOrDefault(line.getId(), new ArrayList<>());
|
|
|
|
|
for (DeviceDO device : lineDevices) {
|
|
|
|
|
// 设备是否匹配
|
|
|
|
|
boolean deviceMatch = !hasKeyword ||
|
|
|
|
|
(device.getDeviceName() != null &&
|
|
|
|
|
device.getDeviceName().toLowerCase().contains(lowerKeyword));
|
|
|
|
|
boolean deviceMatch = device.getDeviceName() != null &&
|
|
|
|
|
device.getDeviceName().toLowerCase().contains(lowerKeyword);
|
|
|
|
|
deviceMatchedMap.put(device.getId(), deviceMatch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -344,16 +495,7 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
|
|
// 第二遍:构建树结构
|
|
|
|
|
return lines.stream().map(line -> {
|
|
|
|
|
boolean lineMatch = lineMatchedMap.getOrDefault(line.getId(), false);
|
|
|
|
|
|
|
|
|
|
// 关键修改:如果产线匹配,跳过后续的设备过滤逻辑
|
|
|
|
|
if (hasKeyword && !lineMatch) {
|
|
|
|
|
// 检查产线下是否有匹配的设备或参数
|
|
|
|
|
boolean hasMatchingDeviceOrParam = checkIfLineHasMatchingDeviceOrParam(
|
|
|
|
|
line, devicesByLineId, paramsByDeviceId, lowerKeyword, deviceMatchedMap);
|
|
|
|
|
if (!hasMatchingDeviceOrParam) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Long parentId = lineParentIdMap.getOrDefault(line.getId(), 0L);
|
|
|
|
|
|
|
|
|
|
// 获取该产线的设备
|
|
|
|
|
List<DeviceDO> lineDevices = devicesByLineId.getOrDefault(line.getId(), new ArrayList<>());
|
|
|
|
|
@ -362,13 +504,10 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
|
|
List<LineAnalysisTreeDTO.EquipmentNode> equipmentNodes = lineDevices.stream()
|
|
|
|
|
.map(device -> {
|
|
|
|
|
boolean deviceMatch = deviceMatchedMap.getOrDefault(device.getId(), false);
|
|
|
|
|
List<DeviceContactModelDO> deviceParams = paramsByDeviceId.getOrDefault(device.getId(), new ArrayList<>());
|
|
|
|
|
|
|
|
|
|
// 关键修改:如果产线匹配,保留所有设备
|
|
|
|
|
// 如果产线匹配,显示该产线下的所有设备
|
|
|
|
|
if (lineMatch) {
|
|
|
|
|
// 产线匹配时,保留该设备
|
|
|
|
|
List<DeviceContactModelDO> deviceParams = paramsByDeviceId.getOrDefault(device.getId(), new ArrayList<>());
|
|
|
|
|
|
|
|
|
|
// 产线匹配时,显示所有参数
|
|
|
|
|
List<LineAnalysisTreeDTO.ParameterNode> parameterNodes = deviceParams.stream()
|
|
|
|
|
.map(this::buildParameterNode)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
@ -380,33 +519,30 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 以下为原有逻辑:产线不匹配时的处理
|
|
|
|
|
if (hasKeyword && !deviceMatch) {
|
|
|
|
|
boolean hasMatchingParam = checkIfDeviceHasMatchingParam(
|
|
|
|
|
device, paramsByDeviceId, lowerKeyword);
|
|
|
|
|
if (!hasMatchingParam) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
// 如果设备匹配,显示该设备的所有参数
|
|
|
|
|
if (deviceMatch) {
|
|
|
|
|
List<LineAnalysisTreeDTO.ParameterNode> parameterNodes = deviceParams.stream()
|
|
|
|
|
.map(this::buildParameterNode)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
return LineAnalysisTreeDTO.EquipmentNode.builder()
|
|
|
|
|
.id(device.getId())
|
|
|
|
|
.name(device.getDeviceName())
|
|
|
|
|
.parameters(parameterNodes)
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<DeviceContactModelDO> deviceParams = paramsByDeviceId.getOrDefault(device.getId(), new ArrayList<>());
|
|
|
|
|
// 检查是否有匹配的参数
|
|
|
|
|
boolean hasMatchingParam = deviceParams.stream()
|
|
|
|
|
.anyMatch(param -> isParameterMatch(param, lowerKeyword));
|
|
|
|
|
|
|
|
|
|
if (!hasMatchingParam) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 构建参数节点
|
|
|
|
|
// 只显示匹配的参数
|
|
|
|
|
List<LineAnalysisTreeDTO.ParameterNode> parameterNodes = deviceParams.stream()
|
|
|
|
|
.filter(param -> {
|
|
|
|
|
if (!hasKeyword) {
|
|
|
|
|
return true; // 没有关键词,显示所有
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 有关键词时:
|
|
|
|
|
// 如果设备匹配,显示所有参数
|
|
|
|
|
if (deviceMatch) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 否则,只显示匹配的参数
|
|
|
|
|
return isParameterMatch(param, lowerKeyword);
|
|
|
|
|
})
|
|
|
|
|
.filter(param -> isParameterMatch(param, lowerKeyword))
|
|
|
|
|
.map(this::buildParameterNode)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
@ -417,83 +553,60 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
|
|
.build();
|
|
|
|
|
})
|
|
|
|
|
.filter(Objects::nonNull)
|
|
|
|
|
.filter(equipmentNode -> !lineMatch || !equipmentNode.getParameters().isEmpty()) // 修改过滤条件
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
// 构建设备节点
|
|
|
|
|
return LineAnalysisTreeDTO.LineNode.builder()
|
|
|
|
|
.id(line.getId())
|
|
|
|
|
.name(line.getName())
|
|
|
|
|
.parentId(parentId)
|
|
|
|
|
.equipments(equipmentNodes)
|
|
|
|
|
.build();
|
|
|
|
|
})
|
|
|
|
|
.filter(Objects::nonNull)
|
|
|
|
|
.filter(lineNode -> !hasKeyword || lineMatchedMap.getOrDefault(lineNode.getId(), false) || !lineNode.getEquipments().isEmpty())
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 检查产线下是否有匹配的设备或参数
|
|
|
|
|
*/
|
|
|
|
|
private boolean checkIfLineHasMatchingDeviceOrParam(OrganizationRespVO line,
|
|
|
|
|
Map<Long, List<DeviceDO>> devicesByLineId,
|
|
|
|
|
Map<Long, List<DeviceContactModelDO>> paramsByDeviceId,
|
|
|
|
|
String lowerKeyword,
|
|
|
|
|
Map<Long, Boolean> deviceMatchedMap) {
|
|
|
|
|
|
|
|
|
|
List<DeviceDO> lineDevices = devicesByLineId.getOrDefault(line.getId(), new ArrayList<>());
|
|
|
|
|
|
|
|
|
|
for (DeviceDO device : lineDevices) {
|
|
|
|
|
// 检查设备是否匹配
|
|
|
|
|
boolean deviceMatch = deviceMatchedMap.getOrDefault(device.getId(), false);
|
|
|
|
|
if (deviceMatch) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查设备下的参数是否匹配
|
|
|
|
|
List<DeviceContactModelDO> deviceParams = paramsByDeviceId.getOrDefault(device.getId(), new ArrayList<>());
|
|
|
|
|
boolean hasMatchingParam = deviceParams.stream()
|
|
|
|
|
.anyMatch(param -> isParameterMatch(param, lowerKeyword));
|
|
|
|
|
if (hasMatchingParam) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 检查设备下是否有匹配的参数
|
|
|
|
|
*/
|
|
|
|
|
private boolean checkIfDeviceHasMatchingParam(DeviceDO device,
|
|
|
|
|
Map<Long, List<DeviceContactModelDO>> paramsByDeviceId,
|
|
|
|
|
String lowerKeyword) {
|
|
|
|
|
|
|
|
|
|
List<DeviceContactModelDO> deviceParams = paramsByDeviceId.getOrDefault(device.getId(), new ArrayList<>());
|
|
|
|
|
return deviceParams.stream()
|
|
|
|
|
.anyMatch(param -> isParameterMatch(param, lowerKeyword));
|
|
|
|
|
}
|
|
|
|
|
private List<LineAnalysisTreeDTO.LineNode> buildTreeStructure(List<OrganizationRespVO> lines,
|
|
|
|
|
Map<Long, List<DeviceDO>> devicesByLineId,
|
|
|
|
|
Map<Long, List<DeviceContactModelDO>> paramsByDeviceId) {
|
|
|
|
|
return lines.stream().map(line -> {
|
|
|
|
|
LineAnalysisTreeDTO.LineNode lineNode = LineAnalysisTreeDTO.LineNode.builder()
|
|
|
|
|
.id(line.getId())
|
|
|
|
|
.name(line.getName())
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
// 获取该产线的设备
|
|
|
|
|
List<DeviceDO> lineDevices = devicesByLineId.getOrDefault(line.getId(), new ArrayList<>());
|
|
|
|
|
|
|
|
|
|
// 构建设备节点
|
|
|
|
|
List<LineAnalysisTreeDTO.EquipmentNode> equipmentNodes = lineDevices.stream()
|
|
|
|
|
.map(device -> buildEquipmentNode(device, paramsByDeviceId))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
// /**
|
|
|
|
|
// * 检查产线下是否有匹配的设备或参数
|
|
|
|
|
// */
|
|
|
|
|
// private boolean checkIfLineHasMatchingDeviceOrParam(OrganizationRespVO line,
|
|
|
|
|
// Map<Long, List<DeviceDO>> devicesByLineId,
|
|
|
|
|
// Map<Long, List<DeviceContactModelDO>> paramsByDeviceId,
|
|
|
|
|
// String lowerKeyword,
|
|
|
|
|
// Map<Long, Boolean> deviceMatchedMap) {
|
|
|
|
|
//
|
|
|
|
|
// List<DeviceDO> lineDevices = devicesByLineId.getOrDefault(line.getId(), new ArrayList<>());
|
|
|
|
|
//
|
|
|
|
|
// for (DeviceDO device : lineDevices) {
|
|
|
|
|
// // 检查设备是否匹配
|
|
|
|
|
// boolean deviceMatch = deviceMatchedMap.getOrDefault(device.getId(), false);
|
|
|
|
|
// if (deviceMatch) {
|
|
|
|
|
// return true;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 检查设备下的参数是否匹配
|
|
|
|
|
// List<DeviceContactModelDO> deviceParams = paramsByDeviceId.getOrDefault(device.getId(), new ArrayList<>());
|
|
|
|
|
// boolean hasMatchingParam = deviceParams.stream()
|
|
|
|
|
// .anyMatch(param -> isParameterMatch(param, lowerKeyword));
|
|
|
|
|
// if (hasMatchingParam) {
|
|
|
|
|
// return true;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * 检查设备下是否有匹配的参数
|
|
|
|
|
// */
|
|
|
|
|
// private boolean checkIfDeviceHasMatchingParam(DeviceDO device,
|
|
|
|
|
// Map<Long, List<DeviceContactModelDO>> paramsByDeviceId,
|
|
|
|
|
// String lowerKeyword) {
|
|
|
|
|
//
|
|
|
|
|
// List<DeviceContactModelDO> deviceParams = paramsByDeviceId.getOrDefault(device.getId(), new ArrayList<>());
|
|
|
|
|
// return deviceParams.stream()
|
|
|
|
|
// .anyMatch(param -> isParameterMatch(param, lowerKeyword));
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
lineNode.setEquipments(equipmentNodes);
|
|
|
|
|
return lineNode;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断参数是否匹配关键词
|
|
|
|
|
@ -503,33 +616,10 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (param.getAttributeName() != null && param.getAttributeName().toLowerCase().contains(lowerKeyword)) ||
|
|
|
|
|
(param.getAttributeCode() != null && param.getAttributeCode().toLowerCase().contains(lowerKeyword));
|
|
|
|
|
return (param.getAttributeName() != null && param.getAttributeName().toLowerCase().contains(lowerKeyword));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构建设备节点
|
|
|
|
|
*/
|
|
|
|
|
private LineAnalysisTreeDTO.EquipmentNode buildEquipmentNode(DeviceDO device,
|
|
|
|
|
Map<Long, List<DeviceContactModelDO>> paramsByDeviceId) {
|
|
|
|
|
LineAnalysisTreeDTO.EquipmentNode equipmentNode = LineAnalysisTreeDTO.EquipmentNode.builder()
|
|
|
|
|
.id(device.getId())
|
|
|
|
|
.name(device.getDeviceName())
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
// 获取设备参数
|
|
|
|
|
List<DeviceContactModelDO> deviceParams =
|
|
|
|
|
paramsByDeviceId.getOrDefault(device.getId(), new ArrayList<>());
|
|
|
|
|
|
|
|
|
|
// 构建参数节点
|
|
|
|
|
List<LineAnalysisTreeDTO.ParameterNode> parameterNodes = deviceParams.stream()
|
|
|
|
|
.map(this::buildParameterNode)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
equipmentNode.setParameters(parameterNodes);
|
|
|
|
|
return equipmentNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构建参数节点
|
|
|
|
|
@ -549,7 +639,7 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
|
|
|
|
|
|
|
private List<DeviceContactModelDO> getAllParameters(List<DeviceDO> devices) {
|
|
|
|
|
|
|
|
|
|
if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isEmpty(devices)) {
|
|
|
|
|
if (devices.isEmpty()) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|