From 44e258e4f5370a14e92e3c15bccd32e1e4d7280c Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 02 四月 2026 23:17:25 +0800
Subject: [PATCH] #路径清理

---
 src/main/java/com/zy/core/utils/StationOperateProcessUtils.java              |    4 ++++
 src/main/java/com/zy/asrs/task/WrkMastScheduler.java                         |   49 ++++++++++++++++++++++++++++++++++++++++++++-----
 src/main/java/com/zy/core/utils/station/StationRegularDispatchProcessor.java |    2 +-
 3 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/zy/asrs/task/WrkMastScheduler.java b/src/main/java/com/zy/asrs/task/WrkMastScheduler.java
index 9ac3fac..81946e9 100644
--- a/src/main/java/com/zy/asrs/task/WrkMastScheduler.java
+++ b/src/main/java/com/zy/asrs/task/WrkMastScheduler.java
@@ -3,16 +3,18 @@
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.zy.asrs.domain.enums.NotifyMsgType;
+import com.zy.asrs.entity.BasStation;
 import com.zy.asrs.entity.LocMast;
 import com.zy.asrs.entity.WrkMast;
-import com.zy.asrs.service.LocMastService;
-import com.zy.asrs.service.WrkAnalysisService;
-import com.zy.asrs.service.WrkMastLogService;
-import com.zy.asrs.service.WrkMastService;
+import com.zy.asrs.service.*;
 import com.zy.asrs.utils.NotifyUtils;
+import com.zy.core.cache.SlaveConnection;
 import com.zy.core.enums.LocStsType;
+import com.zy.core.enums.SlaveType;
 import com.zy.core.enums.WrkIoType;
 import com.zy.core.enums.WrkStsType;
+import com.zy.core.thread.StationThread;
+import com.zy.core.utils.StationOperateProcessUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
@@ -31,17 +33,24 @@
     private final WrkAnalysisService wrkAnalysisService;
     private final LocMastService locMastService;
     private final NotifyUtils notifyUtils;
+    private final StationOperateProcessUtils stationOperateProcessUtils;
+    private final BasStationService basStationService;
 
     public WrkMastScheduler(WrkMastService wrkMastService,
                             WrkMastLogService wrkMastLogService,
                             WrkAnalysisService wrkAnalysisService,
                             LocMastService locMastService,
-                            NotifyUtils notifyUtils) {
+                            NotifyUtils notifyUtils,
+                            StationOperateProcessUtils stationOperateProcessUtils,
+                            BasStationService basStationService
+    ) {
         this.wrkMastService = wrkMastService;
         this.wrkMastLogService = wrkMastLogService;
         this.wrkAnalysisService = wrkAnalysisService;
         this.locMastService = locMastService;
         this.notifyUtils = notifyUtils;
+        this.stationOperateProcessUtils = stationOperateProcessUtils;
+        this.basStationService = basStationService;
     }
 
     @Scheduled(cron = "0/1 * * * * ? ")
@@ -53,6 +62,10 @@
         }
 
         for (WrkMast wrkMast : wrkMasts) {
+            Integer taskNo = wrkMast.getWrkNo();
+            Integer sourceStaNo = wrkMast.getSourceStaNo();
+            Integer staNo = wrkMast.getStaNo();
+
             String locNo = wrkMast.getLocNo();
             LocMast locMast = locMastService.queryByLoc(locNo);
             if (locMast == null) {
@@ -87,6 +100,17 @@
 
             //涓婃姤
             notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
+
+            //娓呯悊璺緞
+            List<BasStation> basStations = basStationService.list(new QueryWrapper<BasStation>().in("station_id", sourceStaNo, staNo));
+            if (!basStations.isEmpty()) {
+                for (BasStation basStation : basStations) {
+                    StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basStation.getDeviceNo());
+                    if (stationThread != null) {
+                        stationOperateProcessUtils.attemptClearTaskPath(stationThread, taskNo);
+                    }
+                }
+            }
         }
     }
 
@@ -99,6 +123,10 @@
         }
 
         for (WrkMast wrkMast : wrkMasts) {
+            Integer taskNo = wrkMast.getWrkNo();
+            Integer sourceStaNo = wrkMast.getSourceStaNo();
+            Integer staNo = wrkMast.getStaNo();
+
             String locNo = wrkMast.getSourceLocNo();
             LocMast locMast = locMastService.queryByLoc(locNo);
             if (locMast == null) {
@@ -133,6 +161,17 @@
 
             //涓婃姤
             notifyUtils.notify("task", 1, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.TASK_COMPLETE, JSON.toJSONString(wrkMast));
+
+            //娓呯悊璺緞
+            List<BasStation> basStations = basStationService.list(new QueryWrapper<BasStation>().in("station_id", sourceStaNo, staNo));
+            if (!basStations.isEmpty()) {
+                for (BasStation basStation : basStations) {
+                    StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basStation.getDeviceNo());
+                    if (stationThread != null) {
+                        stationOperateProcessUtils.attemptClearTaskPath(stationThread, taskNo);
+                    }
+                }
+            }
         }
     }
 
diff --git a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
index 247d6ee..b9ba6ae 100644
--- a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -461,4 +461,8 @@
     private boolean shouldSkipIdleRecoverForRecentDispatch(Integer taskNo, Integer stationId) {
         return stationRerouteProcessor.shouldSkipIdleRecoverForRecentDispatch(taskNo, stationId);
     }
+
+    public void attemptClearTaskPath(StationThread stationThread, Integer taskNo) {
+        stationRegularDispatchProcessor.attemptClearTaskPath(stationThread, taskNo);
+    }
 }
diff --git a/src/main/java/com/zy/core/utils/station/StationRegularDispatchProcessor.java b/src/main/java/com/zy/core/utils/station/StationRegularDispatchProcessor.java
index 62db459..833d97a 100644
--- a/src/main/java/com/zy/core/utils/station/StationRegularDispatchProcessor.java
+++ b/src/main/java/com/zy/core/utils/station/StationRegularDispatchProcessor.java
@@ -175,7 +175,7 @@
         }
     }
 
-    private void attemptClearTaskPath(StationThread stationThread, Integer taskNo) {
+    public void attemptClearTaskPath(StationThread stationThread, Integer taskNo) {
         if (stationThread == null || taskNo == null || taskNo <= 0) {
             return;
         }

--
Gitblit v1.9.1