Compare commits
18 Commits
99c7448544
...
hainan
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4afcec7fb9 | ||
|
|
a48dad40f6 | ||
|
|
c8217046c6 | ||
|
|
0a16a1fee5 | ||
|
|
391646d416 | ||
|
|
4f3f0833d5 | ||
|
|
924c2e8f45 | ||
|
|
8dca7bf537 | ||
|
|
7e6fb2d981 | ||
|
|
ec9a0ca236 | ||
|
|
7ab5b9a501 | ||
|
|
3959b96040 | ||
|
|
ae5370abdf | ||
|
|
1894cb07a2 | ||
|
|
08dff063c9 | ||
|
|
f640afb4ed | ||
|
|
503018a721 | ||
|
|
391fd0cf4f |
@@ -33,6 +33,8 @@ import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
||||
import com.njcn.gather.source.service.IPqSourceService;
|
||||
import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.SimAndDigNonHarmonicResult;
|
||||
@@ -76,6 +78,7 @@ public class SocketDevResponseService {
|
||||
private final SimAndDigHarmonicService adHarmonicService;
|
||||
private final IAdPlanService adPlanService;
|
||||
private final IDictDataService dictDataService;
|
||||
private final IPqSourceService pqSourceService;
|
||||
|
||||
/**
|
||||
* 存储的装置相序数据
|
||||
@@ -391,6 +394,8 @@ public class SocketDevResponseService {
|
||||
if (param.getTestItemList().get(2)) {
|
||||
//如果后续做正式检测
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||
issueParam.setSourceId(sourceInitialize.getSourceId());
|
||||
issueParam.setPlanId(param.getPlanId());
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
@@ -893,10 +898,9 @@ public class SocketDevResponseService {
|
||||
|
||||
//开始下源控制脚本
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||
issueParam.setSourceId(sourceInitialize.getSourceId());
|
||||
issueParam.setPlanId(param.getPlanId());
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
List<SourceIssue> sourceIssues;
|
||||
@@ -1162,8 +1166,9 @@ public class SocketDevResponseService {
|
||||
} else if (param.getTestItemList().get(2)) {
|
||||
// 后续做正式检测
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||
issueParam.setSourceId(sourceInitialize.getSourceId());
|
||||
issueParam.setPlanId(param.getPlanId());
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
|
||||
@@ -1816,8 +1821,9 @@ public class SocketDevResponseService {
|
||||
XiNumberManager.devParameterList.add(devParameterSmall);
|
||||
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||
issueParam.setSourceId(sourceInitialize.getSourceId());
|
||||
issueParam.setPlanId(param.getPlanId());
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
issueParam.setIsPhaseSequence(CommonEnum.COEFFICIENT_TEST.getValue());
|
||||
|
||||
@@ -275,6 +275,9 @@ public class SocketFreqConverterDevService {
|
||||
|
||||
if (DetectionCodeEnum.MAG.getCode().equalsIgnoreCase(sqlDataDTO.getDesc())) {
|
||||
residualVoltage = value;
|
||||
if (residualVoltage <= 6) {
|
||||
return;
|
||||
}
|
||||
} else if (DetectionCodeEnum.DUR.getCode().equalsIgnoreCase(sqlDataDTO.getDesc())) {
|
||||
durationMs = (int) Math.round(value * 1000);
|
||||
}
|
||||
@@ -308,30 +311,21 @@ public class SocketFreqConverterDevService {
|
||||
if (CollUtil.isNotEmpty(statusList)) {
|
||||
FreqConverterStatus status = statusList.get(statusList.size() - 1);
|
||||
PqFreqConverterTestRes testRes = new PqFreqConverterTestRes();
|
||||
testRes.setDipId(pqDipData.getId());
|
||||
testRes.setId(IdUtil.fastSimpleUUID());
|
||||
testRes.setTolerant(originalTolerant == 1 ?
|
||||
(status.getStatusWord1() == freqConverterConfig.getTolerant() ? 1 : 0)
|
||||
: 0);
|
||||
testRes.setStartTime(lastStatusData.getTimestamp());
|
||||
testRes.setDurationMs(pqDipData.getDurationMs());
|
||||
testRes.setResidualVoltage(pqDipData.getResidualVoltage());
|
||||
testRes.setTime(LocalDateTime.now());
|
||||
|
||||
FormalTestManager.pendingDipTaskMap.put(pqDipData.getId(), new FormalTestManager.PendingDipTask(
|
||||
FormalTestManager.pendingDipTaskMap.put(testRes.getId(), new FormalTestManager.PendingDipTask(
|
||||
pqDipData,
|
||||
targetEndTime,
|
||||
originalTolerant
|
||||
));
|
||||
testRes.setEndTime(status.getTimestamp());
|
||||
|
||||
// if (status.getTimestamp().isBefore(targetEndTime)) {
|
||||
// FormalTestManager.pendingDipTaskMap.put(pqDipData.getId(), new FormalTestManager.PendingDipTask(
|
||||
// pqDipData.getId(),
|
||||
// pqDipData.getStartTime(),
|
||||
// targetEndTime,
|
||||
// originalTolerant
|
||||
// ));
|
||||
// } else {
|
||||
// testRes.setEndTime(status.getTimestamp().isAfter(targetEndTime) ? targetEndTime : status.getTimestamp());
|
||||
// }
|
||||
pqFreqConverterTestResService.saveOrUpdateTestRes(suffix, Collections.singletonList(testRes));
|
||||
pqFreqConverterTestResService.saveTestRes(suffix, Collections.singletonList(testRes));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,6 +354,7 @@ public class SocketFreqConverterDevService {
|
||||
|
||||
/**
|
||||
* 如果设备已停止,则清除共享的运行时状态
|
||||
*
|
||||
* @param currentUserId 当前用户ID
|
||||
*/
|
||||
private void clearStateIfStopped(String currentUserId) {
|
||||
@@ -370,6 +365,7 @@ public class SocketFreqConverterDevService {
|
||||
String freqConverterTag = currentUserId + CnSocketUtil.FREQ_CONVERTER_TAG;
|
||||
// 避免过早把 freqConverterTableSuffix 等全局值清掉,造成变频器无法使用全局变量
|
||||
if (!SocketManager.isChannelActive(freqConverterTag)) {
|
||||
FormalTestManager.freqConverterStep = null;
|
||||
FormalTestManager.clearFreqConverterRuntimeState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.gather.detection.handler;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
@@ -28,6 +29,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -48,6 +50,10 @@ public class SocketFreqConverterService {
|
||||
private final IPqFreqConverterConfigService pqFreqConverterConfigService;
|
||||
private final IPqFreqConverterTestResService pqFreqConverterTestResService;
|
||||
private String userId;
|
||||
/**
|
||||
* 上一个暂降点耐受检测结果
|
||||
*/
|
||||
private TolerantPointVO lastTolerancePoint;
|
||||
private final FreqConverterConfig freqConverterConfig;
|
||||
|
||||
/**
|
||||
@@ -106,6 +112,7 @@ public class SocketFreqConverterService {
|
||||
}
|
||||
|
||||
public void init(String userId, String converterId, String monitorId, Boolean reset) {
|
||||
this.lastTolerancePoint = null;
|
||||
this.userId = userId;
|
||||
FormalTestManager.freqConverterStep = null;
|
||||
FormalTestManager.currentFreqConverterId = converterId;
|
||||
@@ -185,6 +192,7 @@ public class SocketFreqConverterService {
|
||||
updateCurrentTestStatus();
|
||||
clearStateIfStopped(currentUserId);
|
||||
this.userId = null;
|
||||
this.lastTolerancePoint = null;
|
||||
}
|
||||
|
||||
private void handleInitSerial(String converterChannelTag, FreqConverterRespDTO respDTO) {
|
||||
@@ -284,6 +292,7 @@ public class SocketFreqConverterService {
|
||||
String devTag = currentUserId + CnSocketUtil.DEV_TAG;
|
||||
// 避免过早把 freqConverterTableSuffix 等全局值清掉,造成设备无法使用全局变量
|
||||
if (!SocketManager.isChannelActive(devTag)) {
|
||||
FormalTestManager.freqConverterDevStep = null;
|
||||
FormalTestManager.clearFreqConverterRuntimeState();
|
||||
}
|
||||
}
|
||||
@@ -294,43 +303,131 @@ public class SocketFreqConverterService {
|
||||
}
|
||||
|
||||
Integer suffix = FormalTestManager.freqConverterTableSuffix;
|
||||
List<String> finishedDipIdList = new ArrayList<>();
|
||||
List<PqFreqConverterTestRes> testResList = new ArrayList<>();
|
||||
for (FormalTestManager.PendingDipTask task : FormalTestManager.pendingDipTaskMap.values()) {
|
||||
PqFreqConverterTestRes testRes = pqFreqConverterTestResService.getByDipId(suffix, task.getPqDipData().getId());
|
||||
if (Objects.isNull(testRes)) {
|
||||
finishedDipIdList.add(task.getPqDipData().getId());
|
||||
continue;
|
||||
}
|
||||
|
||||
testRes.setEndTime(freqConverterStatus.getTimestamp().isAfter(task.getTargetEndTime())
|
||||
? freqConverterStatus.getTimestamp()
|
||||
: task.getTargetEndTime());
|
||||
|
||||
testRes.setTolerant(testRes.getTolerant() & (freqConverterStatus.getStatusWord1() == freqConverterConfig.getTolerant() ? 1 : 0));
|
||||
testResList.add(testRes);
|
||||
List<String> finishedTestResIdList = new ArrayList<>();
|
||||
List<PqFreqConverterTestRes> saveTestResList = new ArrayList<>();
|
||||
List<PqFreqConverterTestRes> updateTestResList = new ArrayList<>();
|
||||
|
||||
FormalTestManager.pendingDipTaskMap.forEach((key, task) -> {
|
||||
if (freqConverterStatus.getTimestamp().isAfter(task.getTargetEndTime())) {
|
||||
finishedDipIdList.add(task.getPqDipData().getId());
|
||||
PqFreqConverterTestRes testRes = new PqFreqConverterTestRes();
|
||||
testRes.setId(key);
|
||||
testRes.setDurationMs(task.getPqDipData().getDurationMs());
|
||||
testRes.setResidualVoltage(task.getPqDipData().getResidualVoltage());
|
||||
testRes.setTolerant(task.getOriginalTolerant() & (freqConverterStatus.getStatusWord1() == freqConverterConfig.getTolerant() ? 1 : 0));
|
||||
|
||||
finishedTestResIdList.add(key);
|
||||
|
||||
SocketDataMsg socketDataMsg = new SocketDataMsg();
|
||||
socketDataMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL + SocketFreqConverterDevService.DIP_DATA_SUFFIX);
|
||||
|
||||
TolerantPointVO tolerantPointVO = new TolerantPointVO();
|
||||
tolerantPointVO.setResidualVoltage(task.getPqDipData().getResidualVoltage());
|
||||
tolerantPointVO.setDurationMs(task.getPqDipData().getDurationMs());
|
||||
tolerantPointVO.setTolerant(testRes.getTolerant());
|
||||
socketDataMsg.setData(JSON.toJSONString(tolerantPointVO));
|
||||
TolerantPointVO newTolerantPointVO = new TolerantPointVO();
|
||||
newTolerantPointVO.setResidualVoltage(task.getPqDipData().getResidualVoltage());
|
||||
newTolerantPointVO.setDurationMs(task.getPqDipData().getDurationMs());
|
||||
newTolerantPointVO.setTolerant(testRes.getTolerant());
|
||||
socketDataMsg.setData(JSON.toJSONString(newTolerantPointVO));
|
||||
WebServiceManager.sendMsg(this.userId, JSON.toJSONString(socketDataMsg));
|
||||
|
||||
if (testRes.getTolerant() == 0) {
|
||||
if (ObjectUtil.isNotNull(this.lastTolerancePoint) && this.lastTolerancePoint.getTolerant() == 1) {
|
||||
TolerantPointVO featurePointVO = new TolerantPointVO();
|
||||
|
||||
featurePointVO.setResidualVoltage(Math.round((task.getPqDipData().getResidualVoltage() + this.lastTolerancePoint.getResidualVoltage()) / 2D * 100) / 100D);
|
||||
featurePointVO.setDurationMs(Integer.valueOf((task.getPqDipData().getDurationMs().intValue() + this.lastTolerancePoint.getDurationMs().intValue()) / 2));
|
||||
featurePointVO.setTolerant(2);
|
||||
socketDataMsg.setData(JSON.toJSONString(featurePointVO));
|
||||
WebServiceManager.sendMsg(this.userId, JSON.toJSONString(socketDataMsg));
|
||||
|
||||
PqFreqConverterTestRes featureTestRes = new PqFreqConverterTestRes();
|
||||
featureTestRes.setId(IdUtil.fastSimpleUUID());
|
||||
featureTestRes.setDurationMs(featurePointVO.getDurationMs());
|
||||
featureTestRes.setResidualVoltage(featurePointVO.getResidualVoltage());
|
||||
featureTestRes.setTolerant(2);
|
||||
featureTestRes.setTime(LocalDateTime.now());
|
||||
saveTestResList.add(featureTestRes);
|
||||
}
|
||||
|
||||
// 从数据库按照列查询距离该暂降点最近的一个暂降点
|
||||
if (freqConverterConfig.getDirection() == 0) {
|
||||
PqFreqConverterTestRes lastByDuration = pqFreqConverterTestResService.getLastByDuration(suffix, key, task.getPqDipData().getDurationMs());
|
||||
if (ObjectUtil.isNotNull(lastByDuration) && lastByDuration.getTolerant() == 1) {
|
||||
TolerantPointVO featurePointVO = new TolerantPointVO();
|
||||
|
||||
featurePointVO.setResidualVoltage(Math.round((task.getPqDipData().getResidualVoltage() + lastByDuration.getResidualVoltage()) / 2D * 100) / 100D);
|
||||
featurePointVO.setDurationMs(Integer.valueOf((task.getPqDipData().getDurationMs().intValue() + lastByDuration.getDurationMs().intValue()) / 2));
|
||||
featurePointVO.setTolerant(2);
|
||||
socketDataMsg.setData(JSON.toJSONString(featurePointVO));
|
||||
WebServiceManager.sendMsg(this.userId, JSON.toJSONString(socketDataMsg));
|
||||
|
||||
PqFreqConverterTestRes featureTestRes = new PqFreqConverterTestRes();
|
||||
featureTestRes.setId(IdUtil.fastSimpleUUID());
|
||||
featureTestRes.setDurationMs(featurePointVO.getDurationMs());
|
||||
featureTestRes.setResidualVoltage(featurePointVO.getResidualVoltage());
|
||||
featureTestRes.setTolerant(2);
|
||||
featureTestRes.setTime(LocalDateTime.now());
|
||||
saveTestResList.add(featureTestRes);
|
||||
}
|
||||
}
|
||||
// 从数据库按照行查询距离该暂降点最近的一个暂降点
|
||||
if (freqConverterConfig.getDirection() == 1) {
|
||||
PqFreqConverterTestRes lastByResidualVoltage = pqFreqConverterTestResService.getLastByResidualVoltage(suffix, key, task.getPqDipData().getResidualVoltage());
|
||||
if (ObjectUtil.isNotNull(lastByResidualVoltage) && lastByResidualVoltage.getTolerant() == 1) {
|
||||
TolerantPointVO featurePointVO = new TolerantPointVO();
|
||||
|
||||
featurePointVO.setResidualVoltage(Math.round((task.getPqDipData().getResidualVoltage() + lastByResidualVoltage.getResidualVoltage()) / 2D * 100) / 100D);
|
||||
featurePointVO.setDurationMs(Integer.valueOf((task.getPqDipData().getDurationMs().intValue() + lastByResidualVoltage.getDurationMs().intValue()) / 2));
|
||||
featurePointVO.setTolerant(2);
|
||||
socketDataMsg.setData(JSON.toJSONString(featurePointVO));
|
||||
WebServiceManager.sendMsg(this.userId, JSON.toJSONString(socketDataMsg));
|
||||
|
||||
PqFreqConverterTestRes featureTestRes = new PqFreqConverterTestRes();
|
||||
featureTestRes.setId(IdUtil.fastSimpleUUID());
|
||||
featureTestRes.setDurationMs(featurePointVO.getDurationMs());
|
||||
featureTestRes.setResidualVoltage(featurePointVO.getResidualVoltage());
|
||||
featureTestRes.setTolerant(2);
|
||||
featureTestRes.setTime(LocalDateTime.now());
|
||||
saveTestResList.add(featureTestRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.lastTolerancePoint = newTolerantPointVO;
|
||||
updateTestResList.add(testRes);
|
||||
}
|
||||
});
|
||||
|
||||
if (!saveTestResList.isEmpty()) {
|
||||
pqFreqConverterTestResService.saveTestRes(suffix, saveTestResList);
|
||||
}
|
||||
if (!updateTestResList.isEmpty()) {
|
||||
pqFreqConverterTestResService.updateTestRes(suffix, updateTestResList);
|
||||
}
|
||||
|
||||
pqFreqConverterTestResService.saveOrUpdateTestRes(suffix, testResList);
|
||||
|
||||
for (String dipId : finishedDipIdList) {
|
||||
for (String dipId : finishedTestResIdList) {
|
||||
FormalTestManager.pendingDipTaskMap.remove(dipId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为新的一组测试脚本
|
||||
*
|
||||
* @param lastTolerancePoint 上一个暂降点
|
||||
* @param newTolerantPointVO 最新的暂降点
|
||||
* @return
|
||||
*/
|
||||
private boolean isNewGroup(TolerantPointVO lastTolerancePoint, TolerantPointVO newTolerantPointVO) {
|
||||
// 横向分组
|
||||
if (freqConverterConfig.getDirection() == 0) {
|
||||
return lastTolerancePoint.getDurationMs() - newTolerantPointVO.getDurationMs() >= 10;
|
||||
}
|
||||
// 纵向分租
|
||||
if (freqConverterConfig.getDirection() == 1) {
|
||||
return lastTolerancePoint.getResidualVoltage() - newTolerantPointVO.getResidualVoltage() <= -2;
|
||||
}
|
||||
|
||||
// if (Math.abs(lastTolerancePoint.getDurationMs() - newTolerantPointVO.getDurationMs()) >= 10 && Math.abs(lastTolerancePoint.getResidualVoltage() - newTolerantPointVO.getResidualVoltage()) >= 2) {
|
||||
// return true;
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -289,7 +289,8 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
}
|
||||
//组装源控制脚本
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||
issueParam.setSourceId(sourceInitialize.getSourceId());
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
issueParam.setType(1);
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.SIMULATE_TEST.getValue());
|
||||
|
||||
@@ -230,8 +230,6 @@ public class FormalTestManager {
|
||||
* 清理变频器耐受实验运行态数据
|
||||
*/
|
||||
public static void clearFreqConverterRuntimeState() {
|
||||
freqConverterStep = null;
|
||||
freqConverterDevStep = null;
|
||||
currentFreqConverterId = null;
|
||||
freqConverterTableSuffix = null;
|
||||
pendingDipTaskMap.clear();
|
||||
|
||||
@@ -15,4 +15,7 @@ public class FreqConverterConfig {
|
||||
private Long schedulePeriod;
|
||||
private Integer tolerant;
|
||||
private Integer dt;
|
||||
private Integer direction;
|
||||
private Integer allowErrorDuration;
|
||||
private Double allowErrorResidualVoltage;
|
||||
}
|
||||
|
||||
@@ -104,13 +104,13 @@ public class FreqConverterController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, tolerantPoints, methodDescribe);
|
||||
}
|
||||
|
||||
@GetMapping("/scurve")
|
||||
@ApiOperation("获取绘制特性曲线的point点")
|
||||
@ApiImplicitParam(name = "converterId", value = "变频器ID", required = true)
|
||||
public HttpResult<List<TolerantPointVO>> getScurvePoints(@RequestParam("converterId") String converterId) {
|
||||
String methodDescribe = getMethodDescribe("getScurvePoints");
|
||||
LogUtil.njcnDebug(log, "{},查询ID数据为:{}", methodDescribe, converterId);
|
||||
List<TolerantPointVO> tolerantPoints = freqConverterService.getFeaturesScurvePoints(converterId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, tolerantPoints, methodDescribe);
|
||||
}
|
||||
// @GetMapping("/scurve")
|
||||
// @ApiOperation("获取绘制特性曲线的point点")
|
||||
// @ApiImplicitParam(name = "converterId", value = "变频器ID", required = true)
|
||||
// public HttpResult<List<TolerantPointVO>> getScurvePoints(@RequestParam("converterId") String converterId) {
|
||||
// String methodDescribe = getMethodDescribe("getScurvePoints");
|
||||
// LogUtil.njcnDebug(log, "{},查询ID数据为:{}", methodDescribe, converterId);
|
||||
// List<TolerantPointVO> tolerantPoints = freqConverterService.getFeaturesScurvePoints(converterId);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, tolerantPoints, methodDescribe);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.gather.freqConverter.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@@ -18,9 +19,14 @@ public class PqFreqConverterTestRes {
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 装置暂降数据id
|
||||
* 残余电压,单位:%Ur
|
||||
*/
|
||||
private String dipId;
|
||||
private Double residualVoltage;
|
||||
|
||||
/**
|
||||
* 持续时间,单位:ms
|
||||
*/
|
||||
private Integer durationMs;
|
||||
|
||||
/**
|
||||
* 0为不耐受,1为耐受,2为特性曲线点
|
||||
@@ -28,12 +34,8 @@ public class PqFreqConverterTestRes {
|
||||
private Integer tolerant;
|
||||
|
||||
/**
|
||||
* 该暂降时期对应变频器的起始时间戳
|
||||
* 时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 该暂降时期对应变频器的结束时间戳
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8")
|
||||
private LocalDateTime time;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.njcn.gather.freqConverter.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-04-13
|
||||
@@ -22,4 +25,10 @@ public class TolerantPointVO {
|
||||
* 是否耐受。0-否,1-是,2-表示特性曲线点
|
||||
*/
|
||||
private Integer tolerant;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8")
|
||||
private LocalDateTime time;
|
||||
}
|
||||
|
||||
@@ -19,13 +19,22 @@ public interface IPqFreqConverterTestResService extends IService<PqFreqConverter
|
||||
void clearAllData(Integer suffix);
|
||||
|
||||
/**
|
||||
* 保存结果记录
|
||||
* 新增结果记录
|
||||
*
|
||||
* @param suffix 表后缀
|
||||
* @param suffix 表后缀
|
||||
* @param testResList 结果数据
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean saveOrUpdateTestRes(Integer suffix, List<PqFreqConverterTestRes> testResList);
|
||||
boolean saveTestRes(Integer suffix, List<PqFreqConverterTestRes> testResList);
|
||||
|
||||
/**
|
||||
* 更新结果记录
|
||||
*
|
||||
* @param suffix 表后缀
|
||||
* @param testResList 结果数据
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean updateTestRes(Integer suffix, List<PqFreqConverterTestRes> testResList);
|
||||
|
||||
/**
|
||||
* 查询结果记录
|
||||
@@ -35,11 +44,7 @@ public interface IPqFreqConverterTestResService extends IService<PqFreqConverter
|
||||
*/
|
||||
List<PqFreqConverterTestRes> listTestRes(Integer suffix);
|
||||
|
||||
/**
|
||||
* 根据DIPID查询结果
|
||||
* @param suffix
|
||||
* @param dipId
|
||||
* @return
|
||||
*/
|
||||
PqFreqConverterTestRes getByDipId(Integer suffix, String dipId);
|
||||
PqFreqConverterTestRes getLastByDuration(Integer suffix, String id, Integer durationMs);
|
||||
|
||||
PqFreqConverterTestRes getLastByResidualVoltage(Integer suffix, String id, Double residualVoltage);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
import com.njcn.gather.dip.pojo.po.PqDipData;
|
||||
import com.njcn.gather.dip.service.IPqDipDataService;
|
||||
import com.njcn.gather.freqConverter.mapper.FreqConverterStatusMapper;
|
||||
import com.njcn.gather.freqConverter.pojo.po.FreqConverterStatus;
|
||||
@@ -18,11 +17,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;
|
||||
|
||||
/**
|
||||
@@ -84,16 +79,15 @@ public class FreqConverterServiceImpl extends ServiceImpl<FreqConverterStatusMap
|
||||
List<PqFreqConverterTestRes> pqFreqConverterTestResList = pqFreqConverterTestResService.list();
|
||||
DynamicTableNameHandler.remove();
|
||||
List<TolerantPointVO> 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;
|
||||
}).sorted(Comparator.comparingInt(TolerantPointVO::getDurationMs)).collect(Collectors.toList());
|
||||
|
||||
TolerantPointVO tolerantPointVO = new TolerantPointVO();
|
||||
tolerantPointVO.setDurationMs(item.getDurationMs());
|
||||
tolerantPointVO.setResidualVoltage(item.getResidualVoltage());
|
||||
tolerantPointVO.setTolerant(item.getTolerant());
|
||||
tolerantPointVO.setTime(item.getTime());
|
||||
return tolerantPointVO;
|
||||
})
|
||||
.sorted(Comparator.comparingInt(TolerantPointVO::getDurationMs))
|
||||
.sorted(Comparator.comparingDouble(TolerantPointVO::getResidualVoltage)).collect(Collectors.toList());
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -128,11 +122,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()))
|
||||
|
||||
@@ -81,10 +81,10 @@ public class PqFreqConverterConfigServiceImpl extends ServiceImpl<PqFreqConverte
|
||||
|
||||
tableSql = "CREATE TABLE `" + PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX + maxSuffix + "` (" +
|
||||
" `id` char(32) NOT NULL COMMENT '主键ID'," +
|
||||
" `dip_id` char(32) NOT NULL COMMENT '装置暂降数据id'," +
|
||||
" `start_time` datetime(3) DEFAULT NULL COMMENT '该暂降时期对应变频器的起始时间戳'," +
|
||||
" `end_time` datetime(3) DEFAULT NULL COMMENT '该暂降时期对应变频器的结束时间戳'," +
|
||||
" `tolerant` tinyInt(1) NOT NULL COMMENT '0为不耐受,1为耐受'," +
|
||||
" `residual_voltage` decimal(6,2) NOT NULL COMMENT '残余电压(%Ur)'," +
|
||||
" `duration_ms` int(11) NOT NULL COMMENT '持续时间(ms)'," +
|
||||
" `tolerant` tinyInt(1) NOT NULL COMMENT '0为不耐受,1为耐受,2为特征点'," +
|
||||
" `time` datetime(3) DEFAULT NULL COMMENT '时间',"+
|
||||
" PRIMARY KEY (`id`)" +
|
||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='变频器耐受实验结果';";
|
||||
tableGenMapper.genTable(tableSql);
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.njcn.gather.freqConverter.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
import com.njcn.gather.freqConverter.config.FreqConverterConfig;
|
||||
import com.njcn.gather.freqConverter.mapper.PqFreqConverterTestResMapper;
|
||||
import com.njcn.gather.freqConverter.pojo.po.PqFreqConverterTestRes;
|
||||
import com.njcn.gather.freqConverter.service.IPqFreqConverterTestResService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -16,51 +17,65 @@ import java.util.List;
|
||||
* @data 2026-04-14
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class PqFreqConverterTestResServiceImpl extends ServiceImpl<PqFreqConverterTestResMapper, PqFreqConverterTestRes> implements IPqFreqConverterTestResService {
|
||||
private final FreqConverterConfig freqConverterConfig;
|
||||
|
||||
@Override
|
||||
public void clearAllData(Integer suffix) {
|
||||
DynamicTableNameHandler.setTableName("pq_freq_converter_test_res_" + suffix);
|
||||
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX + suffix);
|
||||
this.remove(null);
|
||||
DynamicTableNameHandler.remove();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean saveOrUpdateTestRes(Integer suffix, List<PqFreqConverterTestRes> testResList) {
|
||||
DynamicTableNameHandler.setTableName("pq_freq_converter_test_res_" + suffix);
|
||||
|
||||
List<PqFreqConverterTestRes> existedTestResList = new ArrayList<>();
|
||||
List<PqFreqConverterTestRes> newTestResList = new ArrayList<>();
|
||||
for (PqFreqConverterTestRes testRes : testResList) {
|
||||
if (ObjectUtil.isNotNull(testRes.getId())) {
|
||||
existedTestResList.add(testRes);
|
||||
} else {
|
||||
newTestResList.add(testRes);
|
||||
}
|
||||
}
|
||||
if (existedTestResList.size() > 0) {
|
||||
this.updateBatchById(existedTestResList);
|
||||
}
|
||||
if (newTestResList.size() > 0) {
|
||||
this.saveBatch(newTestResList);
|
||||
}
|
||||
public boolean saveTestRes(Integer suffix, List<PqFreqConverterTestRes> testResList) {
|
||||
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX + suffix);
|
||||
this.saveBatch(testResList);
|
||||
DynamicTableNameHandler.remove();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateTestRes(Integer suffix, List<PqFreqConverterTestRes> testResList) {
|
||||
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX + suffix);
|
||||
this.updateBatchById(testResList);
|
||||
DynamicTableNameHandler.remove();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqFreqConverterTestRes> listTestRes(Integer suffix) {
|
||||
DynamicTableNameHandler.setTableName("pq_freq_converter_test_res_" + suffix);
|
||||
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX + suffix);
|
||||
List<PqFreqConverterTestRes> result = this.list();
|
||||
DynamicTableNameHandler.remove();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PqFreqConverterTestRes getByDipId(Integer suffix, String dipId) {
|
||||
DynamicTableNameHandler.setTableName("pq_freq_converter_test_res_" + suffix);
|
||||
PqFreqConverterTestRes one = this.lambdaQuery().eq(PqFreqConverterTestRes::getDipId, dipId).one();
|
||||
public PqFreqConverterTestRes getLastByDuration(Integer suffix, String id, Integer durationMs) {
|
||||
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX + suffix);
|
||||
LambdaQueryWrapper<PqFreqConverterTestRes> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.between(PqFreqConverterTestRes::getDurationMs, durationMs - freqConverterConfig.getAllowErrorDuration(), durationMs + freqConverterConfig.getAllowErrorDuration())
|
||||
.ne(PqFreqConverterTestRes::getId, id)
|
||||
.orderByAsc(PqFreqConverterTestRes::getResidualVoltage)
|
||||
.last("limit 1");
|
||||
PqFreqConverterTestRes result = this.getOne(queryWrapper);
|
||||
DynamicTableNameHandler.remove();
|
||||
return one;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PqFreqConverterTestRes getLastByResidualVoltage(Integer suffix, String id, Double residualVoltage) {
|
||||
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX + suffix);
|
||||
LambdaQueryWrapper<PqFreqConverterTestRes> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.between(PqFreqConverterTestRes::getResidualVoltage, residualVoltage - freqConverterConfig.getAllowErrorResidualVoltage(), residualVoltage + freqConverterConfig.getAllowErrorResidualVoltage())
|
||||
.ne(PqFreqConverterTestRes::getId, id)
|
||||
.orderByDesc(PqFreqConverterTestRes::getDurationMs)
|
||||
.last("limit 1");
|
||||
PqFreqConverterTestRes result = this.getOne(queryWrapper);
|
||||
DynamicTableNameHandler.remove();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.script.util.ScriptDtlsDesc;
|
||||
import com.njcn.gather.script.util.ThreePhaseUnbalance;
|
||||
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
||||
import com.njcn.gather.source.service.IPqSourceService;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||
@@ -68,13 +70,13 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
private final static String INHARM_I = "InHarm_I";
|
||||
private final static String DIP = "Dip";
|
||||
private final static String FLICKER = "Flicker";
|
||||
// @Value("${Dip.fPreTime}")
|
||||
// @Value("${Dip.fPreTime}")
|
||||
// private Double fPreTime;
|
||||
@Value("${Dip.fRampIn}")
|
||||
private Double fRampIn;
|
||||
@Value("${Dip.fRampOut}")
|
||||
private Double fRampOut;
|
||||
// @Value("${Dip.fAfterTime}")
|
||||
// @Value("${Dip.fAfterTime}")
|
||||
// private Double fAfterTime;
|
||||
@Value("${Flicker.waveFluType}")
|
||||
private String waveFluType;
|
||||
@@ -91,6 +93,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
private final IDevTypeService devTypeService;
|
||||
private final IDictTreeService dictTreeService;
|
||||
private final AdPlanMapper adPlanMapper;
|
||||
private final IPqSourceService pqSourceService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@@ -781,7 +784,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
@Override
|
||||
public Set<String> getScriptToIcdCheckInfo(PreDetectionParam param) {
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||
issueParam.setSourceId(sourceInitialize.getSourceId());
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
||||
@@ -974,7 +978,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
for (int i = 0; i < pqScriptDtls.size(); i++) {
|
||||
PqScriptDtls scriptDtls = pqScriptDtls.get(i);
|
||||
// 注意此处scriptDtls.getValue() < 1.0,考虑到有些已经投入运行的地方,可能没有改库,避免不必要的异常
|
||||
if(scriptDtls.getValueType().equalsIgnoreCase("CUR") && scriptDtls.getValue() < 1.0){
|
||||
if (scriptDtls.getValueType().equalsIgnoreCase("CUR") && scriptDtls.getValue() < 1.0) {
|
||||
scriptDtls.setValue(devCurr * scriptDtls.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ spring:
|
||||
# url: jdbc:mysql://192.168.1.24:13306/pqs91002?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||
# username: root
|
||||
# password: njcnpqs
|
||||
url: jdbc:mysql://192.168.1.24:13306/pqs9100?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||
url: jdbc:mysql://192.168.1.24:13306/pqs9100_hn?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||
username: root
|
||||
password: njcnpqs
|
||||
#初始化建立物理连接的个数、最小、最大连接数
|
||||
@@ -130,4 +130,7 @@ activate:
|
||||
freq-converter:
|
||||
schedule-period: 200 #定时器运行间隔
|
||||
tolerant: 1 #耐受状态
|
||||
dt: 200 #延迟时间ms
|
||||
dt: 200 #延迟时间ms
|
||||
direction: 0 #0为横向1为纵向
|
||||
allow-error-duration: 6 #暂态持续时间允许最大误差ms
|
||||
allow-error-residual-voltage: 2.0 #暂态幅值允许最多误差%
|
||||
|
||||
Reference in New Issue
Block a user