From e7e23e6260588292ff6325eab259f040c03ba726 Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期四, 15 一月 2026 09:58:28 +0800
Subject: [PATCH] #

---
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java |   41 +++++++++++++++++++++++++----------------
 1 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
index 90f5fe9..c6c21d6 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
@@ -936,7 +936,6 @@
                 if (!lastCode.getData().equals(code.getData())) {
 
                     // 璧拌璺緞鑺傜偣
-//                    List<String> pathList = mapService.checkoutPath(agv.getUuid(), lastCode, code);
                     List<String> pathListPart = pathList.subList(pathList.indexOf(lastCode.getData()), pathList.indexOf(code.getData()) + 1);
 
                     for (int i = 0; i < pathListPart.size(); i++) {
@@ -965,11 +964,11 @@
 
                         // 宸烽亾寮哄埗杞集锛屼紭鍏堢骇 > workDirection
                         if (null != nextLaneDir) {
-                            nextDirection = nextLaneDir;
+                            final double oppNextLaneDir = (nextLaneDir + 180) % 360;
 
-                            if (!lastDirection.equals(nextDirection)) {
+                            if (!lastDirection.equals(nextLaneDir)) {
                                 if (!lastCode.getCornerBool()) {
-                                    throw new CoolException(agvNo + "鍙峰皬杞﹁繘鍏ュ贩閬撻渶璋冩暣鏂瑰悜涓� " + nextDirection + "掳锛岃鎺ㄨ嚦杞集鐐规墜鍔ㄨ皟鏁�");
+                                    throw new CoolException(agvNo + "鍙峰皬杞﹁繘鍏ュ贩閬撻渶璋冩暣鏂瑰悜涓� " + nextLaneDir + "掳锛岃鎺ㄨ嚦杞集鐐规墜鍔ㄨ皟鏁�");
                                 }
                                 // turn
                                 actionList.add(new Action(
@@ -979,24 +978,34 @@
                                         null,    // 鍔ㄤ綔鍙�
                                         null,    // 浼樺厛绾�
                                         ActionTypeType.TurnCorner.desc,    // 鍚嶇О
-                                        (double) mapService.spinDirection(lastCode).val,     // 灞炴�у��
+                                        (double) MapService.calcSpinDirection(lastCode, lastDirection, nextLaneDir).val,     // 灞炴�у��
                                         lastCode.getData(),    // 鍦伴潰鐮�
-                                        String.valueOf(nextDirection),   // 鍔ㄤ綔鍙傛暟
+                                        String.valueOf(nextLaneDir),   // 鍔ㄤ綔鍙傛暟
                                         ActionTypeType.TurnCorner.val(),    // 鍔ㄤ綔绫诲瀷
                                         actionPrepareSts,    // 鍔ㄤ綔杩涘害
                                         agvId,    // AGV
                                         now    // 宸ヤ綔鏃堕棿
                                 ));
-                                lastDirection = nextDirection;
+                                lastDirection = nextLaneDir;
                             }
-                        } else if (null != lastLaneDir) {
-                            nextDirection = lastLaneDir;
 
-                            if (!lastDirection.equals(nextDirection)) {
+                            if (nextDirection.equals(oppNextLaneDir)) {
+                                reverse = true;
+                            }
+                            nextDirection = nextLaneDir; // 闃叉 绗竴涓姩浣滀竴瀹氭槸 turn 鍑洪棶棰�
+                        } else if (null != lastLaneDir) { // todo turn 鐜舰鐩磋
+                            final double oppLastLaneDir = (lastLaneDir + 180) % 360;
+
+                            if (!lastDirection.equals(lastLaneDir)) {
                                 if (!lastCode.getCornerBool()) {
                                     throw new CoolException(agvNo + "鍙峰皬杞︾寮�宸烽亾闇�璋冩暣鏂瑰悜涓� " + nextDirection + "掳锛岃鎺ㄨ嚦杞集鐐规墜鍔ㄨ皟鏁�");
                                 }
                             }
+
+                            if (nextDirection.equals(oppLastLaneDir)) {
+                                reverse = true;
+                            }
+                            nextDirection = lastLaneDir; // 闃叉 绗竴涓姩浣滀竴瀹氭槸 turn 鍑洪棶棰�
                         } else {
 
                             // 濡傛灉涓嬩竴涓柟鍚戞濂芥槸浣滀笟鏂瑰悜鐨勭浉鍙嶆柟鍚戯紝鍒欓噸缃笅涓�涓柟鍚戜负浣滀笟鏂瑰悜锛屾爣璁� reverse = true
@@ -1036,7 +1045,7 @@
                                                 null,    // 鍔ㄤ綔鍙�
                                                 null,    // 浼樺厛绾�
                                                 ActionTypeType.TurnCorner.desc,    // 鍚嶇О
-                                                (double) mapService.spinDirection(lastCode).val,     // 灞炴�у��
+                                                (double) MapService.calcSpinDirection(lastCode, lastDirection, nextDirection).val,     // 灞炴�у��
                                                 lastCode.getData(),    // 鍦伴潰鐮�
                                                 String.valueOf(nextDirection),   // 鍔ㄤ綔鍙傛暟
                                                 ActionTypeType.TurnCorner.val(),    // 鍔ㄤ綔绫诲瀷
@@ -1061,7 +1070,7 @@
                                     null,    // 鍔ㄤ綔鍙�
                                     null,    // 浼樺厛绾�
                                     ActionTypeType.TurnCorner.desc,    // 鍚嶇О
-                                    (double) mapService.spinDirection(lastCode).val,    // 灞炴�у��
+                                    (double) MapService.calcSpinDirection(lastCode, lastDirection, nextDirection).val,    // 灞炴�у��
                                     lastCode.getData(),    // 鍦伴潰鐮�
                                     String.valueOf(nextDirection),   // 鍔ㄤ綔鍙傛暟
                                     ActionTypeType.TurnCorner.val(),    // 鍔ㄤ綔绫诲瀷
@@ -1128,7 +1137,7 @@
                                 null,    // 鍔ㄤ綔鍙�
                                 null,    // 浼樺厛绾�
                                 ActionTypeType.TurnCorner.desc,    // 鍚嶇О
-                                (double) mapService.spinDirection(lastCode).val,    // 灞炴�у��
+                                (double) MapService.calcSpinDirection(lastCode, lastDirection, firstTurnDir).val,    // 灞炴�у��
                                 lastCode.getData(),    // 鍦伴潰鐮�
                                 String.valueOf(firstTurnDir),   // 鍔ㄤ綔鍙傛暟
                                 ActionTypeType.TurnCorner.val(),    // 鍔ㄤ綔绫诲瀷
@@ -1254,7 +1263,7 @@
                                     null,    // 鍔ㄤ綔鍙�
                                     null,    // 浼樺厛绾�
                                     ActionTypeType.TurnCorner.desc,    // 鍚嶇О
-                                    (double) mapService.spinDirection(lastCode).val,   // 灞炴�у��
+                                    (double) MapService.calcSpinDirection(lastCode, lastDirection, oriStaWorkDirection).val,   // 灞炴�у��
                                     lastCode.getData(),    // 鍦伴潰鐮�
                                     String.valueOf(oriStaWorkDirection),   // 鍔ㄤ綔鍙傛暟
                                     ActionTypeType.TurnCorner.val(),    // 鍔ㄤ綔绫诲瀷
@@ -1318,7 +1327,7 @@
                                     null,    // 鍔ㄤ綔鍙�
                                     null,    // 浼樺厛绾�
                                     ActionTypeType.TurnCorner.desc,    // 鍚嶇О
-                                    (double) mapService.spinDirection(lastCode).val,    // 灞炴�у��
+                                    (double) MapService.calcSpinDirection(lastCode, lastDirection, destStaWorkDirection).val,    // 灞炴�у��
                                     lastCode.getData(),    // 鍦伴潰鐮�
                                     String.valueOf(destStaWorkDirection),   // 鍔ㄤ綔鍙傛暟
                                     ActionTypeType.TurnCorner.val(),    // 鍔ㄤ綔绫诲瀷
@@ -1377,7 +1386,7 @@
                                     null,    // 鍔ㄤ綔鍙�
                                     null,    // 浼樺厛绾�
                                     ActionTypeType.TurnCorner.desc,    // 鍚嶇О
-                                    (double) mapService.spinDirection(lastCode).val,    // 灞炴�у��
+                                    (double) MapService.calcSpinDirection(lastCode, lastDirection, chargeDirection).val,    // 灞炴�у��
                                     lastCode.getData(),    // 鍦伴潰鐮�
                                     String.valueOf(chargeDirection),   // 鍔ㄤ綔鍙傛暟
                                     ActionTypeType.TurnCorner.val(),    // 鍔ㄤ綔绫诲瀷

--
Gitblit v1.9.1