微调
This commit is contained in:
@@ -74,7 +74,7 @@ public class SocketFreqConverterDevService {
|
|||||||
|
|
||||||
private void init(String userId, String converterId, String monitorId) {
|
private void init(String userId, String converterId, String monitorId) {
|
||||||
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);
|
pqDipDataService.clearAllData(FormalTestManager.freqConverterTableSuffix);
|
||||||
@@ -127,8 +127,17 @@ public class SocketFreqConverterDevService {
|
|||||||
WebServiceManager.sendMsg(this.userId, JSON.toJSONString(socketDataMsg));
|
WebServiceManager.sendMsg(this.userId, JSON.toJSONString(socketDataMsg));
|
||||||
break;
|
break;
|
||||||
case SUCCESS:
|
case SUCCESS:
|
||||||
this.sendGetDipDataMsg(devTag);
|
// 暂态协议触发后等待5秒,将装置历史缓存的暂态数据给抛掉
|
||||||
FormalTestManager.freqConverterDevStep = SourceOperateCodeEnum.FORMAL_REAL;
|
CompletableFuture.runAsync(() -> {
|
||||||
|
try {
|
||||||
|
Thread.sleep(5000);
|
||||||
|
this.sendGetDipDataMsg(devTag);
|
||||||
|
FormalTestManager.freqConverterDevStep = SourceOperateCodeEnum.FORMAL_REAL;
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
log.error("异步调用sendGetDipDataMsg被中断", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log.warn("设备响应异常,devTag={}, operateCode={}, code={}, data={}", devTag, socketDataMsg.getOperateCode(), socketDataMsg.getCode(), socketDataMsg.getData());
|
log.warn("设备响应异常,devTag={}, operateCode={}, code={}, data={}", devTag, socketDataMsg.getOperateCode(), socketDataMsg.getCode(), socketDataMsg.getData());
|
||||||
@@ -146,9 +155,10 @@ public class SocketFreqConverterDevService {
|
|||||||
case NORMAL_RESPONSE:
|
case NORMAL_RESPONSE:
|
||||||
DevData devData = JSON.parseObject(socketDataMsg.getData(), DevData.class);
|
DevData devData = JSON.parseObject(socketDataMsg.getData(), DevData.class);
|
||||||
// 如果变频器不是处于 “故障中” 状态,就保存数据,反之,这段时期内的数据不保存
|
// 如果变频器不是处于 “故障中” 状态,就保存数据,反之,这段时期内的数据不保存
|
||||||
if (!FormalTestManager.stopFlag) {
|
// if (!FormalTestManager.stopFlag) {
|
||||||
saveDipData(devData);
|
// saveDipData(devData);
|
||||||
}
|
// }
|
||||||
|
saveDipData(devData);
|
||||||
break;
|
break;
|
||||||
case DEV_ERROR:
|
case DEV_ERROR:
|
||||||
case DEV_TARGET:
|
case DEV_TARGET:
|
||||||
@@ -214,7 +224,7 @@ public class SocketFreqConverterDevService {
|
|||||||
|
|
||||||
private void sendGetDipDataMsg(String devTag) {
|
private void sendGetDipDataMsg(String devTag) {
|
||||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue()+"&&VOLTAGE");
|
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + "&&VOLTAGE");
|
||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
|
|
||||||
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
||||||
@@ -222,7 +232,7 @@ public class SocketFreqConverterDevService {
|
|||||||
PqDev dev = pqDevService.getById(split[0]);
|
PqDev dev = pqDevService.getById(split[0]);
|
||||||
|
|
||||||
// 设置监测点ID列表
|
// 设置监测点ID列表
|
||||||
phaseSequenceParam.setMoniterIdList(ListUtil.of(dev.getIp()+StrUtil.C_UNDERLINE+split[1]));
|
phaseSequenceParam.setMoniterIdList(ListUtil.of(dev.getIp() + StrUtil.C_UNDERLINE + split[1]));
|
||||||
|
|
||||||
// 设置数据类型列表
|
// 设置数据类型列表
|
||||||
phaseSequenceParam.setDataType(ListUtil.of("avg$MAG", "avg$DUR"));
|
phaseSequenceParam.setDataType(ListUtil.of("avg$MAG", "avg$DUR"));
|
||||||
@@ -280,20 +290,24 @@ public class SocketFreqConverterDevService {
|
|||||||
|
|
||||||
private void initDipTestRes(PqDipData pqDipData) {
|
private void initDipTestRes(PqDipData pqDipData) {
|
||||||
Integer suffix = FormalTestManager.freqConverterTableSuffix;
|
Integer suffix = FormalTestManager.freqConverterTableSuffix;
|
||||||
List<FreqConverterStatus> statusList = freqConverterService.getDipDurationStatusData(suffix, pqDipData.getStartTime(), LocalDateTime.now());
|
FreqConverterStatus lastStatusData = freqConverterService.getLastStatusData(suffix, pqDipData.getStartTime());
|
||||||
List<PqFreqConverterTestRes> testResList = new ArrayList<>();
|
List<FreqConverterStatus> statusList = freqConverterService.getDipDurationStatusData(suffix, lastStatusData.getTimestamp(), pqDipData.getStartTime().plusNanos(pqDipData.getDurationMs() * 1000_000L));
|
||||||
for (FreqConverterStatus status : statusList) {
|
boolean originalTolerant = lastStatusData.getStatusWord1() != freqConverterConfig.getNoTolerant();
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(statusList)) {
|
||||||
|
FreqConverterStatus status = statusList.get(statusList.size() - 1);
|
||||||
PqFreqConverterTestRes testRes = new PqFreqConverterTestRes();
|
PqFreqConverterTestRes testRes = new PqFreqConverterTestRes();
|
||||||
testRes.setDipId(pqDipData.getId());
|
testRes.setDipId(pqDipData.getId());
|
||||||
testRes.setStatusId(status.getId());
|
testRes.setTolerant(originalTolerant ? status.getStatusWord1() != freqConverterConfig.getNoTolerant() : false);
|
||||||
testRes.setTolerant(status.getStatusWord1() != freqConverterConfig.getNoTolerant());
|
testRes.setStartTime(lastStatusData.getTimestamp());
|
||||||
testResList.add(testRes);
|
|
||||||
}
|
|
||||||
pqFreqConverterTestResService.saveTestRes(suffix, testResList);
|
|
||||||
|
|
||||||
int collectCount = (int) Math.ceil((freqConverterConfig.getDt()) / freqConverterConfig.getSchedulePeriod());
|
int collectCount = (int) Math.ceil((freqConverterConfig.getDt()) / freqConverterConfig.getSchedulePeriod());
|
||||||
if (collectCount > 0) {
|
if (collectCount > 0) {
|
||||||
FormalTestManager.pendingDipTaskMap.put(pqDipData.getId(), new FormalTestManager.PendingDipTask(pqDipData.getId(), collectCount));
|
FormalTestManager.pendingDipTaskMap.put(pqDipData.getId(), new FormalTestManager.PendingDipTask(pqDipData.getId(), pqDipData.getStartTime(), originalTolerant, collectCount));
|
||||||
|
} else {
|
||||||
|
testRes.setEndTime(status.getTimestamp());
|
||||||
|
}
|
||||||
|
pqFreqConverterTestResService.saveTestRes(suffix, Collections.singletonList(testRes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class SocketFreqConverterService {
|
|||||||
public void onReconnectSuccess(String converterChannelTag) {
|
public void onReconnectSuccess(String converterChannelTag) {
|
||||||
log.info("变频器重连成功,恢复数据采集,converterChannelTag={}", converterChannelTag);
|
log.info("变频器重连成功,恢复数据采集,converterChannelTag={}", converterChannelTag);
|
||||||
|
|
||||||
FormalTestManager.stopFlag = false;
|
// FormalTestManager.stopFlag = false;
|
||||||
|
|
||||||
if (FormalTestManager.scheduler == null) {
|
if (FormalTestManager.scheduler == null) {
|
||||||
FormalTestManager.scheduler = Executors.newScheduledThreadPool(1);
|
FormalTestManager.scheduler = Executors.newScheduledThreadPool(1);
|
||||||
@@ -165,7 +165,7 @@ public class SocketFreqConverterService {
|
|||||||
public void cleanup(String converterChannelTag) {
|
public void cleanup(String converterChannelTag) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
@@ -193,11 +193,11 @@ public class SocketFreqConverterService {
|
|||||||
|
|
||||||
FreqConverterStatus freqConverterStatus = JSON.parseObject(obj.toString(), FreqConverterStatus.class);
|
FreqConverterStatus freqConverterStatus = JSON.parseObject(obj.toString(), FreqConverterStatus.class);
|
||||||
// 变频器故障中,移除这段时期内的设备数据
|
// 变频器故障中,移除这段时期内的设备数据
|
||||||
if (freqConverterStatus.getStatusWord1() == freqConverterConfig.getNoTolerant()) {
|
// if (freqConverterStatus.getStatusWord1() == freqConverterConfig.getNoTolerant()) {
|
||||||
FormalTestManager.stopFlag = true;
|
// FormalTestManager.stopFlag = true;
|
||||||
} else {
|
// } else {
|
||||||
FormalTestManager.stopFlag = false;
|
// FormalTestManager.stopFlag = false;
|
||||||
}
|
// }
|
||||||
freqConverterService.saveFreqConverterStatus(FormalTestManager.freqConverterTableSuffix, freqConverterStatus);
|
freqConverterService.saveFreqConverterStatus(FormalTestManager.freqConverterTableSuffix, freqConverterStatus);
|
||||||
this.consumePendingDipTasks(freqConverterStatus);
|
this.consumePendingDipTasks(freqConverterStatus);
|
||||||
}
|
}
|
||||||
@@ -253,27 +253,26 @@ public class SocketFreqConverterService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PqFreqConverterTestRes> resList = new ArrayList<>();
|
|
||||||
Integer suffix = FormalTestManager.freqConverterTableSuffix;
|
Integer suffix = FormalTestManager.freqConverterTableSuffix;
|
||||||
List<String> finishedDipIdList = new ArrayList<>();
|
List<String> finishedDipIdList = new ArrayList<>();
|
||||||
|
List<PqFreqConverterTestRes> testResList = new ArrayList<>();
|
||||||
for (FormalTestManager.PendingDipTask task : FormalTestManager.pendingDipTaskMap.values()) {
|
for (FormalTestManager.PendingDipTask task : FormalTestManager.pendingDipTaskMap.values()) {
|
||||||
if (task.getRemainingCount() <= 0) {
|
if (task.getRemainingCount() <= 0) {
|
||||||
finishedDipIdList.add(task.getDipId());
|
finishedDipIdList.add(task.getDipId());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PqFreqConverterTestRes testRes = new PqFreqConverterTestRes();
|
PqFreqConverterTestRes testRes = pqFreqConverterTestResService.getByDipId(suffix, task.getDipId());
|
||||||
testRes.setDipId(task.getDipId());
|
testRes.setEndTime(freqConverterStatus.getTimestamp());
|
||||||
testRes.setStatusId(freqConverterStatus.getId());
|
testRes.setTolerant(testRes.getTolerant() && (freqConverterStatus.getStatusWord1() != freqConverterConfig.getNoTolerant()));
|
||||||
testRes.setTolerant(freqConverterStatus.getStatusWord1() != freqConverterConfig.getNoTolerant());
|
testResList.add(testRes);
|
||||||
resList.add(testRes);
|
|
||||||
|
|
||||||
task.decrementRemainingCount();
|
task.decrementRemainingCount();
|
||||||
if (task.getRemainingCount() <= 0) {
|
if (task.getRemainingCount() <= 0) {
|
||||||
finishedDipIdList.add(task.getDipId());
|
finishedDipIdList.add(task.getDipId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pqFreqConverterTestResService.saveTestRes(suffix, resList);
|
pqFreqConverterTestResService.saveTestRes(suffix, testResList);
|
||||||
|
|
||||||
for (String dipId : finishedDipIdList) {
|
for (String dipId : finishedDipIdList) {
|
||||||
FormalTestManager.pendingDipTaskMap.remove(dipId);
|
FormalTestManager.pendingDipTaskMap.remove(dipId);
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ import com.njcn.gather.plan.pojo.po.AdPlan;
|
|||||||
import com.njcn.gather.plan.pojo.po.AdPlanTestConfig;
|
import com.njcn.gather.plan.pojo.po.AdPlanTestConfig;
|
||||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -223,23 +225,20 @@ public class FormalTestManager {
|
|||||||
*/
|
*/
|
||||||
public static boolean isXu;
|
public static boolean isXu;
|
||||||
|
|
||||||
|
@Data
|
||||||
public static class PendingDipTask {
|
public static class PendingDipTask {
|
||||||
private final String dipId;
|
private final String dipId;
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
private Boolean originalTolerant;
|
||||||
private int remainingCount;
|
private int remainingCount;
|
||||||
|
|
||||||
public PendingDipTask(String dipId, int remainingCount) {
|
public PendingDipTask(String dipId, LocalDateTime startTime, Boolean originalTolerant, int remainingCount) {
|
||||||
this.dipId = dipId;
|
this.dipId = dipId;
|
||||||
|
this.startTime = startTime;
|
||||||
|
this.originalTolerant = originalTolerant;
|
||||||
this.remainingCount = remainingCount;
|
this.remainingCount = remainingCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDipId() {
|
|
||||||
return dipId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRemainingCount() {
|
|
||||||
return remainingCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void decrementRemainingCount() {
|
public void decrementRemainingCount() {
|
||||||
this.remainingCount--;
|
this.remainingCount--;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ public class NettyFreqConverterClientHandler extends SimpleChannelInboundHandler
|
|||||||
log.info("变频器重连成功,converterChannelTag={}, 重连次数={}", converterChannelTag, reconnectAttempts);
|
log.info("变频器重连成功,converterChannelTag={}, 重连次数={}", converterChannelTag, reconnectAttempts);
|
||||||
reconnectAttempts = 0;
|
reconnectAttempts = 0;
|
||||||
isReconnecting = false;
|
isReconnecting = false;
|
||||||
FormalTestManager.stopFlag = false;
|
|
||||||
socketFreqConverterService.onReconnectSuccess(converterChannelTag);
|
socketFreqConverterService.onReconnectSuccess(converterChannelTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +98,6 @@ public class NettyFreqConverterClientHandler extends SimpleChannelInboundHandler
|
|||||||
attemptReconnect(ctx);
|
attemptReconnect(ctx);
|
||||||
} else if (reconnectAttempts >= MAX_RECONNECT_ATTEMPTS) {
|
} else if (reconnectAttempts >= MAX_RECONNECT_ATTEMPTS) {
|
||||||
log.error("变频器重连失败,已达到最大重连次数{}次,converterChannelTag={}", MAX_RECONNECT_ATTEMPTS, converterChannelTag);
|
log.error("变频器重连失败,已达到最大重连次数{}次,converterChannelTag={}", MAX_RECONNECT_ATTEMPTS, converterChannelTag);
|
||||||
FormalTestManager.stopFlag = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
super.channelInactive(ctx);
|
super.channelInactive(ctx);
|
||||||
@@ -108,8 +106,6 @@ public class NettyFreqConverterClientHandler extends SimpleChannelInboundHandler
|
|||||||
@Override
|
@Override
|
||||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||||
log.error("变频器连接发生异常,converterChannelTag={}, error={}", converterChannelTag, cause.getMessage(), cause);
|
log.error("变频器连接发生异常,converterChannelTag={}, error={}", converterChannelTag, cause.getMessage(), cause);
|
||||||
FormalTestManager.stopFlag = true;
|
|
||||||
log.warn("变频器连接异常,设置stopFlag=true,设备数据将不再入库");
|
|
||||||
ctx.close();
|
ctx.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class NettyFreqConverterDevClientHandler extends SimpleChannelInboundHand
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
|
||||||
log.info("收到设备消息,devChannelTag={}, msg={},FormalTestManager.stopFlag={}", devChannelTag, msg, FormalTestManager.stopFlag);
|
log.info("收到设备消息,devChannelTag={}, msg={}", devChannelTag, msg);
|
||||||
|
|
||||||
socketFreqConverterDevService.handleRead(devChannelTag, msg);
|
socketFreqConverterDevService.handleRead(devChannelTag, msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.njcn.gather.dip.pojo.po.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2026-04-16
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DipPoint {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 残余电压,单位:%Ur
|
||||||
|
*/
|
||||||
|
private Double residualVoltage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 持续时间,单位:ms
|
||||||
|
*/
|
||||||
|
private Integer durationMs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0为不耐受,1为耐受
|
||||||
|
*/
|
||||||
|
private Boolean tolerant;
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@ package com.njcn.gather.freqConverter.pojo.po;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author caozehui
|
* @author caozehui
|
||||||
* @data 2026-04-14
|
* @data 2026-04-14
|
||||||
@@ -20,13 +22,18 @@ public class PqFreqConverterTestRes {
|
|||||||
*/
|
*/
|
||||||
private String dipId;
|
private String dipId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 变频器状态数据id
|
|
||||||
*/
|
|
||||||
private String statusId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 0为不耐受,1为耐受
|
* 0为不耐受,1为耐受
|
||||||
*/
|
*/
|
||||||
private Boolean tolerant;
|
private Boolean tolerant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 该暂降时期对应变频器的起始时间戳
|
||||||
|
*/
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 该暂降时期对应变频器的结束时间戳
|
||||||
|
*/
|
||||||
|
private LocalDateTime endTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,4 +49,6 @@ public interface IFreqConverterService extends IService<FreqConverterStatus> {
|
|||||||
List<TolerantPointVO> getTolerantPoints(String converterId);
|
List<TolerantPointVO> getTolerantPoints(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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,4 +34,12 @@ public interface IPqFreqConverterTestResService extends IService<PqFreqConverter
|
|||||||
* @return 结果列表
|
* @return 结果列表
|
||||||
*/
|
*/
|
||||||
List<PqFreqConverterTestRes> listTestRes(Integer suffix);
|
List<PqFreqConverterTestRes> listTestRes(Integer suffix);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据DIPID查询结果
|
||||||
|
* @param suffix
|
||||||
|
* @param dipId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
PqFreqConverterTestRes getByDipId(Integer suffix, String dipId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,9 +102,20 @@ public class FreqConverterServiceImpl extends ServiceImpl<FreqConverterStatusMap
|
|||||||
DynamicTableNameHandler.setTableName("pq_freq_converter_status_" + suffix);
|
DynamicTableNameHandler.setTableName("pq_freq_converter_status_" + suffix);
|
||||||
List<FreqConverterStatus> result = this.lambdaQuery()
|
List<FreqConverterStatus> result = this.lambdaQuery()
|
||||||
.between(FreqConverterStatus::getTimestamp, startTime, endTime)
|
.between(FreqConverterStatus::getTimestamp, startTime, endTime)
|
||||||
.orderByDesc(FreqConverterStatus::getTimestamp)
|
.orderByAsc(FreqConverterStatus::getTimestamp)
|
||||||
.list();
|
.list();
|
||||||
DynamicTableNameHandler.remove();
|
DynamicTableNameHandler.remove();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FreqConverterStatus getLastStatusData(Integer suffix, LocalDateTime startTime) {
|
||||||
|
DynamicTableNameHandler.setTableName("pq_freq_converter_status_" + suffix);
|
||||||
|
FreqConverterStatus one = this.lambdaQuery().le(FreqConverterStatus::getTimestamp, startTime)
|
||||||
|
.orderByDesc(FreqConverterStatus::getTimestamp)
|
||||||
|
.last("limit 1")
|
||||||
|
.one();
|
||||||
|
DynamicTableNameHandler.remove();
|
||||||
|
return one;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ public class PqFreqConverterConfigServiceImpl extends ServiceImpl<PqFreqConverte
|
|||||||
tableSql = "CREATE TABLE `pq_freq_converter_test_res_" + maxSuffix + "` (" +
|
tableSql = "CREATE TABLE `pq_freq_converter_test_res_" + 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'," +
|
||||||
" `status_id` char(32) NOT NULL COMMENT '变频器状态数据id'," +
|
" `start_time` datetime(3) DEFAULT NULL COMMENT '该暂降时期对应变频器的起始时间戳'," +
|
||||||
|
" `end_time` datetime(3) DEFAULT NULL COMMENT '该暂降时期对应变频器的结束时间戳'," +
|
||||||
" `tolerant` tinyInt(1) NOT NULL COMMENT '0为不耐受,1为耐受'," +
|
" `tolerant` tinyInt(1) NOT NULL COMMENT '0为不耐受,1为耐受'," +
|
||||||
" PRIMARY KEY (`id`)" +
|
" PRIMARY KEY (`id`)" +
|
||||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='变频器耐受实验结果';";
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='变频器耐受实验结果';";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.njcn.gather.freqConverter.service.impl;
|
package com.njcn.gather.freqConverter.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
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.mapper.PqFreqConverterTestResMapper;
|
import com.njcn.gather.freqConverter.mapper.PqFreqConverterTestResMapper;
|
||||||
@@ -8,6 +8,7 @@ import com.njcn.gather.freqConverter.pojo.po.PqFreqConverterTestRes;
|
|||||||
import com.njcn.gather.freqConverter.service.IPqFreqConverterTestResService;
|
import com.njcn.gather.freqConverter.service.IPqFreqConverterTestResService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,9 +27,25 @@ public class PqFreqConverterTestResServiceImpl extends ServiceImpl<PqFreqConvert
|
|||||||
@Override
|
@Override
|
||||||
public boolean saveTestRes(Integer suffix, List<PqFreqConverterTestRes> testResList) {
|
public boolean saveTestRes(Integer suffix, List<PqFreqConverterTestRes> testResList) {
|
||||||
DynamicTableNameHandler.setTableName("pq_freq_converter_test_res_" + suffix);
|
DynamicTableNameHandler.setTableName("pq_freq_converter_test_res_" + suffix);
|
||||||
boolean result = this.saveBatch(testResList);
|
|
||||||
|
List<PqFreqConverterTestRes> existedTestResList = new ArrayList<>();
|
||||||
|
List<PqFreqConverterTestRes> newTestResList = new ArrayList<>();
|
||||||
|
for (PqFreqConverterTestRes testRes : testResList) {
|
||||||
|
if (ObjectUtil.isNotNull(testRes.getId())) {
|
||||||
|
existedTestResList.add(testRes);
|
||||||
|
} else {
|
||||||
|
newTestResList.add(testRes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (existedTestResList.size() > 0) {
|
||||||
|
this.updateBatchById(existedTestResList);
|
||||||
|
}
|
||||||
|
if (newTestResList.size() > 0) {
|
||||||
|
this.saveBatch(newTestResList);
|
||||||
|
}
|
||||||
|
|
||||||
DynamicTableNameHandler.remove();
|
DynamicTableNameHandler.remove();
|
||||||
return result;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -38,4 +55,12 @@ public class PqFreqConverterTestResServiceImpl extends ServiceImpl<PqFreqConvert
|
|||||||
DynamicTableNameHandler.remove();
|
DynamicTableNameHandler.remove();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PqFreqConverterTestRes getByDipId(Integer suffix, String dipId) {
|
||||||
|
DynamicTableNameHandler.setTableName("pq_freq_converter_test_res_" + suffix);
|
||||||
|
PqFreqConverterTestRes one = this.lambdaQuery().eq(PqFreqConverterTestRes::getDipId, dipId).one();
|
||||||
|
DynamicTableNameHandler.remove();
|
||||||
|
return one;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,6 +128,6 @@ activate:
|
|||||||
public-key: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnFMmIVanMxsW5S/qP8Wcxf/J3/i4631BP3UtWkRzO7jAw9HIAgK4Y7X53hXj6zMbfme1vMjQc0mq7m/KrH4WlTYpFexLO6Gnk8oH40F04tp+ABZIq93zNOydPEaVoZeTPH/LlkwrrxVGAMNNIKuebcqapp25JiWtlSFMv4kH/nDAj+2m8+P4zYVM1Ed6gO01eKDEYE3SBA1Ket2BfHTgviR/F8WKwlXh11enywsJnrHTM5dJQdlUxCjHy214TpheYOz/cv9elQnDfFAbmZW8mH5/hgMSTkm3h4uR7ITin6Erg+yc/t1kGaTWrzloyBRMSiFN/Pwr5yQjj+1wQqqUkwIDAQAB"
|
public-key: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnFMmIVanMxsW5S/qP8Wcxf/J3/i4631BP3UtWkRzO7jAw9HIAgK4Y7X53hXj6zMbfme1vMjQc0mq7m/KrH4WlTYpFexLO6Gnk8oH40F04tp+ABZIq93zNOydPEaVoZeTPH/LlkwrrxVGAMNNIKuebcqapp25JiWtlSFMv4kH/nDAj+2m8+P4zYVM1Ed6gO01eKDEYE3SBA1Ket2BfHTgviR/F8WKwlXh11enywsJnrHTM5dJQdlUxCjHy214TpheYOz/cv9elQnDfFAbmZW8mH5/hgMSTkm3h4uR7ITin6Erg+yc/t1kGaTWrzloyBRMSiFN/Pwr5yQjj+1wQqqUkwIDAQAB"
|
||||||
|
|
||||||
freq-converter:
|
freq-converter:
|
||||||
schedule-period: 1000 #定时器运行间隔
|
schedule-period: 200 #定时器运行间隔
|
||||||
no-tolerant: 4 #不耐受状态
|
no-tolerant: 4 #不耐受状态
|
||||||
dt: 200 #延迟时间ms
|
dt: 200 #延迟时间ms
|
||||||
Reference in New Issue
Block a user