2 Commits

Author SHA1 Message Date
caozehui
503018a721 起点 2026-04-30 09:34:44 +08:00
caozehui
391fd0cf4f 最后状态清空 2026-04-23 15:37:40 +08:00
4 changed files with 26 additions and 9 deletions

View File

@@ -370,6 +370,7 @@ public class SocketFreqConverterDevService {
String freqConverterTag = currentUserId + CnSocketUtil.FREQ_CONVERTER_TAG;
// 避免过早把 freqConverterTableSuffix 等全局值清掉,造成变频器无法使用全局变量
if (!SocketManager.isChannelActive(freqConverterTag)) {
FormalTestManager.freqConverterStep = null;
FormalTestManager.clearFreqConverterRuntimeState();
}
}

View File

@@ -284,6 +284,7 @@ public class SocketFreqConverterService {
String devTag = currentUserId + CnSocketUtil.DEV_TAG;
// 避免过早把 freqConverterTableSuffix 等全局值清掉,造成设备无法使用全局变量
if (!SocketManager.isChannelActive(devTag)) {
FormalTestManager.freqConverterDevStep = null;
FormalTestManager.clearFreqConverterRuntimeState();
}
}

View File

@@ -230,8 +230,6 @@ public class FormalTestManager {
* 清理变频器耐受实验运行态数据
*/
public static void clearFreqConverterRuntimeState() {
freqConverterStep = null;
freqConverterDevStep = null;
currentFreqConverterId = null;
freqConverterTableSuffix = null;
pendingDipTaskMap.clear();

View File

@@ -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()))