From 36f621b17dc24753e555b850820942f2b6211e53 Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Fri, 17 Jul 2026 14:39:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=95=BF=E9=97=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/SocketDevResponseService.java | 85 +++++++++++++++++-- .../handler/SocketSourceResponseService.java | 12 +-- .../pojo/enums/DetectionCodeEnum.java | 1 + .../gather/detection/pojo/po/DevData.java | 2 +- .../service/impl/DetectionServiceImpl.java | 3 +- .../service/impl/PreDetectionServiceImpl.java | 4 +- .../util/socket/FormalTestManager.java | 8 +- .../socket/cilent/NettyDevClientHandler.java | 11 ++- .../service/impl/PqScriptDtlsServiceImpl.java | 5 +- 9 files changed, 106 insertions(+), 25 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java index 35ab9ba7..b7a5631d 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java @@ -796,7 +796,7 @@ public class SocketDevResponseService { boolean isContinue = true; List descList = icdCheckData.getResultData().stream().map( obj -> { - if (DetectionCodeEnum.MAG.getCode().equals(obj.getDesc()) || DetectionCodeEnum.DUR.getCode().equals(obj.getDesc()) || DetectionCodeEnum.PST.getCode().equals(obj.getDesc())) { + if (DetectionCodeEnum.MAG.getCode().equals(obj.getDesc()) || DetectionCodeEnum.DUR.getCode().equals(obj.getDesc()) || DetectionCodeEnum.PST.getCode().equals(obj.getDesc()) || DetectionCodeEnum.PLT.getCode().equals(obj.getDesc())) { return DetectionCodeEnum.AVG_PREFIX.getCode() + obj.getDesc(); } else { return DetectionCodeEnum.REAL_PREFIX.getCode() + obj.getDesc(); @@ -1225,7 +1225,7 @@ public class SocketDevResponseService { WebSocketVO webSocketVO = new WebSocketVO<>(); String type = firstIssue.getType(); if (StrUtil.isNotBlank(firstIssue.getOtherType())) { - firstIssue.setType(PowerIndexEnum.V.getKey()); + firstIssue.setType(PowerIndexEnum.LF.getKey().equals(firstIssue.getOtherType()) ? PowerIndexEnum.F.getKey() : PowerIndexEnum.V.getKey()); webSocketVO.setRequestId(firstIssue.getOtherType() + CnSocketUtil.START_TAG); type = firstIssue.getOtherType(); } else { @@ -1244,6 +1244,46 @@ public class SocketDevResponseService { WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO)); } + /** + * 添加并且按照slowValueTimeList中的时间去重 + * + * @param devDataList + * @param devData + */ + private void addAndRemoveDuplicate(List devDataList, DevData devData) { + if (ObjectUtil.isNotNull(devData) && CollUtil.isNotEmpty(devData.getSlowValueTimeList())) { + List slowValueTimeList1 = devData.getSlowValueTimeList(); + + long count1 = devDataList.stream().flatMap(devData1 -> devData.getSlowValueTimeList().stream()).filter(slowValueTimeDTO -> { + long count2 = slowValueTimeList1.stream().filter(slowValueTimeDTO1 -> { + if (slowValueTimeDTO.getDesc().equals(slowValueTimeDTO1.getDesc())) { + DevData.SlowValueTimeDTO.ListDTO list = slowValueTimeDTO.getList(); + DevData.SlowValueTimeDTO.ListDTO list1 = slowValueTimeDTO1.getList(); + String a = list.getA(); + String b = list.getB(); + String c = list.getC(); + String t = list.getT(); + + String a1 = list1.getA(); + String b1 = list1.getB(); + String c1 = list1.getC(); + String t1 = list1.getT(); + if (StrUtil.equals(a, a1) && StrUtil.equals(b, b1) && StrUtil.equals(c, c1) && StrUtil.equals(t, t1)) { + return true; + } + } + return false; + }).count(); + + return count2 > 0; + }).count(); + + if (count1 <= 0) { + devDataList.add(devData); + } + } + } + /** * 正式检测 */ @@ -1256,12 +1296,31 @@ public class SocketDevResponseService { switch (Objects.requireNonNull(dictDataEnumByCode)) { case SUCCESS: if (devData.getResult()) { - FormalTestManager.realDataXiList.add(devData); - successComm.add(devData.getId()); + // 判断是否是长闪数据 + if (PowerIndexEnum.LF.getKey().equals(sourceIssue.getOtherType())) { + List sqlData = devData.getSqlData(); + if (CollUtil.isNotEmpty(sqlData)) { + if (isEvenHour(devData.getTime())) { + if (FormalTestManager.longFlickerDataCount >= FormalTestManager.monitorIdListComm.size()) { + FormalTestManager.realDataXiList.add(devData); + successComm.add(devData.getId()); + } - //成功收到数据后重置超时统计时间 - if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) { - SocketManager.clockMap.put(sourceIssue.getIndex(), 0L); + //成功收到数据后重置超时统计时间 + if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) { + SocketManager.clockMap.put(sourceIssue.getIndex(), 0L); + } + FormalTestManager.longFlickerDataCount++; + } + } + } else { + FormalTestManager.realDataXiList.add(devData); + successComm.add(devData.getId()); + + //成功收到数据后重置超时统计时间 + if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) { + SocketManager.clockMap.put(sourceIssue.getIndex(), 0L); + } } //当成功的通道数量和检测通道数量相同时进入 @@ -1334,7 +1393,7 @@ public class SocketDevResponseService { String type = sourceIssues.getType(); if (StrUtil.isNotBlank(sourceIssues.getOtherType())) { - sourceIssues.setType(PowerIndexEnum.V.getKey()); + sourceIssues.setType(PowerIndexEnum.LF.getKey().equals(sourceIssues.getOtherType()) ? PowerIndexEnum.F.getKey() : PowerIndexEnum.V.getKey()); type = sourceIssues.getOtherType(); } // 如果上一个大项检测完成,则检测下一个大项,并向前端推送消息 @@ -1912,6 +1971,16 @@ public class SocketDevResponseService { System.out.println(XiNumberManager.xiSourceIssueList); } + /** + * 判断时间是否为偶数小时 + * + * @param timeStr + * @return + */ + private boolean isEvenHour(String timeStr) { + LocalDateTime localDateTime = DetectionUtil.timeFormat(timeStr, DetectionUtil.FORMATTER); + return localDateTime.getHour() % 2 == 0 && localDateTime.getMinute() == 0; + } /** * 原始数据入库 diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java index ec84a46d..e5af5463 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java @@ -543,11 +543,13 @@ public class SocketSourceResponseService { ignoreCount = 1; // 读取2次数据计算闪变值 readData = 2; - socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue()); - } else if (PowerIndexEnum.LF.getKey().equals(sourceIssue.getType())) { - // 长时间闪变检测 - ignoreCount = 1; - readData = 1; + + if (PowerIndexEnum.LF.getKey().equals(sourceIssue.getOtherType())) { + FormalTestManager.longFlickerDataCount = 0; + // 长时间闪变检测 + ignoreCount = 0; + readData = 0; + } socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue()); } else if (PowerIndexEnum.VOLTAGE.getKey().equals(sourceIssue.getType())) { // 暂态电压检测:需要更多预热时间,但只读取一次快照 diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionCodeEnum.java b/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionCodeEnum.java index c20e457b..67502436 100644 --- a/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionCodeEnum.java +++ b/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionCodeEnum.java @@ -37,6 +37,7 @@ public enum DetectionCodeEnum { I_UNBAN("I_UNBAN", "三相电流负序不平衡度"), SeqA("SeqA", "电流序分量"), PST("PST", "短时间闪变"), + PLT("PLT", "长时间闪变"), W("W", "总有功功率"), VARW("VARW", "总无功功率"), VAW("VAW", "总视在功率"), diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/po/DevData.java b/detection/src/main/java/com/njcn/gather/detection/pojo/po/DevData.java index d3bec831..cdc39c6c 100644 --- a/detection/src/main/java/com/njcn/gather/detection/pojo/po/DevData.java +++ b/detection/src/main/java/com/njcn/gather/detection/pojo/po/DevData.java @@ -33,7 +33,7 @@ public class DevData { @JSONField(name = "SqlDataHarm", ordinal = 5) private List sqlDataHarm; - @JSONField(name = "SqlDataHarm", ordinal = 6) + @JSONField(name = "SlowValueTimeList", ordinal = 6) private List slowValueTimeList; @NoArgsConstructor diff --git a/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java b/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java index 4f244a86..db6c0175 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/impl/DetectionServiceImpl.java @@ -226,6 +226,7 @@ public class DetectionServiceImpl { * 闪变 */ case F: + case LF: return isUnBalanceOrFlickerQualified(dev, devIdMapComm, errDtlsCheckData, DetectionCodeEnum.PST.getCode(), sourceIssue, dataRule, code, oneConfig.getScale()); /** * 暂态 @@ -667,7 +668,7 @@ public class DetectionServiceImpl { } result.setResultFlag(isQualified); // 闪变 - if (DetectionCodeEnum.PST.getCode().equals(splitArr[1]) || DetectionCodeEnum.SeqV.getCode().equals(splitArr[1]) || DetectionCodeEnum.SeqA.getCode().equals(splitArr[1])) { + if (DetectionCodeEnum.PST.getCode().equals(splitArr[1]) || DetectionCodeEnum.PLT.getCode().equals(splitArr[1]) || DetectionCodeEnum.SeqV.getCode().equals(splitArr[1]) || DetectionCodeEnum.SeqA.getCode().equals(splitArr[1])) { //取出源所对应的相别信息 List channelTypeAList = checkData.stream() diff --git a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java index 64a9bd84..ee42154e 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java @@ -306,7 +306,7 @@ public class PreDetectionServiceImpl implements PreDetectionService { String type = resolveFormalIssueType(sourceIssues); sendBigItemStartIfFirstFormalIssue(runtimeParam, sourceIssues, type); if (StrUtil.isNotBlank(sourceIssues.getOtherType())) { - sourceIssues.setType(PowerIndexEnum.V.getKey()); + sourceIssues.setType(PowerIndexEnum.LF.getKey().equals(sourceIssues.getOtherType()) ? PowerIndexEnum.F.getKey() : PowerIndexEnum.V.getKey()); } SocketMsg xuMsg = new SocketMsg<>(); xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue()); @@ -570,7 +570,7 @@ public class PreDetectionServiceImpl implements PreDetectionService { SourceIssue sourceIssue = sourceIssues.get(0); String type = sourceIssue.getType(); if (StrUtil.isNotBlank(sourceIssue.getOtherType())) { - sourceIssue.setType(PowerIndexEnum.V.getKey()); + sourceIssue.setType(PowerIndexEnum.LF.getKey().equals(sourceIssue.getOtherType()) ? PowerIndexEnum.F.getKey() : PowerIndexEnum.V.getKey()); type = sourceIssue.getOtherType(); } diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/FormalTestManager.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/FormalTestManager.java index d26bc452..b9e15aa4 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/FormalTestManager.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/FormalTestManager.java @@ -14,10 +14,7 @@ import com.njcn.gather.script.pojo.po.SourceIssue; import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; @@ -234,6 +231,9 @@ public class FormalTestManager { */ public static String reCheckType; + public static Integer longFlickerDataCount; + + public static void clearFormalRuntime() { stopFlag = false; hasStopFlag = false; diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyDevClientHandler.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyDevClientHandler.java index 9ace5153..bc1b35e9 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyDevClientHandler.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyDevClientHandler.java @@ -59,6 +59,11 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler { */ private static final long SHORT_FLICKER_TIMEOUT = 1300L; + /** + * 长闪检测超时时间:120分钟+30分 + */ + private static final long LONG_FLICKER_TIMEOUT = 120 * 60 + 30 * 60; + /** * 统计数据检测超时时间:3分钟+100秒(190秒) */ @@ -303,9 +308,11 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler { private boolean isTimeout(SourceIssue sourceIssue) { long currentTime = SocketManager.clockMap.get(sourceIssue.getIndex()); String type = sourceIssue.getType(); + String otherType = sourceIssue.getOtherType(); - // 根据不同检测类型使用不同的超时阈值 - if (PowerIndexEnum.F.getKey().equals(type) || PowerIndexEnum.LF.getKey().equals(type)) { + if (PowerIndexEnum.LF.getKey().equals(otherType)) { + return currentTime >= LONG_FLICKER_TIMEOUT; + } else if (PowerIndexEnum.F.getKey().equals(type)) { return currentTime >= SHORT_FLICKER_TIMEOUT; } else if (PowerIndexEnum.VOLTAGE.getKey().equals(type) || PowerIndexEnum.HP.getKey().equals(type)) { // 统计数据类型(电压、谐波):中等时间,3分钟超时 diff --git a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java index 54a23ac5..59d3647e 100644 --- a/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/script/service/impl/PqScriptDtlsServiceImpl.java @@ -203,7 +203,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl x.getChannelType().contains("U")).collect(Collectors.toList()); for (PqScriptDtlsParam.ChannelListDTO listDTO : channelU) {