From 2c175f2b2c00dfe18c349b92a6f6b1ec55bc3db1 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期四, 25 九月 2025 16:46:00 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |  107 ++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 93 insertions(+), 14 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
index e1d18d0..ab0027e 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -617,18 +617,13 @@
         //1.鐢熸垚鍏ュ簱浠诲姟 ==> 3.鎻愬崌鏈烘惉杩愪腑
         if (wrkMast.getWrkSts() == WrkStsType.NEW_INBOUND.sts) {
             //鑾峰彇鐩爣杈撻�佺珯
-            ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
+            LiftStaProtocol liftSta = LiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
             if (liftSta == null) {
                 return false;//鎵句笉鍒扮珯鐐�
             }
 
             if (liftSta.getHasTray()) {
                 News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀洰鏍囩珯瀛樺湪鎵樼洏", wrkMast.getWrkNo());
-                return false;
-            }
-
-            if (liftSta.getHasCar()) {
-                News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀洰鏍囩珯瀛樺湪灏忚溅", wrkMast.getWrkNo());
                 return false;
             }
 
@@ -701,7 +696,7 @@
             }
 
             //鑾峰彇鎻愬崌鏈哄懡浠�
-            LiftCommand liftCommand = liftThread.getPickAndPutCommand(wrkMast.getWrkNo(), wrkMast.getSourceStaNo(), liftSta.getLev());
+            LiftCommand liftCommand = liftThread.getPickAndPutCommand(wrkMast.getWrkNo(), wrkMast.getSourceStaNo(), liftSta.getSiteId());
             ArrayList<LiftCommand> commands = new ArrayList<>();
             commands.add(liftCommand);
 
@@ -771,11 +766,6 @@
                     wrkMastService.updateById(wrkMast);
                     return false;
                 }
-                return false;
-            }
-
-            if (liftSta.getHasCar()) {
-                News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}绔欑偣瀛樺湪灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftSta.getSiteId());
                 return false;
             }
 
@@ -1388,6 +1378,11 @@
                 return false;
             }
 
+            Object limitObj = redisUtil.get(RedisKeyType.TASK_RUN_LIMIT.key + wrkMast.getWrkNo());
+            if (limitObj != null) {
+                return false;
+            }
+
             //灏忚溅宸茬粡鍦ㄥ厖鐢垫々浣嶇疆锛屼笅鍙戝仠姝㈠厖鐢靛懡浠�
             ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
             assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//鍥涘悜绌挎杞﹀彿
@@ -1400,6 +1395,7 @@
 
             //涓嬪彂浠诲姟
             shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand);
+            redisUtil.set(RedisKeyType.TASK_RUN_LIMIT.key + wrkMast.getWrkNo(), "limit", 10);
             return false;
         }
         return true;
@@ -1666,7 +1662,13 @@
             int targetLev = Utils.getLev(shuttleProtocol.getCurrentLocNo());
             if (object == null || liftProtocol.getLev() != targetLev) {
                 //鑾峰彇鎻愬崌鏈哄懡浠�
-                LiftCommand liftCommand = liftThread.getMoveCommand(wrkMast.getWrkNo(), liftProtocol.getLev(), targetLev);
+                LiftStaProtocol startSta = LiftUtils.getLiftStaByLev(liftProtocol.getLiftNo(), liftProtocol.getLev());
+                LiftStaProtocol targetSta = LiftUtils.getLiftStaByLev(liftProtocol.getLiftNo(), targetLev);
+                if (startSta == null || targetSta == null) {
+                    News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛岀珯鐐规暟鎹笉瀛樺湪", wrkMast.getWrkNo(), wrkMast.getLiftNo());
+                    return false;
+                }
+                LiftCommand liftCommand = liftThread.getMoveCommand(commonService.getWorkNo(WrkIoType.PREVIEW_LIFT_MOVE.id), startSta.getSiteId(), targetSta.getSiteId());
                 ArrayList<LiftCommand> commands = new ArrayList<>();
                 commands.add(liftCommand);
 
@@ -1680,6 +1682,12 @@
                 liftAction.assignWork(wrkMast.getLiftNo(), assignCommand);
                 News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満鍦▄}灞傦紝鎻愬崌鏈轰笉鍦ㄥ皬杞﹀眰锛岃皟搴︾Щ鍔ㄤ腑", wrkMast.getWrkNo(), liftProtocol.getLev(), wrkMast.getLiftNo());
                 redisUtil.set(RedisKeyType.LIFT_MOVE_TO_SHUTTLE_LIMIT.key + wrkMast.getWrkNo(), "lift_moving", 60 * 3);
