From 41aeff86351d1dd94fe2408175f96475f227c1b9 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 02 四月 2026 17:15:27 +0800
Subject: [PATCH] #执行优化

---
 src/main/java/com/zy/core/utils/station/StationRegularDispatchProcessor.java |   85 +++++++++++++++---------------------------
 1 files changed, 30 insertions(+), 55 deletions(-)

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 e33d401..62db459 100644
--- a/src/main/java/com/zy/core/utils/station/StationRegularDispatchProcessor.java
+++ b/src/main/java/com/zy/core/utils/station/StationRegularDispatchProcessor.java
@@ -77,52 +77,46 @@
         }
     }
 
-    public void stationOutExecuteFinish() {
+    public void stationOutExecuteFinish(StationObjModel stationObjModel) {
         try {
-            List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>().eq("wrk_sts", WrkStsType.STATION_RUN.sts));
-            for (WrkMast wrkMast : wrkMasts) {
-                stationOutExecuteFinish(wrkMast);
+            if (stationObjModel == null) {
+                return;
             }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
 
-    public void stationOutExecuteFinish(WrkMast wrkMast) {
-        try {
+            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
+            if (stationThread == null) {
+                return;
+            }
+            Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
+            StationProtocol stationProtocol = statusMap == null ? null : statusMap.get(stationObjModel.getStationId());
+            if (stationProtocol == null) {
+                return;
+            }
+            if (stationProtocol.getTaskNo() <= 0) {
+                return;
+            }
+            WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
             if (wrkMast == null) {
                 return;
             }
-            Integer wrkNo = wrkMast.getWrkNo();
-            Integer targetStaNo = wrkMast.getStaNo();
-            if (wrkNo == null || targetStaNo == null) {
+
+            if (!wrkMast.getWrkSts().equals(WrkStsType.STATION_RUN.sts)) {
                 return;
             }
+            Integer wrkNo = wrkMast.getWrkNo();
 
-            boolean complete = false;
-            Integer targetDeviceNo = null;
-            StationThread stationThread = null;
-            BasStation basStation = basStationService.getOne(new QueryWrapper<BasStation>().eq("station_id", targetStaNo));
-            if (basStation != null) {
-                targetDeviceNo = basStation.getDeviceNo();
-                stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basStation.getDeviceNo());
-                if (stationThread != null) {
-                    Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
-                    StationProtocol stationProtocol = statusMap == null ? null : statusMap.get(basStation.getStationId());
-                    boolean arrived = stationProtocol != null && wrkNo.equals(stationProtocol.getTaskNo());
-                    if (arrived || stationThread.hasRecentArrival(basStation.getStationId(), wrkNo)) {
-                        complete = true;
-                        if (!arrived) {
-                            News.info("杈撻�佺珯鐐瑰嚭搴撳埌杈惧垽瀹氫娇鐢ㄦ渶杩戝埌绔欒ˉ鍋匡紝宸ヤ綔鍙�={}锛岀洰鏍囩珯={}", wrkNo, targetStaNo);
-                        }
-                    }
-                }
+            if (stationMoveCoordinator != null) {
+                stationMoveCoordinator.finishSession(wrkMast.getWrkNo());
             }
-
-            if (complete) {
-                attemptClearTaskPath(stationThread, wrkNo);
-                completeStationRunTask(wrkMast, targetDeviceNo);
-            }
+            Date now = new Date();
+            wrkMast.setWrkSts(WrkStsType.STATION_RUN_COMPLETE.sts);
+            wrkMast.setIoTime(now);
+            wrkMast.setModiTime(now);
+            wrkMastService.updateById(wrkMast);
+            wrkAnalysisService.markOutboundStationComplete(wrkMast, now);
+            notifyUtils.notify(String.valueOf(SlaveType.Devp), stationObjModel.getDeviceNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.STATION_OUT_TASK_RUN_COMPLETE, null);
+            redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkMast.getWrkNo(), "lock", 60);
+            attemptClearTaskPath(stationThread, wrkNo);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -193,25 +187,6 @@
         } catch (Exception e) {
             News.error("杈撻�佺珯鐐逛换鍔¤繍琛屽畬鎴愬悗娓呯悊娈嬬暀璺緞寮傚父锛屽伐浣滃彿={}", taskNo, e);
         }
-    }
-
-    private void completeStationRunTask(WrkMast wrkMast, Integer deviceNo) {
-        if (wrkMast == null || wrkMast.getWrkNo() == null) {
-            return;
-        }
-        if (stationMoveCoordinator != null) {
-            stationMoveCoordinator.finishSession(wrkMast.getWrkNo());
-        }
-        Date now = new Date();
-        wrkMast.setWrkSts(WrkStsType.STATION_RUN_COMPLETE.sts);
-        wrkMast.setIoTime(now);
-        wrkMast.setModiTime(now);
-        wrkMastService.updateById(wrkMast);
-        wrkAnalysisService.markOutboundStationComplete(wrkMast, now);
-        if (deviceNo != null) {
-            notifyUtils.notify(String.valueOf(SlaveType.Devp), deviceNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.STATION_OUT_TASK_RUN_COMPLETE, null);
-        }
-        redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkMast.getWrkNo(), "lock", 60);
     }
 
     private boolean offerDevpCommandWithDedup(Integer deviceNo, StationCommand command, String scene) {

--
Gitblit v1.9.1