起点
This commit is contained in:
@@ -18,11 +18,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -128,11 +124,32 @@ public class FreqConverterServiceImpl extends ServiceImpl<FreqConverterStatusMap
|
||||
}
|
||||
|
||||
Map<Integer, List<TolerantPointVO>> durationPointMap = dipPoints.stream()
|
||||
.collect(Collectors.groupingBy(TolerantPointVO::getDurationMs));
|
||||
.collect(Collectors.groupingBy(TolerantPointVO::getDurationMs, TreeMap::new, Collectors.toList()));
|
||||
if (durationPointMap.size() < 2) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<TolerantPointVO> result = new ArrayList<>();
|
||||
|
||||
TolerantPointVO firstPoint = new TolerantPointVO();
|
||||
|
||||
List<Integer> keyList = durationPointMap.keySet().stream().collect(Collectors.toList());
|
||||
Integer i1 = keyList.get(0);
|
||||
List<TolerantPointVO> tolerantPointVOS1 = durationPointMap.get(i1);
|
||||
Collections.sort(tolerantPointVOS1,Comparator.comparing(TolerantPointVO::getResidualVoltage));
|
||||
TolerantPointVO tolerantPointVO1 = tolerantPointVOS1.get(0);
|
||||
|
||||
Integer i2 = keyList.get(1);
|
||||
List<TolerantPointVO> tolerantPointVOS2 = durationPointMap.get(i2);
|
||||
Collections.sort(tolerantPointVOS2,Comparator.comparing(TolerantPointVO::getResidualVoltage));
|
||||
TolerantPointVO tolerantPointVO2 = tolerantPointVOS2.get(0);
|
||||
|
||||
firstPoint.setDurationMs((i1 + i2)/2);
|
||||
firstPoint.setResidualVoltage((tolerantPointVO1.getResidualVoltage() + tolerantPointVO2.getResidualVoltage()) / 2D);
|
||||
firstPoint.setTolerant(2);
|
||||
result.add(firstPoint);
|
||||
|
||||
durationPointMap.entrySet().stream()
|
||||
.sorted(Map.Entry.comparingByKey())
|
||||
.forEach(entry -> {
|
||||
List<TolerantPointVO> sameDurationPoints = entry.getValue().stream()
|
||||
.sorted(Comparator.comparing(TolerantPointVO::getResidualVoltage, Comparator.reverseOrder()))
|
||||
|
||||
Reference in New Issue
Block a user