From 3b8bd7dbba101f4207a08bf0254a9e58bc708348 Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期一, 19 一月 2026 13:34:12 +0800
Subject: [PATCH] #

---
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/HandlerController.java |   60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/HandlerController.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/HandlerController.java
index c3895f2..4cedd28 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/HandlerController.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/HandlerController.java
@@ -75,6 +75,8 @@
     private PatrolService patrolService;
     @Autowired
     private StaReserveService staReserveService;
+    @Autowired
+    private AgvAreaDispatcher agvAreaDispatcher;
 
     @PreAuthorize("hasAuthority('manager:agv:update')")
     @OperationLog("Locate All Agv")
@@ -171,6 +173,7 @@
         task.setPriority(999);
         task.setIoTime(now);
         task.setStartTime(now);
+        task.setMemo("AUTO");
         if (!taskService.save(task)) {
             throw new BusinessException(task.getSeqNum() + "浠诲姟淇濆瓨澶辫触");
         }
@@ -192,12 +195,23 @@
                 if (null == endCode) {
                     return R.error();
                 }
+                if (!agvAreaDispatcher.match(agv.getId(), endCode.getId())) {
+                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + endCode.getData());
+                }
+                if (!taskService.removeById(task.getId())) {
+                    throw new BusinessException("failed to remove task");
+                }
+                task = null;
                 if (!mainLockWrapService.buildMinorTask(agv.getId(), param.getTaskMode(), endCode.getData(), null)) {
                     return R.error();
                 }
                 break;
             case TO_CHARGE:
             case TO_STANDBY:
+                if (!taskService.removeById(task.getId())) {
+                    throw new BusinessException("failed to remove task");
+                }
+                task = null;
                 if (!mainLockWrapService.buildMinorTask(agv.getId(), param.getTaskMode(), null, null)) {
                     return R.error();
                 }
@@ -212,6 +226,10 @@
                 }
                 if (null == oriLoc) {
                     return R.error();
+                }
+                if (!agvAreaDispatcher.match(agv.getId(), oriLoc.getCode())) {
+//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriLoc.getCode$());
+                    throw new BusinessException("AGV銆�" + agv.getUuid() + "銆戞棤娉曞埌杈捐捣濮嬪簱浣嶃��" + oriLoc.getLocNo() + "銆�");
                 }
                 if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
                     throw new BusinessException("oriLoc锛�" + oriLoc.getLocNo() + " 涓嶆槸鍦ㄥ簱鐘舵��");
@@ -231,6 +249,10 @@
                 }
                 if (null == destLoc) {
                     return R.error();
+                }
+                if (!agvAreaDispatcher.match(agv.getId(), destLoc.getCode())) {
+//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destLoc.getCode$());
+                    throw new BusinessException("AGV銆�" + agv.getUuid() + "銆戞棤娉曞埌杈剧洰鏍囧簱浣嶃��" + destLoc.getLocNo() + "銆�");
                 }
                 if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
                     throw new BusinessException("destLoc锛�" + destLoc.getLocNo() + " 涓嶆槸绌洪棽鐘舵��");
@@ -258,6 +280,10 @@
                 if (null == oriLoc) {
                     return R.error();
                 }
+                if (!agvAreaDispatcher.match(agv.getId(), oriLoc.getCode())) {
+//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriLoc.getCode$());
+                    throw new BusinessException("AGV銆�" + agv.getUuid() + "銆戞棤娉曞埌杈捐捣濮嬪簱浣嶃��" + oriLoc.getLocNo() + "銆�");
+                }
                 if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
                     throw new BusinessException("oriLoc锛�" + oriLoc.getLocNo() + " 涓嶆槸鍦ㄥ簱鐘舵��");
                 }
@@ -277,15 +303,20 @@
                 if (null == destSta) {
                     return R.error();
                 }
+                if (!agvAreaDispatcher.match(agv.getId(), destSta.getCode())) {
+//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destSta.getCode$());
+                    throw new BusinessException("AGV銆�" + agv.getUuid() + "銆戞棤娉曞埌杈剧洰鏍囩珯鐐广��" + destSta.getStaNo() + "銆�");
+                }
                 if (null == staReserveService.reserveStaIn(destSta, task, 1)) {
                     throw new BusinessException("destSta锛�" + destSta.getStaNo() + " 棰勭害澶辫触");
                 }
