From cd67e854d4715bc92a16dc7bffdbde7be1da9957 Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期四, 27 三月 2025 13:02:37 +0800
Subject: [PATCH] #

---
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java |  122 +++++++++++++++++++++++++++-------------
 1 files changed, 83 insertions(+), 39 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 8b08e91..e14d05b 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
@@ -667,7 +667,7 @@
             List<Action> actionList = new ArrayList<>();
             // start node
             Code lastCode = codeService.getCacheById(agvDetail.getRecentCode());
-            Double lastDirection = agvDetail.getAgvAngle();
+            Double lastDirection = MapService.mapToNearest(agvDetail.getAgvAngle());
             if (!lastCode.getData().equals(pathList.get(0))) {
                 throw new CoolException("AGV[" + agvNo + "]瀹氫綅鍋忕Щ...");
             }
@@ -696,12 +696,55 @@
                         Code nextCode = codeService.getCacheByData(next);
                         Double nextDirection = mapService.calculateDirection(lastCode, nextCode, angleOffsetVal);
 
+                        // 绗竴姝ワ細濡傛灉涓嬩竴涓柟鍚戞濂芥槸浣滀笟鏂瑰悜鐨勭浉鍙嶆柟鍚戯紝鍒欓噸缃笅涓�涓柟鍚戜负浣滀笟鏂瑰悜锛屾爣璁� reverse = true
                         boolean reverse = false;
                         if (nextDirection.equals((workDirection + 180) % 360)) {
                             nextDirection = workDirection;
                             reverse = true;
                         }
