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/asrs/task/WrkMastScheduler.java |   70 ++++++++++++++++++++++++++++++++--
 1 files changed, 65 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/zy/asrs/task/WrkMastScheduler.java b/src/main/java/com/zy/asrs/task/WrkMastScheduler.java
index 87dfaea..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);
+                    }
+                }
+            }
         }
     }
 
@@ -205,6 +244,27 @@
 
     @Scheduled(cron = "0/1 * * * * ? ")
     @Transactional
+    public void executeCrnMove(){
+        List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>().eq("wrk_sts", WrkStsType.COMPLETE_CRN_MOVE.sts));
+        if (wrkMasts.isEmpty()) {
+            return;
+        }
+
+        for (WrkMast wrkMast : wrkMasts) {
+            if (!wrkMastLogService.save(wrkMast.getWrkNo())) {
+                log.info("淇濆瓨宸ヤ綔鍘嗗彶妗workNo={}]澶辫触", wrkMast.getWrkNo());
+            } else {
+                wrkAnalysisService.finishTask(wrkMast, resolveFinishTime(wrkMast));
+            }
+
+            if (!wrkMastService.removeById(wrkMast.getWrkNo())) {
+                log.info("鍒犻櫎宸ヤ綔涓绘。[workNo={}]澶辫触", wrkMast.getWrkNo());
+            }
+        }
+    }
+
+    @Scheduled(cron = "0/1 * * * * ? ")
+    @Transactional
     public void executeCancelTask(){
         List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>().eq("mk", "taskCancel"));
         if (wrkMasts.isEmpty()) {

--
Gitblit v1.9.1