From d62f97dabd206364220b74dfa0bb065d4e64dc7b Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 20 三月 2026 18:16:56 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/StationCycleCapacityServiceImpl.java |   45 ++++++++++++++++++++++++++++++++++++---------
 1 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/StationCycleCapacityServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/StationCycleCapacityServiceImpl.java
index f06ff9a..08525e5 100644
--- a/src/main/java/com/zy/asrs/service/impl/StationCycleCapacityServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/StationCycleCapacityServiceImpl.java
@@ -74,7 +74,9 @@
 
     private StationCycleCapacityVo buildSnapshot() {
         GraphContext context = buildStationGraph();
-        Map<Integer, Integer> workNoMap = buildStationWorkNoMap();
+        StationOccupancyContext occupancyContext = buildStationOccupancyContext();
+        Map<Integer, Integer> workNoMap = occupancyContext.workNoMap;
+        Set<Integer> manualStationSet = occupancyContext.manualStationSet;
 
         Set<Integer> availableStationSet = new HashSet<>(context.graph.keySet());
         availableStationSet.removeAll(context.excludeStationSet);
@@ -97,6 +99,8 @@
         int loopNo = 1;
         int totalStationCount = 0;
         int taskStationCount = 0;
+        int manualStationCount = 0;
+        int occupiedStationCount = 0;
         Set<Integer> actualWorkNoSet = new HashSet<>();
 
         for (Set<Integer> scc : sccList) {
@@ -112,12 +116,17 @@
 
                 List<Integer> workNoList = new ArrayList<>();
                 int currentLoopTaskCount = 0;
+                int currentLoopManualStationCount = 0;
                 for (Integer stationId : stationIdList) {
                     Integer workNo = workNoMap.get(stationId);
                     if (workNo != null && workNo > 0) {
                         workNoList.add(workNo);
                         currentLoopTaskCount++;
                         actualWorkNoSet.add(workNo);
+                        continue;
+                    }
+                    if (manualStationSet.contains(stationId)) {
+                        currentLoopManualStationCount++;
                     }
                 }
 
@@ -127,23 +136,30 @@
                 loopVo.setWorkNoList(workNoList);
                 loopVo.setStationCount(stationIdList.size());
                 loopVo.setTaskCount(currentLoopTaskCount);
-                loopVo.setCurrentLoad(calcCurrentLoad(currentLoopTaskCount, stationIdList.size()));
+                loopVo.setManualStationCount(currentLoopManualStationCount);
+                loopVo.setOccupiedStationCount(currentLoopTaskCount + currentLoopManualStationCount);
+                loopVo.setCurrentLoad(calcCurrentLoad(toNonNegative(loopVo.getOccupiedStationCount()), stationIdList.size()));
                 loopList.add(loopVo);
 
                 totalStationCount += stationIdList.size();
                 taskStationCount += currentLoopTaskCount;
+                manualStationCount += currentLoopManualStationCount;
+                occupiedStationCount += toNonNegative(loopVo.getOccupiedStationCount());
             }
         }
 
         int reserveTaskCount = mergeReserveTaskCount(loopList, actualWorkNoSet);
         taskStationCount += reserveTaskCount;
+        occupiedStationCount += reserveTaskCount;
 
         StationCycleCapacityVo vo = new StationCycleCapacityVo();
         vo.setLoopList(loopList);
         vo.setLoopCount(loopList.size());
         vo.setTotalStationCount(totalStationCount);
         vo.setTaskStationCount(taskStationCount);
-        vo.setCurrentLoad(calcCurrentLoad(taskStationCount, totalStationCount));
+        vo.setManualStationCount(manualStationCount);
+        vo.setOccupiedStationCount(occupiedStationCount);
+        vo.setCurrentLoad(calcCurrentLoad(occupiedStationCount, totalStationCount));
         vo.setRefreshTime(new Date());
         return vo;
     }
@@ -217,8 +233,10 @@
             Collections.sort(workNoList);
 
             int mergedTaskCount = toNonNegative(loopVo.getTaskCount()) + 1;
+            int mergedOccupiedCount = toNonNegative(loopVo.getOccupiedStationCount()) + 1;
             loopVo.setTaskCount(mergedTaskCount);
-            loopVo.setCurrentLoad(calcCurrentLoad(mergedTaskCount, toNonNegative(loopVo.getStationCount())));
+            loopVo.setOccupiedStationCount(mergedOccupiedCount);
+            loopVo.setCurrentLoad(calcCurrentLoad(mergedOccupiedCount, toNonNegative(loopVo.getStationCount())));
             mergedCount++;
         }
 
@@ -416,12 +434,12 @@
                 || (isBarcodeStation != null && isBarcodeStation == 1);
     }
 
-    private Map<Integer, Integer> buildStationWorkNoMap() {
-        Map<Integer, Integer> workNoMap = new HashMap<>();
+    private StationOccupancyContext buildStationOccupancyContext() {
+        StationOccupancyContext context = new StationOccupancyContext();
         List<DeviceConfig> devpList = deviceConfigService.list(new QueryWrapper<DeviceConfig>()
                 .eq("device_type", String.valueOf(SlaveType.Devp)));
         if (devpList == null || devpList.isEmpty()) {
-            return workNoMap;
+            return context;
         }
 
         for (DeviceConfig deviceConfig : devpList) {
@@ -440,11 +458,15 @@
                 }
                 Integer taskNo = protocol.getTaskNo();
                 if (taskNo != null && taskNo > 0) {
-                    workNoMap.put(protocol.getStationId(), taskNo);
+                    context.workNoMap.put(protocol.getStationId(), taskNo);
+                    continue;
+                }
+                if (!protocol.isAutoing()) {
+                    context.manualStationSet.add(protocol.getStationId());
                 }
             }
         }
-        return workNoMap;
+        return context;
     }
 
     private List<Set<Integer>> findStrongConnectedComponents(Map<Integer, Set<Integer>> graph) {
@@ -620,4 +642,9 @@
         private final Map<Integer, Set<Integer>> graph = new HashMap<>();
         private final Set<Integer> excludeStationSet = new HashSet<>();
     }
+
+    private static class StationOccupancyContext {
+        private final Map<Integer, Integer> workNoMap = new HashMap<>();
+        private final Set<Integer> manualStationSet = new HashSet<>();
+    }
 }

--
Gitblit v1.9.1