From a3e46674b399cb021ee69595310793cd448242c2 Mon Sep 17 00:00:00 2001 From: 86156 <823267011@qq.com> Date: Tue, 20 Jan 2026 17:56:48 +0800 Subject: [PATCH] =?UTF-8?q?1,2=E5=86=99=E5=85=A5=E5=8C=BA=E5=88=86?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/strip/SegmentTrackerService.java | 58 +++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/business/src/main/java/com/fizz/business/service/strip/SegmentTrackerService.java b/business/src/main/java/com/fizz/business/service/strip/SegmentTrackerService.java index 123d274..5c99033 100644 --- a/business/src/main/java/com/fizz/business/service/strip/SegmentTrackerService.java +++ b/business/src/main/java/com/fizz/business/service/strip/SegmentTrackerService.java @@ -98,6 +98,8 @@ public class SegmentTrackerService { firstMeasure = false; listSegment.clear(); coilReachedDevices.remove(coilId); + coilReachedDevices.remove(coilId + "#POR1"); + coilReachedDevices.remove(coilId + "#POR2"); long now1 = System.currentTimeMillis(); Long lastTime1 = lastNewCoilLogTimeMap.get(coilId); @@ -152,6 +154,8 @@ public class SegmentTrackerService { BigDecimal celLength = entry != null ? entry.getCelLength() : BigDecimal.ZERO; BigDecimal cxlLength = exit != null ? exit.getCxlLength() : BigDecimal.ZERO; + // payOffReelNumber=1/2 代表当前跟踪的是哪一路开卷机入口。 + // 这里做保护,避免 entry 为空或值异常导致误写 matmap。 // === 【处理开始日志】=== log.info("【TRACK-TREAT】开始处理段数据,共 {} 段,weldDev={},celLength = {},cxlLength = {}。 ", listSegment.size(), weldDev, celLength, cxlLength); logDataService.logInfo("TRACK", "Start processing segments: count=" + listSegment.size() + ", weldDev=" + weldDev); @@ -371,7 +375,14 @@ public class SegmentTrackerService { logDataService.logInfo("MATMAP-TRACK", "CoilId=" + coilId + "Weld position matching logic, current weld length ="+headPos); } - Set prevReached = coilReachedDevices.computeIfAbsent(coilId, + Integer payOffReelNumber = entry != null ? entry.getPayOffReelNumber() : null; + if (payOffReelNumber == null || payOffReelNumber < 1) { + log.warn("trackCoilHeadPosition: invalid payOffReelNumber={}, coilId={}", payOffReelNumber, coilId); + return; + } + + String reachKey = coilId + "#POR" + payOffReelNumber; + Set prevReached = coilReachedDevices.computeIfAbsent(reachKey, k -> Collections.newSetFromMap(new ConcurrentHashMap<>())); if (LogRateLimiter.shouldLog("TRACK:" + coilId, 5000)) { @@ -385,10 +396,49 @@ public class SegmentTrackerService { double dynPos = stripPositionService.calculate(d, celLength, cxlLength); log.info("焊缝位置匹配逻辑,当前焊缝长度{},当前计算的设备长度:{}", headPos, dynPos); - if (headPos.compareTo(BigDecimal.valueOf(dynPos)) >= 0 && !prevReached.contains(d)) { + boolean positionReached = headPos.compareTo(BigDecimal.valueOf(dynPos)) >= 0; - MatmapDTO matmap = MatmapUtil.getMatmap(entry.getPayOffReelNumber()-1); - MatmapUtil.setMatId(d.getIdx(), coilId,matmap.getPlanId()); + // --- 针对大辊缝时 stripLocation 更新延迟的补偿逻辑 --- + // 只要入口段速度 > 阈值,就认为已经开始进入生产状态,可以触发 WELDER 到达 + boolean welderIsMoving = false; + if (d == DeviceEnum.WELDER && entry != null && entry.getStripSpeed() != null) { + if (entry.getStripSpeed().doubleValue() > LOWSPEEDLIMIT) { + welderIsMoving = true; + log.info("【WELDER-SPEED-TRIGGER】CoilId: {}, Speed: {} > {}, 触发状态变更", + coilId, entry.getStripSpeed().doubleValue(), LOWSPEEDLIMIT); + } + } + + if ((positionReached || welderIsMoving) && !prevReached.contains(d)) { + + MatmapDTO matmap = MatmapUtil.getMatmap(payOffReelNumber - 1); + + // 关键点:POR1/POR2 是两路入口,各自有独立的 matmap 槽位。 + // 设备到达时只更新该入口对应的设备槽位,避免把另一入口(另一开卷机/活套)覆盖。 + int targetIdx = d.getIdx(); + if (payOffReelNumber == 1) { + if (d == DeviceEnum.POR2) { + continue; + } + if (d == DeviceEnum.ENL2 || d == DeviceEnum.ENL3) { + continue; + } + if (d == DeviceEnum.CXL2) { + continue; + } + } else if (payOffReelNumber == 2) { + if (d == DeviceEnum.POR1) { + continue; + } + if (d == DeviceEnum.ENL1 || d == DeviceEnum.ENL3) { + continue; + } + if (d == DeviceEnum.CXL1) { + continue; + } + } + + MatmapUtil.setMatId(targetIdx, coilId, matmap.getPlanId()); if (d == DeviceEnum.WELDER) { logDataService.logInfo("MATMAP-TRACK", "Coil reached welder, update plan status. coil=" + coilId + ", headPos=" + headPos);