From 377e207801eec0014b806394166a68caa52561ab Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期三, 07 一月 2026 10:09:20 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/plugin/FakeProcess.java |  124 ++++++++++++++++++++++++++++------------
 1 files changed, 86 insertions(+), 38 deletions(-)

diff --git a/src/main/java/com/zy/core/plugin/FakeProcess.java b/src/main/java/com/zy/core/plugin/FakeProcess.java
index f202acc..9c20eaf 100644
--- a/src/main/java/com/zy/core/plugin/FakeProcess.java
+++ b/src/main/java/com/zy/core/plugin/FakeProcess.java
@@ -8,6 +8,7 @@
 import com.zy.asrs.domain.param.CreateOutTaskParam;
 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.RedisUtil;
@@ -20,11 +21,15 @@
 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;
@@ -61,6 +66,8 @@
     @Autowired
     private BasCrnpService basCrnpService;
     @Autowired
+    private BasDualCrnpService basDualCrnpService;
+    @Autowired
     private RedisUtil redisUtil;
     @Autowired
     private CrnOperateProcessUtils crnOperateUtils;
@@ -68,6 +75,8 @@
     private StationOperateProcessUtils stationOperateProcessUtils;
     @Autowired
     private WmsOperateUtils wmsOperateUtils;
+    @Autowired
+    private DualCrnOperateProcessUtils dualCrnOperateProcessUtils;
 
     @Override
     public void run() {
@@ -84,6 +93,11 @@
         stationOperateProcessUtils.stationOutExecute();
         //妫�娴嬭緭閫佺珯鐐瑰嚭搴撲换鍔℃墽琛屽畬鎴�
         stationOperateProcessUtils.stationOutExecuteFinish();
+
+        //鎵ц鍙屽伐浣嶅爢鍨涙満浠诲姟
+        dualCrnOperateProcessUtils.dualCrnIoExecute();
+        //鍙屽伐浣嶅爢鍨涙満浠诲姟鎵ц瀹屾垚
+        dualCrnOperateProcessUtils.dualCrnIoExecuteFinish();
     }
 
     public void asyncRun() {
@@ -222,7 +236,7 @@
                         && !stationProtocol.isLoading()
                         && stationProtocol.getTaskNo() == 0
                 ) {
-                    StationCommand command = stationThread.getMoveCommand(commonService.getWorkNo(WrkIoType.FAKE_TASK_NO.id), stationId, entity.getBarcodeStation().getStationId(), 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", 5);
                 }
@@ -293,12 +307,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;
                     }
@@ -311,7 +325,7 @@
                     taskParam.setBarcode(stationProtocol.getBarcode());
                     WrkMast wrkMast = commonService.createInTask(taskParam);
 
-                    StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationId, stationId, 0);
+                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationId, stationId, 0);
                     if(command == null){
                         News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
                         continue;
@@ -374,11 +388,6 @@
                     }
 
                     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)));
@@ -458,7 +467,7 @@
                         taskParam.setBarcode(stationProtocol.getBarcode());
                         WrkMast wrkMast = commonService.createInTask(taskParam);
 
-                        StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationId, stationId, 0);
+                        StationCommand command = stationThread.getCommand(StationCommandType.WRITE_INFO, wrkMast.getWrkNo(), stationId, stationId, 0);
                         if(command == null){
                             News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
                             continue;
@@ -519,7 +528,7 @@
                         continue;
                     }
 
-                    StationCommand command = stationThread.getMoveCommand(0, stationObjModel.getStationId(), 0, 0);
+                    StationCommand command = stationThread.getCommand(StationCommandType.RESET, 0, stationObjModel.getStationId(), 0, 0);
                     if(command == null){
                         continue;
                     }
@@ -541,44 +550,83 @@
                 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){
-                    continue;
-                }
+        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);
+        }
+    }
 
-                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
-                if(stationThread == null){
-                    continue;
-                }
+    private 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;
+            }
 
-                StationCommand command = stationThread.getMoveCommand(0, stationObjModel.getStationId(), 0, 0);
+            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;
                 }
 
-                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("杈撻�佺珯鐐归噸缃懡浠や笅鍙戞垚鍔�(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();
+                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.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("杈撻�佺珯鐐归噸缃懡浠や笅鍙戞垚鍔�(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;
                             }
 
@@ -645,7 +693,7 @@
                             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 if(wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_RUN.sts){

--
Gitblit v1.9.1