1,2写入区分修正

This commit is contained in:
2026-01-20 17:56:48 +08:00
parent 65d9f59ac4
commit a3e46674b3

View File

@@ -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<DeviceEnum> 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<DeviceEnum> 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);