From 2c12f4966a082c081ef3019e4ec32366ae425198 Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Wed, 9 Apr 2025 14:24:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../line/SpecialAnalysisServiceImpl.java | 63 +++++++++++++------ 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/SpecialAnalysisServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/SpecialAnalysisServiceImpl.java index b629313..4a10788 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/SpecialAnalysisServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/SpecialAnalysisServiceImpl.java @@ -133,7 +133,7 @@ public class SpecialAnalysisServiceImpl implements ISpecialAnalysisService { waveDataDTO = (WaveDataDTO) ois.readObject(); bis.close(); ois.close(); - Arrays.fill(bytes, (byte)0); + Arrays.fill(bytes, (byte) 0); } catch (Exception e) { e.printStackTrace(); } @@ -167,7 +167,7 @@ public class SpecialAnalysisServiceImpl implements ISpecialAnalysisService { if (line.getBigObjType().equals(powerStation.getId())) { if (BooleanUtil.or(isDipThrough(0, 150, 1, voltageLevel, newListRmsData), isDipThrough(20, 625, 1, voltageLevel, newListRmsData), - isDipThrough(20, 90, null, voltageLevel, newListRmsData))) { + isDipThrough(20, 90, 3, voltageLevel, newListRmsData))) { spThroughPO.setIsOrNot(1); } } @@ -238,11 +238,7 @@ public class SpecialAnalysisServiceImpl implements ISpecialAnalysisService { for (int i = 0; i < 10; i++) { try { Field minTime = RActivePowerRangeDto.class.getDeclaredField("minsTime" + i); - Field minNum = RActivePowerRangeDto.class.getDeclaredField("minsNum" + i); - Field isOrNot = RActivePowerRangeDto.class.getDeclaredField("isOrNot" + i); minTime.setAccessible(true); - minNum.setAccessible(true); - isOrNot.setAccessible(true); minTime.set(dto, "[]"); if (CollUtil.isNotEmpty(min[i])) { List mins = min[i].stream().distinct().collect(Collectors.toList()); @@ -250,14 +246,16 @@ public class SpecialAnalysisServiceImpl implements ISpecialAnalysisService { if (CollUtil.isNotEmpty(limitTime)) { List collect = mins.stream().filter(x -> limitTime.contains(x)).sorted().collect(Collectors.toList()); if (CollUtil.isNotEmpty(collect)) { + Field minNum = RActivePowerRangeDto.class.getDeclaredField("minsNum" + i); + Field isOrNot = RActivePowerRangeDto.class.getDeclaredField("isOrNot" + i); + minNum.setAccessible(true); + isOrNot.setAccessible(true); minTime.set(dto, JSON.toJSONString(collect)); + minNum.set(dto, collect.size()); isOrNot.set(dto, 1); - } else { - minTime.set(dto, "[]"); } } } - minNum.set(dto, min[i].size()); } catch (Exception e) { e.printStackTrace(); } @@ -374,16 +372,17 @@ public class SpecialAnalysisServiceImpl implements ISpecialAnalysisService { } } if (3 == option) { - //方案三:20%以上至90%时,需要判断上升信息 - -// if (voltageLevel > v && anchorPoint != -1.0) { -// anchorPoint = time + ms; -// } else if (anchorPoint.equals(time)) { -// if (v < voltageLevel*0.9) { -// return true; -// } -// anchorPoint = -1.0; -// } + //todo 方案三:20%以上至90%时,需要判断信息 + if (NumberUtil.isIn(curValue, BigDecimal.valueOf(20), BigDecimal.valueOf(90))) { + temp.add(num); + } else { + if (CollUtil.isNotEmpty(temp)) { + if (isMonotonic(temp)) { + return true; + } + temp = new ArrayList<>(); + } + } } } } @@ -391,6 +390,32 @@ public class SpecialAnalysisServiceImpl implements ISpecialAnalysisService { return false; } + /** + * 判断有不连续的暂降 + * + * @param temp + * @return + */ + private boolean isMonotonic(List temp) { + List nums = temp.stream().map(x -> Integer.valueOf(x.split("_")[1])).collect(Collectors.toList()); + //增加 + boolean increasing = true; + //减少 + boolean decreasing = true; + for (int i = 0; i < nums.size() - 1; i++) { + if (nums.get(i) > nums.get(i + 1)) { + increasing = false; + } + if (nums.get(i) > nums.get(i + 1)) { + decreasing = false; + } + // 提前终止循环,如果已确定非升序且非降序 + if (!increasing && !decreasing) { + break; + } + } + return increasing || decreasing; + } /** * 暂升