From e14a4372b6bd4a38e40a3a68bde32350d96071ab Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 15 一月 2026 13:11:56 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/plugin/FakeProcess.java |  652 ++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 445 insertions(+), 207 deletions(-)

diff --git a/src/main/java/com/zy/core/plugin/FakeProcess.java b/src/main/java/com/zy/core/plugin/FakeProcess.java
index 181f5f2..16a90f8 100644
--- a/src/main/java/com/zy/core/plugin/FakeProcess.java
+++ b/src/main/java/com/zy/core/plugin/FakeProcess.java
@@ -3,20 +3,14 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.core.common.Cools;
 import com.zy.asrs.domain.param.CreateInTaskParam;
 import com.zy.asrs.domain.param.CreateOutTaskParam;
-import com.zy.asrs.entity.BasCrnp;
-import com.zy.asrs.entity.BasDevp;
-import com.zy.asrs.entity.LocMast;
-import com.zy.asrs.entity.WrkMast;
-import com.zy.asrs.service.BasCrnpService;
-import com.zy.asrs.service.BasDevpService;
-import com.zy.asrs.service.LocMastService;
-import com.zy.asrs.service.WrkMastService;
-import com.zy.asrs.utils.Utils;
+import com.zy.asrs.entity.*;
+import com.zy.asrs.service.*;
+import com.zy.common.entity.FindCrnNoResult;
 import com.zy.common.model.StartupDto;
 import com.zy.common.service.CommonService;
-import com.zy.common.utils.HttpHandler;
 import com.zy.common.utils.RedisUtil;
 import com.zy.core.News;
 import com.zy.core.cache.MessageQueue;
@@ -27,11 +21,17 @@
 import com.zy.core.model.command.CrnCommand;
 import com.zy.core.model.command.StationCommand;
 import com.zy.core.model.protocol.CrnProtocol;
+import com.zy.core.model.protocol.DualCrnProtocol;
 import com.zy.core.model.protocol.StationProtocol;
+import com.zy.core.plugin.api.MainProcessPluginApi;
+import com.zy.core.properties.SystemProperties;
 import com.zy.core.thread.CrnThread;
+import com.zy.core.thread.DualCrnThread;
 import com.zy.core.thread.StationThread;
 import com.zy.core.utils.CrnOperateProcessUtils;
+import com.zy.core.utils.DualCrnOperateProcessUtils;
 import com.zy.core.utils.StationOperateProcessUtils;
+import com.zy.core.utils.WmsOperateUtils;
 import com.zy.system.entity.Config;
 import com.zy.system.service.ConfigService;
 import lombok.extern.slf4j.Slf4j;
