From 4a1aabe58c417352b62504255603f790b0a6228b Mon Sep 17 00:00:00 2001
From: cpT <1@123>
Date: 星期五, 30 一月 2026 15:37:43 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/plugin/NormalProcess.java                |    1 
 src/main/java/com/zy/core/utils/StationOperateProcessUtils.java    |  636 +++++++++++++------------
 src/main/java/com/zy/core/plugin/XiaosongProcess.java              |    1 
 src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java    |  502 ++++++++++----------
 src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java        |    2 
 src/main/java/com/zy/core/enums/RedisKeyType.java                  |    1 
 src/main/java/com/zy/core/thread/impl/ZySiemensDualCrnThread.java  |  230 ++++-----
 src/main/java/com/zy/core/model/param/SendDualCrnCommandParam.java |   19 
 src/main/resources/application.yml                                 |    4 
 src/main/java/com/zy/core/model/StationObjModel.java               |    2 
 10 files changed, 700 insertions(+), 698 deletions(-)

diff --git a/src/main/java/com/zy/core/enums/RedisKeyType.java b/src/main/java/com/zy/core/enums/RedisKeyType.java
index 88281e4..4e56779 100644
--- a/src/main/java/com/zy/core/enums/RedisKeyType.java
+++ b/src/main/java/com/zy/core/enums/RedisKeyType.java
@@ -10,7 +10,6 @@
     LIFT_FLAG("lift_"),
 
     DUAL_CRN_COMMAND_("dual_crn_command_"),
-    DUAL_CRN_COMMAND_STATION_TASK_NO("dual_crn_command_station_task_no_"),
 
     QUEUE_CRN("queue_crn_"),
     QUEUE_DUAL_CRN("queue_dual_crn_"),
diff --git a/src/main/java/com/zy/core/model/StationObjModel.java b/src/main/java/com/zy/core/model/StationObjModel.java
index 58158b5..631ae0c 100644
--- a/src/main/java/com/zy/core/model/StationObjModel.java
+++ b/src/main/java/com/zy/core/model/StationObjModel.java
@@ -26,6 +26,4 @@
 
     private StationObjModel backStation;
 
-    private StationObjModel dualCrnSlaveStation;
-
 }
diff --git a/src/main/java/com/zy/core/model/param/SendDualCrnCommandParam.java b/src/main/java/com/zy/core/model/param/SendDualCrnCommandParam.java
new file mode 100644
index 0000000..e158330
--- /dev/null
+++ b/src/main/java/com/zy/core/model/param/SendDualCrnCommandParam.java
@@ -0,0 +1,19 @@
+package com.zy.core.model.param;
+
+import com.zy.core.model.command.DualCrnCommand;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class SendDualCrnCommandParam {
+
+    private Integer crnNo;
+
+    private Integer station;
+
+    private List<DualCrnCommand> commands;
+
+    private Integer commandIdx;
+
+}
diff --git a/src/main/java/com/zy/core/plugin/NormalProcess.java b/src/main/java/com/zy/core/plugin/NormalProcess.java
index 2154359..ce5404f 100644
--- a/src/main/java/com/zy/core/plugin/NormalProcess.java
+++ b/src/main/java/com/zy/core/plugin/NormalProcess.java
@@ -124,6 +124,7 @@
                     // 婊¤冻鑷姩銆佹湁鐗┿�佹湁宸ヤ綔鍙凤紝鐢熸垚鍏ュ簱鏁版嵁
                     if (stationProtocol.isAutoing()
                             && stationProtocol.isLoading()
+                            && stationProtocol.isInEnable()
                             && stationProtocol.getTaskNo() > 0) {
                         if (Cools.isEmpty(stationProtocol.getBarcode())) {
                             continue;
diff --git a/src/main/java/com/zy/core/plugin/XiaosongProcess.java b/src/main/java/com/zy/core/plugin/XiaosongProcess.java
index 87a8091..e0c90ce 100644
--- a/src/main/java/com/zy/core/plugin/XiaosongProcess.java
+++ b/src/main/java/com/zy/core/plugin/XiaosongProcess.java
@@ -134,6 +134,7 @@
                     // 婊¤冻鑷姩銆佹湁鐗┿�佹湁宸ヤ綔鍙凤紝鐢熸垚鍏ュ簱鏁版嵁
                     if (stationProtocol.isAutoing()
                             && stationProtocol.isLoading()
+                            && stationProtocol.isInEnable()
                             && stationProtocol.getTaskNo() > 0) {
                         if (Cools.isEmpty(stationProtocol.getBarcode())) {
                             continue;
diff --git a/src/main/java/com/zy/core/thread/impl/ZySiemensDualCrnThread.java b/src/main/java/com/zy/core/thread/impl/ZySiemensDualCrnThread.java
index 7bf7e62..84b76a6 100644
--- a/src/main/java/com/zy/core/thread/impl/ZySiemensDualCrnThread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZySiemensDualCrnThread.java
@@ -20,6 +20,7 @@
 import com.zy.core.model.StationObjModel;
 import com.zy.core.model.Task;
 import com.zy.core.model.command.DualCrnCommand;
+import com.zy.core.model.param.SendDualCrnCommandParam;
 import com.zy.core.model.protocol.DualCrnProtocol;
 import com.zy.core.model.protocol.StationProtocol;
 import com.zy.core.network.DeviceConnectPool;
@@ -31,10 +32,8 @@
 import lombok.extern.slf4j.Slf4j;
 
 import java.text.MessageFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+
 import com.zy.asrs.entity.BasDualCrnpErrLog;
 import com.zy.asrs.service.BasDualCrnpErrLogService;
 
@@ -85,15 +84,8 @@
                     }
 
                     if (step == 2) {
-                        List<DualCrnCommand> commandList = (List<DualCrnCommand>) task.getData();
-                        DualCrnCommand command = commandList.get(0);
-
-                        HashMap<String, Object> map = new HashMap<>();
-                        map.put("commands", commandList);
-                        map.put("idx", 1);
-                        redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_.key + command.getTaskNo(), JSON.toJSONString(map, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
-                        redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_STATION_TASK_NO.key + crnProtocol.getCrnNo() + "_" + command.getStation(), command.getTaskNo(), 60 * 60 * 24);
-                        sendCommand(command);
+                        List<SendDualCrnCommandParam> commandList = (List<SendDualCrnCommandParam>) task.getData();
+                        redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_.key + crnProtocol.getCrnNo(), JSON.toJSONString(commandList, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
                     } else if (step == 3) {
                         sendCommand((DualCrnCommand) task.getData());
                     }
@@ -117,121 +109,28 @@
                         continue;
                     }
 
-                    if (crnProtocol.getLoaded() == 1 && crnProtocol.getLoadedTwo() == 1) {
-                        Object wait = redisUtil.get(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo());
-                        if (wait != null) {
-                            redisUtil.del(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo());
+//                    if (crnProtocol.getLoaded() == 1 && crnProtocol.getLoadedTwo() == 1) {
+//                        Object wait = redisUtil.get(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo());
+//                        if (wait != null) {
+//                            redisUtil.del(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo());
+//                        }
+//                    }
+
+                    Object commandListObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + crnProtocol.getCrnNo());
+                    if (commandListObj == null) {
+                        continue;
+                    }
+                    List<SendDualCrnCommandParam> commandList = JSON.parseArray(commandListObj.toString(), SendDualCrnCommandParam.class);
+
+                    List<SendDualCrnCommandParam> newCommandList = new ArrayList<>();
+                    for (SendDualCrnCommandParam commandParam : commandList) {
+                        SendDualCrnCommandParam processed = processStation(commandParam);
+                        if(processed != null) {
+                            newCommandList.add(processed);
                         }
                     }
 
-                    if(crnProtocol.getTaskNo() == 0 && crnProtocol.getStatus().equals(DualCrnStatusType.FETCH_COMPLETE.id)) {
-                        Integer taskNo = null;
-                        Object stationObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_STATION_TASK_NO.key + crnProtocol.getCrnNo() + "_" + 1);
-                        if(stationObj != null) {
-                            taskNo = Integer.parseInt(String.valueOf(stationObj));
-                        }
-
-                        if (taskNo == null) {
-                            News.error("鍙屽伐浣嶅爢鍨涙満锛屽伐浣�1绌洪棽绛夊緟涓嬪彂鍛戒护锛屼絾鏈壘鍒板伐浣滃彿銆傚爢鍨涙満鍙�={}", crnProtocol.getCrnNo());
-                            continue;
-                        }
-
-                        Object commandObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + taskNo);
-                        if (commandObj == null) {
-                            News.error("鍙屽伐浣嶅爢鍨涙満锛屽伐浣�1绌洪棽绛夊緟涓嬪彂鍛戒护锛屼絾鏈壘鍒板懡浠ゃ�傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", crnProtocol.getCrnNo(), taskNo);
-                            continue;
-                        }
-
-                        JSONObject commandMap = JSON.parseObject(commandObj.toString());
-                        Integer idx = commandMap.getInteger("idx");
-                        List<DualCrnCommand> commandList = commandMap.getJSONArray("commands").toJavaList(DualCrnCommand.class);
-                        if (idx >= commandList.size()) {
-                            continue;
-                        }
-                        DualCrnCommand dualCommand = commandList.get(idx);
-
-                        if (dualCommand.getTaskMode() == DualCrnTaskModeType.PUT.id.shortValue()) {
-                            //绛夊緟涓嬩竴涓换鍔�
-                            Object wait = redisUtil.get(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo());
-                            if (wait != null) {
-                                continue;
-                            }
-
-                            Object outTaskStationInfoObj = redisUtil.get(RedisKeyType.DUAL_CRN_OUT_TASK_STATION_INFO.key + taskNo);
-                            if (outTaskStationInfoObj != null) {
-                                //妫�娴嬪嚭鍙g珯鏄惁鍙墽琛屾斁璐у姩浣�
-                                StationObjModel stationObjModel = JSON.parseObject(outTaskStationInfoObj.toString(), StationObjModel.class);
-                                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.isAutoing()) {
-                                    continue;
-                                }
-
-                                if (stationProtocol.isLoading()) {
-                                    continue;
-                                }
-
-                                if (stationProtocol.getTaskNo() > 0) {
-                                    continue;
-                                }
-                            }
-                        }
-
-                        idx++;
-                        commandMap.put("idx", idx);
-                        sendCommand(dualCommand);
-                        redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_.key + taskNo, commandMap.toJSONString(), 60 * 60 * 24);
-                    }
-
-                    if(crnProtocol.getTaskNoTwo() == 0 && crnProtocol.getStatusTwo().equals(DualCrnStatusType.FETCH_COMPLETE.id)) {
-                        Integer taskNo = null;
-                        Object stationObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_STATION_TASK_NO.key + crnProtocol.getCrnNo() + "_" + 2);
-                        if(stationObj != null) {
-                            taskNo = Integer.parseInt(String.valueOf(stationObj));
-                        }
-
-                        if (taskNo == null) {
-                            News.error("鍙屽伐浣嶅爢鍨涙満锛屽伐浣�1绌洪棽绛夊緟涓嬪彂鍛戒护锛屼絾鏈壘鍒板伐浣滃彿銆傚爢鍨涙満鍙�={}", crnProtocol.getCrnNo());
-                            continue;
-                        }
-
-                        Object commandObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + taskNo);
-                        if (commandObj == null) {
-                            News.error("鍙屽伐浣嶅爢鍨涙満锛屽伐浣�2绌洪棽绛夊緟涓嬪彂鍛戒护锛屼絾鏈壘鍒板懡浠ゃ�傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", crnProtocol.getCrnNo(), taskNo);
-                            continue;
-                        }
-
-                        JSONObject commandMap = JSON.parseObject(commandObj.toString());
-                        Integer idx = commandMap.getInteger("idx");
-                        List<DualCrnCommand> commandList = commandMap.getJSONArray("commands").toJavaList(DualCrnCommand.class);
-                        if (idx >= commandList.size()) {
-                            continue;
-                        }
-                        DualCrnCommand dualCommand = commandList.get(idx);
-
-                        if (dualCommand.getTaskMode() == DualCrnTaskModeType.PUT.id.shortValue()) {
-                            //绛夊緟涓嬩竴涓换鍔�
-                            Object wait = redisUtil.get(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo());
-                            if (wait != null) {
-                                continue;
-                            }
-                        }
-
-                        idx++;
-                        commandMap.put("idx", idx);
-                        sendCommand(dualCommand);
-                        redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_.key + taskNo, commandMap.toJSONString(), 60 * 60 * 24);
-                    }
-
+                    redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_.key + crnProtocol.getCrnNo(), JSON.toJSONString(newCommandList, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
                     Thread.sleep(100);
                 } catch (Exception e) {
                     log.error("DualCrnCommand Fail", e);
@@ -239,6 +138,85 @@
             }
         });
         commandThread.start();
