jianghaiyue
7 天以前 1d520bffcd63cb8389c9cdf719c3cf7e7c4af567
algo-zkd/src/main/java/com/algo/service/RemainingPathProcessor.java
@@ -193,8 +193,16 @@
            String currentDirection = currentCode.getDirection();
            String nextDirection = nextCode.getDirection();
            if (!currentDirection.equals(nextDirection)) {
                stayTime += config.getTurnTime(currentDirection, nextDirection);
            if (currentDirection != null && nextDirection != null) {
                if (!currentDirection.equals(nextDirection)) {
                    stayTime += config.getTurnTime(currentDirection, nextDirection);
                }
            } else {
                if (pathIndex == agv.getCurrentPathIndex()) {
                    System.out.println("AGV " + agv.getAgvId() +
                                     " 的剩余路径中direction字段为null");
                }
                stayTime += 0.5;
            }
        }
@@ -208,7 +216,7 @@
                    stayTime += 2.0; // 放货需要2秒
                    break;
                case "3": // 充电
                    stayTime += 10.0; // 充电停靠需要10秒
                    stayTime += 100.0; // 充电停靠
                    break;
                default:
                    stayTime += 1.0; // 其他动作需要1秒
@@ -402,11 +410,26 @@
        connectedPath.setAgvId(agv.getAgvId());
        connectedPath.setCodeList(remainingCodes);
        // 生成新的段落ID
        String segId = agv.getAgvId() + "_CONNECTED_" + System.currentTimeMillis();
        if (newPath != null && newPath.getSegId() != null) {
            segId = newPath.getSegId() + "_EXTENDED";
        // 使用剩余路径的原始segId
        String segId = remainingPath.getSegId();
        if (segId != null && !segId.trim().isEmpty()) {
            // 如果有新路径连接,在原segId基础上添加扩展标记
            if (newPath != null && newPath.getCodeList() != null && !newPath.getCodeList().isEmpty()) {
                // 检查是否已经有扩展标记,避免重复添加
                if (!segId.endsWith("_EXTENDED")) {
                    segId = segId + "_EXTENDED";
                }
            }
        } else {
            // 如果原始路径没有segId,根据情况生成
            if (newPath != null && newPath.getSegId() != null && !newPath.getSegId().trim().isEmpty()) {
                segId = newPath.getSegId() + "_EXTENDED";
            } else {
                segId = agv.getAgvId() + "_CONNECTED_" + System.currentTimeMillis();
            }
        }
        connectedPath.setSegId(segId);
        return connectedPath;