java
List<CurveTimeAndValueDomain> curves = new ArrayList<>();
for (int i = 0; i < columnNames.size(); i++){
if (columnNames.get(i).equals(PlantConstant.TENDOWNFX) || columnNames.get(i).equals(PlantConstant.TENDOWNQP)) {
//10千伏以下 数据 进行缓慢处理
curveTimeAndValueDomains = gently(belongDay, columnNames.get(i));
}else{
//一个一个场站加
curveTimeAndValueDomains = curveManagerCommonMapper.selectSinglePlantPowerDay2(belongDay, columnNames.get(i), belongDay.substring(0, 4));
}
if(!Objects.isNull(curveTimeAndValueDomains)){
for (CurveTimeAndValueDomain curve:curveTimeAndValueDomains){
curves.add(curve);
}
}
}
第一步:将多个List 相加
java
for (CurveTimeAndValueDomain curve:curveTimeAndValueDomains){
curves.add(curve);
}
第二步:将加起来的List 中:time 相同的value值相加
java
//将曲线中 time 相同的 value 相加 并 去重
List<CurveTimeAndValueDomain> newCurve = merge(curves);
public static List<CurveTimeAndValueDomain> merge(List<CurveTimeAndValueDomain> curves){
Map<String,CurveTimeAndValueDomain> map = new HashMap<>();
curves.stream().forEach(curve ->{
CurveTimeAndValueDomain last = map.get(curve.getTime());
if (null != last){
if(!Objects.isNull(last.getValue())){
curve.setValue(curve.getValue().add(last.getValue()));
}
}
map.put(curve.getTime(),curve);
});
return map.values().stream().collect(Collectors.toList());
}
第三步:将新的到的newCurve List 排序
java
//按照time 进行排序
newCurve.sort((curve1,curve2)->{
Integer time1 = Integer.parseInt(curve1.getTime().replace(":",""));
Integer time2 = Integer.parseInt(curve2.getTime().replace(":",""));
return time1.compareTo(time2);
});