代码调整
This commit is contained in:
@@ -154,9 +154,9 @@ public class LineIntegrityDataServiceImpl extends ServiceImpl<LineIntegrityDataM
|
|||||||
}
|
}
|
||||||
|
|
||||||
//处理变电站
|
//处理变电站
|
||||||
dealChildrenData(subList, lineList, true);
|
dealChildrenData(subList, lineList, true,3);
|
||||||
//处理供电公司
|
//处理供电公司
|
||||||
dealChildrenData(gdList, subList, false);
|
dealChildrenData(gdList, subList, false,2);
|
||||||
|
|
||||||
//double areaDataIntegrity = DataStatisticsUtil.getAreaDataIntegrity(percentageOfCompleteDatas);
|
//double areaDataIntegrity = DataStatisticsUtil.getAreaDataIntegrity(percentageOfCompleteDatas);
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ public class LineIntegrityDataServiceImpl extends ServiceImpl<LineIntegrityDataM
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 数据封装
|
// 数据封装
|
||||||
Double temValue = gdList.stream().filter(item -> item.getIntegrityData() != 3.14159).mapToDouble(LineIntegrityDataVO::getIntegrityData).average().orElse(3.14159);
|
Double temValue = lineList.stream().filter(item -> item.getIntegrityData() != 3.14159).mapToDouble(LineIntegrityDataVO::getIntegrityData).average().orElse(3.14159);
|
||||||
LineIntegrityDataVO temp = lineList.stream().filter(t -> t.getAlgoDescribe() != null).min(Comparator.comparing(LineIntegrityDataVO::getAlgoDescribe)).orElse(new LineIntegrityDataVO());
|
LineIntegrityDataVO temp = lineList.stream().filter(t -> t.getAlgoDescribe() != null).min(Comparator.comparing(LineIntegrityDataVO::getAlgoDescribe)).orElse(new LineIntegrityDataVO());
|
||||||
lineIntegrityDataVO.setAlgoDescribe(temp.getAlgoDescribe());
|
lineIntegrityDataVO.setAlgoDescribe(temp.getAlgoDescribe());
|
||||||
lineIntegrityDataVO.setId(generalDeviceDTO.getIndex());
|
lineIntegrityDataVO.setId(generalDeviceDTO.getIndex());
|
||||||
@@ -424,6 +424,13 @@ public class LineIntegrityDataServiceImpl extends ServiceImpl<LineIntegrityDataM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理变电站
|
||||||
|
*
|
||||||
|
* @param targetData 父集合
|
||||||
|
* @param childrenData 子集合
|
||||||
|
* @param isLine 处理策略
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* 处理变电站
|
* 处理变电站
|
||||||
*
|
*
|
||||||
@@ -461,4 +468,58 @@ public class LineIntegrityDataServiceImpl extends ServiceImpl<LineIntegrityDataM
|
|||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理子集
|
||||||
|
*
|
||||||
|
* @param targetData 父集合
|
||||||
|
* @param childrenData 子集合
|
||||||
|
* @param isLine 处理策略
|
||||||
|
*/
|
||||||
|
private void dealChildrenData(List<LineIntegrityDataVO> targetData, List<LineIntegrityDataVO> childrenData, boolean isLine, int level) {
|
||||||
|
// 创建一个map集合,用于封装对象
|
||||||
|
Map<String, List<LineIntegrityDataVO>> groupLine;
|
||||||
|
if (isLine) {
|
||||||
|
// 通过stream流分组
|
||||||
|
groupLine = childrenData.stream().collect(Collectors.groupingBy(lineAdministrationTree -> {
|
||||||
|
// 获取父id字符串,通过 逗号 分割 成一个数组
|
||||||
|
String[] pid = lineAdministrationTree.getPids().split(",");
|
||||||
|
// 判断集合索引为3的元素
|
||||||
|
return pid[LineBaseEnum.SUB_LEVEL.getCode()];
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
groupLine = childrenData.stream().collect(Collectors.groupingBy(LineIntegrityDataVO::getPid));
|
||||||
|
}
|
||||||
|
targetData = targetData.stream().peek(lineAdministrationTree -> {
|
||||||
|
List<Double> data = new ArrayList<>();
|
||||||
|
List<LineIntegrityDataVO> childList = new ArrayList<>();
|
||||||
|
Set<String> pids = groupLine.keySet();
|
||||||
|
for (String pid : pids) {
|
||||||
|
if (lineAdministrationTree.getId().equals(pid)) {
|
||||||
|
List<LineIntegrityDataVO> lineIntegrityDataVOList = groupLine.get(pid);
|
||||||
|
lineAdministrationTree.setChildren(lineIntegrityDataVOList);
|
||||||
|
if (Objects.equals(level,2)){
|
||||||
|
for (LineIntegrityDataVO item : lineIntegrityDataVOList) {
|
||||||
|
childList.addAll(item.getChildren());
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(childList)){
|
||||||
|
data = childList.stream().map(LineIntegrityDataVO::getIntegrityData).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
} else if (Objects.equals(level,3)){
|
||||||
|
data = lineIntegrityDataVOList.stream().map(LineIntegrityDataVO::getIntegrityData).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
LineIntegrityDataVO temp = lineIntegrityDataVOList.stream().filter(t -> t.getAlgoDescribe() != null).min(Comparator.comparing(LineIntegrityDataVO::getAlgoDescribe)).orElse(new LineIntegrityDataVO());
|
||||||
|
lineAdministrationTree.setAlgoDescribe(temp.getAlgoDescribe());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//父级完整性匹配
|
||||||
|
if (CollectionUtil.isNotEmpty(data)){
|
||||||
|
double avg = data.stream().collect(Collectors.averagingDouble(x -> x));
|
||||||
|
lineAdministrationTree.setIntegrityData(DataStatisticsUtil.dataLimits(avg));
|
||||||
|
} else {
|
||||||
|
lineAdministrationTree.setIntegrityData(3.14159);
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user