From 42b2db39fcec9c2329e543595a7a1bfb6464539b Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期五, 06 二月 2026 16:02:06 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java |   76 +++++++++++++++++++++++++++++---------
 1 files changed, 58 insertions(+), 18 deletions(-)

diff --git a/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java b/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
index 52ff58a..c81bf43 100644
--- a/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
@@ -2,6 +2,7 @@
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.core.exception.CoolException;
 import com.zy.asrs.domain.enums.NotifyMsgType;
@@ -96,48 +97,68 @@
                     && crnProtocol.getForkPos() == 0
                     && crnProtocol.getAlarm() == 0
             ) {
+                Object clearLock = redisUtil.get(RedisKeyType.CLEAR_CRN_TASK_LIMIT.key + basCrnp.getCrnNo());
+                if (clearLock != null) {
+                    continue;
+                }
+
                 // 濡傛灉鏈�杩戜竴娆℃槸鍏ュ簱妯″紡
                 if (crnProtocol.getLastIo().equals("I")) {
                     if (basCrnp.getInEnable().equals("Y")) {
-                        this.crnExecuteIn(basCrnp, crnThread); //  鍏ュ簱
+                        boolean result = this.crnExecuteIn(basCrnp, crnThread);//  鍏ュ簱
                         crnProtocol.setLastIo("O");
+                        if (result) {
+                            break;
+                        }
                     } else if (basCrnp.getOutEnable().equals("Y")) {
-                        this.crnExecuteOut(basCrnp, crnThread); //  鍑哄簱
+                        boolean result = this.crnExecuteOut(basCrnp, crnThread);//  鍑哄簱
                         crnProtocol.setLastIo("I");
+                        if (result) {
+                            break;
+                        }
                     }
                 }
                 // 濡傛灉鏈�杩戜竴娆℃槸鍑哄簱妯″紡
                 else if (crnProtocol.getLastIo().equals("O")) {
                     if (basCrnp.getOutEnable().equals("Y")) {
-                        this.crnExecuteOut(basCrnp, crnThread); //  鍑哄簱
+                        boolean result = this.crnExecuteOut(basCrnp, crnThread);//  鍑哄簱
                         crnProtocol.setLastIo("I");
+                        if (result) {
+                            break;
+                        }
                     } else if (basCrnp.getInEnable().equals("Y")) {
-                        this.crnExecuteIn(basCrnp, crnThread); //  鍏ュ簱
+                        boolean result = this.crnExecuteIn(basCrnp, crnThread);//  鍏ュ簱
                         crnProtocol.setLastIo("O");
+                        if (result) {
+                            break;
+                        }
                     }
                 }
 
                 //搴撲綅绉昏浆
-                this.crnExecuteLocTransfer(basCrnp, crnThread);
+                boolean transfer = this.crnExecuteLocTransfer(basCrnp, crnThread);
+                if (transfer) {
+                    break;
+                }
             }
         }
     }
 
-    private synchronized void crnExecuteIn(BasCrnp basCrnp, CrnThread crnThread) {
+    private synchronized boolean crnExecuteIn(BasCrnp basCrnp, CrnThread crnThread) {
         CrnProtocol crnProtocol = crnThread.getStatus();
         if(crnProtocol == null){
-            return;
+            return false;
         }
 
         if(!basCrnp.getInEnable().equals("Y")){
             News.info("鍫嗗灈鏈�:{} 鍙叆淇″彿涓嶆弧瓒�", basCrnp.getCrnNo());
-            return;
+            return false;
         }
 
         List<StationObjModel> inStationList = basCrnp.getInStationList$();
         if(inStationList.isEmpty()){
             News.info("鍫嗗灈鏈�:{} 鍏ュ簱绔欑偣鏈缃�", basCrnp.getCrnNo());
-            return;
+            return false;
         }
 
         Integer crnNo = basCrnp.getCrnNo();
@@ -213,25 +234,27 @@
                 MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command));
                 notifyUtils.notify(String.valueOf(SlaveType.Crn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_IN_TASK_RUN, null);
                 News.info("鍫嗗灈鏈哄懡浠や笅鍙戞垚鍔燂紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(command));
+                return true;
             }
         }
+        return false;
     }
 
