From 70930071a49190f414c8d8bc9c9e9795a4096739 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期一, 23 三月 2026 16:08:27 +0800
Subject: [PATCH] Merge branch 'refs/heads/rcs_master' into jdxaj

---
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AllocateService.java |   35 ++++++++++++++++++++---------------
 1 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AllocateService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AllocateService.java
index 0dc1f6f..9b5d35c 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AllocateService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AllocateService.java
@@ -15,6 +15,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import com.zy.acs.common.utils.News;
 
 import java.util.*;
 import java.util.stream.Collectors;
@@ -50,6 +51,8 @@
     private AgvAreaDispatcher agvAreaDispatcher;
     @Autowired
     private SegmentService segmentService;
+    @Autowired
+    private TravelService travelService;
 
     /**
      * get available agv list which is idle
@@ -62,7 +65,6 @@
         List<String> result = new ArrayList<>();
         for (Agv agv : agvList) {
             if (!hasRunning) {
-                // 1. without running tasks
                 if (0 < taskService.count(new LambdaQueryWrapper<Task>()
                         .eq(Task::getAgvId, agv.getId())
                         .and(i -> i
@@ -73,10 +75,13 @@
                 )) {
                     continue;
                 }
-            }
-            // 2. in idle status
-            if (!agvService.judgeEnable(agv.getId(), true)) {
-                continue;
+                if (!agvService.judgeEnable(agv.getId(), true, true)) {
+                    continue;
+                }
+            } else {
+                if (!agvService.judgeEnable(agv.getId(), true, false)) {
+                    continue;
+                }
             }
 
             result.add(agv.getUuid());
@@ -158,7 +163,7 @@
         List<String> availableAgvNos = this.getAvailableAgvNos(agvAreaDispatcher.getAgvIdsByTask(task), false);
 //        List<String> availableAgvNos = this.getAvailableAgvNos(null);
         if (Cools.isEmpty(availableAgvNos)) {
-//            log.warn("No available agv to assign the task[{}]", task.getSeqNum());
+//            News.warn("No available agv to assign the task[{}]", task.getSeqNum());
             return null;
         }
 
@@ -221,15 +226,15 @@
 //                continue;
 //            }
             // in TransferStationHandler.hasDelayAtSta
-            Segment currSeg = segmentService.getRollerWaiting(agvId, sta.getCode(), TaskPosDto.PosType.ORI_STA);
-            if (null == currSeg) {
+            Travel currTravelInRollerWaiting = travelService.findRollerWaitingTravel(agvId, currentCode.getId());
+            if (null == currTravelInRollerWaiting) {
                 continue;
             }
 
             // has enough backpack space to load
-            Integer backpack = agvService.getBackpack(agvId);
-            List<Integer> usedBackpacks = segmentService.selectUsedBackpacks(null, agvId);
-            if (usedBackpacks.size() >= backpack) {
+            Integer backpackCap = agvService.getBackpack(agvId);
+            List<Integer> usedBackpacks = segmentService.selectUsedBackpacks(currTravelInRollerWaiting.getId(), agvId);
+            if (usedBackpacks.size() >= backpackCap) {
                 continue;
             }
 
@@ -321,16 +326,16 @@
 
         // valid
         if (Cools.isEmpty(availableAgvNosByOriLane)) {
-            log.warn("No available agv to assign the task origin[{}]", task.getSeqNum());
+            News.warn("No available agv to assign the task origin[{}]", task.getSeqNum());
             return null;
         }
         if (Cools.isEmpty(availableAgvNosByDestLane)) {
-            log.warn("No available agv to assign the task destination[{}]", task.getSeqNum());
+            News.warn("No available agv to assign the task destination[{}]", task.getSeqNum());
             return null;
         }
         List<String> actualAvailableAgvNos = Cools.getIntersection(availableAgvNosByOriLane, availableAgvNosByDestLane);
         if (Cools.isEmpty(actualAvailableAgvNos)) {
-            log.warn("No available agv to assign the task[{}]", task.getSeqNum());
+            News.warn("No available agv to assign the task[{}]", task.getSeqNum());
             return null;
         }
 
@@ -522,4 +527,4 @@
         }
     }
 
-}
+}
\ No newline at end of file

--
Gitblit v1.9.1