Compare commits
25 Commits
a658d6e81a
...
hainan
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4afcec7fb9 | ||
|
|
a48dad40f6 | ||
|
|
c8217046c6 | ||
|
|
0a16a1fee5 | ||
|
|
391646d416 | ||
|
|
4f3f0833d5 | ||
|
|
924c2e8f45 | ||
|
|
8dca7bf537 | ||
|
|
7e6fb2d981 | ||
|
|
ec9a0ca236 | ||
|
|
7ab5b9a501 | ||
|
|
3959b96040 | ||
|
|
ae5370abdf | ||
|
|
1894cb07a2 | ||
|
|
08dff063c9 | ||
|
|
f640afb4ed | ||
|
|
503018a721 | ||
|
|
391fd0cf4f | ||
|
|
99c7448544 | ||
|
|
83296d257c | ||
|
|
e020aa466e | ||
|
|
f20e2c9b32 | ||
|
|
e03c3e3607 | ||
|
|
27f25d2404 | ||
|
|
a77313171c |
@@ -181,11 +181,11 @@ public class PreDetectionController extends BaseController {
|
|||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
@GetMapping("/startFreqConverter")
|
@GetMapping("/startFreqConverter")
|
||||||
@ApiOperation("开启变频器测试")
|
@ApiOperation("开启变频器测试")
|
||||||
public HttpResult<String> startFreqConverter(@RequestParam("userId") String userId, @RequestParam("converterId") String converterId, @RequestParam("monitorId") String monitorId) {
|
public HttpResult<String> startFreqConverter(@RequestParam("userId") String userId, @RequestParam("converterId") String converterId, @RequestParam("monitorId") String monitorId, @RequestParam("reset") Boolean reset) {
|
||||||
String methodDescribe = getMethodDescribe("startFreqConverter");
|
String methodDescribe = getMethodDescribe("startFreqConverter");
|
||||||
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||||
|
|
||||||
preDetectionService.startFreqConverter(userId, converterId, monitorId);
|
preDetectionService.startFreqConverter(userId, converterId, monitorId,reset);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.pojo.po.SourceIssue;
|
||||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
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.param.StorageParam;
|
||||||
import com.njcn.gather.storage.pojo.po.SimAndDigHarmonicResult;
|
import com.njcn.gather.storage.pojo.po.SimAndDigHarmonicResult;
|
||||||
import com.njcn.gather.storage.pojo.po.SimAndDigNonHarmonicResult;
|
import com.njcn.gather.storage.pojo.po.SimAndDigNonHarmonicResult;
|
||||||
@@ -76,6 +78,7 @@ public class SocketDevResponseService {
|
|||||||
private final SimAndDigHarmonicService adHarmonicService;
|
private final SimAndDigHarmonicService adHarmonicService;
|
||||||
private final IAdPlanService adPlanService;
|
private final IAdPlanService adPlanService;
|
||||||
private final IDictDataService dictDataService;
|
private final IDictDataService dictDataService;
|
||||||
|
private final IPqSourceService pqSourceService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 存储的装置相序数据
|
* 存储的装置相序数据
|
||||||
@@ -391,6 +394,8 @@ public class SocketDevResponseService {
|
|||||||
if (param.getTestItemList().get(2)) {
|
if (param.getTestItemList().get(2)) {
|
||||||
//如果后续做正式检测
|
//如果后续做正式检测
|
||||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||||
|
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||||
|
issueParam.setSourceId(sourceInitialize.getSourceId());
|
||||||
issueParam.setPlanId(param.getPlanId());
|
issueParam.setPlanId(param.getPlanId());
|
||||||
issueParam.setSourceId(param.getSourceId());
|
issueParam.setSourceId(param.getSourceId());
|
||||||
issueParam.setDevIds(param.getDevIds());
|
issueParam.setDevIds(param.getDevIds());
|
||||||
@@ -893,10 +898,9 @@ public class SocketDevResponseService {
|
|||||||
|
|
||||||
//开始下源控制脚本
|
//开始下源控制脚本
|
||||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||||
|
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||||
|
issueParam.setSourceId(sourceInitialize.getSourceId());
|
||||||
issueParam.setPlanId(param.getPlanId());
|
issueParam.setPlanId(param.getPlanId());
|
||||||
issueParam.setSourceId(param.getSourceId());
|
|
||||||
issueParam.setDevIds(param.getDevIds());
|
|
||||||
issueParam.setScriptId(param.getScriptId());
|
|
||||||
|
|
||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
List<SourceIssue> sourceIssues;
|
List<SourceIssue> sourceIssues;
|
||||||
@@ -1162,8 +1166,9 @@ public class SocketDevResponseService {
|
|||||||
} else if (param.getTestItemList().get(2)) {
|
} else if (param.getTestItemList().get(2)) {
|
||||||
// 后续做正式检测
|
// 后续做正式检测
|
||||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||||
|
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||||
|
issueParam.setSourceId(sourceInitialize.getSourceId());
|
||||||
issueParam.setPlanId(param.getPlanId());
|
issueParam.setPlanId(param.getPlanId());
|
||||||
issueParam.setSourceId(param.getSourceId());
|
|
||||||
issueParam.setDevIds(param.getDevIds());
|
issueParam.setDevIds(param.getDevIds());
|
||||||
issueParam.setScriptId(param.getScriptId());
|
issueParam.setScriptId(param.getScriptId());
|
||||||
|
|
||||||
@@ -1816,8 +1821,9 @@ public class SocketDevResponseService {
|
|||||||
XiNumberManager.devParameterList.add(devParameterSmall);
|
XiNumberManager.devParameterList.add(devParameterSmall);
|
||||||
|
|
||||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||||
|
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||||
|
issueParam.setSourceId(sourceInitialize.getSourceId());
|
||||||
issueParam.setPlanId(param.getPlanId());
|
issueParam.setPlanId(param.getPlanId());
|
||||||
issueParam.setSourceId(param.getSourceId());
|
|
||||||
issueParam.setDevIds(param.getDevIds());
|
issueParam.setDevIds(param.getDevIds());
|
||||||
issueParam.setScriptId(param.getScriptId());
|
issueParam.setScriptId(param.getScriptId());
|
||||||
issueParam.setIsPhaseSequence(CommonEnum.COEFFICIENT_TEST.getValue());
|
issueParam.setIsPhaseSequence(CommonEnum.COEFFICIENT_TEST.getValue());
|
||||||
|
|||||||
@@ -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.freqConverterDevStep = null;
|
||||||
// FormalTestManager.stopFlag = false;
|
// FormalTestManager.stopFlag = false;
|
||||||
FormalTestManager.isRemoveSocket = false;
|
FormalTestManager.isRemoveSocket = false;
|
||||||
FormalTestManager.pendingDipTaskMap.clear();
|
FormalTestManager.pendingDipTaskMap.clear();
|
||||||
pqDipDataService.clearAllData(FormalTestManager.freqConverterTableSuffix);
|
if (reset) {
|
||||||
pqFreqConverterTestResService.clearAllData(FormalTestManager.freqConverterTableSuffix);
|
pqDipDataService.clearAllData(FormalTestManager.freqConverterTableSuffix);
|
||||||
|
pqFreqConverterTestResService.clearAllData(FormalTestManager.freqConverterTableSuffix);
|
||||||
|
}
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.monitorId = monitorId;
|
this.monitorId = monitorId;
|
||||||
}
|
}
|
||||||
@@ -88,8 +90,8 @@ public class SocketFreqConverterDevService {
|
|||||||
/**
|
/**
|
||||||
* 连接设备
|
* 连接设备
|
||||||
*/
|
*/
|
||||||
public void connectionDev(String userId, String devTag, String converterId, String monitorId) {
|
public void connectionDev(String userId, String devTag, String converterId, String monitorId, Boolean reset) {
|
||||||
this.init(userId, converterId, monitorId);
|
this.init(userId, converterId, monitorId, reset);
|
||||||
|
|
||||||
String payload = buildSingleMonitorPayload(monitorId);
|
String payload = buildSingleMonitorPayload(monitorId);
|
||||||
if (StrUtil.isBlank(payload)) {
|
if (StrUtil.isBlank(payload)) {
|
||||||
@@ -273,6 +275,9 @@ public class SocketFreqConverterDevService {
|
|||||||
|
|
||||||
if (DetectionCodeEnum.MAG.getCode().equalsIgnoreCase(sqlDataDTO.getDesc())) {
|
if (DetectionCodeEnum.MAG.getCode().equalsIgnoreCase(sqlDataDTO.getDesc())) {
|
||||||
residualVoltage = value;
|
residualVoltage = value;
|
||||||
|
if (residualVoltage <= 6) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else if (DetectionCodeEnum.DUR.getCode().equalsIgnoreCase(sqlDataDTO.getDesc())) {
|
} else if (DetectionCodeEnum.DUR.getCode().equalsIgnoreCase(sqlDataDTO.getDesc())) {
|
||||||
durationMs = (int) Math.round(value * 1000);
|
durationMs = (int) Math.round(value * 1000);
|
||||||
}
|
}
|
||||||
@@ -298,7 +303,7 @@ public class SocketFreqConverterDevService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<FreqConverterStatus> statusList = freqConverterService.getDipDurationStatusData(suffix, lastStatusData.getTimestamp(), pqDipData.getStartTime().plusNanos(pqDipData.getDurationMs() * 1000_000L));
|
List<FreqConverterStatus> statusList = freqConverterService.getDipDurationStatusData(suffix, lastStatusData.getTimestamp(), pqDipData.getStartTime().plusNanos(pqDipData.getDurationMs() * 1000_000L));
|
||||||
boolean originalTolerant = lastStatusData.getStatusWord1() != freqConverterConfig.getNoTolerant();
|
Integer originalTolerant = (lastStatusData.getStatusWord1() == freqConverterConfig.getTolerant()) ? 1 : 0;
|
||||||
LocalDateTime targetEndTime = pqDipData.getStartTime()
|
LocalDateTime targetEndTime = pqDipData.getStartTime()
|
||||||
.plusNanos(pqDipData.getDurationMs() * 1000_000L)
|
.plusNanos(pqDipData.getDurationMs() * 1000_000L)
|
||||||
.plusNanos(freqConverterConfig.getDt() * 1000_000L);
|
.plusNanos(freqConverterConfig.getDt() * 1000_000L);
|
||||||
@@ -306,28 +311,21 @@ public class SocketFreqConverterDevService {
|
|||||||
if (CollUtil.isNotEmpty(statusList)) {
|
if (CollUtil.isNotEmpty(statusList)) {
|
||||||
FreqConverterStatus status = statusList.get(statusList.size() - 1);
|
FreqConverterStatus status = statusList.get(statusList.size() - 1);
|
||||||
PqFreqConverterTestRes testRes = new PqFreqConverterTestRes();
|
PqFreqConverterTestRes testRes = new PqFreqConverterTestRes();
|
||||||
testRes.setDipId(pqDipData.getId());
|
testRes.setId(IdUtil.fastSimpleUUID());
|
||||||
testRes.setTolerant(originalTolerant ? status.getStatusWord1() != freqConverterConfig.getNoTolerant() : false);
|
testRes.setTolerant(originalTolerant == 1 ?
|
||||||
testRes.setStartTime(lastStatusData.getTimestamp());
|
(status.getStatusWord1() == freqConverterConfig.getTolerant() ? 1 : 0)
|
||||||
|
: 0);
|
||||||
|
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,
|
pqDipData,
|
||||||
targetEndTime,
|
targetEndTime,
|
||||||
originalTolerant
|
originalTolerant
|
||||||
));
|
));
|
||||||
testRes.setEndTime(status.getTimestamp());
|
|
||||||
|
|
||||||
// if (status.getTimestamp().isBefore(targetEndTime)) {
|
pqFreqConverterTestResService.saveTestRes(suffix, Collections.singletonList(testRes));
|
||||||
// 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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,8 +343,30 @@ public class SocketFreqConverterDevService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void cleanup(String devTag) {
|
public void cleanup(String devTag) {
|
||||||
|
String currentUserId = this.userId;
|
||||||
FormalTestManager.freqConverterDevStep = null;
|
FormalTestManager.freqConverterDevStep = null;
|
||||||
FormalTestManager.isRemoveSocket = true;
|
FormalTestManager.isRemoveSocket = true;
|
||||||
SocketManager.removeUser(devTag);
|
SocketManager.removeUser(devTag);
|
||||||
|
clearStateIfStopped(currentUserId);
|
||||||
|
this.userId = null;
|
||||||
|
this.monitorId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果设备已停止,则清除共享的运行时状态
|
||||||
|
*
|
||||||
|
* @param currentUserId 当前用户ID
|
||||||
|
*/
|
||||||
|
private void clearStateIfStopped(String currentUserId) {
|
||||||
|
if (StrUtil.isBlank(currentUserId)) {
|
||||||
|
FormalTestManager.clearFreqConverterRuntimeState();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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;
|
package com.njcn.gather.detection.handler;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
@@ -9,6 +10,7 @@ import com.njcn.gather.detection.pojo.dto.FreqConverterRespDTO;
|
|||||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||||
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
||||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||||
|
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||||
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||||
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
||||||
@@ -27,6 +29,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
@@ -47,6 +50,10 @@ public class SocketFreqConverterService {
|
|||||||
private final IPqFreqConverterConfigService pqFreqConverterConfigService;
|
private final IPqFreqConverterConfigService pqFreqConverterConfigService;
|
||||||
private final IPqFreqConverterTestResService pqFreqConverterTestResService;
|
private final IPqFreqConverterTestResService pqFreqConverterTestResService;
|
||||||
private String userId;
|
private String userId;
|
||||||
|
/**
|
||||||
|
* 上一个暂降点耐受检测结果
|
||||||
|
*/
|
||||||
|
private TolerantPointVO lastTolerancePoint;
|
||||||
private final FreqConverterConfig freqConverterConfig;
|
private final FreqConverterConfig freqConverterConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,12 +111,15 @@ public class SocketFreqConverterService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(String userId, String converterId, String monitorId) {
|
public void init(String userId, String converterId, String monitorId, Boolean reset) {
|
||||||
|
this.lastTolerancePoint = null;
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
FormalTestManager.freqConverterStep = null;
|
FormalTestManager.freqConverterStep = null;
|
||||||
FormalTestManager.currentFreqConverterId = converterId;
|
FormalTestManager.currentFreqConverterId = converterId;
|
||||||
Integer suffix = pqFreqConverterConfigService.getSuffix(converterId);
|
Integer suffix = pqFreqConverterConfigService.getSuffix(converterId);
|
||||||
freqConverterService.clearAllData(suffix);
|
if (reset) {
|
||||||
|
freqConverterService.clearAllData(suffix);
|
||||||
|
}
|
||||||
FormalTestManager.freqConverterTableSuffix = suffix;
|
FormalTestManager.freqConverterTableSuffix = suffix;
|
||||||
FormalTestManager.isRemoveSocket = false;
|
FormalTestManager.isRemoveSocket = false;
|
||||||
FormalTestManager.pendingDipTaskMap.clear();
|
FormalTestManager.pendingDipTaskMap.clear();
|
||||||
@@ -120,8 +130,8 @@ public class SocketFreqConverterService {
|
|||||||
/**
|
/**
|
||||||
* 连接变频器
|
* 连接变频器
|
||||||
*/
|
*/
|
||||||
public void connectionFreqConverter(String userId, String freqConverterTag, String converterId, String monitorId) {
|
public void connectionFreqConverter(String userId, String freqConverterTag, String converterId, String monitorId, Boolean reset) {
|
||||||
this.init(userId, converterId, monitorId);
|
this.init(userId, converterId, monitorId, reset);
|
||||||
|
|
||||||
SocketMsg<Map<String, Object>> socketMsg = new SocketMsg<>();
|
SocketMsg<Map<String, Object>> socketMsg = new SocketMsg<>();
|
||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.CMD_INIT_SERIAL.getValue());
|
socketMsg.setOperateCode(SourceOperateCodeEnum.CMD_INIT_SERIAL.getValue());
|
||||||
@@ -147,16 +157,23 @@ public class SocketFreqConverterService {
|
|||||||
public void handleRead(String converterChannelTag, String msg) {
|
public void handleRead(String converterChannelTag, String msg) {
|
||||||
FreqConverterRespDTO respDTO = JSON.parseObject(msg, FreqConverterRespDTO.class);
|
FreqConverterRespDTO respDTO = JSON.parseObject(msg, FreqConverterRespDTO.class);
|
||||||
|
|
||||||
switch (FormalTestManager.freqConverterStep) {
|
if (respDTO.getCode() != 0) {
|
||||||
case CMD_INIT_SERIAL:
|
SocketDataMsg socketDataMsg = new SocketDataMsg();
|
||||||
handleInitSerial(converterChannelTag, respDTO);
|
socketDataMsg.setRequestId(FormalTestManager.freqConverterStep.getValue());
|
||||||
break;
|
socketDataMsg.setCode(respDTO.getCode());
|
||||||
case CMD_GET_DEVICE_STATUS:
|
WebServiceManager.sendMsg(this.userId, JSON.toJSONString(socketDataMsg));
|
||||||
handleGetDeviceStatus(converterChannelTag, respDTO);
|
} else {
|
||||||
break;
|
switch (FormalTestManager.freqConverterStep) {
|
||||||
case CMD_CLOSE_SERIAL:
|
case CMD_INIT_SERIAL:
|
||||||
handleCloseSerial(converterChannelTag, respDTO);
|
handleInitSerial(converterChannelTag, respDTO);
|
||||||
break;
|
break;
|
||||||
|
case CMD_GET_DEVICE_STATUS:
|
||||||
|
handleGetDeviceStatus(converterChannelTag, respDTO);
|
||||||
|
break;
|
||||||
|
case CMD_CLOSE_SERIAL:
|
||||||
|
handleCloseSerial(converterChannelTag, respDTO);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,11 +183,16 @@ public class SocketFreqConverterService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void cleanup(String converterChannelTag) {
|
public void cleanup(String converterChannelTag) {
|
||||||
|
String currentUserId = this.userId;
|
||||||
clearScheduleTask();
|
clearScheduleTask();
|
||||||
FormalTestManager.freqConverterStep = null;
|
FormalTestManager.freqConverterStep = null;
|
||||||
// FormalTestManager.stopFlag = false;
|
// FormalTestManager.stopFlag = false;
|
||||||
FormalTestManager.isRemoveSocket = true;
|
FormalTestManager.isRemoveSocket = true;
|
||||||
SocketManager.removeUser(converterChannelTag);
|
SocketManager.removeUser(converterChannelTag);
|
||||||
|
updateCurrentTestStatus();
|
||||||
|
clearStateIfStopped(currentUserId);
|
||||||
|
this.userId = null;
|
||||||
|
this.lastTolerancePoint = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleInitSerial(String converterChannelTag, FreqConverterRespDTO respDTO) {
|
private void handleInitSerial(String converterChannelTag, FreqConverterRespDTO respDTO) {
|
||||||
@@ -251,48 +273,161 @@ public class SocketFreqConverterService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateCurrentTestStatus() {
|
||||||
|
if (StrUtil.isNotBlank(FormalTestManager.currentFreqConverterId)) {
|
||||||
|
pqFreqConverterConfigService.updateTestStatus(FormalTestManager.currentFreqConverterId, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果变频器已停止,则清除共享的运行时状态
|
||||||
|
*
|
||||||
|
* @param currentUserId 当前用户ID
|
||||||
|
*/
|
||||||
|
private void clearStateIfStopped(String currentUserId) {
|
||||||
|
if (StrUtil.isBlank(currentUserId)) {
|
||||||
|
FormalTestManager.clearFreqConverterRuntimeState();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String devTag = currentUserId + CnSocketUtil.DEV_TAG;
|
||||||
|
// 避免过早把 freqConverterTableSuffix 等全局值清掉,造成设备无法使用全局变量
|
||||||
|
if (!SocketManager.isChannelActive(devTag)) {
|
||||||
|
FormalTestManager.freqConverterDevStep = null;
|
||||||
|
FormalTestManager.clearFreqConverterRuntimeState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void consumePendingDipTasks(FreqConverterStatus freqConverterStatus) {
|
private void consumePendingDipTasks(FreqConverterStatus freqConverterStatus) {
|
||||||
if (FormalTestManager.pendingDipTaskMap.isEmpty()) {
|
if (FormalTestManager.pendingDipTaskMap.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer suffix = FormalTestManager.freqConverterTableSuffix;
|
Integer suffix = FormalTestManager.freqConverterTableSuffix;
|
||||||
List<String> finishedDipIdList = new ArrayList<>();
|
List<String> finishedTestResIdList = new ArrayList<>();
|
||||||
List<PqFreqConverterTestRes> testResList = new ArrayList<>();
|
List<PqFreqConverterTestRes> saveTestResList = new ArrayList<>();
|
||||||
for (FormalTestManager.PendingDipTask task : FormalTestManager.pendingDipTaskMap.values()) {
|
List<PqFreqConverterTestRes> updateTestResList = new ArrayList<>();
|
||||||
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.getNoTolerant()));
|
|
||||||
testResList.add(testRes);
|
|
||||||
|
|
||||||
|
FormalTestManager.pendingDipTaskMap.forEach((key, task) -> {
|
||||||
if (freqConverterStatus.getTimestamp().isAfter(task.getTargetEndTime())) {
|
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 socketDataMsg = new SocketDataMsg();
|
||||||
socketDataMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL + SocketFreqConverterDevService.DIP_DATA_SUFFIX);
|
socketDataMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL + SocketFreqConverterDevService.DIP_DATA_SUFFIX);
|
||||||
|
|
||||||
TolerantPointVO tolerantPointVO = new TolerantPointVO();
|
TolerantPointVO newTolerantPointVO = new TolerantPointVO();
|
||||||
tolerantPointVO.setResidualVoltage(task.getPqDipData().getResidualVoltage());
|
newTolerantPointVO.setResidualVoltage(task.getPqDipData().getResidualVoltage());
|
||||||
tolerantPointVO.setDurationMs(task.getPqDipData().getDurationMs());
|
newTolerantPointVO.setDurationMs(task.getPqDipData().getDurationMs());
|
||||||
tolerantPointVO.setTolerant(testRes.getTolerant());
|
newTolerantPointVO.setTolerant(testRes.getTolerant());
|
||||||
socketDataMsg.setData(JSON.toJSONString(tolerantPointVO));
|
socketDataMsg.setData(JSON.toJSONString(newTolerantPointVO));
|
||||||
WebServiceManager.sendMsg(this.userId, JSON.toJSONString(socketDataMsg));
|
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 : finishedTestResIdList) {
|
||||||
|
|
||||||
for (String dipId : finishedDipIdList) {
|
|
||||||
FormalTestManager.pendingDipTaskMap.remove(dipId);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public interface PreDetectionService {
|
|||||||
|
|
||||||
void startCoefficient();
|
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);
|
void stopFreqConverter(String converterId, String monitorId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -289,7 +289,8 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
}
|
}
|
||||||
//组装源控制脚本
|
//组装源控制脚本
|
||||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||||
issueParam.setSourceId(param.getSourceId());
|
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||||
|
issueParam.setSourceId(sourceInitialize.getSourceId());
|
||||||
issueParam.setScriptId(param.getScriptId());
|
issueParam.setScriptId(param.getScriptId());
|
||||||
issueParam.setType(1);
|
issueParam.setType(1);
|
||||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.SIMULATE_TEST.getValue());
|
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.SIMULATE_TEST.getValue());
|
||||||
@@ -394,7 +395,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 freqConverterTag = userId + CnSocketUtil.FREQ_CONVERTER_TAG;
|
||||||
String devTag = userId + CnSocketUtil.DEV_TAG;
|
String devTag = userId + CnSocketUtil.DEV_TAG;
|
||||||
// socketFreqConverterService.init(userId, converterId, monitorId);
|
// socketFreqConverterService.init(userId, converterId, monitorId);
|
||||||
@@ -406,8 +407,8 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
while (true) {
|
while (true) {
|
||||||
if (SocketManager.isChannelActive(freqConverterTag) && SocketManager.isChannelActive(devTag)) {
|
if (SocketManager.isChannelActive(freqConverterTag) && SocketManager.isChannelActive(devTag)) {
|
||||||
// if (SocketManager.isChannelActive(devTag)) {
|
// if (SocketManager.isChannelActive(devTag)) {
|
||||||
socketFreqConverterService.connectionFreqConverter(userId, freqConverterTag, converterId, monitorId);
|
socketFreqConverterService.connectionFreqConverter(userId, freqConverterTag, converterId, monitorId, reset);
|
||||||
socketFreqConverterDevService.connectionDev(userId, devTag, converterId, monitorId);
|
socketFreqConverterDevService.connectionDev(userId, devTag, converterId, monitorId,reset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -226,14 +226,23 @@ public class FormalTestManager {
|
|||||||
*/
|
*/
|
||||||
public static boolean isXu;
|
public static boolean isXu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理变频器耐受实验运行态数据
|
||||||
|
*/
|
||||||
|
public static void clearFreqConverterRuntimeState() {
|
||||||
|
currentFreqConverterId = null;
|
||||||
|
freqConverterTableSuffix = null;
|
||||||
|
pendingDipTaskMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class PendingDipTask {
|
public static class PendingDipTask {
|
||||||
private PqDipData pqDipData;
|
private PqDipData pqDipData;
|
||||||
|
|
||||||
private LocalDateTime targetEndTime;
|
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.pqDipData = pqDipData;
|
||||||
this.targetEndTime = targetEndTime;
|
this.targetEndTime = targetEndTime;
|
||||||
this.originalTolerant = originalTolerant;
|
this.originalTolerant = originalTolerant;
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ import org.springframework.stereotype.Component;
|
|||||||
@ConfigurationProperties(prefix = "freq-converter")
|
@ConfigurationProperties(prefix = "freq-converter")
|
||||||
public class FreqConverterConfig {
|
public class FreqConverterConfig {
|
||||||
private Long schedulePeriod;
|
private Long schedulePeriod;
|
||||||
private Integer noTolerant;
|
private Integer tolerant;
|
||||||
private Integer dt;
|
private Integer dt;
|
||||||
|
private Integer direction;
|
||||||
|
private Integer allowErrorDuration;
|
||||||
|
private Double allowErrorResidualVoltage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,12 +95,22 @@ public class FreqConverterController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/result")
|
@GetMapping("/result")
|
||||||
@ApiOperation("查询耐受实验结果")
|
@ApiOperation("查询变频器测试结果")
|
||||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||||
public HttpResult<List<TolerantPointVO>> result(@RequestParam("converterId") String converterId) {
|
public HttpResult<List<TolerantPointVO>> result(@RequestParam("converterId") String converterId) {
|
||||||
String methodDescribe = getMethodDescribe("result");
|
String methodDescribe = getMethodDescribe("result");
|
||||||
LogUtil.njcnDebug(log, "{},查询ID数据为:{}", methodDescribe, converterId);
|
LogUtil.njcnDebug(log, "{},查询ID数据为:{}", methodDescribe, converterId);
|
||||||
List<TolerantPointVO> tolerantPoints = freqConverterService.getTolerantPoints(converterId);
|
List<TolerantPointVO> tolerantPoints = freqConverterService.getDipPoints(converterId);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, tolerantPoints, methodDescribe);
|
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;
|
package com.njcn.gather.freqConverter.pojo.po;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -18,22 +19,23 @@ public class PqFreqConverterTestRes {
|
|||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 装置暂降数据id
|
* 残余电压,单位:%Ur
|
||||||
*/
|
*/
|
||||||
private String dipId;
|
private Double residualVoltage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 0为不耐受,1为耐受
|
* 持续时间,单位:ms
|
||||||
*/
|
*/
|
||||||
private Boolean tolerant;
|
private Integer durationMs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 该暂降时期对应变频器的起始时间戳
|
* 0为不耐受,1为耐受,2为特性曲线点
|
||||||
*/
|
*/
|
||||||
private LocalDateTime startTime;
|
private Integer tolerant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 该暂降时期对应变频器的结束时间戳
|
* 时间
|
||||||
*/
|
*/
|
||||||
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;
|
package com.njcn.gather.freqConverter.pojo.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author caozehui
|
* @author caozehui
|
||||||
* @data 2026-04-13
|
* @data 2026-04-13
|
||||||
@@ -19,7 +22,13 @@ public class TolerantPointVO {
|
|||||||
private Double residualVoltage;
|
private Double residualVoltage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否耐受
|
* 是否耐受。0-否,1-是,2-表示特性曲线点
|
||||||
*/
|
*/
|
||||||
private boolean tolerant;
|
private Integer tolerant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8")
|
||||||
|
private LocalDateTime time;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,9 +46,17 @@ public interface IFreqConverterService extends IService<FreqConverterStatus> {
|
|||||||
* @param converterId 变频器Id
|
* @param converterId 变频器Id
|
||||||
* @return 是否耐受
|
* @return 是否耐受
|
||||||
*/
|
*/
|
||||||
List<TolerantPointVO> getTolerantPoints(String converterId);
|
List<TolerantPointVO> getDipPoints(String converterId);
|
||||||
|
|
||||||
List<FreqConverterStatus> getDipDurationStatusData(Integer suffix, LocalDateTime startTime, LocalDateTime endTime);
|
List<FreqConverterStatus> getDipDurationStatusData(Integer suffix, LocalDateTime startTime, LocalDateTime endTime);
|
||||||
|
|
||||||
FreqConverterStatus getLastStatusData(Integer suffix, LocalDateTime startTime);
|
FreqConverterStatus getLastStatusData(Integer suffix, LocalDateTime startTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取变频器特性曲线点
|
||||||
|
*
|
||||||
|
* @param converterId 变频器ID
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<TolerantPointVO> getFeaturesScurvePoints(String converterId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,13 +19,22 @@ public interface IPqFreqConverterTestResService extends IService<PqFreqConverter
|
|||||||
void clearAllData(Integer suffix);
|
void clearAllData(Integer suffix);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存结果记录
|
* 新增结果记录
|
||||||
*
|
*
|
||||||
* @param suffix 表后缀
|
* @param suffix 表后缀
|
||||||
* @param testResList 结果数据
|
* @param testResList 结果数据
|
||||||
* @return 是否成功
|
* @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);
|
List<PqFreqConverterTestRes> listTestRes(Integer suffix);
|
||||||
|
|
||||||
/**
|
PqFreqConverterTestRes getLastByDuration(Integer suffix, String id, Integer durationMs);
|
||||||
* 根据DIPID查询结果
|
|
||||||
* @param suffix
|
PqFreqConverterTestRes getLastByResidualVoltage(Integer suffix, String id, Double residualVoltage);
|
||||||
* @param dipId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
PqFreqConverterTestRes getByDipId(Integer suffix, String dipId);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import cn.hutool.core.util.IdUtil;
|
|||||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
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.dip.service.IPqDipDataService;
|
||||||
import com.njcn.gather.freqConverter.mapper.FreqConverterStatusMapper;
|
import com.njcn.gather.freqConverter.mapper.FreqConverterStatusMapper;
|
||||||
import com.njcn.gather.freqConverter.pojo.po.FreqConverterStatus;
|
import com.njcn.gather.freqConverter.pojo.po.FreqConverterStatus;
|
||||||
@@ -18,9 +17,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,13 +38,14 @@ public class FreqConverterServiceImpl extends ServiceImpl<FreqConverterStatusMap
|
|||||||
private final IPqDipDataService dipDataService;
|
private final IPqDipDataService dipDataService;
|
||||||
private final IPqFreqConverterTestResService pqFreqConverterTestResService;
|
private final IPqFreqConverterTestResService pqFreqConverterTestResService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean saveFreqConverterStatus(Integer suffix, FreqConverterStatus status) {
|
public boolean saveFreqConverterStatus(Integer suffix, FreqConverterStatus status) {
|
||||||
if (status.getId() == null) {
|
if (status.getId() == null) {
|
||||||
status.setId(IdUtil.fastSimpleUUID());
|
status.setId(IdUtil.fastSimpleUUID());
|
||||||
}
|
}
|
||||||
DynamicTableNameHandler.setTableName("pq_freq_converter_status_" + suffix);
|
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_STATUS_TB_PREFIX + suffix);
|
||||||
boolean result = this.save(status);
|
boolean result = this.save(status);
|
||||||
DynamicTableNameHandler.remove();
|
DynamicTableNameHandler.remove();
|
||||||
return result;
|
return result;
|
||||||
@@ -57,7 +55,7 @@ public class FreqConverterServiceImpl extends ServiceImpl<FreqConverterStatusMap
|
|||||||
public List<FreqConverterStatus> listStatusData(String converterId) {
|
public List<FreqConverterStatus> listStatusData(String converterId) {
|
||||||
Integer suffix = pqFreqConverterConfigService.getSuffix(converterId);
|
Integer suffix = pqFreqConverterConfigService.getSuffix(converterId);
|
||||||
|
|
||||||
DynamicTableNameHandler.setTableName("pq_freq_converter_status_" + suffix);
|
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_STATUS_TB_PREFIX + suffix);
|
||||||
LambdaQueryChainWrapper<FreqConverterStatus> wrapper = this.lambdaQuery().orderByAsc(FreqConverterStatus::getTimestamp);
|
LambdaQueryChainWrapper<FreqConverterStatus> wrapper = this.lambdaQuery().orderByAsc(FreqConverterStatus::getTimestamp);
|
||||||
List<FreqConverterStatus> result = wrapper.list();
|
List<FreqConverterStatus> result = wrapper.list();
|
||||||
DynamicTableNameHandler.remove();
|
DynamicTableNameHandler.remove();
|
||||||
@@ -68,38 +66,35 @@ public class FreqConverterServiceImpl extends ServiceImpl<FreqConverterStatusMap
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void clearAllData(Integer suffix) {
|
public void clearAllData(Integer suffix) {
|
||||||
DynamicTableNameHandler.setTableName("pq_freq_converter_status_" + suffix);
|
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_STATUS_TB_PREFIX + suffix);
|
||||||
this.remove(null);
|
this.remove(null);
|
||||||
DynamicTableNameHandler.remove();
|
DynamicTableNameHandler.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TolerantPointVO> getTolerantPoints(String converterId) {
|
public List<TolerantPointVO> getDipPoints(String converterId) {
|
||||||
Integer suffix = pqFreqConverterConfigService.getSuffix(converterId);
|
Integer suffix = pqFreqConverterConfigService.getSuffix(converterId);
|
||||||
List<PqDipData> dipDataList = dipDataService.listDipData(suffix);
|
|
||||||
List<PqFreqConverterTestRes> testResList = pqFreqConverterTestResService.listTestRes(suffix);
|
|
||||||
dipDataList.sort(Comparator.comparing(PqDipData::getDurationMs));
|
|
||||||
|
|
||||||
List<TolerantPointVO> res = new ArrayList<>();
|
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX + suffix);
|
||||||
for (PqDipData dipData : dipDataList) {
|
List<PqFreqConverterTestRes> pqFreqConverterTestResList = pqFreqConverterTestResService.list();
|
||||||
TolerantPointVO tolerantPointVO = new TolerantPointVO();
|
DynamicTableNameHandler.remove();
|
||||||
tolerantPointVO.setDurationMs(dipData.getDurationMs());
|
List<TolerantPointVO> result = pqFreqConverterTestResList.stream().map(item -> {
|
||||||
tolerantPointVO.setResidualVoltage(dipData.getResidualVoltage());
|
TolerantPointVO tolerantPointVO = new TolerantPointVO();
|
||||||
List<PqFreqConverterTestRes> matchedResList = testResList.stream()
|
tolerantPointVO.setDurationMs(item.getDurationMs());
|
||||||
.filter(item -> dipData.getId().equals(item.getDipId()))
|
tolerantPointVO.setResidualVoltage(item.getResidualVoltage());
|
||||||
.collect(Collectors.toList());
|
tolerantPointVO.setTolerant(item.getTolerant());
|
||||||
|
tolerantPointVO.setTime(item.getTime());
|
||||||
|
return tolerantPointVO;
|
||||||
|
})
|
||||||
|
.sorted(Comparator.comparingInt(TolerantPointVO::getDurationMs))
|
||||||
|
.sorted(Comparator.comparingDouble(TolerantPointVO::getResidualVoltage)).collect(Collectors.toList());
|
||||||
|
|
||||||
boolean tolerant = matchedResList.stream().allMatch(PqFreqConverterTestRes::getTolerant);
|
return result;
|
||||||
tolerantPointVO.setTolerant(tolerant);
|
|
||||||
|
|
||||||
res.add(tolerantPointVO);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FreqConverterStatus> getDipDurationStatusData(Integer suffix, LocalDateTime startTime, LocalDateTime endTime) {
|
public List<FreqConverterStatus> getDipDurationStatusData(Integer suffix, LocalDateTime startTime, LocalDateTime endTime) {
|
||||||
DynamicTableNameHandler.setTableName("pq_freq_converter_status_" + suffix);
|
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_STATUS_TB_PREFIX + suffix);
|
||||||
List<FreqConverterStatus> result = this.lambdaQuery()
|
List<FreqConverterStatus> result = this.lambdaQuery()
|
||||||
.between(FreqConverterStatus::getTimestamp, startTime, endTime)
|
.between(FreqConverterStatus::getTimestamp, startTime, endTime)
|
||||||
.orderByAsc(FreqConverterStatus::getTimestamp)
|
.orderByAsc(FreqConverterStatus::getTimestamp)
|
||||||
@@ -110,7 +105,7 @@ public class FreqConverterServiceImpl extends ServiceImpl<FreqConverterStatusMap
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FreqConverterStatus getLastStatusData(Integer suffix, LocalDateTime startTime) {
|
public FreqConverterStatus getLastStatusData(Integer suffix, LocalDateTime startTime) {
|
||||||
DynamicTableNameHandler.setTableName("pq_freq_converter_status_" + suffix);
|
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_STATUS_TB_PREFIX + suffix);
|
||||||
FreqConverterStatus one = this.lambdaQuery().le(FreqConverterStatus::getTimestamp, startTime)
|
FreqConverterStatus one = this.lambdaQuery().le(FreqConverterStatus::getTimestamp, startTime)
|
||||||
.orderByDesc(FreqConverterStatus::getTimestamp)
|
.orderByDesc(FreqConverterStatus::getTimestamp)
|
||||||
.last("limit 1")
|
.last("limit 1")
|
||||||
@@ -118,4 +113,60 @@ public class FreqConverterServiceImpl extends ServiceImpl<FreqConverterStatusMap
|
|||||||
DynamicTableNameHandler.remove();
|
DynamicTableNameHandler.remove();
|
||||||
return one;
|
return one;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TolerantPointVO> getFeaturesScurvePoints(String converterId) {
|
||||||
|
List<TolerantPointVO> dipPoints = this.getDipPoints(converterId);
|
||||||
|
if (dipPoints == null || dipPoints.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Integer, List<TolerantPointVO>> durationPointMap = dipPoints.stream()
|
||||||
|
.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()
|
||||||
|
.forEach(entry -> {
|
||||||
|
List<TolerantPointVO> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,13 @@ import java.util.List;
|
|||||||
public class PqFreqConverterConfigServiceImpl extends ServiceImpl<PqFreqConverterConfigMapper, PqFreqConverterConfig> implements IPqFreqConverterConfigService {
|
public class PqFreqConverterConfigServiceImpl extends ServiceImpl<PqFreqConverterConfigMapper, PqFreqConverterConfig> implements IPqFreqConverterConfigService {
|
||||||
private final TableGenMapper tableGenMapper;
|
private final TableGenMapper tableGenMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表名前缀
|
||||||
|
*/
|
||||||
|
public static final String PQ_FREQ_CONVERTER_STATUS_TB_PREFIX = "pq_freq_converter_status_";
|
||||||
|
public static final String PQ_DIP_DATA_TB_PREFIX = "pq_dip_data_";
|
||||||
|
public static final String PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX = "pq_freq_converter_test_res_";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<PqFreqConverterConfig> listPqFreqConverterConfigs(PqFreqConverterParam.QueryParam queryParam) {
|
public Page<PqFreqConverterConfig> listPqFreqConverterConfigs(PqFreqConverterParam.QueryParam queryParam) {
|
||||||
QueryWrapper wrapper = new QueryWrapper<>();
|
QueryWrapper wrapper = new QueryWrapper<>();
|
||||||
@@ -53,7 +60,7 @@ public class PqFreqConverterConfigServiceImpl extends ServiceImpl<PqFreqConverte
|
|||||||
maxSuffix = freqConverterConfig.getSuffix() + 1;
|
maxSuffix = freqConverterConfig.getSuffix() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
String tableSql = "CREATE TABLE `pq_freq_converter_status_" + maxSuffix + "` (" +
|
String tableSql = "CREATE TABLE `" + PQ_FREQ_CONVERTER_STATUS_TB_PREFIX + maxSuffix + "`(" +
|
||||||
" `id` char(32) NOT NULL COMMENT '主键ID'," +
|
" `id` char(32) NOT NULL COMMENT '主键ID'," +
|
||||||
" `slave_address` int(11) DEFAULT NULL COMMENT '从机地址'," +
|
" `slave_address` int(11) DEFAULT NULL COMMENT '从机地址'," +
|
||||||
" `status_word1` int(11) DEFAULT NULL COMMENT '状态字1'," +
|
" `status_word1` int(11) DEFAULT NULL COMMENT '状态字1'," +
|
||||||
@@ -63,7 +70,7 @@ public class PqFreqConverterConfigServiceImpl extends ServiceImpl<PqFreqConverte
|
|||||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='变频器状态表';";
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='变频器状态表';";
|
||||||
tableGenMapper.genTable(tableSql);
|
tableGenMapper.genTable(tableSql);
|
||||||
|
|
||||||
tableSql = "CREATE TABLE `pq_dip_data_" + maxSuffix + "` (" +
|
tableSql = "CREATE TABLE `" + PQ_DIP_DATA_TB_PREFIX + maxSuffix + "` (" +
|
||||||
" `id` char(32) NOT NULL COMMENT '主键ID'," +
|
" `id` char(32) NOT NULL COMMENT '主键ID'," +
|
||||||
" `start_time` datetime(3) NOT NULL COMMENT '起始时间戳'," +
|
" `start_time` datetime(3) NOT NULL COMMENT '起始时间戳'," +
|
||||||
" `residual_voltage` decimal(6,2) NOT NULL COMMENT '残余电压(%Ur)'," +
|
" `residual_voltage` decimal(6,2) NOT NULL COMMENT '残余电压(%Ur)'," +
|
||||||
@@ -72,12 +79,12 @@ public class PqFreqConverterConfigServiceImpl extends ServiceImpl<PqFreqConverte
|
|||||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电压暂降数据表';";
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='电压暂降数据表';";
|
||||||
tableGenMapper.genTable(tableSql);
|
tableGenMapper.genTable(tableSql);
|
||||||
|
|
||||||
tableSql = "CREATE TABLE `pq_freq_converter_test_res_" + maxSuffix + "` (" +
|
tableSql = "CREATE TABLE `" + PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX + maxSuffix + "` (" +
|
||||||
" `id` char(32) NOT NULL COMMENT '主键ID'," +
|
" `id` char(32) NOT NULL COMMENT '主键ID'," +
|
||||||
" `dip_id` char(32) NOT NULL COMMENT '装置暂降数据id'," +
|
" `residual_voltage` decimal(6,2) NOT NULL COMMENT '残余电压(%Ur)'," +
|
||||||
" `start_time` datetime(3) DEFAULT NULL COMMENT '该暂降时期对应变频器的起始时间戳'," +
|
" `duration_ms` int(11) NOT NULL COMMENT '持续时间(ms)'," +
|
||||||
" `end_time` datetime(3) DEFAULT NULL COMMENT '该暂降时期对应变频器的结束时间戳'," +
|
" `tolerant` tinyInt(1) NOT NULL COMMENT '0为不耐受,1为耐受,2为特征点'," +
|
||||||
" `tolerant` tinyInt(1) NOT NULL COMMENT '0为不耐受,1为耐受'," +
|
" `time` datetime(3) DEFAULT NULL COMMENT '时间',"+
|
||||||
" PRIMARY KEY (`id`)" +
|
" PRIMARY KEY (`id`)" +
|
||||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='变频器耐受实验结果';";
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='变频器耐受实验结果';";
|
||||||
tableGenMapper.genTable(tableSql);
|
tableGenMapper.genTable(tableSql);
|
||||||
@@ -105,9 +112,9 @@ public class PqFreqConverterConfigServiceImpl extends ServiceImpl<PqFreqConverte
|
|||||||
List<PqFreqConverterConfig> pqFreqConverterConfigs = this.listByIds(ids);
|
List<PqFreqConverterConfig> pqFreqConverterConfigs = this.listByIds(ids);
|
||||||
for (PqFreqConverterConfig pqFreqConverterConfig : pqFreqConverterConfigs) {
|
for (PqFreqConverterConfig pqFreqConverterConfig : pqFreqConverterConfigs) {
|
||||||
Integer suffix = pqFreqConverterConfig.getSuffix();
|
Integer suffix = pqFreqConverterConfig.getSuffix();
|
||||||
sql.append("pq_freq_converter_status_" + suffix + ",")
|
sql.append(PQ_FREQ_CONVERTER_STATUS_TB_PREFIX + suffix + ",")
|
||||||
.append("pq_dip_data_" + suffix + ",")
|
.append(PQ_DIP_DATA_TB_PREFIX + suffix + ",")
|
||||||
.append("pq_freq_converter_test_res_" + suffix + ",");
|
.append(PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX + suffix + ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
sql.deleteCharAt(sql.length() - 1);
|
sql.deleteCharAt(sql.length() - 1);
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
package com.njcn.gather.freqConverter.service.impl;
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
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.mapper.PqFreqConverterTestResMapper;
|
||||||
import com.njcn.gather.freqConverter.pojo.po.PqFreqConverterTestRes;
|
import com.njcn.gather.freqConverter.pojo.po.PqFreqConverterTestRes;
|
||||||
import com.njcn.gather.freqConverter.service.IPqFreqConverterTestResService;
|
import com.njcn.gather.freqConverter.service.IPqFreqConverterTestResService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,51 +17,65 @@ import java.util.List;
|
|||||||
* @data 2026-04-14
|
* @data 2026-04-14
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@AllArgsConstructor
|
||||||
public class PqFreqConverterTestResServiceImpl extends ServiceImpl<PqFreqConverterTestResMapper, PqFreqConverterTestRes> implements IPqFreqConverterTestResService {
|
public class PqFreqConverterTestResServiceImpl extends ServiceImpl<PqFreqConverterTestResMapper, PqFreqConverterTestRes> implements IPqFreqConverterTestResService {
|
||||||
|
private final FreqConverterConfig freqConverterConfig;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clearAllData(Integer suffix) {
|
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);
|
this.remove(null);
|
||||||
DynamicTableNameHandler.remove();
|
DynamicTableNameHandler.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveOrUpdateTestRes(Integer suffix, List<PqFreqConverterTestRes> testResList) {
|
public boolean saveTestRes(Integer suffix, List<PqFreqConverterTestRes> testResList) {
|
||||||
DynamicTableNameHandler.setTableName("pq_freq_converter_test_res_" + suffix);
|
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX + suffix);
|
||||||
|
this.saveBatch(testResList);
|
||||||
List<PqFreqConverterTestRes> existedTestResList = new ArrayList<>();
|
DynamicTableNameHandler.remove();
|
||||||
List<PqFreqConverterTestRes> newTestResList = new ArrayList<>();
|
return true;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@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();
|
DynamicTableNameHandler.remove();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PqFreqConverterTestRes> listTestRes(Integer suffix) {
|
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();
|
List<PqFreqConverterTestRes> result = this.list();
|
||||||
DynamicTableNameHandler.remove();
|
DynamicTableNameHandler.remove();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PqFreqConverterTestRes getByDipId(Integer suffix, String dipId) {
|
public PqFreqConverterTestRes getLastByDuration(Integer suffix, String id, Integer durationMs) {
|
||||||
DynamicTableNameHandler.setTableName("pq_freq_converter_test_res_" + suffix);
|
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX + suffix);
|
||||||
PqFreqConverterTestRes one = this.lambdaQuery().eq(PqFreqConverterTestRes::getDipId, dipId).one();
|
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();
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1265,7 +1265,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|||||||
for (int i = 1; i <= maxTime; i++) {
|
for (int i = 1; i <= maxTime; i++) {
|
||||||
row2[i] = i + "次检测";
|
row2[i] = i + "次检测";
|
||||||
int tempI = i;
|
int tempI = i;
|
||||||
List<PqDevVO> tempDevList = devList.stream().filter(dev -> dev.getRecheckNum() <= tempI).collect(Collectors.toList());
|
List<PqDevVO> tempDevList = devList.stream().filter(dev -> dev.getRecheckNum() == tempI).collect(Collectors.toList());
|
||||||
long passCount = tempDevList.stream().filter(dev -> dev.getCheckResult() == CheckResultEnum.ACCORD.getValue()).count();
|
long passCount = tempDevList.stream().filter(dev -> dev.getCheckResult() == CheckResultEnum.ACCORD.getValue()).count();
|
||||||
row3[i] = passCount + "";
|
row3[i] = passCount + "";
|
||||||
row4[i] = total + "";
|
row4[i] = total + "";
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
|||||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||||
import com.njcn.gather.script.util.ScriptDtlsDesc;
|
import com.njcn.gather.script.util.ScriptDtlsDesc;
|
||||||
import com.njcn.gather.script.util.ThreePhaseUnbalance;
|
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.pojo.po.DictTree;
|
||||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
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 INHARM_I = "InHarm_I";
|
||||||
private final static String DIP = "Dip";
|
private final static String DIP = "Dip";
|
||||||
private final static String FLICKER = "Flicker";
|
private final static String FLICKER = "Flicker";
|
||||||
// @Value("${Dip.fPreTime}")
|
// @Value("${Dip.fPreTime}")
|
||||||
// private Double fPreTime;
|
// private Double fPreTime;
|
||||||
@Value("${Dip.fRampIn}")
|
@Value("${Dip.fRampIn}")
|
||||||
private Double fRampIn;
|
private Double fRampIn;
|
||||||
@Value("${Dip.fRampOut}")
|
@Value("${Dip.fRampOut}")
|
||||||
private Double fRampOut;
|
private Double fRampOut;
|
||||||
// @Value("${Dip.fAfterTime}")
|
// @Value("${Dip.fAfterTime}")
|
||||||
// private Double fAfterTime;
|
// private Double fAfterTime;
|
||||||
@Value("${Flicker.waveFluType}")
|
@Value("${Flicker.waveFluType}")
|
||||||
private String waveFluType;
|
private String waveFluType;
|
||||||
@@ -91,6 +93,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
private final IDevTypeService devTypeService;
|
private final IDevTypeService devTypeService;
|
||||||
private final IDictTreeService dictTreeService;
|
private final IDictTreeService dictTreeService;
|
||||||
private final AdPlanMapper adPlanMapper;
|
private final AdPlanMapper adPlanMapper;
|
||||||
|
private final IPqSourceService pqSourceService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -781,7 +784,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
@Override
|
@Override
|
||||||
public Set<String> getScriptToIcdCheckInfo(PreDetectionParam param) {
|
public Set<String> getScriptToIcdCheckInfo(PreDetectionParam param) {
|
||||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||||
issueParam.setSourceId(param.getSourceId());
|
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||||
|
issueParam.setSourceId(sourceInitialize.getSourceId());
|
||||||
issueParam.setDevIds(param.getDevIds());
|
issueParam.setDevIds(param.getDevIds());
|
||||||
issueParam.setScriptId(param.getScriptId());
|
issueParam.setScriptId(param.getScriptId());
|
||||||
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
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++) {
|
for (int i = 0; i < pqScriptDtls.size(); i++) {
|
||||||
PqScriptDtls scriptDtls = pqScriptDtls.get(i);
|
PqScriptDtls scriptDtls = pqScriptDtls.get(i);
|
||||||
// 注意此处scriptDtls.getValue() < 1.0,考虑到有些已经投入运行的地方,可能没有改库,避免不必要的异常
|
// 注意此处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());
|
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
|
# url: jdbc:mysql://192.168.1.24:13306/pqs91002?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||||
# username: root
|
# username: root
|
||||||
# password: njcnpqs
|
# 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
|
username: root
|
||||||
password: njcnpqs
|
password: njcnpqs
|
||||||
#初始化建立物理连接的个数、最小、最大连接数
|
#初始化建立物理连接的个数、最小、最大连接数
|
||||||
@@ -129,5 +129,8 @@ activate:
|
|||||||
|
|
||||||
freq-converter:
|
freq-converter:
|
||||||
schedule-period: 200 #定时器运行间隔
|
schedule-period: 200 #定时器运行间隔
|
||||||
no-tolerant: 4 #不耐受状态
|
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