-                        if (!lastDirection.equals(nextDirection) || actionList.isEmpty()) {
+
+                        // 绗簩姝ワ細鍒ゆ柇褰撳墠鑺傜偣鏄惁鍙互鏃嬭浆
+                        if (!lastCode.getCornerBool()) {
+                            // 濡傛灉鏄綔涓氭柟鍚戯紝浣嗘槸灏忚溅鍦ㄥ贩閬撳唴鏂瑰悜閿欒锛屽垯鍋滄
+                            if (reverse && !lastDirection.equals(nextDirection)) {
+//                                throw new CoolException(agvNo + "鍙峰皬杞︽柟鍚戦敊璇紝璇锋帹鑷宠浆寮偣鎵嬪姩璋冩暣");
+                            }
+                            // 濡傛灉涓嶆槸浣滀笟鏂瑰悜锛屽垽鏂槸鍚︾浉鍙嶆柟鍚戯紝濡傛灉鍙嶆柟鍚戝垯鍊掗��琛岃蛋
+                            if (nextDirection.equals((lastDirection + 180) % 360)) {
+                                nextDirection = lastDirection;
+                                reverse = true;
+                            }
+                        } else {
+                            if (!lastDirection.equals(nextDirection)) {
+                                // 濡傛灉涓嬩釜鑺傜偣鏂瑰悜涓庡綋鍓峚gv鏂瑰悜鐩稿弽锛屽垯鍊掗��琛岃蛋锛屼絾鏄鏋滃綋鍓峚gv鏂瑰悜姝eソ涓庡伐浣滄柟鍚戠浉鍙嶏紝鍒欐棆杞嚦宸ヤ綔鏂瑰悜
+                                if (nextDirection.equals((lastDirection + 180) % 360) && !workDirection.equals((lastDirection + 180) % 360)) {
+                                    nextDirection = lastDirection;
+                                    reverse = true;
+                                } else {
+                                    // turn
+                                    actionList.add(new Action(
+                                            null,    // 缂栧彿s
+                                            task.getBusId(),    // 鎬荤嚎
+                                            task.getId(),    // 浠诲姟
+                                            null,    // 鍔ㄤ綔鍙�
+                                            null,    // 浼樺厛绾�
+                                            ActionTypeType.TurnCorner.desc,    // 鍚嶇О
+                                            mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D,    // 灞炴�у��
+                                            lastCode.getData(),    // 鍦伴潰鐮�
+                                            String.valueOf(nextDirection),   // 鍔ㄤ綔鍙傛暟
+                                            ActionTypeType.TurnCorner.val(),    // 鍔ㄤ綔绫诲瀷
+                                            actionPrepareSts,    // 鍔ㄤ綔杩涘害
+                                            agvId,    // AGV
+                                            now    // 宸ヤ綔鏃堕棿
+                                    ));
+
+                                    lastDirection = nextDirection;
+                                }
+                            }
+                        }
+
+                        // 绗竴涓姩浣滀竴瀹氭槸 turn
+                        if (actionList.isEmpty()) {
                             // turn
                             actionList.add(new Action(
                                     null,    // 缂栧彿
@@ -720,7 +763,6 @@
                             ));
 
                             lastDirection = nextDirection;
-
                         }
 
                         // run
@@ -785,23 +827,24 @@
                         assert backpackType != null;
                         // 妫�楠屾柟鍚�
                         if (!lastDirection.equals(workDirection)) {
+                            throw new CoolException(agvNo + "鍙峰皬杞︽柟鍚戦敊璇紝璇锋帹鑷宠浆寮偣鎵嬪姩璋冩暣");
                             // turn
-                            actionList.add(new Action(
-                                    null,    // 缂栧彿
-                                    task.getBusId(),    // 鎬荤嚎
-                                    task.getId(),    // 浠诲姟
-                                    null,    // 鍔ㄤ綔鍙�
-                                    null,    // 浼樺厛绾�
-                                    ActionTypeType.TurnCorner.desc,    // 鍚嶇О
-                                    mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D,    // 灞炴�у��
-                                    lastCode.getData(),    // 鍦伴潰鐮�
-                                    String.valueOf(workDirection),   // 鍔ㄤ綔鍙傛暟
-                                    ActionTypeType.TurnCorner.val(),    // 鍔ㄤ綔绫诲瀷
-                                    actionPrepareSts,    // 鍔ㄤ綔杩涘害
-                                    agvId,    // AGV
-                                    now    // 宸ヤ綔鏃堕棿
-                            ));
-                            lastDirection = workDirection;
+//                            actionList.add(new Action(
+//                                    null,    // 缂栧彿
+//                                    task.getBusId(),    // 鎬荤嚎
+//                                    task.getId(),    // 浠诲姟
+//                                    null,    // 鍔ㄤ綔鍙�
+//                                    null,    // 浼樺厛绾�
+//                                    ActionTypeType.TurnCorner.desc,    // 鍚嶇О
+//                                    mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D,    // 灞炴�у��
+//                                    lastCode.getData(),    // 鍦伴潰鐮�
+//                                    String.valueOf(workDirection),   // 鍔ㄤ綔鍙傛暟
+//                                    ActionTypeType.TurnCorner.val(),    // 鍔ㄤ綔绫诲瀷
+//                                    actionPrepareSts,    // 鍔ㄤ綔杩涘害
+//                                    agvId,    // AGV
+//                                    now    // 宸ヤ綔鏃堕棿
+//                            ));
+//                            lastDirection = workDirection;
                         }
                         // 璐ф灦鍙栬揣
                         Loc oriLoc = locService.getById(task.getOriLoc());
@@ -843,23 +886,24 @@
                         assert backpackType != null;
                         // 妫�楠屾柟鍚�
                         if (!lastDirection.equals(workDirection)) {
-                            // turn
-                            actionList.add(new Action(
-                                    null,    // 缂栧彿
-                                    task.getBusId(),    // 鎬荤嚎
-                                    task.getId(),    // 浠诲姟
-                                    null,    // 鍔ㄤ綔鍙�
-                                    null,    // 浼樺厛绾�
-                                    ActionTypeType.TurnCorner.desc,    // 鍚嶇О
-                                    mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D,    // 灞炴�у��
-                                    lastCode.getData(),    // 鍦伴潰鐮�
-                                    String.valueOf(workDirection),   // 鍔ㄤ綔鍙傛暟
-                                    ActionTypeType.TurnCorner.val(),    // 鍔ㄤ綔绫诲瀷
-                                    actionPrepareSts,    // 鍔ㄤ綔杩涘害
-                                    agvId,    // AGV
-                                    now    // 宸ヤ綔鏃堕棿
-                            ));
-                            lastDirection = workDirection;
+                            throw new CoolException(agvNo + "鍙峰皬杞︽柟鍚戦敊璇紝璇锋帹鑷宠浆寮偣鎵嬪姩璋冩暣");
+//                            // turn
+//                            actionList.add(new Action(
+//                                    null,    // 缂栧彿
+//                                    task.getBusId(),    // 鎬荤嚎
+//                                    task.getId(),    // 浠诲姟
+//                                    null,    // 鍔ㄤ綔鍙�
+//                                    null,    // 浼樺厛绾�
+//                                    ActionTypeType.TurnCorner.desc,    // 鍚嶇О
+//                                    mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D,    // 灞炴�у��
+//                                    lastCode.getData(),    // 鍦伴潰鐮�
+//                                    String.valueOf(workDirection),   // 鍔ㄤ綔鍙傛暟
+//                                    ActionTypeType.TurnCorner.val(),    // 鍔ㄤ綔绫诲瀷
+//                                    actionPrepareSts,    // 鍔ㄤ綔杩涘害
+//                                    agvId,    // AGV
+//                                    now    // 宸ヤ綔鏃堕棿
+//                            ));
+//                            lastDirection = workDirection;
                         }
                         // 鏆傚瓨鐐瑰彇璐ц揣
                         actionList.add(new Action(
@@ -1050,9 +1094,9 @@
                 action.setStartTime(now);
                 action.setIoTime(now);
                 action.setUpdateTime(now);
-                if (!actionService.updateById(action)) {
-                    throw new BusinessException(action.getPriority() + " - " + action.getName() + "鍔ㄤ綔鏇存柊澶辫触");
-                }
+            }
+            if (!actionService.updateBatchById(actionList)) {
+                throw new BusinessException("failed to update action batch !!!");
             }
 
             // task

--
Gitblit v1.9.1