-
                 // task
                 task.setOriLoc(oriLoc.getId());
                 task.setOriCode(oriLoc.getCode());
                 task.setDestSta(destSta.getId());
                 task.setDestCode(destSta.getCode());
+
+                staReserveService.allocateCallBack(task, agv.getId());
                 break;
             case STA_TO_LOC:
                 // oriSta
@@ -297,6 +328,10 @@
                 }
                 if (null == oriSta) {
                     return R.error();
+                }
+                if (!agvAreaDispatcher.match(agv.getId(), oriSta.getCode())) {
+//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriSta.getCode$());
+                    throw new BusinessException("AGV銆�" + agv.getUuid() + "銆戞棤娉曞埌杈捐捣濮嬬珯鐐广��" + oriSta.getStaNo() + "銆�");
                 }
                 if (null == staReserveService.reserveStaOut(oriSta, task, 1)) {
                     throw new BusinessException("oriSta锛�" + oriSta.getStaNo() + " 棰勭害澶辫触");
@@ -312,6 +347,10 @@
                 if (null == destLoc) {
                     return R.error();
                 }
+                if (!agvAreaDispatcher.match(agv.getId(), destLoc.getCode())) {
+//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destLoc.getCode$());
+                    throw new BusinessException("AGV銆�" + agv.getUuid() + "銆戞棤娉曞埌杈剧洰鏍囧簱浣嶃��" + destLoc.getLocNo() + "銆�");
+                }
                 if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
                     throw new BusinessException("destLoc锛�" + destLoc.getLocNo() + " 涓嶆槸绌洪棽鐘舵��");
                 }
@@ -326,6 +365,8 @@
                 task.setOriCode(oriSta.getCode());
                 task.setDestLoc(destLoc.getId());
                 task.setDestCode(destLoc.getCode());
+
+                staReserveService.allocateCallBack(task, agv.getId());
                 break;
             case STA_TO_STA:
                 // oriSta
@@ -338,9 +379,14 @@
                 if (null == oriSta) {
                     return R.error();
                 }
+                if (!agvAreaDispatcher.match(agv.getId(), oriSta.getCode())) {
+//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriSta.getCode$());
+                    throw new BusinessException("AGV銆�" + agv.getUuid() + "銆戞棤娉曞埌杈捐捣濮嬬珯鐐广��" + oriSta.getStaNo() + "銆�");
+                }
                 if (null == staReserveService.reserveStaOut(oriSta, task, 1)) {
                     throw new BusinessException("oriSta锛�" + oriSta.getStaNo() + " 棰勭害澶辫触");
                 }
+
 
                 // destSta
                 if (!Cools.isEmpty(param.getEndStaNo())) {
@@ -352,6 +398,10 @@
                 if (null == destSta) {
                     return R.error();
                 }
+                if (!agvAreaDispatcher.match(agv.getId(), destSta.getCode())) {
+//                    throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destSta.getCode$());
+                    throw new BusinessException("AGV銆�" + agv.getUuid() + "銆戞棤娉曞埌杈剧洰鏍囩珯鐐广��" + destSta.getStaNo() + "銆�");
+                }
                 if (null == staReserveService.reserveStaIn(destSta, task, 1)) {
                     throw new BusinessException("destSta锛�" + destSta.getStaNo() + " 棰勭害澶辫触");
                 }
@@ -361,13 +411,17 @@
                 task.setOriCode(oriSta.getCode());
                 task.setDestSta(destSta.getId());
                 task.setDestCode(destSta.getCode());
+
+                staReserveService.allocateCallBack(task, agv.getId());
                 break;
             default:
                 break;
         }
 
-        if (!taskService.updateById(task)) {
-            throw new BusinessException("浠诲姟鏇存柊澶辫触");
+        if (null != task) {
+            if (!taskService.updateById(task)) {
+                throw new BusinessException("浠诲姟鏇存柊澶辫触");
+            }
         }
         return R.ok();
     }

--
Gitblit v1.9.1