微调
This commit is contained in:
@@ -2,6 +2,7 @@ package com.njcn.gather.detection.handler;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
@@ -20,10 +21,15 @@ import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyFreqConverterDevClientHandler;
|
||||
import com.njcn.gather.detection.util.socket.config.SocketConnectionConfig;
|
||||
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.dip.pojo.po.PqDipData;
|
||||
import com.njcn.gather.dip.service.IPqDipDataService;
|
||||
import com.njcn.gather.freqConverter.config.FreqConverterConfig;
|
||||
import com.njcn.gather.freqConverter.pojo.po.FreqConverterStatus;
|
||||
import com.njcn.gather.freqConverter.pojo.po.PqFreqConverterTestRes;
|
||||
import com.njcn.gather.freqConverter.service.IFreqConverterService;
|
||||
import com.njcn.gather.freqConverter.service.IPqFreqConverterTestResService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -42,7 +48,9 @@ public class SocketFreqConverterDevService {
|
||||
private final SocketConnectionConfig socketConnectionConfig;
|
||||
private final IPqDevService pqDevService;
|
||||
private final IPqDipDataService pqDipDataService;
|
||||
private final IFreqConverterService freqConverterService;
|
||||
private final IPqFreqConverterTestResService pqFreqConverterTestResService;
|
||||
private final FreqConverterConfig freqConverterConfig;
|
||||
private String monitorId;
|
||||
private String userId;
|
||||
|
||||
@@ -68,6 +76,7 @@ public class SocketFreqConverterDevService {
|
||||
FormalTestManager.freqConverterDevStep = null;
|
||||
FormalTestManager.stopFlag = false;
|
||||
FormalTestManager.isRemoveSocket = false;
|
||||
FormalTestManager.pendingDipTaskMap.clear();
|
||||
pqDipDataService.clearAllData(FormalTestManager.freqConverterTableSuffix);
|
||||
pqFreqConverterTestResService.clearAllData(FormalTestManager.freqConverterTableSuffix);
|
||||
this.userId = userId;
|
||||
@@ -122,7 +131,7 @@ public class SocketFreqConverterDevService {
|
||||
FormalTestManager.freqConverterDevStep = SourceOperateCodeEnum.FORMAL_REAL;
|
||||
break;
|
||||
default:
|
||||
log.info("设备响应异常,devTag={}, operateCode={}, code={}, data={}", devTag, socketDataMsg.getOperateCode(), socketDataMsg.getCode(), socketDataMsg.getData());
|
||||
log.warn("设备响应异常,devTag={}, operateCode={}, code={}, data={}", devTag, socketDataMsg.getOperateCode(), socketDataMsg.getCode(), socketDataMsg.getData());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -147,7 +156,7 @@ public class SocketFreqConverterDevService {
|
||||
case DATA_RESOLVE:
|
||||
case NO_INIT_DEV:
|
||||
default:
|
||||
log.info("设备响应异常,devTag={}, operateCode={}, code={}, data={}", devTag, socketDataMsg.getOperateCode(), socketDataMsg.getCode(), socketDataMsg.getData());
|
||||
log.warn("设备响应异常,devTag={}, operateCode={}, code={}, data={}", devTag, socketDataMsg.getOperateCode(), socketDataMsg.getCode(), socketDataMsg.getData());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -156,6 +165,8 @@ public class SocketFreqConverterDevService {
|
||||
SourceResponseCodeEnum responseCodeEnum = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
|
||||
switch (responseCodeEnum) {
|
||||
case UNPROCESSED_BUSINESS:
|
||||
break;
|
||||
case SUCCESS:
|
||||
cleanup(devTag);
|
||||
break;
|
||||
@@ -203,12 +214,15 @@ public class SocketFreqConverterDevService {
|
||||
|
||||
private void sendGetDipDataMsg(String devTag) {
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue());
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue()+"&&VOLTAGE");
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
|
||||
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
||||
String[] split = this.monitorId.split(String.valueOf(StrUtil.C_UNDERLINE));
|
||||
PqDev dev = pqDevService.getById(split[0]);
|
||||
|
||||
// 设置监测点ID列表
|
||||
phaseSequenceParam.setMoniterIdList(ListUtil.of(this.monitorId));
|
||||
phaseSequenceParam.setMoniterIdList(ListUtil.of(dev.getIp()+StrUtil.C_UNDERLINE+split[1]));
|
||||
|
||||
// 设置数据类型列表
|
||||
phaseSequenceParam.setDataType(ListUtil.of("avg$MAG", "avg$DUR"));
|
||||
@@ -253,12 +267,34 @@ public class SocketFreqConverterDevService {
|
||||
}
|
||||
|
||||
PqDipData pqDipData = new PqDipData();
|
||||
pqDipData.setId(IdUtil.fastSimpleUUID());
|
||||
pqDipData.setStartTime(LocalDateTime.parse(devData.getTime()));
|
||||
pqDipData.setResidualVoltage(residualVoltage);
|
||||
pqDipData.setDurationMs(durationMs);
|
||||
DynamicTableNameHandler.setTableName("pq_dip_data_" + FormalTestManager.freqConverterTableSuffix);
|
||||
pqDipDataService.save(pqDipData);
|
||||
DynamicTableNameHandler.remove();
|
||||
|
||||
this.initDipTestRes(pqDipData);
|
||||
}
|
||||
|
||||
private void initDipTestRes(PqDipData pqDipData) {
|
||||
Integer suffix = FormalTestManager.freqConverterTableSuffix;
|
||||
List<FreqConverterStatus> statusList = freqConverterService.getDipDurationStatusData(suffix, pqDipData.getStartTime(), LocalDateTime.now());
|
||||
List<PqFreqConverterTestRes> testResList = new ArrayList<>();
|
||||
for (FreqConverterStatus status : statusList) {
|
||||
PqFreqConverterTestRes testRes = new PqFreqConverterTestRes();
|
||||
testRes.setDipId(pqDipData.getId());
|
||||
testRes.setStatusId(status.getId());
|
||||
testRes.setTolerant(status.getStatusWord1() != freqConverterConfig.getNoTolerant());
|
||||
testResList.add(testRes);
|
||||
}
|
||||
pqFreqConverterTestResService.saveTestRes(suffix, testResList);
|
||||
|
||||
int collectCount = (int) Math.ceil((freqConverterConfig.getDt()) / freqConverterConfig.getSchedulePeriod());
|
||||
if (collectCount > 0) {
|
||||
FormalTestManager.pendingDipTaskMap.put(pqDipData.getId(), new FormalTestManager.PendingDipTask(pqDipData.getId(), collectCount));
|
||||
}
|
||||
}
|
||||
|
||||
private Double getSqlDataValue(DevData.SqlDataDTO.ListDTO listDTO) {
|
||||
|
||||
@@ -13,17 +13,18 @@ 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.NettyFreqConverterClientHandler;
|
||||
import com.njcn.gather.detection.util.socket.config.SocketConnectionConfig;
|
||||
import com.njcn.gather.freqConverter.config.FreqConverterConfig;
|
||||
import com.njcn.gather.freqConverter.pojo.po.FreqConverterStatus;
|
||||
import com.njcn.gather.freqConverter.pojo.po.PqFreqConverterConfig;
|
||||
import com.njcn.gather.freqConverter.pojo.po.PqFreqConverterTestRes;
|
||||
import com.njcn.gather.freqConverter.service.IFreqConverterService;
|
||||
import com.njcn.gather.freqConverter.service.IPqFreqConverterConfigService;
|
||||
import com.njcn.gather.freqConverter.service.IPqFreqConverterTestResService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -41,7 +42,9 @@ public class SocketFreqConverterService {
|
||||
private final SocketConnectionConfig socketConnectionConfig;
|
||||
|
||||
private final IPqFreqConverterConfigService pqFreqConverterConfigService;
|
||||
private final IPqFreqConverterTestResService pqFreqConverterTestResService;
|
||||
private String userId;
|
||||
private final FreqConverterConfig freqConverterConfig;
|
||||
|
||||
/**
|
||||
* 连接变频器Socket
|
||||
@@ -98,13 +101,16 @@ public class SocketFreqConverterService {
|
||||
}
|
||||
}
|
||||
|
||||
private void init(String userId, String converterId, String monitorId) {
|
||||
public void init(String userId, String converterId, String monitorId) {
|
||||
this.userId = userId;
|
||||
FormalTestManager.freqConverterStep = null;
|
||||
FormalTestManager.currentFreqConverterId = converterId;
|
||||
Integer suffix = pqFreqConverterConfigService.getSuffix(converterId);
|
||||
freqConverterService.clearAllData(suffix);
|
||||
FormalTestManager.freqConverterTableSuffix = suffix;
|
||||
FormalTestManager.isRemoveSocket = false;
|
||||
FormalTestManager.pendingDipTaskMap.clear();
|
||||
pqFreqConverterConfigService.updateTestStatus(converterId, 0);
|
||||
clearScheduleTask();
|
||||
}
|
||||
|
||||
@@ -172,10 +178,10 @@ public class SocketFreqConverterService {
|
||||
FormalTestManager.scheduler = Executors.newScheduledThreadPool(1);
|
||||
FormalTestManager.scheduledFuture = FormalTestManager.scheduler.scheduleAtFixedRate(() -> {
|
||||
this.sendGetDeviceStatusMsg(converterChannelTag);
|
||||
}, 0l, 200l, TimeUnit.SECONDS);
|
||||
}, 0l, freqConverterConfig.getSchedulePeriod(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
} else {
|
||||
log.error("变频器初始化串口失败,converterChannelTag={}, converterId={}, converterTag={}, msg={}", converterChannelTag, converterChannelTag, converterChannelTag, respDTO.getMessage());
|
||||
log.warn("变频器初始化串口失败,converterChannelTag={}, converterId={}, converterTag={}, msg={}", converterChannelTag, converterChannelTag, converterChannelTag, respDTO.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,16 +193,20 @@ public class SocketFreqConverterService {
|
||||
|
||||
FreqConverterStatus freqConverterStatus = JSON.parseObject(obj.toString(), FreqConverterStatus.class);
|
||||
// 变频器故障中,移除这段时期内的设备数据
|
||||
if (freqConverterStatus.getStatusWord1() == 4) {
|
||||
if (freqConverterStatus.getStatusWord1() == freqConverterConfig.getNoTolerant()) {
|
||||
FormalTestManager.stopFlag = true;
|
||||
} else {
|
||||
FormalTestManager.stopFlag = false;
|
||||
}
|
||||
freqConverterService.saveFreqConverterStatus(FormalTestManager.freqConverterTableSuffix, freqConverterStatus);
|
||||
this.consumePendingDipTasks(freqConverterStatus);
|
||||
}
|
||||
|
||||
private void handleCloseSerial(String converterChannelTag, FreqConverterRespDTO respDTO) {
|
||||
if (respDTO.getCode() == 0 && respDTO.getSuccess()) {
|
||||
if (FormalTestManager.currentFreqConverterId != null) {
|
||||
pqFreqConverterConfigService.updateTestStatus(FormalTestManager.currentFreqConverterId, 1);
|
||||
}
|
||||
cleanup(converterChannelTag);
|
||||
} else {
|
||||
this.sendClose(converterChannelTag);
|
||||
@@ -238,6 +248,37 @@ public class SocketFreqConverterService {
|
||||
}
|
||||
}
|
||||
|
||||
private void consumePendingDipTasks(FreqConverterStatus freqConverterStatus) {
|
||||
if (FormalTestManager.pendingDipTaskMap.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<PqFreqConverterTestRes> resList = new ArrayList<>();
|
||||
Integer suffix = FormalTestManager.freqConverterTableSuffix;
|
||||
List<String> finishedDipIdList = new ArrayList<>();
|
||||
for (FormalTestManager.PendingDipTask task : FormalTestManager.pendingDipTaskMap.values()) {
|
||||
if (task.getRemainingCount() <= 0) {
|
||||
finishedDipIdList.add(task.getDipId());
|
||||
continue;
|
||||
}
|
||||
|
||||
PqFreqConverterTestRes testRes = new PqFreqConverterTestRes();
|
||||
testRes.setDipId(task.getDipId());
|
||||
testRes.setStatusId(freqConverterStatus.getId());
|
||||
testRes.setTolerant(freqConverterStatus.getStatusWord1() != freqConverterConfig.getNoTolerant());
|
||||
resList.add(testRes);
|
||||
|
||||
task.decrementRemainingCount();
|
||||
if (task.getRemainingCount() <= 0) {
|
||||
finishedDipIdList.add(task.getDipId());
|
||||
}
|
||||
}
|
||||
pqFreqConverterTestResService.saveTestRes(suffix, resList);
|
||||
|
||||
for (String dipId : finishedDipIdList) {
|
||||
FormalTestManager.pendingDipTaskMap.remove(dipId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -397,6 +397,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
public void startFreqConverter(String userId, String converterId, String monitorId) {
|
||||
String freqConverterTag = userId + CnSocketUtil.FREQ_CONVERTER_TAG;
|
||||
String devTag = userId + CnSocketUtil.DEV_TAG;
|
||||
// socketFreqConverterService.init(userId, converterId, monitorId);
|
||||
socketFreqConverterService.connectSocket(freqConverterTag);
|
||||
socketFreqConverterDevService.connectSocket(devTag);
|
||||
|
||||
@@ -404,7 +405,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
long timeout = 3000; // 3秒超时时间
|
||||
while (true) {
|
||||
if (SocketManager.isChannelActive(freqConverterTag) && SocketManager.isChannelActive(devTag)) {
|
||||
// if (SocketManager.isChannelActive(freqConverterTag)) {
|
||||
// if (SocketManager.isChannelActive(devTag)) {
|
||||
socketFreqConverterService.connectionFreqConverter(userId, freqConverterTag, converterId, monitorId);
|
||||
socketFreqConverterDevService.connectionDev(userId, devTag, converterId, monitorId);
|
||||
break;
|
||||
|
||||
@@ -38,6 +38,13 @@ public class FormalTestManager {
|
||||
*/
|
||||
public static Integer freqConverterTableSuffix;
|
||||
|
||||
public static String currentFreqConverterId;
|
||||
|
||||
/**
|
||||
* 待采集后续变频器状态的Dip任务
|
||||
*/
|
||||
public static Map<String, PendingDipTask> pendingDipTaskMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* key:设备ip,value:当前设备下面的监测点ID(ip_通道号)
|
||||
*/
|
||||
@@ -215,4 +222,26 @@ public class FormalTestManager {
|
||||
* 是否进行相序校验
|
||||
*/
|
||||
public static boolean isXu;
|
||||
|
||||
public static class PendingDipTask {
|
||||
private final String dipId;
|
||||
private int remainingCount;
|
||||
|
||||
public PendingDipTask(String dipId, int remainingCount) {
|
||||
this.dipId = dipId;
|
||||
this.remainingCount = remainingCount;
|
||||
}
|
||||
|
||||
public String getDipId() {
|
||||
return dipId;
|
||||
}
|
||||
|
||||
public int getRemainingCount() {
|
||||
return remainingCount;
|
||||
}
|
||||
|
||||
public void decrementRemainingCount() {
|
||||
this.remainingCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,12 +32,8 @@ public class NettyFreqConverterDevClientHandler extends SimpleChannelInboundHand
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||
if (FormalTestManager.stopFlag) {
|
||||
log.debug("变频器异常或重连中,丢弃设备数据,devChannelTag={}, msg={}", devChannelTag, msg);
|
||||
return;
|
||||
}
|
||||
log.info("收到设备消息,devChannelTag={}, msg={},FormalTestManager.stopFlag={}", devChannelTag, msg, FormalTestManager.stopFlag);
|
||||
|
||||
log.info("收到设备消息,devChannelTag={}, msg={}", devChannelTag, msg);
|
||||
socketFreqConverterDevService.handleRead(devChannelTag, msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -189,4 +189,14 @@ public class PqDevController extends BaseController {
|
||||
}
|
||||
return pqDevService.importDev(file, patternId, planId, response, cover);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/listAll")
|
||||
@ApiOperation("查询所有未删除设备数据")
|
||||
public HttpResult<List<PqDevVO>> listAll() {
|
||||
String methodDescribe = getMethodDescribe("listAll");
|
||||
LogUtil.njcnDebug(log, "{},查询所有设备", methodDescribe);
|
||||
List<PqDevVO> result = pqDevService.listAll();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,4 +288,6 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @return
|
||||
*/
|
||||
List<ContrastDevExcel> getExportContrastDevData(List<PqDevVO> pqDevVOList);
|
||||
|
||||
List<PqDevVO> listAll();
|
||||
}
|
||||
|
||||
@@ -1625,4 +1625,31 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqDevVO> listAll() {
|
||||
return this.lambdaQuery()
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
.orderByDesc(PqDev::getCreateTime)
|
||||
.list().stream().map(pqDev -> {
|
||||
PqDevVO pqDevVO = new PqDevVO();
|
||||
BeanUtil.copyProperties(pqDev, pqDevVO);
|
||||
// 解密序列号和密钥
|
||||
if (StrUtil.isNotBlank(pqDevVO.getSeries())) {
|
||||
pqDevVO.setSeries(EncryptionUtil.decoderString(1, pqDevVO.getSeries()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDevVO.getDevKey())) {
|
||||
pqDevVO.setDevKey(EncryptionUtil.decoderString(1, pqDevVO.getDevKey()));
|
||||
}
|
||||
// 填充设备类型信息
|
||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||
if (ObjectUtil.isNotNull(devType)) {
|
||||
pqDevVO.setDevType(devType.getName());
|
||||
pqDevVO.setDevChns(devType.getDevChns());
|
||||
pqDevVO.setDevVolt(devType.getDevVolt());
|
||||
pqDevVO.setDevCurr(devType.getDevCurr());
|
||||
}
|
||||
return pqDevVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.gather.freqConverter.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-04-15
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "freq-converter")
|
||||
public class FreqConverterConfig {
|
||||
private Long schedulePeriod;
|
||||
private Integer noTolerant;
|
||||
private Integer dt;
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.njcn.gather.freqConverter.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.pojo.constant.DetectionValidMessage;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@@ -40,6 +39,7 @@ public class PqFreqConverterParam {
|
||||
|
||||
@ApiModelProperty(value = "串口读写超时,单位毫秒", required = true)
|
||||
private Integer timeoutMs;
|
||||
private Integer testStatus;
|
||||
|
||||
/**
|
||||
* 分页查询实体
|
||||
|
||||
@@ -61,6 +61,11 @@ public class PqFreqConverterConfig extends BaseEntity {
|
||||
*/
|
||||
private Integer suffix;
|
||||
|
||||
/**
|
||||
* 检测状态,0未检测,1检测完成
|
||||
*/
|
||||
private Integer testStatus;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.freqConverter.pojo.po.FreqConverterStatus;
|
||||
import com.njcn.gather.freqConverter.pojo.vo.TolerantPointVO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -46,4 +47,6 @@ public interface IFreqConverterService extends IService<FreqConverterStatus> {
|
||||
* @return 是否耐受
|
||||
*/
|
||||
List<TolerantPointVO> getTolerantPoints(String converterId);
|
||||
|
||||
List<FreqConverterStatus> getDipDurationStatusData(Integer suffix, LocalDateTime startTime, LocalDateTime endTime);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.njcn.gather.freqConverter.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.freqConverter.pojo.param.PqFreqConverterParam;
|
||||
import com.njcn.gather.freqConverter.pojo.po.PqFreqConverterConfig;
|
||||
|
||||
@@ -23,4 +22,6 @@ public interface IPqFreqConverterConfigService extends IService<PqFreqConverterC
|
||||
|
||||
boolean deletePqFreqConverterConfig(List<String> ids);
|
||||
|
||||
boolean updateTestStatus(String converterId, Integer testStatus);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.njcn.gather.freqConverter.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.freqConverter.pojo.po.PqFreqConverterTestRes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-04-14
|
||||
@@ -15,4 +17,21 @@ public interface IPqFreqConverterTestResService extends IService<PqFreqConverter
|
||||
* @return
|
||||
*/
|
||||
void clearAllData(Integer suffix);
|
||||
|
||||
/**
|
||||
* 保存结果记录
|
||||
*
|
||||
* @param suffix 表后缀
|
||||
* @param testResList 结果数据
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean saveTestRes(Integer suffix, List<PqFreqConverterTestRes> testResList);
|
||||
|
||||
/**
|
||||
* 查询结果记录
|
||||
*
|
||||
* @param suffix 表后缀
|
||||
* @return 结果列表
|
||||
*/
|
||||
List<PqFreqConverterTestRes> listTestRes(Integer suffix);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.freqConverter.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
@@ -7,9 +8,11 @@ import com.njcn.gather.dip.pojo.po.PqDipData;
|
||||
import com.njcn.gather.dip.service.IPqDipDataService;
|
||||
import com.njcn.gather.freqConverter.mapper.FreqConverterStatusMapper;
|
||||
import com.njcn.gather.freqConverter.pojo.po.FreqConverterStatus;
|
||||
import com.njcn.gather.freqConverter.pojo.po.PqFreqConverterTestRes;
|
||||
import com.njcn.gather.freqConverter.pojo.vo.TolerantPointVO;
|
||||
import com.njcn.gather.freqConverter.service.IFreqConverterService;
|
||||
import com.njcn.gather.freqConverter.service.IPqFreqConverterConfigService;
|
||||
import com.njcn.gather.freqConverter.service.IPqFreqConverterTestResService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -18,6 +21,7 @@ import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 变频器状态数据Service实现类
|
||||
@@ -35,10 +39,14 @@ import java.util.List;
|
||||
public class FreqConverterServiceImpl extends ServiceImpl<FreqConverterStatusMapper, FreqConverterStatus> implements IFreqConverterService {
|
||||
private final IPqFreqConverterConfigService pqFreqConverterConfigService;
|
||||
private final IPqDipDataService dipDataService;
|
||||
private final IPqFreqConverterTestResService pqFreqConverterTestResService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean saveFreqConverterStatus(Integer suffix, FreqConverterStatus status) {
|
||||
if (status.getId() == null) {
|
||||
status.setId(IdUtil.fastSimpleUUID());
|
||||
}
|
||||
DynamicTableNameHandler.setTableName("pq_freq_converter_status_" + suffix);
|
||||
boolean result = this.save(status);
|
||||
DynamicTableNameHandler.remove();
|
||||
@@ -68,8 +76,8 @@ public class FreqConverterServiceImpl extends ServiceImpl<FreqConverterStatusMap
|
||||
@Override
|
||||
public List<TolerantPointVO> getTolerantPoints(String converterId) {
|
||||
Integer suffix = pqFreqConverterConfigService.getSuffix(converterId);
|
||||
List<FreqConverterStatus> freqConverterDataList = this.listStatusData(converterId);
|
||||
List<PqDipData> dipDataList = dipDataService.listDipData(suffix);
|
||||
List<PqFreqConverterTestRes> testResList = pqFreqConverterTestResService.listTestRes(suffix);
|
||||
dipDataList.sort(Comparator.comparing(PqDipData::getDurationMs));
|
||||
|
||||
List<TolerantPointVO> res = new ArrayList<>();
|
||||
@@ -77,18 +85,26 @@ public class FreqConverterServiceImpl extends ServiceImpl<FreqConverterStatusMap
|
||||
TolerantPointVO tolerantPointVO = new TolerantPointVO();
|
||||
tolerantPointVO.setDurationMs(dipData.getDurationMs());
|
||||
tolerantPointVO.setResidualVoltage(dipData.getResidualVoltage());
|
||||
LocalDateTime dipEndTime = dipData.getStartTime().plusNanos(dipData.getDurationMs() * 1_000_000L);
|
||||
FreqConverterStatus nextStatus = freqConverterDataList.stream()
|
||||
.filter(item -> item.getTimestamp() != null && !item.getTimestamp().isBefore(dipEndTime))
|
||||
.min(Comparator.comparing(FreqConverterStatus::getTimestamp))
|
||||
.orElse(null);
|
||||
if (nextStatus == null || nextStatus.getStatusWord1() == null || nextStatus.getStatusWord1() != 4) {
|
||||
tolerantPointVO.setTolerant(true);
|
||||
} else {
|
||||
tolerantPointVO.setTolerant(false);
|
||||
}
|
||||
List<PqFreqConverterTestRes> matchedResList = testResList.stream()
|
||||
.filter(item -> dipData.getId().equals(item.getDipId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
boolean tolerant = matchedResList.stream().allMatch(PqFreqConverterTestRes::getTolerant);
|
||||
tolerantPointVO.setTolerant(tolerant);
|
||||
|
||||
res.add(tolerantPointVO);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FreqConverterStatus> getDipDurationStatusData(Integer suffix, LocalDateTime startTime, LocalDateTime endTime) {
|
||||
DynamicTableNameHandler.setTableName("pq_freq_converter_status_" + suffix);
|
||||
List<FreqConverterStatus> result = this.lambdaQuery()
|
||||
.between(FreqConverterStatus::getTimestamp, startTime, endTime)
|
||||
.orderByDesc(FreqConverterStatus::getTimestamp)
|
||||
.list();
|
||||
DynamicTableNameHandler.remove();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ public class PqFreqConverterConfigServiceImpl extends ServiceImpl<PqFreqConverte
|
||||
|
||||
PqFreqConverterConfig pqFreqConverterConfig = BeanUtil.copyProperties(param, PqFreqConverterConfig.class);
|
||||
pqFreqConverterConfig.setSuffix(maxSuffix);
|
||||
pqFreqConverterConfig.setTestStatus(0);
|
||||
pqFreqConverterConfig.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(pqFreqConverterConfig);
|
||||
}
|
||||
@@ -115,4 +116,13 @@ public class PqFreqConverterConfigServiceImpl extends ServiceImpl<PqFreqConverte
|
||||
.in(CollectionUtil.isNotEmpty(ids), PqFreqConverterConfig::getId, ids)
|
||||
.set(PqFreqConverterConfig::getState, 0).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateTestStatus(String converterId, Integer testStatus) {
|
||||
return this.lambdaUpdate()
|
||||
.eq(PqFreqConverterConfig::getId, converterId)
|
||||
.set(PqFreqConverterConfig::getTestStatus, testStatus)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.freqConverter.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
import com.njcn.gather.freqConverter.mapper.PqFreqConverterTestResMapper;
|
||||
@@ -7,6 +8,8 @@ import com.njcn.gather.freqConverter.pojo.po.PqFreqConverterTestRes;
|
||||
import com.njcn.gather.freqConverter.service.IPqFreqConverterTestResService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-04-14
|
||||
@@ -19,4 +22,20 @@ public class PqFreqConverterTestResServiceImpl extends ServiceImpl<PqFreqConvert
|
||||
this.remove(null);
|
||||
DynamicTableNameHandler.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveTestRes(Integer suffix, List<PqFreqConverterTestRes> testResList) {
|
||||
DynamicTableNameHandler.setTableName("pq_freq_converter_test_res_" + suffix);
|
||||
boolean result = this.saveBatch(testResList);
|
||||
DynamicTableNameHandler.remove();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqFreqConverterTestRes> listTestRes(Integer suffix) {
|
||||
DynamicTableNameHandler.setTableName("pq_freq_converter_test_res_" + suffix);
|
||||
List<PqFreqConverterTestRes> result = this.list();
|
||||
DynamicTableNameHandler.remove();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ spring:
|
||||
datasource:
|
||||
druid:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://192.168.1.24:13306/pqs91002?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||
# username: root
|
||||
# password: njcnpqs
|
||||
# url: jdbc:mysql://192.168.1.24:13306/pqs91002?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||
# username: root
|
||||
# password: njcnpqs
|
||||
url: jdbc:mysql://192.168.1.24:13306/pqs9100?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
||||
username: root
|
||||
password: njcnpqs
|
||||
@@ -126,3 +126,8 @@ power-quality:
|
||||
activate:
|
||||
private-key: "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCcUyYhVqczGxblL+o/xZzF/8nf+LjrfUE/dS1aRHM7uMDD0cgCArhjtfneFePrMxt+Z7W8yNBzSarub8qsfhaVNikV7Es7oaeTygfjQXTi2n4AFkir3fM07J08RpWhl5M8f8uWTCuvFUYAw00gq55typqmnbkmJa2VIUy/iQf+cMCP7abz4/jNhUzUR3qA7TV4oMRgTdIEDUp63YF8dOC+JH8XxYrCVeHXV6fLCwmesdMzl0lB2VTEKMfLbXhOmF5g7P9y/16VCcN8UBuZlbyYfn+GAxJOSbeHi5HshOKfoSuD7Jz+3WQZpNavOWjIFExKIU38/CvnJCOP7XBCqpSTAgMBAAECggEAYeWokWRE3TpvwiOZnUpR/aVMdVi75a3ROL5XIpqPV61B+t/bU3cEpl0GF9C5pUeiRi0IoStZb3mI9D1KPW/REKyUWkhabQO1gFYbTnRlkNOn6MILzKX4cwJjDaZeeo4EBPU7N+qHyOOXrU6hdH5FfxhMdV983ajm5eeuupxER1C2kAcIklTeVpTX6EKOgZb5LBp5ssOVm2P42pOauvcRozRcvZmqnErXmukv0H4l3EVNt4rHpTn9riHUC63e8JfiYzVaF6zuNUxv6nHEft0/SRMw11XSTnNfDzcKqgjz6ksFBS/6eQQYKESk+ONC53HUuYHFAknkwsPupDCT2W8FIQKBgQDLHT/xCU3nxGr4vFKBDNaO2D5oK20ECbBO4oDvLWWmQG7f+6TsMy8PgVdMnoL4RfqGlwFAKEpS6KVFHnBVqnNEhcdy9uCI7x7Xx8UnyUtxj1EDTm76uta9Ki9OrlqB6tImDM9+Ya3vGktW37ht4WOx2OsJRhG1dbf6RLwFlH7DWwKBgQDFBxvi5I1BR6hg6Tj7xd2SqOT2Y+BED3xuSYENhWbmMhLJDResaB7mjztbxlYaY2mOE0holWm2uDmVFFhMh4jYXik4hYH8nmDzq9mDpZCZ9pyjYqnAP8THoAa8EbgrUWB8A6BPH4iL3KbMnBfBKY0pIr2xrvnjQjNBAgta7KDRKQKBgCe6oe4wxrdF2TKsC2tIqpMoQxS3Icy/ZGgZr+SYuaBKTCWtoDW/UT40K3JGMxIDBhzbXphBCUCsVt9tM8Xd4EwP6tJW7dZ7B0pnve2pVwNwaAVAiz6p2yUHIle+jN+Koe5lZRSwYIg7WW81tWpwwsJfzqFyvjYDP6hJV4mz4ROvAoGAaRcdnKvjXApomShMqJ4lTPChD3q+SA8qg3jZSOj6tZXHx00gb2kp8jg7pPvpOTIFPy6x1Ha9aCRjMk0ju84fA6lVuzwa1S907wOehUVuF3Eeo1cgy9Y3k3KbpPyeixxgpkUY4JslLdSHc2NemD0dee951qhJyRmqVOZOQDUuoeECgYEAqBw2cAFk3vM97WY06TSldGA8ajVHx3BYRjj+zl62NTQthy8fw3tqxb3c5e8toOmZWKjZvDhg2TRLhsDDQWEYg3LZG87REqVIjgEPcpjNLidjygGX8n3JF2o0O5I/EMvl0s/+LVQONfduOBvhwDqr8QNisbLsyneiAq7umewMolo="
|
||||
public-key: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnFMmIVanMxsW5S/qP8Wcxf/J3/i4631BP3UtWkRzO7jAw9HIAgK4Y7X53hXj6zMbfme1vMjQc0mq7m/KrH4WlTYpFexLO6Gnk8oH40F04tp+ABZIq93zNOydPEaVoZeTPH/LlkwrrxVGAMNNIKuebcqapp25JiWtlSFMv4kH/nDAj+2m8+P4zYVM1Ed6gO01eKDEYE3SBA1Ket2BfHTgviR/F8WKwlXh11enywsJnrHTM5dJQdlUxCjHy214TpheYOz/cv9elQnDfFAbmZW8mH5/hgMSTkm3h4uR7ITin6Erg+yc/t1kGaTWrzloyBRMSiFN/Pwr5yQjj+1wQqqUkwIDAQAB"
|
||||
|
||||
freq-converter:
|
||||
schedule-period: 1000 #定时器运行间隔
|
||||
no-tolerant: 4 #不耐受状态
|
||||
dt: 200 #延迟时间ms
|
||||
Reference in New Issue
Block a user