From 27f25d24042b2903b79f458ba01c6d8e0ac3f6f6 Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Fri, 17 Apr 2026 08:56:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PreDetectionController.java | 4 +- .../SocketFreqConverterDevService.java | 18 +++++--- .../handler/SocketFreqConverterService.java | 13 ++++-- .../service/PreDetectionService.java | 2 +- .../service/impl/PreDetectionServiceImpl.java | 6 +-- .../util/socket/FormalTestManager.java | 4 +- .../controller/FreqConverterController.java | 10 ++++ .../pojo/po/PqFreqConverterTestRes.java | 4 +- .../pojo/vo/TolerantPointVO.java | 4 +- .../service/IFreqConverterService.java | 8 ++++ .../impl/FreqConverterServiceImpl.java | 46 ++++++++++++++++++- .../PqFreqConverterConfigServiceImpl.java | 2 +- 12 files changed, 94 insertions(+), 27 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/detection/controller/PreDetectionController.java b/detection/src/main/java/com/njcn/gather/detection/controller/PreDetectionController.java index 4cc915c3..de699ac7 100644 --- a/detection/src/main/java/com/njcn/gather/detection/controller/PreDetectionController.java +++ b/detection/src/main/java/com/njcn/gather/detection/controller/PreDetectionController.java @@ -181,11 +181,11 @@ public class PreDetectionController extends BaseController { @OperateInfo(info = LogEnum.SYSTEM_COMMON) @GetMapping("/startFreqConverter") @ApiOperation("开启变频器测试") - public HttpResult startFreqConverter(@RequestParam("userId") String userId, @RequestParam("converterId") String converterId, @RequestParam("monitorId") String monitorId) { + public HttpResult startFreqConverter(@RequestParam("userId") String userId, @RequestParam("converterId") String converterId, @RequestParam("monitorId") String monitorId, @RequestParam("reset") Boolean reset) { String methodDescribe = getMethodDescribe("startFreqConverter"); LogUtil.njcnDebug(log, "{}", methodDescribe); - preDetectionService.startFreqConverter(userId, converterId, monitorId); + preDetectionService.startFreqConverter(userId, converterId, monitorId,reset); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketFreqConverterDevService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketFreqConverterDevService.java index c2ee530e..889274b7 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketFreqConverterDevService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketFreqConverterDevService.java @@ -74,13 +74,15 @@ public class SocketFreqConverterDevService { }); } - private void init(String userId, String converterId, String monitorId) { + private void init(String userId, String converterId, String monitorId, Boolean reset) { FormalTestManager.freqConverterDevStep = null; // FormalTestManager.stopFlag = false; FormalTestManager.isRemoveSocket = false; FormalTestManager.pendingDipTaskMap.clear(); - pqDipDataService.clearAllData(FormalTestManager.freqConverterTableSuffix); - pqFreqConverterTestResService.clearAllData(FormalTestManager.freqConverterTableSuffix); + if (reset) { + pqDipDataService.clearAllData(FormalTestManager.freqConverterTableSuffix); + pqFreqConverterTestResService.clearAllData(FormalTestManager.freqConverterTableSuffix); + } this.userId = userId; this.monitorId = monitorId; } @@ -88,8 +90,8 @@ public class SocketFreqConverterDevService { /** * 连接设备 */ - public void connectionDev(String userId, String devTag, String converterId, String monitorId) { - this.init(userId, converterId, monitorId); + public void connectionDev(String userId, String devTag, String converterId, String monitorId, Boolean reset) { + this.init(userId, converterId, monitorId, reset); String payload = buildSingleMonitorPayload(monitorId); if (StrUtil.isBlank(payload)) { @@ -298,7 +300,7 @@ public class SocketFreqConverterDevService { } List statusList = freqConverterService.getDipDurationStatusData(suffix, lastStatusData.getTimestamp(), pqDipData.getStartTime().plusNanos(pqDipData.getDurationMs() * 1000_000L)); - boolean originalTolerant = lastStatusData.getStatusWord1() != freqConverterConfig.getNoTolerant(); + Integer originalTolerant = (lastStatusData.getStatusWord1() != freqConverterConfig.getNoTolerant()) ? 1 : 0; LocalDateTime targetEndTime = pqDipData.getStartTime() .plusNanos(pqDipData.getDurationMs() * 1000_000L) .plusNanos(freqConverterConfig.getDt() * 1000_000L); @@ -307,7 +309,9 @@ public class SocketFreqConverterDevService { FreqConverterStatus status = statusList.get(statusList.size() - 1); PqFreqConverterTestRes testRes = new PqFreqConverterTestRes(); testRes.setDipId(pqDipData.getId()); - testRes.setTolerant(originalTolerant ? status.getStatusWord1() != freqConverterConfig.getNoTolerant() : false); + testRes.setTolerant(originalTolerant == 1 ? + (status.getStatusWord1() != freqConverterConfig.getNoTolerant() ? 1 : 0) + : 0); testRes.setStartTime(lastStatusData.getTimestamp()); FormalTestManager.pendingDipTaskMap.put(pqDipData.getId(), new FormalTestManager.PendingDipTask( diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketFreqConverterService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketFreqConverterService.java index 3daa2b9a..dc356f89 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketFreqConverterService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketFreqConverterService.java @@ -104,12 +104,14 @@ public class SocketFreqConverterService { } } - public void init(String userId, String converterId, String monitorId) { + public void init(String userId, String converterId, String monitorId, Boolean reset) { this.userId = userId; FormalTestManager.freqConverterStep = null; FormalTestManager.currentFreqConverterId = converterId; Integer suffix = pqFreqConverterConfigService.getSuffix(converterId); - freqConverterService.clearAllData(suffix); + if (reset) { + freqConverterService.clearAllData(suffix); + } FormalTestManager.freqConverterTableSuffix = suffix; FormalTestManager.isRemoveSocket = false; FormalTestManager.pendingDipTaskMap.clear(); @@ -120,8 +122,8 @@ public class SocketFreqConverterService { /** * 连接变频器 */ - public void connectionFreqConverter(String userId, String freqConverterTag, String converterId, String monitorId) { - this.init(userId, converterId, monitorId); + public void connectionFreqConverter(String userId, String freqConverterTag, String converterId, String monitorId, Boolean reset) { + this.init(userId, converterId, monitorId, reset); SocketMsg> socketMsg = new SocketMsg<>(); socketMsg.setOperateCode(SourceOperateCodeEnum.CMD_INIT_SERIAL.getValue()); @@ -269,7 +271,8 @@ public class SocketFreqConverterService { testRes.setEndTime(freqConverterStatus.getTimestamp().isAfter(task.getTargetEndTime()) ? freqConverterStatus.getTimestamp() : task.getTargetEndTime()); - testRes.setTolerant(testRes.getTolerant() && (freqConverterStatus.getStatusWord1() != freqConverterConfig.getNoTolerant())); + + testRes.setTolerant(testRes.getTolerant() & (freqConverterStatus.getStatusWord1() != freqConverterConfig.getNoTolerant() ? 1 : 0)); testResList.add(testRes); if (freqConverterStatus.getTimestamp().isAfter(task.getTargetEndTime())) { diff --git a/detection/src/main/java/com/njcn/gather/detection/service/PreDetectionService.java b/detection/src/main/java/com/njcn/gather/detection/service/PreDetectionService.java index 1cd5f6ba..e4b4e0fa 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/PreDetectionService.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/PreDetectionService.java @@ -65,7 +65,7 @@ public interface PreDetectionService { void startCoefficient(); - void startFreqConverter(String userId, String converterId, String monitorId); + void startFreqConverter(String userId, String converterId, String monitorId,Boolean reset); void stopFreqConverter(String converterId, String monitorId); } diff --git a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java index ee1d31f0..c48c245b 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java @@ -394,7 +394,7 @@ public class PreDetectionServiceImpl implements PreDetectionService { } @Override - public void startFreqConverter(String userId, String converterId, String monitorId) { + public void startFreqConverter(String userId, String converterId, String monitorId, Boolean reset) { String freqConverterTag = userId + CnSocketUtil.FREQ_CONVERTER_TAG; String devTag = userId + CnSocketUtil.DEV_TAG; // socketFreqConverterService.init(userId, converterId, monitorId); @@ -406,8 +406,8 @@ public class PreDetectionServiceImpl implements PreDetectionService { while (true) { if (SocketManager.isChannelActive(freqConverterTag) && SocketManager.isChannelActive(devTag)) { // if (SocketManager.isChannelActive(devTag)) { - socketFreqConverterService.connectionFreqConverter(userId, freqConverterTag, converterId, monitorId); - socketFreqConverterDevService.connectionDev(userId, devTag, converterId, monitorId); + socketFreqConverterService.connectionFreqConverter(userId, freqConverterTag, converterId, monitorId, reset); + socketFreqConverterDevService.connectionDev(userId, devTag, converterId, monitorId,reset); break; } diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/FormalTestManager.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/FormalTestManager.java index 8499a6de..3595d324 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/FormalTestManager.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/FormalTestManager.java @@ -231,9 +231,9 @@ public class FormalTestManager { private PqDipData pqDipData; private LocalDateTime targetEndTime; - private Boolean originalTolerant; + private Integer originalTolerant; - public PendingDipTask(PqDipData pqDipData, LocalDateTime targetEndTime, Boolean originalTolerant) { + public PendingDipTask(PqDipData pqDipData, LocalDateTime targetEndTime, Integer originalTolerant) { this.pqDipData = pqDipData; this.targetEndTime = targetEndTime; this.originalTolerant = originalTolerant; diff --git a/detection/src/main/java/com/njcn/gather/freqConverter/controller/FreqConverterController.java b/detection/src/main/java/com/njcn/gather/freqConverter/controller/FreqConverterController.java index d7f8ec9f..ec3284da 100644 --- a/detection/src/main/java/com/njcn/gather/freqConverter/controller/FreqConverterController.java +++ b/detection/src/main/java/com/njcn/gather/freqConverter/controller/FreqConverterController.java @@ -103,4 +103,14 @@ public class FreqConverterController extends BaseController { List tolerantPoints = freqConverterService.getDipPoints(converterId); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, tolerantPoints, methodDescribe); } + + @GetMapping("/scurve") + @ApiOperation("获取绘制特性曲线的point点") + @ApiImplicitParam(name = "converterId", value = "变频器ID", required = true) + public HttpResult> getScurvePoints(@RequestParam("converterId") String converterId) { + String methodDescribe = getMethodDescribe("getScurvePoints"); + LogUtil.njcnDebug(log, "{},查询ID数据为:{}", methodDescribe, converterId); + List tolerantPoints = freqConverterService.getFeaturesScurvePoints(converterId); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, tolerantPoints, methodDescribe); + } } diff --git a/detection/src/main/java/com/njcn/gather/freqConverter/pojo/po/PqFreqConverterTestRes.java b/detection/src/main/java/com/njcn/gather/freqConverter/pojo/po/PqFreqConverterTestRes.java index 5e54927f..a0813b29 100644 --- a/detection/src/main/java/com/njcn/gather/freqConverter/pojo/po/PqFreqConverterTestRes.java +++ b/detection/src/main/java/com/njcn/gather/freqConverter/pojo/po/PqFreqConverterTestRes.java @@ -23,9 +23,9 @@ public class PqFreqConverterTestRes { private String dipId; /** - * 0为不耐受,1为耐受 + * 0为不耐受,1为耐受,2为特性曲线点 */ - private Boolean tolerant; + private Integer tolerant; /** * 该暂降时期对应变频器的起始时间戳 diff --git a/detection/src/main/java/com/njcn/gather/freqConverter/pojo/vo/TolerantPointVO.java b/detection/src/main/java/com/njcn/gather/freqConverter/pojo/vo/TolerantPointVO.java index 2b8efa50..8fb6dfd1 100644 --- a/detection/src/main/java/com/njcn/gather/freqConverter/pojo/vo/TolerantPointVO.java +++ b/detection/src/main/java/com/njcn/gather/freqConverter/pojo/vo/TolerantPointVO.java @@ -19,7 +19,7 @@ public class TolerantPointVO { private Double residualVoltage; /** - * 是否耐受 + * 是否耐受。0-否,1-是,2-表示特性曲线点 */ - private boolean tolerant; + private Integer tolerant; } diff --git a/detection/src/main/java/com/njcn/gather/freqConverter/service/IFreqConverterService.java b/detection/src/main/java/com/njcn/gather/freqConverter/service/IFreqConverterService.java index ecb136df..c9dc7cd8 100644 --- a/detection/src/main/java/com/njcn/gather/freqConverter/service/IFreqConverterService.java +++ b/detection/src/main/java/com/njcn/gather/freqConverter/service/IFreqConverterService.java @@ -51,4 +51,12 @@ public interface IFreqConverterService extends IService { List getDipDurationStatusData(Integer suffix, LocalDateTime startTime, LocalDateTime endTime); FreqConverterStatus getLastStatusData(Integer suffix, LocalDateTime startTime); + + /** + * 获取变频器特性曲线点 + * + * @param converterId 变频器ID + * @return + */ + List getFeaturesScurvePoints(String converterId); } diff --git a/detection/src/main/java/com/njcn/gather/freqConverter/service/impl/FreqConverterServiceImpl.java b/detection/src/main/java/com/njcn/gather/freqConverter/service/impl/FreqConverterServiceImpl.java index d879abdb..57ea9f4d 100644 --- a/detection/src/main/java/com/njcn/gather/freqConverter/service/impl/FreqConverterServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/freqConverter/service/impl/FreqConverterServiceImpl.java @@ -18,7 +18,11 @@ 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.stream.Collectors; /** @@ -78,15 +82,18 @@ public class FreqConverterServiceImpl extends ServiceImpl pqFreqConverterTestResList = pqFreqConverterTestResService.list(); + DynamicTableNameHandler.remove(); List result = pqFreqConverterTestResList.stream().map(item -> { + DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_DIP_DATA_TB_PREFIX + suffix); PqDipData pqDipData = dipDataService.getById(item.getDipId()); + DynamicTableNameHandler.remove(); TolerantPointVO tolerantPointVO = new TolerantPointVO(); tolerantPointVO.setDurationMs(pqDipData.getDurationMs()); tolerantPointVO.setResidualVoltage(pqDipData.getResidualVoltage()); tolerantPointVO.setTolerant(item.getTolerant()); return tolerantPointVO; - }).collect(Collectors.toList()); - DynamicTableNameHandler.remove(); + }).sorted(Comparator.comparingInt(TolerantPointVO::getDurationMs)).collect(Collectors.toList()); + return result; } @@ -112,4 +119,39 @@ public class FreqConverterServiceImpl extends ServiceImpl getFeaturesScurvePoints(String converterId) { + List dipPoints = this.getDipPoints(converterId); + if (dipPoints == null || dipPoints.isEmpty()) { + return new ArrayList<>(); + } + + Map> durationPointMap = dipPoints.stream() + .collect(Collectors.groupingBy(TolerantPointVO::getDurationMs)); + + List result = new ArrayList<>(); + durationPointMap.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .forEach(entry -> { + List sameDurationPoints = entry.getValue().stream() + .sorted(Comparator.comparing(TolerantPointVO::getResidualVoltage, Comparator.reverseOrder())) + .collect(Collectors.toList()); + + for (int index = 0; index < sameDurationPoints.size() - 1; index++) { + TolerantPointVO currentPoint = sameDurationPoints.get(index); + TolerantPointVO nextPoint = sameDurationPoints.get(index + 1); + if (!Objects.equals(currentPoint.getTolerant(), nextPoint.getTolerant())) { + TolerantPointVO featurePoint = new TolerantPointVO(); + featurePoint.setDurationMs(entry.getKey()); + featurePoint.setResidualVoltage((currentPoint.getResidualVoltage() + nextPoint.getResidualVoltage()) / 2D); + featurePoint.setTolerant(2); + result.add(featurePoint); + break; + } + } + }); + + return result; + } } diff --git a/detection/src/main/java/com/njcn/gather/freqConverter/service/impl/PqFreqConverterConfigServiceImpl.java b/detection/src/main/java/com/njcn/gather/freqConverter/service/impl/PqFreqConverterConfigServiceImpl.java index f3a70b51..ce34e743 100644 --- a/detection/src/main/java/com/njcn/gather/freqConverter/service/impl/PqFreqConverterConfigServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/freqConverter/service/impl/PqFreqConverterConfigServiceImpl.java @@ -32,7 +32,7 @@ public class PqFreqConverterConfigServiceImpl extends ServiceImpl