7 Commits

Author SHA1 Message Date
caozehui
99c7448544 Merge remote-tracking branch 'origin/hainan' into hainan
# Conflicts:
#	detection/src/main/java/com/njcn/gather/detection/util/socket/FormalTestManager.java
2026-04-23 14:08:43 +08:00
caozehui
83296d257c 微调 2026-04-23 13:59:18 +08:00
caozehui
e020aa466e 调整变频器耐受状态字段 2026-04-22 20:39:53 +08:00
caozehui
f20e2c9b32 微调 2026-04-22 09:34:53 +08:00
caozehui
e03c3e3607 状态清空 2026-04-20 09:08:25 +08:00
caozehui
27f25d2404 微调 2026-04-17 08:56:15 +08:00
caozehui
a77313171c 向前端推送暂降点 2026-04-16 15:24:00 +08:00
15 changed files with 201 additions and 67 deletions

View File

@@ -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);
} }

View File

@@ -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.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);
@@ -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.getTolerant() ? 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(
@@ -345,8 +349,28 @@ 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.clearFreqConverterRuntimeState();
}
} }
} }

View File

@@ -9,6 +9,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;
@@ -104,12 +105,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 +123,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 +150,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 +176,15 @@ 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;
} }
private void handleInitSerial(String converterChannelTag, FreqConverterRespDTO respDTO) { private void handleInitSerial(String converterChannelTag, FreqConverterRespDTO respDTO) {
@@ -251,6 +265,29 @@ 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.clearFreqConverterRuntimeState();
}
}
private void consumePendingDipTasks(FreqConverterStatus freqConverterStatus) { private void consumePendingDipTasks(FreqConverterStatus freqConverterStatus) {
if (FormalTestManager.pendingDipTaskMap.isEmpty()) { if (FormalTestManager.pendingDipTaskMap.isEmpty()) {
return; return;
@@ -269,7 +306,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.getTolerant() ? 1 : 0));
testResList.add(testRes); testResList.add(testRes);
if (freqConverterStatus.getTimestamp().isAfter(task.getTargetEndTime())) { if (freqConverterStatus.getTimestamp().isAfter(task.getTargetEndTime())) {

View File

@@ -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);
} }

View File

@@ -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;
} }

View File

@@ -226,14 +226,25 @@ public class FormalTestManager {
*/ */
public static boolean isXu; public static boolean isXu;
/**
* 清理变频器耐受实验运行态数据
*/
public static void clearFreqConverterRuntimeState() {
freqConverterStep = null;
freqConverterDevStep = null;
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;

View File

@@ -13,6 +13,6 @@ 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;
} }

View File

@@ -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);
}
@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); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, tolerantPoints, methodDescribe);
} }
} }

View File

@@ -23,9 +23,9 @@ public class PqFreqConverterTestRes {
private String dipId; private String dipId;
/** /**
* 0为不耐受1为耐受 * 0为不耐受1为耐受2为特性曲线点
*/ */
private Boolean tolerant; private Integer tolerant;
/** /**
* 该暂降时期对应变频器的起始时间戳 * 该暂降时期对应变频器的起始时间戳

View File

@@ -19,7 +19,7 @@ public class TolerantPointVO {
private Double residualVoltage; private Double residualVoltage;
/** /**
* 是否耐受 * 是否耐受。0-否1-是2-表示特性曲线点
*/ */
private boolean tolerant; private Integer tolerant;
} }

View File

@@ -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);
} }

View File

@@ -21,6 +21,8 @@ import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; 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;
/** /**
@@ -41,13 +43,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 +60,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 +71,36 @@ 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();
DynamicTableNameHandler.remove();
List<TolerantPointVO> result = pqFreqConverterTestResList.stream().map(item -> {
DynamicTableNameHandler.setTableName(PqFreqConverterConfigServiceImpl.PQ_DIP_DATA_TB_PREFIX + suffix);
PqDipData pqDipData = dipDataService.getById(item.getDipId());
DynamicTableNameHandler.remove();
TolerantPointVO tolerantPointVO = new TolerantPointVO(); TolerantPointVO tolerantPointVO = new TolerantPointVO();
tolerantPointVO.setDurationMs(dipData.getDurationMs()); tolerantPointVO.setDurationMs(pqDipData.getDurationMs());
tolerantPointVO.setResidualVoltage(dipData.getResidualVoltage()); tolerantPointVO.setResidualVoltage(pqDipData.getResidualVoltage());
List<PqFreqConverterTestRes> matchedResList = testResList.stream() tolerantPointVO.setTolerant(item.getTolerant());
.filter(item -> dipData.getId().equals(item.getDipId())) return tolerantPointVO;
.collect(Collectors.toList()); }).sorted(Comparator.comparingInt(TolerantPointVO::getDurationMs)).collect(Collectors.toList());
boolean tolerant = matchedResList.stream().allMatch(PqFreqConverterTestRes::getTolerant);
tolerantPointVO.setTolerant(tolerant);
res.add(tolerantPointVO); return result;
}
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 +111,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 +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;
}
} }

View File

@@ -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,7 +79,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_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'," + " `dip_id` char(32) NOT NULL COMMENT '装置暂降数据id'," +
" `start_time` datetime(3) DEFAULT NULL COMMENT '该暂降时期对应变频器的起始时间戳'," + " `start_time` datetime(3) DEFAULT NULL COMMENT '该暂降时期对应变频器的起始时间戳'," +
@@ -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);

View File

@@ -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 + "";

View File

@@ -129,5 +129,5 @@ activate:
freq-converter: freq-converter:
schedule-period: 200 #定时器运行间隔 schedule-period: 200 #定时器运行间隔
no-tolerant: 4 #耐受状态 tolerant: 1 #耐受状态
dt: 200 #延迟时间ms dt: 200 #延迟时间ms