From 70c104c001de0c586b0d468a30729a9a944560ef Mon Sep 17 00:00:00 2001
From: cpT <1@123>
Date: 星期四, 29 一月 2026 16:42:23 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/utils/StationOperateProcessUtils.java |  144 +++++++++++++++++++++++++++++++----------------
 1 files changed, 94 insertions(+), 50 deletions(-)

diff --git a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
index 8237bbe..b3c63d3 100644
--- a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -121,67 +121,111 @@
         }
     }
 
-    //鎵ц杈撻�佺珯鐐瑰嚭搴撲换鍔�
-    public synchronized void stationOutExecute() {
-        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts));
+    //鎵ц鍫嗗灈鏈鸿緭閫佺珯鐐瑰嚭搴撲换鍔�
+    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) {
-            List<StationObjModel> outStationList = new ArrayList<>();
-
-            BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", wrkMast.getCrnNo()));
-            if (basCrnp != null) {
-                outStationList = basCrnp.getOutStationList$();
-                if(outStationList.isEmpty()){
-                    News.info("鍫嗗灈鏈�:{} 鍑哄簱绔欑偣鏈缃�", basCrnp.getCrnNo());
-                    continue;
-                }
+            Object infoObj = redisUtil.get(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
+            if (infoObj == null) {
+                News.info("鍑哄簱浠诲姟{}鏁版嵁缂撳瓨涓嶅瓨鍦�", wrkMast.getWrkNo());
+                continue;
             }
 
-            BasDualCrnp basDualCrnp = basDualCrnpService.selectOne(new EntityWrapper<BasDualCrnp>().eq("crn_no", wrkMast.getDualCrnNo()));
-            if (basDualCrnp != null) {
-                outStationList = basDualCrnp.getOutStationList$();
-                if(outStationList.isEmpty()){
-                    News.info("鍙屽伐浣嶅爢鍨涙満:{} 鍑哄簱绔欑偣鏈缃�", basDualCrnp.getCrnNo());
-                    continue;
-                }
+            StationObjModel stationObjModel = JSON.parseObject(infoObj.toString(), StationObjModel.class);
+            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
+            if(stationThread == null){
+                continue;
             }
 
-            for (StationObjModel stationObjModel : outStationList) {
-                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
-                if(stationThread == null){
+            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;
                 }
 
-                Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
-                StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId());
-                if (stationProtocol == null) {
+                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;
                 }
 
-                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);
-                    }
+                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());
                 }
             }
         }

--
Gitblit v1.9.1