微调
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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)) {
|
||||||
@@ -298,7 +300,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.getNoTolerant()) ? 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);
|
||||||
@@ -307,7 +309,9 @@ public class SocketFreqConverterDevService {
|
|||||||
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.setDipId(pqDipData.getId());
|
||||||
testRes.setTolerant(originalTolerant ? status.getStatusWord1() != freqConverterConfig.getNoTolerant() : false);
|
testRes.setTolerant(originalTolerant == 1 ?
|
||||||
|
(status.getStatusWord1() != freqConverterConfig.getNoTolerant() ? 1 : 0)
|
||||||
|
: 0);
|
||||||
testRes.setStartTime(lastStatusData.getTimestamp());
|
testRes.setStartTime(lastStatusData.getTimestamp());
|
||||||
|
|
||||||
FormalTestManager.pendingDipTaskMap.put(pqDipData.getId(), new FormalTestManager.PendingDipTask(
|
FormalTestManager.pendingDipTaskMap.put(pqDipData.getId(), new FormalTestManager.PendingDipTask(
|
||||||
|
|||||||
@@ -104,12 +104,14 @@ public class SocketFreqConverterService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(String userId, String converterId, String monitorId) {
|
public void init(String userId, String converterId, String monitorId, Boolean reset) {
|
||||||
this.userId = userId;
|
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 +122,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());
|
||||||
@@ -269,7 +271,8 @@ public class SocketFreqConverterService {
|
|||||||
testRes.setEndTime(freqConverterStatus.getTimestamp().isAfter(task.getTargetEndTime())
|
testRes.setEndTime(freqConverterStatus.getTimestamp().isAfter(task.getTargetEndTime())
|
||||||
? freqConverterStatus.getTimestamp()
|
? freqConverterStatus.getTimestamp()
|
||||||
: task.getTargetEndTime());
|
: task.getTargetEndTime());
|
||||||
testRes.setTolerant(testRes.getTolerant() && (freqConverterStatus.getStatusWord1() != freqConverterConfig.getNoTolerant()));
|
|
||||||
|
testRes.setTolerant(testRes.getTolerant() & (freqConverterStatus.getStatusWord1() != freqConverterConfig.getNoTolerant() ? 1 : 0));
|
||||||
testResList.add(testRes);
|
testResList.add(testRes);
|
||||||
|
|
||||||
if (freqConverterStatus.getTimestamp().isAfter(task.getTargetEndTime())) {
|
if (freqConverterStatus.getTimestamp().isAfter(task.getTargetEndTime())) {
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -394,7 +394,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 +406,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -231,9 +231,9 @@ public class FormalTestManager {
|
|||||||
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;
|
||||||
|
|||||||
@@ -103,4 +103,14 @@ public class FreqConverterController extends BaseController {
|
|||||||
List<TolerantPointVO> tolerantPoints = freqConverterService.getDipPoints(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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ public class PqFreqConverterTestRes {
|
|||||||
private String dipId;
|
private String dipId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 0为不耐受,1为耐受
|
* 0为不耐受,1为耐受,2为特性曲线点
|
||||||
*/
|
*/
|
||||||
private Boolean tolerant;
|
private Integer tolerant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 该暂降时期对应变频器的起始时间戳
|
* 该暂降时期对应变频器的起始时间戳
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class TolerantPointVO {
|
|||||||
private Double residualVoltage;
|
private Double residualVoltage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否耐受
|
* 是否耐受。0-否,1-是,2-表示特性曲线点
|
||||||
*/
|
*/
|
||||||
private boolean tolerant;
|
private Integer tolerant;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,4 +51,12 @@ public interface IFreqConverterService extends IService<FreqConverterStatus> {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ 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.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,15 +82,18 @@ public class FreqConverterServiceImpl extends ServiceImpl<FreqConverterStatusMap
|
|||||||
|
|
||||||
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX + suffix);
|
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX + suffix);
|
||||||
List<PqFreqConverterTestRes> pqFreqConverterTestResList = pqFreqConverterTestResService.list();
|
List<PqFreqConverterTestRes> pqFreqConverterTestResList = pqFreqConverterTestResService.list();
|
||||||
|
DynamicTableNameHandler.remove();
|
||||||
List<TolerantPointVO> result = pqFreqConverterTestResList.stream().map(item -> {
|
List<TolerantPointVO> result = pqFreqConverterTestResList.stream().map(item -> {
|
||||||
|
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_DIP_DATA_TB_PREFIX + suffix);
|
||||||
PqDipData pqDipData = dipDataService.getById(item.getDipId());
|
PqDipData pqDipData = dipDataService.getById(item.getDipId());
|
||||||
|
DynamicTableNameHandler.remove();
|
||||||
TolerantPointVO tolerantPointVO = new TolerantPointVO();
|
TolerantPointVO tolerantPointVO = new TolerantPointVO();
|
||||||
tolerantPointVO.setDurationMs(pqDipData.getDurationMs());
|
tolerantPointVO.setDurationMs(pqDipData.getDurationMs());
|
||||||
tolerantPointVO.setResidualVoltage(pqDipData.getResidualVoltage());
|
tolerantPointVO.setResidualVoltage(pqDipData.getResidualVoltage());
|
||||||
tolerantPointVO.setTolerant(item.getTolerant());
|
tolerantPointVO.setTolerant(item.getTolerant());
|
||||||
return tolerantPointVO;
|
return tolerantPointVO;
|
||||||
}).collect(Collectors.toList());
|
}).sorted(Comparator.comparingInt(TolerantPointVO::getDurationMs)).collect(Collectors.toList());
|
||||||
DynamicTableNameHandler.remove();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -112,4 +119,39 @@ 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));
|
||||||
|
|
||||||
|
List<TolerantPointVO> result = new ArrayList<>();
|
||||||
|
durationPointMap.entrySet().stream()
|
||||||
|
.sorted(Map.Entry.comparingByKey())
|
||||||
|
.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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class PqFreqConverterConfigServiceImpl extends ServiceImpl<PqFreqConverte
|
|||||||
* 表名前缀
|
* 表名前缀
|
||||||
*/
|
*/
|
||||||
public static final String PQ_FREQ_CONVERTER_STATUS_TB_PREFIX = "pq_freq_converter_status_";
|
public static final String PQ_FREQ_CONVERTER_STATUS_TB_PREFIX = "pq_freq_converter_status_";
|
||||||
public static final String PQ_DIP_DATA_TB_PREFIX = "pq_diq_data_";
|
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_";
|
public static final String PQ_FREQ_CONVERTER_TEST_RES_TB_PREFIX = "pq_freq_converter_test_res_";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user