+                redisUtil.set(RedisKeyType.TASK_RUN_LIMIT.key + wrkMast.getWrkNo(), "lock", 8);
+                return false;
+            }
+
+            Object limitObj = redisUtil.get(RedisKeyType.TASK_RUN_LIMIT.key + wrkMast.getWrkNo());
+            if (limitObj != null) {
                 return false;
             }
 
@@ -1756,7 +1764,7 @@
             }
 
             //鑾峰彇鎻愬崌鏈哄懡浠�
-            LiftCommand liftCommand = liftThread.getShuttleSwitchCommand(wrkMast.getWrkNo(), sourceLiftSta.getLev(), liftSta.getLev());
+            LiftCommand liftCommand = liftThread.getShuttleSwitchCommand(wrkMast.getWrkNo(), sourceLiftSta.getSiteId(), liftSta.getSiteId());
             ArrayList<LiftCommand> commands = new ArrayList<>();
             commands.add(liftCommand);
 
@@ -1937,4 +1945,75 @@
         return true;
     }
 
+    //鑷姩鍒囨崲鍑哄叆搴撴ā寮�
+    public void autoSwitchLiftIOMode() {
+        List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+                .eq("device_type", String.valueOf(SlaveType.Lift)));
+        for (DeviceConfig device : liftList) {
+            Integer liftNo = device.getDeviceNo();
+            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo);
+            if (liftThread == null) {
+                continue;
+            }
+            LiftProtocol liftProtocol = liftThread.getStatus();
+            if (liftProtocol == null) {
+                continue;
+            }
+
+            List<Integer> liftAllStaNo = LiftUtils.getLiftAllStaNo(liftNo);
+            if (liftAllStaNo.isEmpty()) {
+                continue;
+            }
+
+            List<Integer> conveyorBindLiftAllStaNo = LiftUtils.getConveyorBindLiftAllStaNo(liftNo);
+            if (conveyorBindLiftAllStaNo.isEmpty()) {
+                continue;
+            }
+
+            //鑾峰彇鍏ュ簱浠诲姟
+            List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+                    .in("sta_no", liftAllStaNo)
+                    .in("wrk_sts"
+                            , WrkStsType.NEW_INBOUND.sts
+                            , WrkStsType.INBOUND_DEVICE_RUN.sts
+                            , WrkStsType.INBOUND_LIFT_RUN.sts
+                            , WrkStsType.INBOUND_LIFT_RUN_COMPLETE.sts
+                            , WrkStsType.INBOUND_SHUTTLE_RUN.sts
+                            , WrkStsType.INBOUND_SHUTTLE_RUN_COMPLETE.sts
+                    ));
+
+            //鑾峰彇鍑哄簱浠诲姟
+            List<WrkMast> outWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+                    .in("sta_no", conveyorBindLiftAllStaNo)
+                    .in("wrk_sts"
+                            , WrkStsType.NEW_OUTBOUND.sts
+                            , WrkStsType.OUTBOUND_SHUTTLE_RUN.sts
+                            , WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts
+                            , WrkStsType.OUTBOUND_LIFT_RUN.sts
+                            , WrkStsType.OUTBOUND_LIFT_RUN_COMPLETE.sts
+                    ));
+
+            if (liftProtocol.getIOModeType().equals(LiftIoModeType.NONE)) {
+                //鏈煡妯″紡
+                if (!inWrkMasts.isEmpty()) {
+                    liftThread.switchIOMode(LiftIoModeType.IN);
+                } else if (!outWrkMasts.isEmpty()) {
+                    liftThread.switchIOMode(LiftIoModeType.OUT);
+                }else {
+                    liftThread.switchIOMode(LiftIoModeType.IN);
+                }
+            } else if (liftProtocol.getIOModeType().equals(LiftIoModeType.IN)) {
+                //鍏ュ簱妯″紡
+                if (inWrkMasts.isEmpty() && !outWrkMasts.isEmpty()) {
+                    liftThread.switchIOMode(LiftIoModeType.OUT);
+                }
+            } else if (liftProtocol.getIOModeType().equals(LiftIoModeType.OUT)) {
+                //鍑哄簱妯″紡
+                if (outWrkMasts.isEmpty() && !inWrkMasts.isEmpty()) {
+                    liftThread.switchIOMode(LiftIoModeType.IN);
+                }
+            }
+        }
+    }
+
 }

--
Gitblit v1.9.1