-    private synchronized void crnExecuteOut(BasCrnp basCrnp, CrnThread crnThread) {
+    private synchronized boolean crnExecuteOut(BasCrnp basCrnp, CrnThread crnThread) {
         CrnProtocol crnProtocol = crnThread.getStatus();
         if(crnProtocol == null){
-            return;
+            return false;
         }
 
         if(!basCrnp.getOutEnable().equals("Y")){
             News.info("鍫嗗灈鏈�:{} 鍙嚭淇″彿涓嶆弧瓒�", basCrnp.getCrnNo());
-            return;
+            return false;
         }
 
         List<StationObjModel> outStationList = basCrnp.getOutStationList$();
         if(outStationList.isEmpty()){
             News.info("鍫嗗灈鏈�:{} 鍑哄簱绔欑偣鏈缃�", basCrnp.getCrnNo());
-            return;
+            return false;
         }
 
         Integer crnNo = basCrnp.getCrnNo();
@@ -302,10 +325,11 @@
                     MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command));
                     notifyUtils.notify(String.valueOf(SlaveType.Crn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_OUT_TASK_RUN, null);
                     News.info("鍫嗗灈鏈哄懡浠や笅鍙戞垚鍔燂紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(command));
-                    return;
+                    return true;
                 }
             }
         }
+        return false;
     }
 
     private synchronized boolean crnExecuteInPlanner(BasCrnp basCrnp, CrnThread crnThread, WrkMast wrkMast) {
@@ -486,10 +510,10 @@
         return false;
     }
 
-    private synchronized void crnExecuteLocTransfer(BasCrnp basCrnp, CrnThread crnThread) {
+    private synchronized boolean crnExecuteLocTransfer(BasCrnp basCrnp, CrnThread crnThread) {
         CrnProtocol crnProtocol = crnThread.getStatus();
         if(crnProtocol == null){
-            return;
+            return false;
         }
 
         Integer crnNo = basCrnp.getCrnNo();
@@ -534,9 +558,10 @@
                 MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command));
                 notifyUtils.notify(String.valueOf(SlaveType.Crn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_TRANSFER_TASK_RUN, null);
                 News.info("鍫嗗灈鏈哄懡浠や笅鍙戞垚鍔燂紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(command));
-                return;
+                return true;
             }
         }
+        return false;
     }
 
     //鍫嗗灈鏈轰换鍔℃墽琛屽畬鎴�
@@ -576,6 +601,21 @@
                 }else if(wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts){
                     updateWrkSts = WrkStsType.OUTBOUND_RUN_COMPLETE.sts;
                     notifyUtils.notify(String.valueOf(SlaveType.Crn), crnProtocol.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_OUT_TASK_COMPLETE, null);
+
+                    List<StationObjModel> outStationList = basCrnp.getOutStationList$();
+                    if(outStationList.isEmpty()){
+                        News.info("鍫嗗灈鏈�:{} 鍑哄簱绔欑偣鏈缃�", basCrnp.getCrnNo());
+                        return;
+                    }
+
+                    StationObjModel outStationObjModel = null;
+                    for (StationObjModel stationObjModel : outStationList) {
+                        if (stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) {
+                            outStationObjModel = stationObjModel;
+                            break;
+                        }
+                    }
+                    redisUtil.set(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(outStationObjModel, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
                 }else if(wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_RUN.sts){
                     updateWrkSts = WrkStsType.COMPLETE_LOC_MOVE.sts;
                     notifyUtils.notify(String.valueOf(SlaveType.Crn), crnProtocol.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_TRANSFER_TASK_COMPLETE, null);
@@ -763,13 +803,13 @@
         if (lock != null) {
             return false;
         }
-        redisUtil.set(RedisKeyType.CHECK_SHALLOW_LOC_STATUS_LIMIT.key + taskNo, "lock", 5);
 
         Integer shallowRow = Utils.getShallowRowByDeepRow(Utils.getRow(locNo));
         if (shallowRow == null) {
             return true;
         }
 
+        redisUtil.set(RedisKeyType.CHECK_SHALLOW_LOC_STATUS_LIMIT.key + taskNo, "lock", 5);
         String shallowLocNo = Utils.getLocNo(shallowRow, Utils.getBay(locNo), Utils.getLev(locNo));
         LocMast shallowLocMast = locMastService.queryByLoc(shallowLocNo);
         if (shallowLocMast == null) {

--
Gitblit v1.9.1