@@ -39,13 +39,27 @@
 import org.springframework.stereotype.Component;
 
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 @Slf4j
 @Component
 public class FakeProcess implements MainProcessPluginApi {
 
-    private static Map<Integer,Long> stationStayTimeMap = new HashMap<>();
-    private static String enableFake = "N";
+    private static final long METHOD_TIMEOUT_MS = 15000; // 15绉掕秴鏃�
+    private static final ExecutorService timeoutExecutor = Executors.newCachedThreadPool();
+
+    private static Map<Integer, Long> stationStayTimeMap = new ConcurrentHashMap<>();
+    private static volatile String enableFake = "N";
+    private static volatile String fakeRealTaskRequestWms = "N";
+    private static volatile String fakeGenerateInTask = "Y";
+    private static volatile String fakeGenerateOutTask = "Y";
+
+    private Thread asyncFakeRunThread = null;
 
     @Autowired
     private WrkMastService wrkMastService;
@@ -60,56 +74,147 @@
     @Autowired
     private BasCrnpService basCrnpService;
     @Autowired
+    private BasDualCrnpService basDualCrnpService;
+    @Autowired
     private RedisUtil redisUtil;
     @Autowired
     private CrnOperateProcessUtils crnOperateUtils;
     @Autowired
     private StationOperateProcessUtils stationOperateProcessUtils;
+    @Autowired
+    private WmsOperateUtils wmsOperateUtils;
+    @Autowired
+    private DualCrnOperateProcessUtils dualCrnOperateProcessUtils;
+
+    /**
+     * 甯﹁秴鏃朵繚鎶ゆ墽琛屾柟娉�
+     * 
+     * @param taskName 浠诲姟鍚嶇О锛堢敤浜庢棩蹇楋級
+     * @param task     瑕佹墽琛岀殑浠诲姟
+     */
+    private void executeWithTimeout(String taskName, Runnable task) {
+        Future<?> future = timeoutExecutor.submit(task);
+        try {
+            future.get(METHOD_TIMEOUT_MS, TimeUnit.MILLISECONDS);
+        } catch (TimeoutException e) {
+            // 浣跨敤 cancel(false) 涓嶅彂閫佷腑鏂俊鍙凤紝閬垮厤 RedisCommandInterruptedException
+            // 浠诲姟浼氬湪鍚庡彴缁х画鎵ц鐩村埌瀹屾垚锛屼絾涓诲惊鐜笉浼氱瓑寰�
+            future.cancel(false);
+            News.error("[WCS Warning] 鏂规硶鎵ц瓒呮椂锛屼富寰幆宸茶烦杩�: {}, 瓒呮椂鏃堕棿: {}ms (浠诲姟浠嶅湪鍚庡彴杩愯)", taskName, METHOD_TIMEOUT_MS);
+        } catch (Exception e) {
+            News.error("[WCS Error] 鏂规硶鎵ц寮傚父: {}, 寮傚父: {}", taskName, e.getMessage());
+        }
+    }
 
     @Override
     public void run() {
-        Config enableFakeConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
-        if (enableFakeConfig != null) {
-            enableFake = enableFakeConfig.getValue();
-        }
+        long startTime = System.currentTimeMillis();
+        asyncFakeRun();
 
-        //妫�娴嬪叆搴撶珯鏄惁鏈変换鍔$敓鎴愶紝骞朵豢鐪熺敓鎴愭ā鎷熷叆搴撶珯鐐规暟鎹�
-        checkInStationHasTask();
-        //鐢熸垚浠跨湡妯℃嫙鍏ュ簱浠诲姟
-        generateFakeInTask();
-        //鐢熸垚浠跨湡妯℃嫙鍑哄簱浠诲姟
-        generateFakeOutTask();
-        //璁$畻鎵�鏈夌珯鐐瑰仠鐣欐椂闂�
-        calcAllStationStayTime();
-        //妫�娴嬪嚭搴撶珯鐐瑰仠鐣欐槸鍚﹁秴鏃�
-        checkOutStationStayTimeOut();
-        //妫�娴嬪叆搴撶珯鐐瑰爢鍨涙満鏄惁鍙栬蛋璐х墿
-        checkInStationCrnTake();
+        // 璇锋眰鐢熸垚鍏ュ簱浠诲姟
+        executeWithTimeout("generateStoreWrkFile", this::generateStoreWrkFile);
 
-        //璇锋眰鐢熸垚鍏ュ簱浠诲姟
-        generateStoreWrkFile();
-        //鎵ц鍫嗗灈鏈轰换鍔�
-        crnOperateUtils.crnIoExecute();
-        //鍫嗗灈鏈轰换鍔℃墽琛屽畬鎴�-鍏峰浠跨湡鑳藉姏
-        crnIoExecuteFinish();
-        //鎵ц杈撻�佺珯鐐瑰叆搴撲换鍔�
-        stationOperateProcessUtils.stationInExecute();
-        //鎵ц杈撻�佺珯鐐瑰嚭搴撲换鍔�
-        stationOperateProcessUtils.stationOutExecute();
-        //妫�娴嬭緭閫佺珯鐐瑰嚭搴撲换鍔℃墽琛屽畬鎴�
-        stationOperateProcessUtils.stationOutExecuteFinish();
+        // 鎵ц鍫嗗灈鏈轰换鍔�
+        executeWithTimeout("crnIoExecute", crnOperateUtils::crnIoExecute);
+        // 鍫嗗灈鏈轰换鍔℃墽琛屽畬鎴�-鍏峰浠跨湡鑳藉姏
+        executeWithTimeout("crnIoExecuteFinish", this::crnIoExecuteFinish);
+        // 鎵ц杈撻�佺珯鐐瑰叆搴撲换鍔�
+        executeWithTimeout("stationInExecute", stationOperateProcessUtils::stationInExecute);
+        // 鎵ц杈撻�佺珯鐐瑰嚭搴撲换鍔�
+        executeWithTimeout("stationOutExecute", stationOperateProcessUtils::stationOutExecute);
+        // 妫�娴嬭緭閫佺珯鐐瑰嚭搴撲换鍔℃墽琛屽畬鎴�
+        executeWithTimeout("stationOutExecuteFinish", stationOperateProcessUtils::stationOutExecuteFinish);
+
+        // 鎵ц鍙屽伐浣嶅爢鍨涙満浠诲姟
+        executeWithTimeout("dualCrnIoExecute", dualCrnOperateProcessUtils::dualCrnIoExecute);
+        // 鍙屽伐浣嶅爢鍨涙満浠诲姟鎵ц瀹屾垚
+        executeWithTimeout("dualCrnIoExecuteFinish", dualCrnOperateProcessUtils::dualCrnIoExecuteFinish);
+
+        News.info("[WCS Debug] 涓荤嚎绋婻un鎵ц瀹屾垚,鑰楁椂:{}ms", System.currentTimeMillis() - startTime);
     }
 
-    //妫�娴嬪叆搴撶珯鏄惁鏈変换鍔$敓鎴愶紝骞朵豢鐪熺敓鎴愭ā鎷熷叆搴撶珯鐐规暟鎹�
+    public void asyncFakeRun() {
+        if (asyncFakeRunThread != null) {
+            return;
+        }
+
+        asyncFakeRunThread = new Thread(() -> {
+            while (!Thread.currentThread().isInterrupted()) {
+                try {
+                    Config enableFakeConfig = configService
+                            .selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
+                    if (enableFakeConfig != null) {
+                        enableFake = enableFakeConfig.getValue();
+                    }
+
+                    Config fakeRealTaskRequestWmsConfig = configService
+                            .selectOne(new EntityWrapper<Config>().eq("code", "fakeRealTaskRequestWms"));
+                    if (fakeRealTaskRequestWmsConfig != null) {
+                        fakeRealTaskRequestWms = fakeRealTaskRequestWmsConfig.getValue();
+                    }
+
+                    Config fakeGenerateInTaskConfig = configService
+                            .selectOne(new EntityWrapper<Config>().eq("code", "fakeGenerateInTask"));
+                    if (fakeGenerateInTaskConfig != null) {
+                        fakeGenerateInTask = fakeGenerateInTaskConfig.getValue();
+                    }
+
+                    Config fakeGenerateOutTaskConfig = configService
+                            .selectOne(new EntityWrapper<Config>().eq("code", "fakeGenerateOutTask"));
+                    if (fakeGenerateOutTaskConfig != null) {
+                        fakeGenerateOutTask = fakeGenerateOutTaskConfig.getValue();
+                    }
+
+                    // 绯荤粺杩愯鐘舵�佸垽鏂�
+                    if (!SystemProperties.WCS_RUNNING_STATUS.get()) {
+                        continue;
+                    }
+
+                    // 妫�娴嬪叆搴撶珯鏄惁鏈変换鍔$敓鎴愶紝骞朵豢鐪熺敓鎴愭ā鎷熷叆搴撶珯鐐规暟鎹�
+                    checkInStationHasTask();
+                    // 鐢熸垚浠跨湡妯℃嫙鍏ュ簱浠诲姟
+                    generateFakeInTask();
+                    // 鐢熸垚浠跨湡妯℃嫙鍑哄簱浠诲姟
+                    generateFakeOutTask();
+                    // 璁$畻鎵�鏈夌珯鐐瑰仠鐣欐椂闂�
+                    calcAllStationStayTime();
+                    // 妫�娴嬪嚭搴撶珯鐐瑰仠鐣欐槸鍚﹁秴鏃�
+                    checkOutStationStayTimeOut();
+                    // 妫�娴嬪叆搴撶珯鐐瑰爢鍨涙満鏄惁鍙栬蛋璐х墿
+                    checkInStationCrnTake();
+
+                    // 妫�娴嬭緭閫佺珯鐐规槸鍚﹁繍琛屽牭濉�
+                    stationOperateProcessUtils.checkStationRunBlock();
+
+                    // 闂撮殧
+                    Thread.sleep(50);
+                } catch (InterruptedException ie) {
+                    Thread.currentThread().interrupt();
+                    break;
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+        asyncFakeRunThread.setName("asyncFakeRunProcess");
+        asyncFakeRunThread.setDaemon(true);
+        asyncFakeRunThread.start();
+    }
+
+    // 妫�娴嬪叆搴撶珯鏄惁鏈変换鍔$敓鎴愶紝骞朵豢鐪熺敓鎴愭ā鎷熷叆搴撶珯鐐规暟鎹�
     private synchronized void checkInStationHasTask() {
         if (!enableFake.equals("Y")) {
+            return;
+        }
+
+        if (!fakeGenerateInTask.equals("Y")) {
             return;
         }
 
         List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
         for (BasDevp basDevp : basDevps) {
             StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
-            if(stationThread == null){
+            if (stationThread == null) {
                 continue;
             }
 
@@ -118,7 +223,7 @@
             List<StationObjModel> list = basDevp.getInStationList$();
             for (StationObjModel entity : list) {
                 Integer stationId = entity.getStationId();
-                if(!stationMap.containsKey(stationId)){
+                if (!stationMap.containsKey(stationId)) {
                     continue;
                 }
 
@@ -127,43 +232,52 @@
                     continue;
                 }
 
-                Object object = redisUtil.get(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId);
-                if (object != null) {
+                Object lock = redisUtil.get(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId);
+                if (lock != null) {
                     continue;
                 }
 
-                //婊¤冻鑷姩銆佹棤鐗┿�佸伐浣滃彿0锛岀敓鎴愬叆搴撴暟鎹�
+                // 婊¤冻鑷姩銆佹棤鐗┿�佸伐浣滃彿0锛岀敓鎴愬叆搴撴暟鎹�
                 if (stationProtocol.isAutoing()
                         && !stationProtocol.isLoading()
-                        && stationProtocol.getTaskNo() == 0
-                ) {
-                    StationCommand command = stationThread.getMoveCommand(9999, stationId, 0, 0);
+                        && stationProtocol.getTaskNo() == 0) {
+                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE,
+                            commonService.getWorkNo(WrkIoType.FAKE_TASK_NO.id), stationId,
+                            entity.getBarcodeStation().getStationId(), 0);
                     MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
-                    redisUtil.set(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId, "lock", 10);
+                    redisUtil.set(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId, "lock", 5);
                 }
             }
         }
     }
 
-    //鐢熸垚浠跨湡妯℃嫙鍏ュ簱浠诲姟
+    // 鐢熸垚浠跨湡妯℃嫙鍏ュ簱浠诲姟
     private synchronized void generateFakeInTask() {
         if (!enableFake.equals("Y")) {
+            return;
+        }
+
+        if (fakeRealTaskRequestWms.equals("Y")) {
+            return;
+        }
+
+        if (!fakeGenerateInTask.equals("Y")) {
             return;
         }
 
         List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
         for (BasDevp basDevp : basDevps) {
             StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
-            if(stationThread == null){
+            if (stationThread == null) {
                 continue;
             }
 
             Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
 
-            List<StationObjModel> list = basDevp.getInStationList$();
+            List<StationObjModel> list = basDevp.getBarcodeStationList$();
             for (StationObjModel model : list) {
                 Integer stationId = model.getStationId();
-                if(!stationMap.containsKey(stationId)){
+                if (!stationMap.containsKey(stationId)) {
                     continue;
                 }
 
@@ -174,21 +288,26 @@
 
                 Object object = redisUtil.get(RedisKeyType.GENERATE_FAKE_IN_TASK_LIMIT.key + stationId);
                 if (object != null) {
-                    return;
+                    continue;
                 }
 
-                //婊¤冻鑷姩銆佹湁鐗┿�佸伐浣滃彿9999锛岀敓鎴愬叆搴撴暟鎹�
+                // 婊¤冻鑷姩銆佹湁鐗┿�佹湁宸ヤ綔鍙凤紝鐢熸垚鍏ュ簱鏁版嵁
                 if (stationProtocol.isAutoing()
                         && stationProtocol.isLoading()
-                        && stationProtocol.getTaskNo() == 9999
-                ) {
-                    //妫�娴嬩换鍔℃槸鍚︾敓鎴�
-                    List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
+                        && stationProtocol.getTaskNo() > 0) {
+                    if (Cools.isEmpty(stationProtocol.getBarcode())) {
+                        continue;
+                    }
+
+                    // 妫�娴嬩换鍔℃槸鍚︾敓鎴�
+                    List<WrkMast> wrkMasts = wrkMastService
+                            .selectList(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
                     if (!wrkMasts.isEmpty()) {
                         continue;
                     }
 
-                    List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", String.valueOf(LocStsType.O)));
+                    List<LocMast> locMastList = locMastService
+                            .selectList(new EntityWrapper<LocMast>().eq("loc_sts", String.valueOf(LocStsType.O)));
                     if (locMastList.isEmpty()) {
                         continue;
                     }
@@ -196,12 +315,12 @@
                     int nextInt = new Random().nextInt(locMastList.size());
                     LocMast locMast = locMastList.get(nextInt);
 
-                    Integer crnNo = commonService.findCrnNoByLocNo(locMast.getLocNo());
-                    if (crnNo == null) {
+                    FindCrnNoResult findCrnNoResult = commonService.findCrnNoByLocNo(locMast.getLocNo());
+                    if (findCrnNoResult == null) {
                         continue;
                     }
 
-                    Integer targetStationId = commonService.findInStationId(crnNo, stationId);
+                    Integer targetStationId = commonService.findInStationId(findCrnNoResult, stationId);
                     if (targetStationId == null) {
                         continue;
                     }
@@ -212,24 +331,39 @@
                     taskParam.setStaNo(targetStationId);
                     taskParam.setLocNo(locMast.getLocNo());
                     taskParam.setBarcode(stationProtocol.getBarcode());
-                    boolean result = commonService.createInTask(taskParam);
+                    WrkMast wrkMast = commonService.createInTask(taskParam);
 
+                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(),
+                            stationId, stationId, 0);
+                    if (command == null) {
+                        News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
+                        continue;
+                    }
+                    MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                     redisUtil.set(RedisKeyType.GENERATE_FAKE_IN_TASK_LIMIT.key + stationId, "lock", 5);
                 }
             }
         }
     }
 
-    //鐢熸垚浠跨湡妯℃嫙鍑哄簱浠诲姟
+    // 鐢熸垚浠跨湡妯℃嫙鍑哄簱浠诲姟
     private synchronized void generateFakeOutTask() {
         if (!enableFake.equals("Y")) {
+            return;
+        }
+
+        if (fakeRealTaskRequestWms.equals("Y")) {
+            return;
+        }
+
+        if (!fakeGenerateOutTask.equals("Y")) {
             return;
         }
 
         List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
         for (BasDevp basDevp : basDevps) {
             StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
-            if(stationThread == null){
+            if (stationThread == null) {
                 continue;
             }
 
@@ -238,7 +372,7 @@
             List<StationObjModel> list = basDevp.getOutStationList$();
             for (StationObjModel entity : list) {
                 Integer stationId = entity.getStationId();
-                if(!stationMap.containsKey(stationId)){
+                if (!stationMap.containsKey(stationId)) {
                     continue;
                 }
 
@@ -248,33 +382,28 @@
                 }
 
                 Object object = redisUtil.get(RedisKeyType.GENERATE_FAKE_OUT_TASK_LIMIT.key + stationId);
-                if(object != null){
+                if (object != null) {
                     return;
                 }
 
-                //婊¤冻鑷姩銆佹棤鐗┿�佸伐浣滃彿0锛岀敓鎴愬嚭搴撴暟鎹�
+                // 婊¤冻鑷姩銆佹棤鐗┿�佸伐浣滃彿0锛岀敓鎴愬嚭搴撴暟鎹�
                 if (stationProtocol.isAutoing()
                         && !stationProtocol.isLoading()
-                        && stationProtocol.getTaskNo() == 0
-                ) {
-                    List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", String.valueOf(LocStsType.F)));
+                        && stationProtocol.getTaskNo() == 0) {
+                    List<LocMast> locMastList = locMastService
+                            .selectList(new EntityWrapper<LocMast>().eq("loc_sts", String.valueOf(LocStsType.F)));
                     if (locMastList.isEmpty()) {
                         continue;
                     }
 
                     LocMast locMast = locMastList.get(0);
 
-                    Integer crnNo = commonService.findCrnNoByLocNo(locMast.getLocNo());
-                    if (crnNo == null) {
-                        continue;
-                    }
-
                     CreateOutTaskParam taskParam = new CreateOutTaskParam();
                     taskParam.setTaskNo(String.valueOf(commonService.getWorkNo(WrkIoType.OUT.id)));
                     taskParam.setStaNo(stationId);
                     taskParam.setLocNo(locMast.getLocNo());
                     boolean result = commonService.createOutTask(taskParam);
-                    redisUtil.set(RedisKeyType.GENERATE_FAKE_OUT_TASK_LIMIT.key + stationId, "lock", 15);
+                    redisUtil.set(RedisKeyType.GENERATE_FAKE_OUT_TASK_LIMIT.key + stationId, "lock", 10);
                 }
             }
         }
@@ -285,94 +414,134 @@
      * 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗�
      */
     public synchronized void generateStoreWrkFile() {
-        List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
-        for (BasDevp basDevp : basDevps) {
-            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
-            if(stationThread == null){
-                continue;
+        try {
+            if (fakeRealTaskRequestWms.equals("N")) {
+                return;
             }
 
-            Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
+            Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
+            if (systemConfigMapObj == null) {
+                return;
+            }
+            HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj;
 
-            List<StationObjModel> list = basDevp.getInStationList$();
-            for (StationObjModel entity : list) {
-                Integer stationId = entity.getStationId();
-                if(!stationMap.containsKey(stationId)){
+            int conveyorStationTaskLimit = 30;
+            String conveyorStationTaskLimitStr = systemConfigMap.get("conveyorStationTaskLimit");
+            if (conveyorStationTaskLimitStr != null) {
+                conveyorStationTaskLimit = Integer.parseInt(conveyorStationTaskLimitStr);
+            }
+            int currentStationTaskCount = stationOperateProcessUtils.getCurrentStationTaskCount();
+            if (currentStationTaskCount > conveyorStationTaskLimit) {
+                News.error("杈撻�佺珯鐐逛换鍔″凡杈惧埌涓婇檺锛屼笂闄愬�硷細{}锛岀珯鐐逛换鍔℃暟锛歿}", conveyorStationTaskLimit, currentStationTaskCount);
+                return;
+            }
+
+            List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
+            for (BasDevp basDevp : basDevps) {
+                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
+                if (stationThread == null) {
                     continue;
                 }
 
-                StationProtocol stationProtocol = stationMap.get(stationId);
-                if (stationProtocol == null) {
-                    continue;
-                }
+                Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
 
-                //婊¤冻鑷姩銆佹湁鐗┿�佸伐浣滃彿9999锛岀敓鎴愬叆搴撴暟鎹�
-                if (stationProtocol.isAutoing()
-                        && stationProtocol.isLoading()
-                        && stationProtocol.getTaskNo() == 9999
-                ) {
-                    //妫�娴嬩换鍔℃槸鍚︾敓鎴�
-                    List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
-                    if (!wrkMasts.isEmpty()) {
+                List<StationObjModel> list = basDevp.getBarcodeStationList$();
+                for (StationObjModel entity : list) {
+                    Integer stationId = entity.getStationId();
+                    if (!stationMap.containsKey(stationId)) {
                         continue;
                     }
 
-                    String wmsUrl = null;
-                    Config wmsSystemUriConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsSystemUri"));
-                    if (wmsSystemUriConfig != null) {
-                        wmsUrl = wmsSystemUriConfig.getValue();
+                    StationProtocol stationProtocol = stationMap.get(stationId);
+                    if (stationProtocol == null) {
+                        continue;
                     }
 
-                    if(wmsUrl == null){
-                        News.error("鏈厤缃甒MS绯荤粺URI锛岄厤缃枃浠禖ode缂栫爜锛歸msSystemUri");
-                        return;
-                    }
-
-                    String wmsSystemInUrl = null;
-                    Config wmsSystemInUrlConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsSystemInUrl"));
-                    if (wmsSystemInUrlConfig != null) {
-                        wmsSystemInUrl = wmsSystemInUrlConfig.getValue();
-                    }
-
-                    if(wmsSystemInUrlConfig == null){
-                        News.error("鏈厤缃甒MS鍏ュ簱鎺ュ彛鍦板潃锛岄厤缃枃浠禖ode缂栫爜锛歸msSystemInUrl");
-                        return;
-                    }
-
-                    try {
-                        HashMap<String, Object> param = new HashMap<>();
-                        param.put("barcode", stationProtocol.getBarcode());
-                        param.put("sourceStaNo", stationProtocol.getStationId());
-                        param.put("locType1", stationProtocol.getPalletHeight());
-                        param.put("row", Utils.getInTaskEnableRow());
-
-                        String response = new HttpHandler.Builder()
-                                .setUri(wmsUrl)
-                                .setPath(wmsSystemInUrl)
-                                .setJson(JSON.toJSONString(param))
-                                .build()
-                                .doPost();
-                        JSONObject jsonObject = JSON.parseObject(response);
-                        if (jsonObject.getInteger("code").equals(200)) {
-                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
-
-                            CreateInTaskParam taskParam = new CreateInTaskParam();
-                            taskParam.setTaskNo(String.valueOf(dto.getTaskNo()));
-                            taskParam.setLocNo(dto.getLocNo());
-                            taskParam.setTaskPri(dto.getTaskPri());
-                            boolean result = commonService.createInTask(taskParam);
-                        } else {
-                            News.error("璇锋眰WMS鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
+                    // 婊¤冻鑷姩銆佹湁鐗┿�佹湁宸ヤ綔鍙凤紝鐢熸垚鍏ュ簱鏁版嵁
+                    if (stationProtocol.isAutoing()
+                            && stationProtocol.isLoading()
+                            && stationProtocol.getTaskNo() > 0) {
+                        if (Cools.isEmpty(stationProtocol.getBarcode())) {
+                            continue;
                         }
-                    } catch (Exception e) {
-                        e.printStackTrace();
+
+                        // 妫�娴嬩换鍔℃槸鍚︾敓鎴�
+                        List<WrkMast> wrkMasts = wrkMastService
+                                .selectList(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
+                        if (!wrkMasts.isEmpty()) {
+                            continue;
+                        }
+
+                        Object lock = redisUtil.get(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId);
+                        if (lock != null) {
+                            continue;
+                        }
+
+                        String barcode = stationProtocol.getBarcode();
+                        Integer stationIdVal = stationProtocol.getStationId();
+
+                        // 1. 棣栧厛鏌ヨ鏄惁鏈夊凡瀹屾垚鐨勫紓姝ュ搷搴�
+                        String response = wmsOperateUtils.queryAsyncInTaskResponse(barcode, stationIdVal);
+
+                        if (response != null) {
+                            // 2. 鏈夊搷搴旂粨鏋滐紝澶勭悊鍝嶅簲
+                            if (response.equals("FAILED") || response.startsWith("ERROR:")) {
+                                // 璇锋眰澶辫触锛岄噸鏂板彂璧峰紓姝ヨ姹�
+                                News.error("WMS鍏ュ簱璇锋眰澶辫触锛岄噸鏂板彂璧疯姹傦紝barcode={}锛宻tationId={}锛宺esponse={}", barcode,
+                                        stationIdVal, response);
+                                wmsOperateUtils.applyInTaskAsync(barcode, stationIdVal,
+                                        stationProtocol.getPalletHeight());
+                                redisUtil.set(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId, "lock", 2);
+                                continue;
+                            }
+
+                            // 瑙f瀽鍝嶅簲
+                            JSONObject jsonObject = JSON.parseObject(response);
+                            if (jsonObject.getInteger("code").equals(200)) {
+                                StartupDto dto = jsonObject.getObject("data", StartupDto.class);
+
+                                CreateInTaskParam taskParam = new CreateInTaskParam();
+                                taskParam.setTaskNo(dto.getTaskNo());
+                                taskParam.setLocNo(dto.getLocNo());
+                                taskParam.setTaskPri(dto.getTaskPri());
+                                taskParam.setBarcode(barcode);
+                                WrkMast wrkMast = commonService.createInTask(taskParam);
+
+                                StationCommand command = stationThread.getCommand(StationCommandType.WRITE_INFO,
+                                        wrkMast.getWrkNo(), stationId, stationId, 0);
+                                if (command == null) {
+                                    News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
+                                    continue;
+                                }
+                                MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
+                            } else {
+                                // 鎺ュ彛杩斿洖闈�200锛岄噸鏂板彂璧疯姹�
+                                News.error("WMS鍏ュ簱鎺ュ彛杩斿洖闈�200锛岄噸鏂板彂璧疯姹傦紝barcode={}锛宻tationId={}锛宺esponse={}", barcode,
+                                        stationIdVal, response);
+                                wmsOperateUtils.applyInTaskAsync(barcode, stationIdVal,
+                                        stationProtocol.getPalletHeight());
+                                redisUtil.set(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId, "lock", 2);
+                            }
+                        } else {
+                            // 3. 娌℃湁鍝嶅簲缁撴灉锛屾鏌ユ槸鍚︽湁璇锋眰姝e湪杩涜涓�
+                            if (!wmsOperateUtils.isAsyncRequestInProgress(barcode, stationIdVal)) {
+                                // 娌℃湁璇锋眰杩涜涓紝鍙戣捣鏂扮殑寮傛璇锋眰
+                                News.info("鍙戣捣寮傛WMS鍏ュ簱璇锋眰锛宐arcode={}锛宻tationId={}", barcode, stationIdVal);
+                                wmsOperateUtils.applyInTaskAsync(barcode, stationIdVal,
+                                        stationProtocol.getPalletHeight());
+                                redisUtil.set(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId, "lock", 2);
+                            }
+                            // 濡傛灉鏈夎姹傝繘琛屼腑锛岀瓑寰呬笅娆″惊鐜啀妫�鏌�
+                        }
                     }
                 }
             }
+        } catch (Exception e) {
+            e.printStackTrace();
         }
     }
 
-    //璁$畻鎵�鏈夌珯鐐瑰仠鐣欐椂闂�
+    // 璁$畻鎵�鏈夌珯鐐瑰仠鐣欐椂闂�
     public synchronized void calcAllStationStayTime() {
         List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
         for (BasDevp basDevp : basDevps) {
@@ -383,30 +552,33 @@
 
             List<StationProtocol> list = stationThread.getStatus();
             for (StationProtocol stationProtocol : list) {
-                if (stationProtocol.getTaskNo() > 0 && !stationStayTimeMap.containsKey(stationProtocol.getStationId())) {
+                if (stationProtocol.getTaskNo() > 0
+                        && !stationStayTimeMap.containsKey(stationProtocol.getStationId())) {
                     stationStayTimeMap.put(stationProtocol.getStationId(), System.currentTimeMillis());
                 }
 
-                if(stationProtocol.getTaskNo() <= 0 && stationStayTimeMap.containsKey(stationProtocol.getStationId())) {
+                if (stationProtocol.getTaskNo() <= 0
+                        && stationStayTimeMap.containsKey(stationProtocol.getStationId())) {
                     stationStayTimeMap.remove(stationProtocol.getStationId());
                 }
             }
         }
     }
 
-    //妫�娴嬪嚭搴撶珯鐐瑰仠鐣欐槸鍚﹁秴鏃�
+    // 妫�娴嬪嚭搴撶珯鐐瑰仠鐣欐槸鍚﹁秴鏃�
     public synchronized void checkOutStationStayTimeOut() {
         List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
         for (BasDevp basDevp : basDevps) {
             List<StationObjModel> outStationList = basDevp.getOutStationList$();
-            if(outStationList.isEmpty()){
+            if (outStationList.isEmpty()) {
                 News.info("杈撻�佺嚎:{} 鍑哄簱绔欑偣鏈缃�", basDevp.getDevpNo());
                 continue;
             }
 
             for (StationObjModel stationObjModel : outStationList) {
-                Object lock = redisUtil.get(RedisKeyType.CHECK_OUT_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId());
-                if(lock != null){
+                Object lock = redisUtil
+                        .get(RedisKeyType.CHECK_OUT_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId());
+                if (lock != null) {
                     continue;
                 }
 
@@ -415,78 +587,135 @@
                     continue;
                 }
 
-                if(System.currentTimeMillis() - stayTime > 1000 * 15) {
-                    StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
-                    if(stationThread == null){
+                if (System.currentTimeMillis() - stayTime > 1000 * 15) {
+                    StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp,
+                            stationObjModel.getDeviceNo());
+                    if (stationThread == null) {
                         continue;
                     }
 
-                    StationCommand command = stationThread.getMoveCommand(0, stationObjModel.getStationId(), 0, 0);
-                    if(command == null){
+                    StationCommand command = stationThread.getCommand(StationCommandType.RESET, 0,
+                            stationObjModel.getStationId(), 0, 0);
+                    if (command == null) {
                         continue;
                     }
 
                     MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
-                    redisUtil.set(RedisKeyType.CHECK_OUT_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(), "lock",10);
-                    News.info("杈撻�佺珯鐐归噸缃懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽懡浠ゆ暟鎹�={}", stationObjModel.getStationId(), JSON.toJSONString(command));
+                    redisUtil.set(
+                            RedisKeyType.CHECK_OUT_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(),
+                            "lock", 10);
+                    News.info("杈撻�佺珯鐐瑰嚭搴撻噸缃懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽懡浠ゆ暟鎹�={}", stationObjModel.getStationId(),
+                            JSON.toJSONString(command));
                 }
             }
         }
     }
 
-    //妫�娴嬪叆搴撶珯鐐瑰爢鍨涙満鏄惁鍙栬蛋璐х墿
+    // 妫�娴嬪叆搴撶珯鐐瑰爢鍨涙満鏄惁鍙栬蛋璐х墿
     public synchronized void checkInStationCrnTake() {
         List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>());
         for (BasCrnp basCrnp : basCrnps) {
             List<StationObjModel> inStationList = basCrnp.getInStationList$();
-            if(inStationList.isEmpty()){
+            if (inStationList.isEmpty()) {
                 News.info("鍫嗗灈鏈�:{} 鍏ュ簱绔欑偣鏈缃�", basCrnp.getCrnNo());
                 continue;
             }
+            checkInStationListCrnTake(inStationList);
+        }
 
-            for (StationObjModel stationObjModel : inStationList) {
-                Object lock = redisUtil.get(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId());
-                if(lock != null){
+        List<BasDualCrnp> basDualCrnps = basDualCrnpService.selectList(new EntityWrapper<>());
+        for (BasDualCrnp basDualCrnp : basDualCrnps) {
+            List<StationObjModel> inStationList = basDualCrnp.getInStationList$();
+            if (inStationList.isEmpty()) {
+                News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍏ュ簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
+                continue;
+            }
+            checkInStationListCrnTake(inStationList);
+        }
+    }
+
+    private synchronized void checkInStationListCrnTake(List<StationObjModel> inStationList) {
+        for (StationObjModel stationObjModel : inStationList) {
+            Object lock = redisUtil
+                    .get(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId());
+            if (lock != null) {
+                continue;
+            }
+
+            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp,
+                    stationObjModel.getDeviceNo());
+            if (stationThread == null) {
+                continue;
+            }
+
+            Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
+            StationProtocol stationProtocol = statusMap.get(stationObjModel.getStationId());
+            if (stationProtocol == null) {
+                continue;
+            }
+
+            if (stationProtocol.getTaskNo() > 0) {
+                StationCommand command = stationThread.getCommand(StationCommandType.RESET, 0,
+                        stationObjModel.getStationId(), 0, 0);
+                if (command == null) {
                     continue;
                 }
 
-                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
-                if(stationThread == null){
-                    continue;
-                }
-
-                StationCommand command = stationThread.getMoveCommand(0, stationObjModel.getStationId(), 0, 0);
-                if(command == null){
-                    continue;
-                }
-
-                Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
-                StationProtocol stationProtocol = statusMap.get(stationObjModel.getStationId());
-                if (stationProtocol == null) {
-                    continue;
-                }
-
-                if(stationProtocol.getTaskNo() > 0) {
-                    WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
-                    if (wrkMast == null) {
-                        MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
-                        redisUtil.set(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(), "lock",10);
-                        News.info("杈撻�佺珯鐐归噸缃懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽懡浠ゆ暟鎹�={}", stationObjModel.getStationId(), JSON.toJSONString(command));
-                    }else {
-                        if (wrkMast.getWrkSts() != WrkStsType.NEW_INBOUND.sts && wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts) {
-                            Integer crnNo = wrkMast.getCrnNo();
+                WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
+                if (wrkMast == null) {
+                    MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
+                    redisUtil.set(
+                            RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(),
+                            "lock", 10);
+                    News.info("杈撻�佺珯鐐归噸缃懡浠や笅鍙戞垚鍔�(task_over)锛岀珯鐐瑰彿={}锛屽懡浠ゆ暟鎹�={}", stationObjModel.getStationId(),
+                            JSON.toJSONString(command));
+                } else {
+                    if (wrkMast.getWrkSts() != WrkStsType.NEW_INBOUND.sts
+                            && wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts) {
+                        Integer crnNo = wrkMast.getCrnNo();
+                        if (crnNo != null) {
                             CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crnNo);
                             if (crnThread == null) {
                                 continue;
                             }
                             CrnProtocol crnProtocol = crnThread.getStatus();
-                            if (crnProtocol.getStatusType().equals(CrnStatusType.FETCH_MOVING) || crnProtocol.getStatusType().equals(CrnStatusType.FETCHING)) {
+                            if (!crnProtocol.getStatusType().equals(CrnStatusType.PUT_MOVING)
+                                    && !crnProtocol.getStatusType().equals(CrnStatusType.PUTTING)) {
                                 continue;
                             }
 
                             MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
-                            redisUtil.set(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(), "lock",10);
-                            News.info("杈撻�佺珯鐐归噸缃懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽懡浠ゆ暟鎹�={}", stationObjModel.getStationId(), JSON.toJSONString(command));
+                            redisUtil.set(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key
+                                    + stationObjModel.getStationId(), "lock", 10);
+                            News.info("杈撻�佺珯鐐归噸缃懡浠や笅鍙戞垚鍔�(crn_fetch)锛岀珯鐐瑰彿={}锛屽懡浠ゆ暟鎹�={}", stationObjModel.getStationId(),
+                                    JSON.toJSONString(command));
+                        } else {
+                            Integer dualCrnNo = wrkMast.getDualCrnNo();
+                            DualCrnThread dualCrnThread = (DualCrnThread) SlaveConnection.get(SlaveType.DualCrn,
+                                    dualCrnNo);
+                            if (dualCrnThread == null) {
+                                continue;
+                            }
+                            DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
+
+                            boolean reset = false;
+                            if (dualCrnProtocol.getTaskNo() > 0 && dualCrnProtocol.getLoaded() == 1) {
+                                reset = true;
+                            }
+
+                            if (dualCrnProtocol.getTaskNoTwo() > 0 && dualCrnProtocol.getLoadedTwo() == 1) {
+                                reset = true;
+                            }
+
+                            if (!reset) {
+                                continue;
+                            }
+
+                            MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
+                            redisUtil.set(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key
+                                    + stationObjModel.getStationId(), "lock", 10);
+                            News.info("杈撻�佺珯鐐归噸缃懡浠や笅鍙戞垚鍔�(crn_fetch)锛岀珯鐐瑰彿={}锛屽懡浠ゆ暟鎹�={}", stationObjModel.getStationId(),
+                                    JSON.toJSONString(command));
                         }
                     }
                 }
@@ -494,24 +723,27 @@
         }
     }
 
-    //鍫嗗灈鏈轰换鍔℃墽琛屽畬鎴�
+    // 鍫嗗灈鏈轰换鍔℃墽琛屽畬鎴�
     public synchronized void crnIoExecuteFinish() {
         List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>());
         for (BasCrnp basCrnp : basCrnps) {
             CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo());
-            if(crnThread == null){
+            if (crnThread == null) {
                 continue;
             }
 
             CrnProtocol crnProtocol = crnThread.getStatus();
-            if(crnProtocol == null){
+            if (crnProtocol == null) {
                 continue;
             }
 
             if (crnProtocol.getMode() == CrnModeType.AUTO.id
                     && crnProtocol.getTaskNo() > 0
-                    && crnProtocol.getStatus() == CrnStatusType.WAITING.id
-            ) {
+                    && crnProtocol.getStatus() == CrnStatusType.WAITING.id) {
+                Object lock = redisUtil.get(RedisKeyType.CRN_IO_EXECUTE_FINISH_LIMIT.key + basCrnp.getCrnNo());
+                if (lock != null) {
+                    continue;
+                }
 
                 // 鑾峰彇寰呯‘璁ゅ伐浣滄。
                 WrkMast wrkMast = wrkMastService.selectByWorkNo(crnProtocol.getTaskNo());
@@ -521,14 +753,14 @@
                 }
 
                 Long updateWrkSts = null;
-                if(wrkMast.getWrkSts() == WrkStsType.INBOUND_RUN.sts){
+                if (wrkMast.getWrkSts() == WrkStsType.INBOUND_RUN.sts) {
                     updateWrkSts = WrkStsType.COMPLETE_INBOUND.sts;
-                }else if(wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts){
+                } else if (wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts) {
                     updateWrkSts = WrkStsType.OUTBOUND_RUN_COMPLETE.sts;
 
-                    //鐢熸垚浠跨湡绔欑偣鏁版嵁
+                    // 鐢熸垚浠跨湡绔欑偣鏁版嵁
                     List<StationObjModel> outStationList = basCrnp.getOutStationList$();
-                    if(outStationList.isEmpty()){
+                    if (outStationList.isEmpty()) {
                         News.info("鍫嗗灈鏈�:{} 鍑哄簱绔欑偣鏈缃�", basCrnp.getCrnNo());
                         continue;
                     }
@@ -538,15 +770,19 @@
                             continue;
                         }
 
-                        StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
+                        StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp,
+                                stationObjModel.getDeviceNo());
                         if (stationThread == null) {
                             continue;
                         }
-                        //鐢熸垚浠跨湡绔欑偣鏁版嵁
-                        StationCommand command = stationThread.getMoveCommand(9998, wrkMast.getSourceStaNo(), 0, 0);
+                        // 鐢熸垚浠跨湡绔欑偣鏁版嵁
+                        StationCommand command = stationThread.getCommand(StationCommandType.WRITE_INFO, 9998,
+                                wrkMast.getSourceStaNo(), 0, 0);
                         MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
                     }
-                }else{
+                } else if (wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_RUN.sts) {
+                    updateWrkSts = WrkStsType.COMPLETE_LOC_MOVE.sts;
+                } else {
                     News.error("鍫嗗灈鏈哄浜庣瓑寰呯‘璁や笖浠诲姟瀹屾垚鐘舵�侊紝浣嗗伐浣滅姸鎬佸紓甯搞�傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo());
                     continue;
                 }
@@ -559,6 +795,8 @@
                     MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, resetCommand));
                     News.info("鍫嗗灈鏈轰换鍔$姸鎬佹洿鏂版垚鍔燂紝鍫嗗灈鏈哄彿={}锛屽伐浣滃彿={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo());
                 }
+
+                redisUtil.set(RedisKeyType.CRN_IO_EXECUTE_FINISH_LIMIT.key + basCrnp.getCrnNo(), "lock", 10);
             }
         }
     }

--
Gitblit v1.9.1