+    }
+
+    private SendDualCrnCommandParam processStation(SendDualCrnCommandParam commandParam) {
+        Integer station = commandParam.getStation();
+        Integer idx = commandParam.getCommandIdx();
+        List<DualCrnCommand> commandList = commandParam.getCommands();
+        if (idx >= commandList.size()) {
+            return commandParam;
+        }
+        DualCrnCommand dualCommand = commandList.get(idx);
+
+        boolean send = false;
+        if (station == 1) {
+            if (crnProtocol.getStatus().equals(DualCrnStatusType.FETCH_COMPLETE.id)
+                    || crnProtocol.getStatus().equals(DualCrnStatusType.IDLE.id)
+            ) {
+                send = true;
+            }
+        }else {
+            if (crnProtocol.getStatusTwo().equals(DualCrnStatusType.FETCH_COMPLETE.id)
+                    || crnProtocol.getStatusTwo().equals(DualCrnStatusType.IDLE.id)
+            ) {
+                send = true;
+            }
+        }
+
+        if (idx == 0) {
+            if(send) {
+                idx++;
+                commandParam.setCommandIdx(idx);
+                sendCommand(dualCommand);
+                redisUtil.set(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo(), "lock", 5);
+            }
+            return commandParam;
+        }else {
+            if (dualCommand.getTaskMode() == DualCrnTaskModeType.PUT.id.shortValue()) {
+                //绛夊緟涓嬩竴涓换鍔�
+                Object wait = redisUtil.get(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo());
+                if (wait != null) {
+                    return commandParam;
+                }
+
+                Integer taskNo = dualCommand.getTaskNo();
+                Object outTaskStationInfoObj = redisUtil.get(RedisKeyType.DUAL_CRN_OUT_TASK_STATION_INFO.key + taskNo);
+                if (outTaskStationInfoObj != null) {
+                    //妫�娴嬪嚭鍙g珯鏄惁鍙墽琛屾斁璐у姩浣�
+                    StationObjModel stationObjModel = JSON.parseObject(outTaskStationInfoObj.toString(), StationObjModel.class);
+                    StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
+                    if (stationThread == null) {
+                        return commandParam;
+                    }
+
+                    Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
+                    StationProtocol stationProtocol = statusMap.get(stationObjModel.getStationId());
+                    if (stationProtocol == null) {
+                        return commandParam;
+                    }
+
+                    if (!stationProtocol.isAutoing()) {
+                        return commandParam;
+                    }
+
+                    if (stationProtocol.isLoading()) {
+                        return commandParam;
+                    }
+
+                    if (stationProtocol.getTaskNo() > 0) {
+                        return commandParam;
+                    }
+                }
+            }
+
+            if(send) {
+                idx++;
+                commandParam.setCommandIdx(idx);
+                sendCommand(dualCommand);
+            }
+            return commandParam;
+        }
     }
 
     /**
@@ -513,7 +491,7 @@
     }
 
     @Override
-    public synchronized CommandResponse sendCommand(DualCrnCommand command) {
+    public CommandResponse sendCommand(DualCrnCommand command) {
         this.crnProtocol.setLastCommandTime(System.currentTimeMillis());
         CommandResponse response = null;
         try {
diff --git a/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java b/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
index 5bcb5f5..b9b9546 100644
--- a/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
@@ -779,13 +779,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) {
diff --git a/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java b/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
index c0b1e29..3d66a89 100644
--- a/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
@@ -15,7 +15,6 @@
 import com.zy.asrs.service.WrkMastService;
 import com.zy.asrs.utils.NotifyUtils;
 import com.zy.asrs.utils.Utils;
-import com.zy.common.entity.FindCrnNoResult;
 import com.zy.common.model.StartupDto;
 import com.zy.common.service.CommonService;
 import com.zy.common.utils.RedisUtil;
@@ -27,6 +26,7 @@
 import com.zy.core.model.Task;
 import com.zy.core.model.command.DualCrnCommand;
 import com.zy.core.model.command.StationCommand;
+import com.zy.core.model.param.SendDualCrnCommandParam;
 import com.zy.core.model.protocol.DualCrnProtocol;
 import com.zy.core.model.protocol.StationProtocol;
 import com.zy.core.thread.DualCrnThread;
@@ -101,43 +101,175 @@
             return;
         }
 
-        List<WrkMast> allTaskList = new ArrayList<>();
-        List<WrkMast> inTaskList = getInTaskList(basDualCrnp);
-        List<WrkMast> outTaskList = getOutTaskList(basDualCrnp);
-        List<WrkMast> locMoveTaskList = getLocMoveTaskList(basDualCrnp);
-
-        if (!locMoveTaskList.isEmpty()) {
-            allTaskList.addAll(locMoveTaskList);
+        if (!(dualCrnProtocol.getStatusType().equals(DualCrnStatusType.IDLE) && dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.IDLE))) {
+            return;
         }
 
         // 濡傛灉鏈�杩戜竴娆℃槸鍑哄簱妯″紡
         if (dualCrnProtocol.getLastIo().equals("O")) {
-            allTaskList.addAll(inTaskList);
-            allTaskList.addAll(outTaskList);
+            processLoveMove(basDualCrnp, dualCrnThread);
+            processIn(basDualCrnp, dualCrnThread);
+            processOut(basDualCrnp, dualCrnThread);
         }
         // 濡傛灉鏈�杩戜竴娆℃槸鍏ュ簱妯″紡
         else if (dualCrnProtocol.getLastIo().equals("I")) {
-            allTaskList.addAll(outTaskList);
-            allTaskList.addAll(inTaskList);
+            processLoveMove(basDualCrnp, dualCrnThread);
+            processOut(basDualCrnp, dualCrnThread);
+            processIn(basDualCrnp, dualCrnThread);
+        }
+    }
+
+    private void processIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) {
+        List<WrkMast> inTaskList = getInTaskList(basDualCrnp);
+        if (inTaskList.isEmpty()) {
+            return;
         }
 
-        for (WrkMast wrkMast : allTaskList) {
-            if (wrkMast.getIoType() == WrkIoType.IN.id) {
-                boolean result = this.crnExecuteIn(basDualCrnp, dualCrnThread, wrkMast);
-                if (result) {
-                    break;
-                }
-            } else if (wrkMast.getIoType() == WrkIoType.OUT.id) {
-                boolean result = this.crnExecuteOut(basDualCrnp, dualCrnThread, wrkMast);
-                if (result) {
-                    break;
-                }
-            } else if (wrkMast.getIoType() == WrkIoType.LOC_MOVE.id) {
-                boolean result = this.crnExecuteLocMove(basDualCrnp, dualCrnThread, wrkMast);
-                if (result) {
-                    break;
+        WrkMast stationOneWrkMast = inTaskList.get(0);
+        WrkMast stationTwoWrkMast = null;
+
+        if (inTaskList.size() >= 2) {
+            stationTwoWrkMast = inTaskList.get(1);
+        }
+
+        SendDualCrnCommandParam oneResult = null;
+        SendDualCrnCommandParam twoResult = null;
+
+        if(stationOneWrkMast != null){
+            oneResult = crnExecuteIn(basDualCrnp, dualCrnThread, stationOneWrkMast);
+        }
+
+        if(stationTwoWrkMast != null){
+            twoResult = crnExecuteIn(basDualCrnp, dualCrnThread, stationTwoWrkMast);
+        }
+
+        List<SendDualCrnCommandParam> list = new ArrayList<>();
+        if (oneResult != null) {
+            list.add(oneResult);
+        }
+
+        if (twoResult != null) {
+            list.add(twoResult);
+        }
+
+        if (!list.isEmpty()) {
+            DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
+            Integer crnNo = basDualCrnp.getCrnNo();
+            MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, list));
+            News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂鎴愬姛锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(list));
+            dualCrnProtocol.setLastIo("I");
+        }
+    }
+
+    private void processOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) {
+        List<WrkMast> outTaskList = getOutTaskList(basDualCrnp);
+        if (outTaskList.isEmpty()) {
+            return;
+        }
+
+        WrkMast stationOneWrkMast = null;
+        WrkMast stationTwoWrkMast = null;
+
+        List<Integer> disableList = basDualCrnp.getDisableStationOneBays$();
+
+        for (WrkMast wrkMast : outTaskList) {
+            if (stationOneWrkMast == null) {
+                if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) {
+                    stationOneWrkMast = wrkMast;
+                    continue;
                 }
             }
+
+            if (stationTwoWrkMast == null) {
+                if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) {
+                    stationTwoWrkMast = wrkMast;
+                    continue;
+                }
+            }
+        }
+
+        SendDualCrnCommandParam oneResult = null;
+        SendDualCrnCommandParam twoResult = null;
+
+        if(stationOneWrkMast != null){
+            oneResult = crnExecuteOut(basDualCrnp, dualCrnThread, stationOneWrkMast, 1);
+        }
+
+        if(stationTwoWrkMast != null){
+            twoResult = crnExecuteOut(basDualCrnp, dualCrnThread, stationTwoWrkMast, 2);
+        }
+
+        List<SendDualCrnCommandParam> list = new ArrayList<>();
+        if (oneResult != null) {
+            list.add(oneResult);
+        }
+
+        if (twoResult != null) {
+            list.add(twoResult);
+        }
+
+        if (!list.isEmpty()) {
+            DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
+            Integer crnNo = basDualCrnp.getCrnNo();
+            MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, list));
+            News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂鎴愬姛锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(list));
+            dualCrnProtocol.setLastIo("O");
+        }
+    }
+
+    private void processLoveMove(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) {
+        List<WrkMast> locMoveTaskList = getLocMoveTaskList(basDualCrnp);
+        if (locMoveTaskList.isEmpty()) {
+            return;
+        }
+
+        WrkMast stationOneWrkMast = null;
+        WrkMast stationTwoWrkMast = null;
+
+        List<Integer> disableList = basDualCrnp.getDisableStationOneBays$();
+
+        for (WrkMast wrkMast : locMoveTaskList) {
+            if (stationOneWrkMast == null) {
+                if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) {
+                    stationOneWrkMast = wrkMast;
+                    continue;
+                }
+            }
+
+            if (stationTwoWrkMast == null) {
+                if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) {
+                    stationTwoWrkMast = wrkMast;
+                    continue;
+                }
+            }
+        }
+
+        SendDualCrnCommandParam oneResult = null;
+        SendDualCrnCommandParam twoResult = null;
+
+        if(stationOneWrkMast != null){
+            oneResult = crnExecuteLocMove(basDualCrnp, dualCrnThread, stationOneWrkMast, 1);
+        }
+
+        if(stationTwoWrkMast != null){
+            twoResult = crnExecuteLocMove(basDualCrnp, dualCrnThread, stationTwoWrkMast, 2);
+        }
+
+        List<SendDualCrnCommandParam> list = new ArrayList<>();
+        if (oneResult != null) {
+            list.add(oneResult);
+        }
+
+        if (twoResult != null) {
+            list.add(twoResult);
+        }
+
+        if (!list.isEmpty()) {
+            DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
+            Integer crnNo = basDualCrnp.getCrnNo();
+            MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, list));
+            News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂鎴愬姛锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(list));
+            dualCrnProtocol.setLastIo("O");
         }
     }
 
@@ -148,55 +280,39 @@
             return list;
         }
 
+        List<Integer> taskList = new ArrayList<>();
         List<StationObjModel> inStationList = basDualCrnp.getInStationList$();
-        if(inStationList.isEmpty()){
-            News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍏ュ簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
-            return list;
-        }
-
         for (StationObjModel stationObjModel : inStationList) {
             StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
             if (stationThread == null) {
                 continue;
             }
 
-            Map<Integer, StationProtocol> stationProtocolMap = stationThread.getStatusMap();
-            StationProtocol stationProtocol = stationProtocolMap.get(stationObjModel.getStationId());
+            Map<Integer, StationProtocol> map = stationThread.getStatusMap();
+            StationProtocol stationProtocol = map.get(stationObjModel.getStationId());
             if (stationProtocol == null) {
                 continue;
             }
 
-            if (!stationProtocol.isAutoing()) {
-                continue;
+            if (stationProtocol.isAutoing()
+                    && stationProtocol.isLoading()
+                    && stationProtocol.getTaskNo() > 0
+            ) {
+                taskList.add(stationProtocol.getTaskNo());
             }
+        }
 
-            if (!stationProtocol.isLoading()) {
-                continue;
-            }
-
-            if (stationProtocol.getTaskNo() <= 0) {
-                continue;
-            }
-
-            if (!stationProtocol.isInEnable()) {
-                News.taskInfo(stationProtocol.getTaskNo(), "鍙栬揣绔欑偣:{} 娌℃湁鍙叆淇″彿", stationObjModel.getStationId());
-                continue;
-            }
-
-            // 鑾峰彇浠诲姟
-            WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
-            if (null == wrkMast) {
-                News.taskInfo(stationProtocol.getTaskNo(), "宸ヤ綔鍙�:{} 浠诲姟淇℃伅涓嶅瓨鍦�", stationProtocol.getTaskNo());
-                continue;
-            }
-
+        // 鑾峰彇浠诲姟
+        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+                .eq("dual_crn_no", basDualCrnp.getCrnNo())
+                .in("wrk_no", taskList)
+        );
+        for (WrkMast wrkMast : wrkMasts) {
             if(wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts){
                 continue;
             }
-
             list.add(wrkMast);
         }
-
         return list;
     }
 
@@ -231,46 +347,46 @@
         return list;
     }
 
-    private synchronized boolean crnExecuteIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
+    private synchronized SendDualCrnCommandParam crnExecuteIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
         DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
         if (dualCrnProtocol == null) {
-            return false;
+            return null;
         }
 
         if (!basDualCrnp.getInEnable().equals("Y")) {
             News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍙叆淇″彿涓嶆弧瓒�", basDualCrnp.getCrnNo());
-            return false;
+            return null;
         }
 
         List<StationObjModel> inStationList = basDualCrnp.getInStationList$();
         if(inStationList.isEmpty()){
             News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍏ュ簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
-            return false;
+            return null;
         }
 
         Integer crnNo = basDualCrnp.getCrnNo();
 
         if (wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts) {
-            return false;
+            return null;
         }
 
         // 鑾峰彇搴撲綅淇℃伅
         LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
         if (locMast == null) {
             News.taskInfo(wrkMast.getWrkNo(), "鐩爣搴撲綅:{} 淇℃伅涓嶅瓨鍦�", wrkMast.getLocNo());
-            return false;
+            return null;
         }
 
         if (!locMast.getLocSts().equals("S")) {
             News.taskInfo(wrkMast.getWrkNo(), "鐩爣搴撲綅:{} 鐘舵�佸紓甯�", wrkMast.getLocNo());
-            return false;
+            return null;
         }
 
         //妫�娴嬫祬搴撲綅鐘舵��
         boolean checkStatus = checkShallowLocStatus(locMast.getLocNo(), wrkMast.getWrkNo());
         if (!checkStatus) {
             News.taskInfo(wrkMast.getWrkNo(), "鍥犳祬搴撲綅鍫靛鏃犳硶鎵ц");
-            return false;
+            return null;
         }
 
         StationObjModel inStationObjModel = null;
@@ -307,38 +423,11 @@
                 inStationObjModel = stationObjModel;
                 break;
             }
-
-            StationObjModel dualCrnSlaveStationObjModel = stationObjModel.getDualCrnSlaveStation();
-            if (dualCrnSlaveStationObjModel == null) {
-                continue;
-            }
-
-            StationProtocol slaveStationProtocol = stationProtocolMap.get(dualCrnSlaveStationObjModel.getStationId());
-            if (slaveStationProtocol == null) {
-                continue;
-            }
-
-            if (!slaveStationProtocol.isAutoing()) {
-                continue;
-            }
-
-            if (!slaveStationProtocol.isLoading()) {
-                continue;
-            }
-
-            if (slaveStationProtocol.getTaskNo() <= 0) {
-                continue;
-            }
-
-            if (slaveStationProtocol.getTaskNo().equals(wrkMast.getWrkNo())) {
-                inStationObjModel = dualCrnSlaveStationObjModel;
-                break;
-            }
         }
 
         if (inStationObjModel == null) {
             News.taskInfo(wrkMast.getWrkNo(), "鏈悳绱㈠埌鍙栬揣绔欑偣");
-            return false;
+            return null;
         }
 
         Integer station = inStationObjModel.getDualCrnExecuteStation();
@@ -347,14 +436,14 @@
             if (basList.contains(Utils.getBay(wrkMast.getLocNo()))) {
                 //绂佹鏀捐揣鍒楋紝鐢宠閲嶆柊鍒嗛厤
                 reassignTaskLocNo(wrkMast, inStationObjModel);
-                return false;
+                return null;
             }
         }else {
             List<Integer> basList = basDualCrnp.getDisableStationTwoBays$();
             if (basList.contains(Utils.getBay(wrkMast.getLocNo()))) {
                 //绂佹鏀捐揣鍒楋紝鐢宠閲嶆柊鍒嗛厤
                 reassignTaskLocNo(wrkMast, inStationObjModel);
-                return false;
+                return null;
             }
         }
 
@@ -371,60 +460,44 @@
         wrkMast.setSystemMsg("");
         wrkMast.setIoTime(new Date());
         if (wrkMastService.updateById(wrkMast)) {
-            MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
+            SendDualCrnCommandParam sendDualCrnCommandParam = new SendDualCrnCommandParam();
+            sendDualCrnCommandParam.setCrnNo(crnNo);
+            sendDualCrnCommandParam.setStation(station);
+            sendDualCrnCommandParam.setCommands(commandList);
+            sendDualCrnCommandParam.setCommandIdx(0);
+
             notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_IN_TASK_RUN, null);
-            News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂鎴愬姛锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(commandList));
-            dualCrnProtocol.setLastIo("I");
-            return true;
+            return sendDualCrnCommandParam;
         }
-        return false;
+        return null;
     }
 
-    private synchronized boolean crnExecuteOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
+    private synchronized SendDualCrnCommandParam crnExecuteOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast, int station) {
         DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
         if (dualCrnProtocol == null) {
-            return false;
+            return null;
         }
 
         if (!basDualCrnp.getOutEnable().equals("Y")) {
             News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍙嚭淇″彿涓嶆弧瓒�", basDualCrnp.getCrnNo());
-            return false;
+            return null;
         }
 
         List<StationObjModel> outStationList = basDualCrnp.getOutStationList$();
         if (outStationList.isEmpty()) {
             News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍑哄簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
-            return false;
+            return null;
         }
 
         Integer crnNo = basDualCrnp.getCrnNo();
-        int station = calcStation(dualCrnProtocol, "out");
-        if (station == 0) {
-            News.info("鍙屽伐浣嶅爢鍨涙満:{} 鏃犲彲鐢ㄥ伐浣�", basDualCrnp.getCrnNo());
-            return false;
-        }
 
-        List<StationObjModel> enableUseStationList = new ArrayList<>();
         for (StationObjModel stationObjModel : outStationList) {
-            if (!stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) {
+            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
+            if (stationThread == null) {
                 continue;
             }
 
-            if(stationObjModel.getDualCrnExecuteStation().equals(station)) {
-                enableUseStationList.add(stationObjModel);
-            }
-
-            StationObjModel dualCrnSlaveStation = stationObjModel.getDualCrnSlaveStation();
-            if(dualCrnSlaveStation != null) {
-                if (dualCrnSlaveStation.getDualCrnExecuteStation().equals(station)) {
-                    enableUseStationList.add(stationObjModel);
-                }
-            }
-        }
-
-        for (StationObjModel stationObjModel : enableUseStationList) {
-            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
-            if (stationThread == null) {
+            if (stationObjModel.getDualCrnExecuteStation() != station) {
                 continue;
             }
 
@@ -483,65 +556,58 @@
             wrkMast.setSystemMsg("");
             wrkMast.setIoTime(new Date());
             if (wrkMastService.updateById(wrkMast)) {
-                MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
-                notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_OUT_TASK_RUN, null);
-                News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂鎴愬姛锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(commandList));
-                dualCrnProtocol.setLastIo("O");
-
                 redisUtil.set(RedisKeyType.DUAL_CRN_OUT_TASK_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(stationObjModel, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
-                return true;
+
+                SendDualCrnCommandParam sendDualCrnCommandParam = new SendDualCrnCommandParam();
+                sendDualCrnCommandParam.setCrnNo(crnNo);
+                sendDualCrnCommandParam.setStation(station);
+                sendDualCrnCommandParam.setCommands(commandList);
+                sendDualCrnCommandParam.setCommandIdx(0);
+
+                notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_OUT_TASK_RUN, null);
+                return sendDualCrnCommandParam;
             }
         }
-        return false;
+        return null;
     }
 
-    private synchronized boolean crnExecuteLocMove(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
+    private synchronized SendDualCrnCommandParam crnExecuteLocMove(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast, int station) {
         DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
         if (dualCrnProtocol == null) {
-            return false;
+            return null;
         }
 
         Integer crnNo = basDualCrnp.getCrnNo();
-        int station = calcStation(dualCrnProtocol, "locMove");
-        if (station == 0) {
-            News.info("鍙屽伐浣嶅爢鍨涙満:{} 鏃犲彲鐢ㄥ伐浣�", basDualCrnp.getCrnNo());
-            return false;
-        }
-
-        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
-                .eq("crn_no", crnNo)
-                .eq("wrk_sts", WrkStsType.NEW_LOC_MOVE.sts)
-        );
 
         // 鑾峰彇婧愬簱浣嶄俊鎭�
         LocMast sourceLocMast = locMastService.selectById(wrkMast.getSourceLocNo());
         if (sourceLocMast == null) {
             News.taskInfo(wrkMast.getWrkNo(), "婧愬簱浣�:{} 淇℃伅涓嶅瓨鍦�", wrkMast.getSourceLocNo());
-            return false;
+            return null;
         }
 
-        if(!sourceLocMast.getLocSts().equals("R")){
+        if (!sourceLocMast.getLocSts().equals("R")) {
             News.taskInfo(wrkMast.getWrkNo(), "婧愬簱浣�:{} 鐘舵�佸紓甯革紝涓嶅睘浜庡嚭搴撻绾︾姸鎬�", wrkMast.getSourceLocNo());
-            return false;
+            return null;
         }
 
         // 鑾峰彇搴撲綅淇℃伅
         LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
         if (locMast == null) {
             News.taskInfo(wrkMast.getWrkNo(), "搴撲綅:{} 淇℃伅涓嶅瓨鍦�", wrkMast.getLocNo());
-            return false;
+            return null;
         }
 
         if (!locMast.getLocSts().equals("S")) {
             News.taskInfo(wrkMast.getWrkNo(), "搴撲綅:{} 鐘舵�佸紓甯革紝涓嶅睘浜庡叆搴撻绾︾姸鎬�", wrkMast.getLocNo());
-            return false;
+            return null;
         }
 
         //妫�娴嬫祬搴撲綅鐘舵��
         boolean checkStatus = checkShallowLocStatus(locMast.getLocNo(), wrkMast.getWrkNo());
         if (!checkStatus) {
             News.taskInfo(wrkMast.getWrkNo(), "鍥犳祬搴撲綅鍫靛鏃犳硶鎵ц");
-            return false;
+            return null;
         }
 
         List<DualCrnCommand> commandList = new ArrayList<>();
@@ -555,13 +621,16 @@
         wrkMast.setSystemMsg("");
         wrkMast.setIoTime(new Date());
         if (wrkMastService.updateById(wrkMast)) {
-            MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
+            SendDualCrnCommandParam sendDualCrnCommandParam = new SendDualCrnCommandParam();
+            sendDualCrnCommandParam.setCrnNo(crnNo);
+            sendDualCrnCommandParam.setStation(station);
+            sendDualCrnCommandParam.setCommands(commandList);
+            sendDualCrnCommandParam.setCommandIdx(0);
+
             notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_TRANSFER_TASK_RUN, null);
-            News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂鎴愬姛锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crnNo, JSON.toJSON(commandList));
-            dualCrnProtocol.setLastIo("I");
-            return true;
+            return sendDualCrnCommandParam;
         }
-        return false;
+        return null;
     }
 
     //鍙屽伐浣嶅爢鍨涙満浠诲姟鎵ц瀹屾垚
@@ -609,15 +678,27 @@
             return;
         }
 
-        Object commandObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + wrkMast.getWrkNo());
-        if (commandObj == null) {
+        Object commandListObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + basDualCrnp.getCrnNo());
+        if (commandListObj == null) {
+            News.error("鍙屽伐浣嶅爢鍨涙満澶勪簬绛夊緟纭涓斾换鍔″畬鎴愮姸鎬侊紝浣嗘湭鎵惧埌鍛戒护銆傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", basDualCrnp.getCrnNo(), taskNo);
+            return;
+        }
+        List<SendDualCrnCommandParam> dualCrnCommandParamList = JSON.parseArray(commandListObj.toString(), SendDualCrnCommandParam.class);
+        SendDualCrnCommandParam taskCommand = null;
+        for (SendDualCrnCommandParam sendDualCrnCommandParam : dualCrnCommandParamList) {
+            DualCrnCommand dualCrnCommand = sendDualCrnCommandParam.getCommands().get(0);
+            if(dualCrnCommand.getTaskNo() == taskNo){
+                taskCommand = sendDualCrnCommandParam;
+                break;
+            }
+        }
+        if (taskCommand == null) {
             News.error("鍙屽伐浣嶅爢鍨涙満澶勪簬绛夊緟纭涓斾换鍔″畬鎴愮姸鎬侊紝浣嗘湭鎵惧埌鍛戒护銆傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", basDualCrnp.getCrnNo(), taskNo);
             return;
         }
 
-        JSONObject commandMap = JSON.parseObject(commandObj.toString());
-        Integer idx = commandMap.getInteger("idx");
-        List<DualCrnCommand> commandList = commandMap.getJSONArray("commands").toJavaList(DualCrnCommand.class);
+        Integer idx = taskCommand.getCommandIdx();
+        List<DualCrnCommand> commandList = taskCommand.getCommands();
         if (idx >= commandList.size()) {
             Long updateWrkSts = null;
             if (wrkMast.getWrkSts() == WrkStsType.INBOUND_RUN.sts) {
@@ -631,25 +712,6 @@
                 if(outStationList.isEmpty()){
                     News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍑哄簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
                     return;
-                }
-
-                StationObjModel outStationObjModel = null;
-                for (StationObjModel stationObjModel : outStationList) {
-                    if (stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) {
-                        outStationObjModel = stationObjModel;
-                        break;
-                    }
-                }
-
-                if (outStationObjModel == null) {
-                    News.info("鍙屽伐浣嶅爢鍨涙満:{} 鏈壘鍒板尮閰嶇殑浠诲姟鍑哄簱绔�", basDualCrnp.getCrnNo());
-                    return;
-                }
-
-                if (station == 1) {
-                    redisUtil.set(RedisKeyType.DUAL_CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(outStationObjModel, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
-                }else {
-                    redisUtil.set(RedisKeyType.DUAL_CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(outStationObjModel.getDualCrnSlaveStation(), SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
                 }
 
                 if(mainProcessPlugin.contains("Fake")) {
@@ -689,12 +751,6 @@
                 redisUtil.set(RedisKeyType.DUAL_CRN_IO_EXECUTE_FINISH_LIMIT.key + basDualCrnp.getCrnNo() + "_" + taskNo, "lock", 10);
             }
         }else {
-            DualCrnCommand command = commandList.get(idx - 1);
-            if (command.getTaskMode() == DualCrnTaskModeType.PICK.id.shortValue()) {
-                //鍙栬揣鍚庣瓑寰呬笅涓�涓换鍔℃椂闀�
-                redisUtil.set(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + basDualCrnp.getCrnNo(), "wait", 10);
-            }
-
             DualCrnCommand resetCommand = dualCrnThread.getResetCommand(dualCrnProtocol.getCrnNo(), station);
             MessageQueue.offer(SlaveType.DualCrn, dualCrnProtocol.getCrnNo(), new Task(3, resetCommand));
             News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护瀹屾垚纭鎴愬姛锛屽爢鍨涙満鍙�={}锛屽伐浣滃彿={}", basDualCrnp.getCrnNo(), taskNo);
@@ -718,13 +774,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) {
@@ -762,76 +818,6 @@
             }
         }
         return false;
-    }
-
-    private int calcStation(DualCrnProtocol dualCrnProtocol, String type) {
-        List<Integer> idleStationList = new ArrayList<>();
-
-        if (dualCrnProtocol.getTaskNo() == 0
-                && dualCrnProtocol.getLoaded() == 0
-                && dualCrnProtocol.getStatusType().equals(DualCrnStatusType.IDLE)
-                && dualCrnProtocol.getTaskReceive() == 0
-        ) {
-            idleStationList.add(1);
-        }
-
-        if (dualCrnProtocol.getTaskNoTwo() == 0
-                && dualCrnProtocol.getLoadedTwo() == 0
-                && dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.IDLE)
-                && dualCrnProtocol.getTaskReceiveTwo() == 0
-        ) {
-            idleStationList.add(2);
-        }
-
-        if (type.equals("locMove")) {
-            if (idleStationList.size() != 2) {
-                return 0;
-            }
-            return idleStationList.get(0);
-        }
-
-        if (idleStationList.size() == 2) {
-            return idleStationList.get(0);
-        }
-
-        Integer idleStation = idleStationList.get(0);
-        int workingStation = idleStation == 1 ? 2 : 1;
-
-        int executeTaskNo = 0;
-        if (workingStation == 1) {
-            executeTaskNo = dualCrnProtocol.getTaskNo();
-            //妫�娴嬪伐浣嶅凡杩涘叆鏀捐揣闃舵锛屾斁璐ч樁娈典笉鎺ユ柊浠诲姟
-            if (dualCrnProtocol.getStatusType().equals(DualCrnStatusType.PUT_MOVING)
-                    || dualCrnProtocol.getStatusType().equals(DualCrnStatusType.PUTTING)
-                    || dualCrnProtocol.getStatusType().equals(DualCrnStatusType.WAITING)
-            ) {
-                return 0;
-            }
-        } else {
-            executeTaskNo = dualCrnProtocol.getTaskNoTwo();
-            //妫�娴嬪伐浣嶅凡杩涘叆鏀捐揣闃舵锛屾斁璐ч樁娈典笉鎺ユ柊浠诲姟
-            if (dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.PUT_MOVING)
-                    || dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.PUTTING)
-                    || dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.WAITING)
-            ) {
-                return 0;
-            }
-        }
-
-        if (executeTaskNo == 0) {
-            return 0;
-        }
-
-        WrkMast wrkMast = wrkMastService.selectByWorkNo(executeTaskNo);
-        if (wrkMast.getIoType().equals(WrkIoType.IN.id) && type.equals("in")) {
-            return idleStation;
-        }
-
-        if (wrkMast.getIoType().equals(WrkIoType.OUT.id) && type.equals("out")) {
-            return idleStation;
-        }
-
-        return 0;
     }
 
     private boolean reassignTaskLocNo(WrkMast wrkMast, StationObjModel stationObjModel) {
diff --git a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
index b3c63d3..627d207 100644
--- a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -46,203 +46,7 @@
 
     //鎵ц杈撻�佺珯鐐瑰叆搴撲换鍔�
     public synchronized void stationInExecute() {
-        List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
-        for (BasDevp basDevp : basDevps) {
-            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
-            if(stationThread == null){
-                continue;
-            }
-
-            Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
-
-            List<StationObjModel> list = basDevp.getBarcodeStationList$();
-            for (StationObjModel entity : list) {
-                Integer stationId = entity.getStationId();
-                if(!stationMap.containsKey(stationId)){
-                    continue;
-                }
-
-                StationProtocol stationProtocol = stationMap.get(stationId);
-                if (stationProtocol == null) {
-                    continue;
-                }
-
-                Object lock = redisUtil.get(RedisKeyType.STATION_IN_EXECUTE_LIMIT.key + stationId);
-                if(lock != null){
-                    continue;
-                }
-
-                //婊¤冻鑷姩銆佹湁鐗┿�佹湁宸ヤ綔鍙�
-                if (stationProtocol.isAutoing()
-                        && stationProtocol.isLoading()
-                        && stationProtocol.getTaskNo() > 0
-                ) {
-                    //妫�娴嬩换鍔℃槸鍚︾敓鎴�
-                    WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
-                    if (wrkMast == null) {
-                        continue;
-                    }
-
-                    if (wrkMast.getWrkSts() == WrkStsType.INBOUND_DEVICE_RUN.sts) {
-                        continue;
-                    }
-
-                    String locNo = wrkMast.getLocNo();
-                    FindCrnNoResult findCrnNoResult = commonService.findCrnNoByLocNo(locNo);
-                    if (findCrnNoResult == null) {
-                        News.taskInfo(wrkMast.getWrkNo(), "{}宸ヤ綔,鏈尮閰嶅埌鍫嗗灈鏈�", wrkMast.getWrkNo());
-                        continue;
-                    }
-
-                    Integer targetStationId = commonService.findInStationId(findCrnNoResult, stationId);
-                    if (targetStationId == null) {
-                        News.taskInfo(wrkMast.getWrkNo(), "{}绔欑偣,鎼滅储鍏ュ簱绔欑偣澶辫触", stationId);
-                        continue;
-                    }
-
-                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationId, targetStationId, 0);
-                    if(command == null){
-                        News.taskInfo(wrkMast.getWrkNo(), "{}宸ヤ綔,鑾峰彇杈撻�佺嚎鍛戒护澶辫触", wrkMast.getWrkNo());
-                        continue;
-                    }
-
-                    wrkMast.setWrkSts(WrkStsType.INBOUND_DEVICE_RUN.sts);
-                    wrkMast.setSourceStaNo(stationProtocol.getStationId());
-                    wrkMast.setStaNo(targetStationId);
-                    wrkMast.setSystemMsg("");
-                    wrkMast.setIoTime(new Date());
-                    if (wrkMastService.updateById(wrkMast)) {
-                        MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
-                        News.info("杈撻�佺珯鐐瑰叆搴撳懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽伐浣滃彿={}锛屽懡浠ゆ暟鎹�={}", stationId, wrkMast.getWrkNo(), JSON.toJSONString(command));
-                        redisUtil.set(RedisKeyType.STATION_IN_EXECUTE_LIMIT.key + stationId, "lock", 5);
-                    }
-                }
-            }
-        }
-    }
-
-    //鎵ц鍫嗗灈鏈鸿緭閫佺珯鐐瑰嚭搴撲换鍔�
-    public synchronized void crnStationOutExecute() {
-        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
-                .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
-                .isNotNull("crn_no")
-        );
-        for (WrkMast wrkMast : wrkMasts) {
-            Object infoObj = redisUtil.get(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
-            if (infoObj == null) {
-                News.info("鍑哄簱浠诲姟{}鏁版嵁缂撳瓨涓嶅瓨鍦�", wrkMast.getWrkNo());
-                continue;
-            }
-
-            StationObjModel stationObjModel = JSON.parseObject(infoObj.toString(), StationObjModel.class);
-            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
-            if(stationThread == null){
-                continue;
-            }
-
-            Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
-            StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId());
-            if (stationProtocol == null) {
-                continue;
-            }
-
-            Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId());
-            if (lock != null) {
-                continue;
-            }
-
-            //婊¤冻鑷姩銆佹湁鐗┿�佸伐浣滃彿0
-            if (stationProtocol.isAutoing()
-                    && stationProtocol.isLoading()
-                    && stationProtocol.getTaskNo() == 0
-            ) {
-                StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
-                if(command == null){
-                    News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
-                    continue;
-                }
-
-                wrkMast.setWrkSts(WrkStsType.STATION_RUN.sts);
-                wrkMast.setSystemMsg("");
-                wrkMast.setIoTime(new Date());
-                if (wrkMastService.updateById(wrkMast)) {
-                    MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
-                    News.info("杈撻�佺珯鐐瑰嚭搴撳懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽伐浣滃彿={}锛屽懡浠ゆ暟鎹�={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
-                    redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
-                    redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkMast.getWrkNo(), "lock", 60 * 5);
-                    redisUtil.del(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
-                }
-            }
-        }
-    }
-
-    //鎵ц鍙屽伐浣嶅爢鍨涙満杈撻�佺珯鐐瑰嚭搴撲换鍔�
-    public synchronized void dualCrnStationOutExecute() {
-        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
-                .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
-                .isNotNull("dual_crn_no")
-        );
-        for (WrkMast wrkMast : wrkMasts) {
-            Object infoObj = redisUtil.get(RedisKeyType.DUAL_CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
-            if (infoObj == null) {
-                News.info("鍑哄簱浠诲姟{}鏁版嵁缂撳瓨涓嶅瓨鍦�", wrkMast.getWrkNo());
-                continue;
-            }
-
-            StationObjModel stationObjModel = JSON.parseObject(infoObj.toString(), StationObjModel.class);
-            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
-            if(stationThread == null){
-                continue;
-            }
-
-            Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
-            StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId());
-            if (stationProtocol == null) {
-                continue;
-            }
-
-            Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId());
-            if (lock != null) {
-                continue;
-            }
-
-            //婊¤冻鑷姩銆佹湁鐗┿�佸伐浣滃彿0
-            if (stationProtocol.isAutoing()
-                    && stationProtocol.isLoading()
-                    && stationProtocol.getTaskNo() == 0
-            ) {
-                StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
-                if(command == null){
-                    News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
-                    continue;
-                }
-
-                wrkMast.setWrkSts(WrkStsType.STATION_RUN.sts);
-                wrkMast.setSystemMsg("");
-                wrkMast.setIoTime(new Date());
-                if (wrkMastService.updateById(wrkMast)) {
-                    MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
-                    News.info("杈撻�佺珯鐐瑰嚭搴撳懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽伐浣滃彿={}锛屽懡浠ゆ暟鎹�={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
-                    redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
-                    redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkMast.getWrkNo(), "lock", 60 * 5);
-                    redisUtil.del(RedisKeyType.DUAL_CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
-                }
-            }
-        }
-    }
-
-    //妫�娴嬭緭閫佺珯鐐瑰嚭搴撲换鍔℃墽琛屽畬鎴�
-    public synchronized void stationOutExecuteFinish() {
-        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.STATION_RUN.sts));
-        for (WrkMast wrkMast : wrkMasts) {
-            Integer wrkNo = wrkMast.getWrkNo();
-
-            Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkNo);
-            if (lock != null) {
-                continue;
-            }
-
-            boolean complete = true;
+        try {
             List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
             for (BasDevp basDevp : basDevps) {
                 StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
@@ -250,152 +54,368 @@
                     continue;
                 }
 
-                List<StationProtocol> list = stationThread.getStatus();
-                for (StationProtocol stationProtocol : list) {
-                    if (stationProtocol.getTaskNo().equals(wrkNo)) {
-                        complete = false;
+                Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
+
+                List<StationObjModel> list = basDevp.getBarcodeStationList$();
+                for (StationObjModel entity : list) {
+                    Integer stationId = entity.getStationId();
+                    if (!stationMap.containsKey(stationId)) {
+                        continue;
+                    }
+
+                    StationProtocol stationProtocol = stationMap.get(stationId);
+                    if (stationProtocol == null) {
+                        continue;
+                    }
+
+                    Object lock = redisUtil.get(RedisKeyType.STATION_IN_EXECUTE_LIMIT.key + stationId);
+                    if (lock != null) {
+                        continue;
+                    }
+
+                    //婊¤冻鑷姩銆佹湁鐗┿�佹湁宸ヤ綔鍙�
+                    if (stationProtocol.isAutoing()
+                            && stationProtocol.isLoading()
+                            && stationProtocol.getTaskNo() > 0
+                    ) {
+                        //妫�娴嬩换鍔℃槸鍚︾敓鎴�
+                        WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
+                        if (wrkMast == null) {
+                            continue;
+                        }
+
+                        if (wrkMast.getWrkSts() == WrkStsType.INBOUND_DEVICE_RUN.sts) {
+                            continue;
+                        }
+
+                        String locNo = wrkMast.getLocNo();
+                        FindCrnNoResult findCrnNoResult = commonService.findCrnNoByLocNo(locNo);
+                        if (findCrnNoResult == null) {
+                            News.taskInfo(wrkMast.getWrkNo(), "{}宸ヤ綔,鏈尮閰嶅埌鍫嗗灈鏈�", wrkMast.getWrkNo());
+                            continue;
+                        }
+
+                        Integer targetStationId = commonService.findInStationId(findCrnNoResult, stationId);
+                        if (targetStationId == null) {
+                            News.taskInfo(wrkMast.getWrkNo(), "{}绔欑偣,鎼滅储鍏ュ簱绔欑偣澶辫触", stationId);
+                            continue;
+                        }
+
+                        StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationId, targetStationId, 0);
+                        if (command == null) {
+                            News.taskInfo(wrkMast.getWrkNo(), "{}宸ヤ綔,鑾峰彇杈撻�佺嚎鍛戒护澶辫触", wrkMast.getWrkNo());
+                            continue;
+                        }
+
+                        wrkMast.setWrkSts(WrkStsType.INBOUND_DEVICE_RUN.sts);
+                        wrkMast.setSourceStaNo(stationProtocol.getStationId());
+                        wrkMast.setStaNo(targetStationId);
+                        wrkMast.setSystemMsg("");
+                        wrkMast.setIoTime(new Date());
+                        if (wrkMastService.updateById(wrkMast)) {
+                            MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
+                            News.info("杈撻�佺珯鐐瑰叆搴撳懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽伐浣滃彿={}锛屽懡浠ゆ暟鎹�={}", stationId, wrkMast.getWrkNo(), JSON.toJSONString(command));
+                            redisUtil.set(RedisKeyType.STATION_IN_EXECUTE_LIMIT.key + stationId, "lock", 5);
+                        }
                     }
                 }
             }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
 
-            if (complete) {
-                wrkMast.setWrkSts(WrkStsType.COMPLETE_OUTBOUND.sts);
-                wrkMast.setIoTime(new Date());
-                wrkMastService.updateById(wrkMast);
+    //鎵ц鍫嗗灈鏈鸿緭閫佺珯鐐瑰嚭搴撲换鍔�
+    public synchronized void crnStationOutExecute() {
+        try {
+            List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+                    .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
+                    .isNotNull("crn_no")
+            );
+            for (WrkMast wrkMast : wrkMasts) {
+                Object infoObj = redisUtil.get(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
+                if (infoObj == null) {
+                    News.info("鍑哄簱浠诲姟{}鏁版嵁缂撳瓨涓嶅瓨鍦�", wrkMast.getWrkNo());
+                    continue;
+                }
+
+                StationObjModel stationObjModel = JSON.parseObject(infoObj.toString(), StationObjModel.class);
+                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
+                if (stationThread == null) {
+                    continue;
+                }
+
+                Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
+                StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId());
+                if (stationProtocol == null) {
+                    continue;
+                }
+
+                Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId());
+                if (lock != null) {
+                    continue;
+                }
+
+                //婊¤冻鑷姩銆佹湁鐗┿�佸伐浣滃彿0
+                if (stationProtocol.isAutoing()
+                        && stationProtocol.isLoading()
+                        && stationProtocol.getTaskNo() == 0
+                ) {
+                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
+                    if (command == null) {
+                        News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
+                        continue;
+                    }
+
+                    wrkMast.setWrkSts(WrkStsType.STATION_RUN.sts);
+                    wrkMast.setSystemMsg("");
+                    wrkMast.setIoTime(new Date());
+                    if (wrkMastService.updateById(wrkMast)) {
+                        MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
+                        News.info("杈撻�佺珯鐐瑰嚭搴撳懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽伐浣滃彿={}锛屽懡浠ゆ暟鎹�={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
+                        redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
+                        redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkMast.getWrkNo(), "lock", 60);
+                        redisUtil.del(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
+                    }
+                }
             }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    //鎵ц鍙屽伐浣嶅爢鍨涙満杈撻�佺珯鐐瑰嚭搴撲换鍔�
+    public synchronized void dualCrnStationOutExecute() {
+        try {
+            List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+                    .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
+                    .isNotNull("dual_crn_no")
+            );
+            for (WrkMast wrkMast : wrkMasts) {
+                Object infoObj = redisUtil.get(RedisKeyType.DUAL_CRN_OUT_TASK_STATION_INFO.key + wrkMast.getWrkNo());
+                if (infoObj == null) {
+                    News.info("鍑哄簱浠诲姟{}鏁版嵁缂撳瓨涓嶅瓨鍦�", wrkMast.getWrkNo());
+                    continue;
+                }
+
+                StationObjModel stationObjModel = JSON.parseObject(infoObj.toString(), StationObjModel.class);
+                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
+                if (stationThread == null) {
+                    continue;
+                }
+
+                Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
+                StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId());
+                if (stationProtocol == null) {
+                    continue;
+                }
+
+                Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId());
+                if (lock != null) {
+                    continue;
+                }
+
+                //婊¤冻鑷姩銆佹湁鐗┿�佸伐浣滃彿0
+                if (stationProtocol.isAutoing()
+                        && stationProtocol.isLoading()
+                        && stationProtocol.getTaskNo() == 0
+                ) {
+                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
+                    if (command == null) {
+                        News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
+                        continue;
+                    }
+
+                    wrkMast.setWrkSts(WrkStsType.STATION_RUN.sts);
+                    wrkMast.setSystemMsg("");
+                    wrkMast.setIoTime(new Date());
+                    if (wrkMastService.updateById(wrkMast)) {
+                        MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
+                        News.info("杈撻�佺珯鐐瑰嚭搴撳懡浠や笅鍙戞垚鍔燂紝绔欑偣鍙�={}锛屽伐浣滃彿={}锛屽懡浠ゆ暟鎹�={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
+                        redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
+                        redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkMast.getWrkNo(), "lock", 60);
+                        redisUtil.del(RedisKeyType.DUAL_CRN_OUT_TASK_STATION_INFO.key + wrkMast.getWrkNo());
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    //妫�娴嬭緭閫佺珯鐐瑰嚭搴撲换鍔℃墽琛屽畬鎴�
+    public synchronized void stationOutExecuteFinish() {
+        try {
+            List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.STATION_RUN.sts));
+            for (WrkMast wrkMast : wrkMasts) {
+                Integer wrkNo = wrkMast.getWrkNo();
+
+                Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkNo);
+                if (lock != null) {
+                    continue;
+                }
+
+                boolean complete = true;
+                List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
+                for (BasDevp basDevp : basDevps) {
+                    StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
+                    if (stationThread == null) {
+                        continue;
+                    }
+
+                    List<StationProtocol> list = stationThread.getStatus();
+                    for (StationProtocol stationProtocol : list) {
+                        if (stationProtocol.getTaskNo().equals(wrkNo)) {
+                            complete = false;
+                        }
+                    }
+                }
+
+                if (complete) {
+                    wrkMast.setWrkSts(WrkStsType.COMPLETE_OUTBOUND.sts);
+                    wrkMast.setIoTime(new Date());
+                    wrkMastService.updateById(wrkMast);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
         }
     }
 
     //妫�娴嬭緭閫佺珯鐐规槸鍚﹁繍琛屽牭濉�
     public synchronized void checkStationRunBlock() {
-        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 {
+            List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
+            for (BasDevp basDevp : basDevps) {
+                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
+                if (stationThread == null) {
+                    continue;
+                }
 
-            List<Integer> runBlockReassignLocStationList = new ArrayList<>();
-            for (StationObjModel stationObjModel : basDevp.getRunBlockReassignLocStationList$()) {
-                runBlockReassignLocStationList.add(stationObjModel.getStationId());
-            }
+                List<Integer> runBlockReassignLocStationList = new ArrayList<>();
+                for (StationObjModel stationObjModel : basDevp.getRunBlockReassignLocStationList$()) {
+                    runBlockReassignLocStationList.add(stationObjModel.getStationId());
+                }
 
-            List<StationProtocol> list = stationThread.getStatus();
-            for (StationProtocol stationProtocol : list) {
-                if(stationProtocol.isAutoing()
-                    && stationProtocol.isLoading()
-                    && stationProtocol.getTaskNo() > 0
-                    && stationProtocol.isRunBlock()
-                ) {
-                    WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
-                    if (wrkMast == null) {
-                        News.info("杈撻�佺珯鐐瑰彿={} 杩愯闃诲锛屼絾鏃犳硶鎵惧埌瀵瑰簲浠诲姟锛屽伐浣滃彿={}", stationProtocol.getStationId(), stationProtocol.getTaskNo());
-                        continue;
-                    }
-
-                    Object lock = redisUtil.get(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo());
-                    if (lock != null) {
-                        continue;
-                    }
-                    redisUtil.set(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo(), "lock", 15);
-
-                    if (wrkMast.getIoType() == WrkIoType.IN.id && runBlockReassignLocStationList.contains(stationProtocol.getStationId())) {
-                        //绔欑偣澶勪簬閲嶆柊鍒嗛厤搴撲綅鍖哄煙
-                        //杩愯鍫靛锛岄噸鏂扮敵璇蜂换鍔�
-                        String response = wmsOperateUtils.applyReassignTaskLocNo(wrkMast.getWrkNo(), stationProtocol.getStationId());
-                        if (response == null) {
-                            News.taskError(wrkMast.getWrkNo(), "璇锋眰WMS閲嶆柊鍒嗛厤搴撲綅鎺ュ彛澶辫触锛屾帴鍙f湭鍝嶅簲锛侊紒锛乺esponse锛歿}", response);
+                List<StationProtocol> list = stationThread.getStatus();
+                for (StationProtocol stationProtocol : list) {
+                    if (stationProtocol.isAutoing()
+                            && stationProtocol.isLoading()
+                            && stationProtocol.getTaskNo() > 0
+                            && stationProtocol.isRunBlock()
+                    ) {
+                        WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
+                        if (wrkMast == null) {
+                            News.info("杈撻�佺珯鐐瑰彿={} 杩愯闃诲锛屼絾鏃犳硶鎵惧埌瀵瑰簲浠诲姟锛屽伐浣滃彿={}", stationProtocol.getStationId(), stationProtocol.getTaskNo());
                             continue;
                         }
-                        JSONObject jsonObject = JSON.parseObject(response);
-                        if (jsonObject.getInteger("code").equals(200)) {
-                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
 
-                            String sourceLocNo = wrkMast.getLocNo();
-                            String locNo = dto.getLocNo();
+                        Object lock = redisUtil.get(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo());
+                        if (lock != null) {
+                            continue;
+                        }
+                        redisUtil.set(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo(), "lock", 15);
 
-                            LocMast sourceLocMast = locMastService.queryByLoc(sourceLocNo);
-                            if (sourceLocMast == null) {
-                                News.taskInfo(wrkMast.getWrkNo(), "搴撲綅鍙�:{} 婧愬簱浣嶄俊鎭笉瀛樺湪", sourceLocNo);
+                        if (wrkMast.getIoType() == WrkIoType.IN.id && runBlockReassignLocStationList.contains(stationProtocol.getStationId())) {
+                            //绔欑偣澶勪簬閲嶆柊鍒嗛厤搴撲綅鍖哄煙
+                            //杩愯鍫靛锛岄噸鏂扮敵璇蜂换鍔�
+                            String response = wmsOperateUtils.applyReassignTaskLocNo(wrkMast.getWrkNo(), stationProtocol.getStationId());
+                            if (response == null) {
+                                News.taskError(wrkMast.getWrkNo(), "璇锋眰WMS閲嶆柊鍒嗛厤搴撲綅鎺ュ彛澶辫触锛屾帴鍙f湭鍝嶅簲锛侊紒锛乺esponse锛歿}", response);
                                 continue;
                             }
+                            JSONObject jsonObject = JSON.parseObject(response);
+                            if (jsonObject.getInteger("code").equals(200)) {
+                                StartupDto dto = jsonObject.getObject("data", StartupDto.class);
 
-                            if (!sourceLocMast.getLocSts().equals("S")) {
-                                News.taskInfo(wrkMast.getWrkNo(), "搴撲綅鍙�:{} 婧愬簱浣嶇姸鎬佷笉澶勪簬鍏ュ簱棰勭害", sourceLocNo);
-                                continue;
-                            }
+                                String sourceLocNo = wrkMast.getLocNo();
+                                String locNo = dto.getLocNo();
 
-                            LocMast locMast = locMastService.queryByLoc(locNo);
-                            if (locMast == null) {
-                                News.taskInfo(wrkMast.getWrkNo(), "搴撲綅鍙�:{} 鐩爣搴撲綅淇℃伅涓嶅瓨鍦�", locNo);
-                                continue;
-                            }
+                                LocMast sourceLocMast = locMastService.queryByLoc(sourceLocNo);
+                                if (sourceLocMast == null) {
+                                    News.taskInfo(wrkMast.getWrkNo(), "搴撲綅鍙�:{} 婧愬簱浣嶄俊鎭笉瀛樺湪", sourceLocNo);
+                                    continue;
+                                }
 
-                            if (!locMast.getLocSts().equals("O")) {
-                                News.taskInfo(wrkMast.getWrkNo(), "搴撲綅鍙�:{} 鐩爣搴撲綅鐘舵�佷笉澶勪簬绌哄簱浣�", locNo);
-                                continue;
-                            }
+                                if (!sourceLocMast.getLocSts().equals("S")) {
+                                    News.taskInfo(wrkMast.getWrkNo(), "搴撲綅鍙�:{} 婧愬簱浣嶇姸鎬佷笉澶勪簬鍏ュ簱棰勭害", sourceLocNo);
+                                    continue;
+                                }
 
-                            FindCrnNoResult findCrnNoResult = commonService.findCrnNoByLocNo(locNo);
-                            if (findCrnNoResult == null) {
-                                News.taskInfo(wrkMast.getWrkNo(), "{}宸ヤ綔,鏈尮閰嶅埌鍫嗗灈鏈�", wrkMast.getWrkNo());
-                                continue;
-                            }
-                            Integer crnNo = findCrnNoResult.getCrnNo();
+                                LocMast locMast = locMastService.queryByLoc(locNo);
+                                if (locMast == null) {
+                                    News.taskInfo(wrkMast.getWrkNo(), "搴撲綅鍙�:{} 鐩爣搴撲綅淇℃伅涓嶅瓨鍦�", locNo);
+                                    continue;
+                                }
 
-                            Integer targetStationId = commonService.findInStationId(findCrnNoResult, stationProtocol.getStationId());
-                            if (targetStationId == null) {
-                                News.taskInfo(wrkMast.getWrkNo(), "{}绔欑偣,鎼滅储鍏ュ簱绔欑偣澶辫触", stationProtocol.getStationId());
-                                continue;
-                            }
+                                if (!locMast.getLocSts().equals("O")) {
+                                    News.taskInfo(wrkMast.getWrkNo(), "搴撲綅鍙�:{} 鐩爣搴撲綅鐘舵�佷笉澶勪簬绌哄簱浣�", locNo);
+                                    continue;
+                                }
 
-                            StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), targetStationId, 0);
-                            if(command == null){
-                                News.taskInfo(wrkMast.getWrkNo(), "{}宸ヤ綔,鑾峰彇杈撻�佺嚎鍛戒护澶辫触", wrkMast.getWrkNo());
-                                continue;
-                            }
+                                FindCrnNoResult findCrnNoResult = commonService.findCrnNoByLocNo(locNo);
+                                if (findCrnNoResult == null) {
+                                    News.taskInfo(wrkMast.getWrkNo(), "{}宸ヤ綔,鏈尮閰嶅埌鍫嗗灈鏈�", wrkMast.getWrkNo());
+                                    continue;
+                                }
+                                Integer crnNo = findCrnNoResult.getCrnNo();
 
-                            //鏇存柊婧愬簱浣�
-                            sourceLocMast.setLocSts("O");
-                            sourceLocMast.setModiTime(new Date());
-                            locMastService.updateById(sourceLocMast);
+                                Integer targetStationId = commonService.findInStationId(findCrnNoResult, stationProtocol.getStationId());
+                                if (targetStationId == null) {
+                                    News.taskInfo(wrkMast.getWrkNo(), "{}绔欑偣,鎼滅储鍏ュ簱绔欑偣澶辫触", stationProtocol.getStationId());
+                                    continue;
+                                }
 
-                            //鏇存柊鐩爣搴撲綅
-                            locMast.setLocSts("S");
-                            locMast.setModiTime(new Date());
-                            locMastService.updateById(locMast);
+                                StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), targetStationId, 0);
+                                if (command == null) {
+                                    News.taskInfo(wrkMast.getWrkNo(), "{}宸ヤ綔,鑾峰彇杈撻�佺嚎鍛戒护澶辫触", wrkMast.getWrkNo());
+                                    continue;
+                                }
 
-                            //鏇存柊宸ヤ綔妗f暟鎹�
-                            wrkMast.setLocNo(locNo);
-                            wrkMast.setStaNo(targetStationId);
+                                //鏇存柊婧愬簱浣�
+                                sourceLocMast.setLocSts("O");
+                                sourceLocMast.setModiTime(new Date());
+                                locMastService.updateById(sourceLocMast);
 
-                            if (findCrnNoResult.getCrnType().equals(SlaveType.Crn)) {
-                                wrkMast.setCrnNo(crnNo);
-                            } else if (findCrnNoResult.getCrnType().equals(SlaveType.DualCrn)) {
-                                wrkMast.setDualCrnNo(crnNo);
-                            }else {
-                                throw new CoolException("鏈煡璁惧绫诲瀷");
-                            }
+                                //鏇存柊鐩爣搴撲綅
+                                locMast.setLocSts("S");
+                                locMast.setModiTime(new Date());
+                                locMastService.updateById(locMast);
 
-                            if (wrkMastService.updateById(wrkMast)) {
-                                MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
+                                //鏇存柊宸ヤ綔妗f暟鎹�
+                                wrkMast.setLocNo(locNo);
+                                wrkMast.setStaNo(targetStationId);
+
+                                if (findCrnNoResult.getCrnType().equals(SlaveType.Crn)) {
+                                    wrkMast.setCrnNo(crnNo);
+                                } else if (findCrnNoResult.getCrnType().equals(SlaveType.DualCrn)) {
+                                    wrkMast.setDualCrnNo(crnNo);
+                                } else {
+                                    throw new CoolException("鏈煡璁惧绫诲瀷");
+                                }
+
+                                if (wrkMastService.updateById(wrkMast)) {
+                                    MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
+                                }
+                            } else {
+                                News.error("璇锋眰WMS鎺ュ彛澶辫触锛侊紒锛乺esponse锛歿}", response);
                             }
                         } else {
-                            News.error("璇锋眰WMS鎺ュ彛澶辫触锛侊紒锛乺esponse锛歿}", response);
-                        }
-                    }else {
-                        //杩愯鍫靛锛岄噸鏂拌绠楄矾绾�
-                        StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
-                        if(command == null){
-                            News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
-                            continue;
-                        }
+                            //杩愯鍫靛锛岄噸鏂拌绠楄矾绾�
+                            StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
+                            if (command == null) {
+                                News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
+                                continue;
+                            }
 
-                        MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
-                        News.info("杈撻�佺珯鐐瑰牭濉炲悗閲嶆柊璁$畻璺緞鍛戒护涓嬪彂鎴愬姛锛岀珯鐐瑰彿={}锛屽伐浣滃彿={}锛屽懡浠ゆ暟鎹�={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
+                            MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
+                            News.info("杈撻�佺珯鐐瑰牭濉炲悗閲嶆柊璁$畻璺緞鍛戒护涓嬪彂鎴愬姛锛岀珯鐐瑰彿={}锛屽伐浣滃彿={}锛屽懡浠ゆ暟鎹�={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
+                        }
                     }
                 }
             }
+        } catch (Exception e) {
+            e.printStackTrace();
         }
     }
 
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index c2cd2f2..5e20c67 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -1,6 +1,6 @@
 # 绯荤粺鐗堟湰淇℃伅
 app:
-  version: 1.0.2.2
+  version: 1.0.3.0
   version-type: dev  # prd 鎴� dev
 
 server:
@@ -72,7 +72,7 @@
   threadControlCount: 10
   liftType: lift
 
-mainProcessPlugin: FakeProcess
+mainProcessPlugin: XiaosongProcess
 
 deviceLogStorage:
   # 璁惧鏃ュ織瀛樺偍鏂瑰紡 mysql file

--
Gitblit v1.9.1