From 358a65169e422bacfa8bd3134f7723e2eca32628 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 10 四月 2026 14:37:43 +0800
Subject: [PATCH] #出入库模式管控

---
 src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java |   57 +++++++++++++++++++++++++++++++++------------------------
 1 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java b/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
index b4090f5..ed14a84 100644
--- a/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
@@ -75,13 +75,6 @@
 
     private static final String CRN_OUT_REQUIRE_STATION_OUT_ENABLE_CONFIG = "crnOutRequireStationOutEnable";
 
-    public synchronized void crnIoExecute() {
-        List<BasCrnp> basCrnps = basCrnpService.list(new QueryWrapper<>());
-        for (BasCrnp basCrnp : basCrnps) {
-            crnIoExecute(basCrnp);
-        }
-    }
-
     public void crnIoExecute(BasCrnp basCrnp) {
         if (basCrnp == null || basCrnp.getCrnNo() == null) {
             return;
@@ -170,7 +163,7 @@
             if (wrkMast.getWrkSts() != null && wrkMast.getWrkSts() == WrkStsType.INBOUND_STATION_RUN_COMPLETE.sts) {
                 boolean result = this.crnExecuteInPlanner(currentCrn, crnThread, wrkMast);
                 if (result) {
-                    crnProtocol.setLastIo("O");
+                    crnProtocol.setLastIo("I");
                     return;
                 }
                 continue;
@@ -179,7 +172,7 @@
             if (wrkMast.getWrkSts() != null && wrkMast.getWrkSts() == WrkStsType.NEW_OUTBOUND.sts) {
                 boolean result = this.crnExecuteOutPlanner(currentCrn, crnThread, wrkMast);
                 if (result) {
-                    crnProtocol.setLastIo("I");
+                    crnProtocol.setLastIo("O");
                     return;
                 }
                 continue;
@@ -395,6 +388,11 @@
         }
 
         if (!allowBatchOutboundExecute(wrkMast, true)) {
+            return false;
+        }
+
+        //妫�鏌ユ槸鍚︿负鍑哄簱妯″紡
+        if(!checkOutTargetStationIoMode(wrkMast)) {
             return false;
         }
 
@@ -629,6 +627,32 @@
         return false;
     }
 
+    //妫�鏌ユ槸鍚︿负鍑哄簱妯″紡
+    private boolean checkOutTargetStationIoMode(WrkMast wrkMast) {
+        if (wrkMast == null || wrkMast.getStaNo() == null) {
+            return false;
+        }
+        BasStation basStation = basStationService.getById(wrkMast.getStaNo());
+        if (basStation == null) {
+            return false;
+        }
+
+        StationThread targetStationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basStation.getDeviceNo());
+        if (targetStationThread == null) {
+            return false;
+        }
+
+        StationProtocol targetStationProtocol = targetStationThread.getStatusMap().get(wrkMast.getStaNo());
+        if (targetStationProtocol == null) {
+            return false;
+        }
+
+        if (targetStationProtocol.getIoMode() == 2) {
+            return true;//鍑哄簱妯″紡
+        }
+        return false;
+    }
+
     private int getSystemConfigInt(String code, int defaultValue) {
         Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
         if (systemConfigMapObj == null) {
@@ -666,14 +690,6 @@
         } catch (Exception ignore) {
         }
         return defaultValue;
-    }
-
-    //鍫嗗灈鏈轰换鍔℃墽琛屽畬鎴�
-    public synchronized void crnIoExecuteFinish() {
-        List<BasCrnp> basCrnps = basCrnpService.list(new QueryWrapper<>());
-        for (BasCrnp basCrnp : basCrnps) {
-            crnIoExecuteFinish(basCrnp);
-        }
     }
 
     public void crnIoExecuteFinish(BasCrnp basCrnp) {
@@ -735,13 +751,6 @@
             }
 
             redisUtil.set(RedisKeyType.CRN_IO_EXECUTE_FINISH_LIMIT.key + basCrnp.getCrnNo(), "lock",10);
-        }
-    }
-
-    public synchronized void plannerExecute() {
-        List<BasCrnp> basCrnps = basCrnpService.list(new QueryWrapper<>());
-        for (BasCrnp basCrnp : basCrnps) {
-            plannerExecute(basCrnp);
         }
     }
 

--
Gitblit v1.9.1