From edacfca5a8e4e3abd4498eb81a34696b9ccd4c73 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 19 九月 2023 10:07:24 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |  105 ++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 85 insertions(+), 20 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 70fc05b..01078e7 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -2,6 +2,7 @@
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.core.common.Cools;
 import com.core.exception.CoolException;
 import com.zy.asrs.entity.*;
@@ -783,6 +784,45 @@
     public boolean shuttleOutExecuteStep1(WrkMast wrkMast) {
         //21.鐢熸垚鍑哄簱浠诲姟 => 22.灏忚溅鎼繍涓�
         if (wrkMast.getWrkSts() == 21) {
+            EntityWrapper<StaDesc> wrapper = new EntityWrapper<>();
+            wrapper.eq("type_no", wrkMast.getIoType());//璺緞绫诲瀷
+            wrapper.eq("stn_no", wrkMast.getStaNo());//鍑哄簱绔欑偣缂栧彿
+            StaDesc staDesc = staDescService.selectOne(wrapper);
+            if (staDesc == null) {
+                return false;//鍑哄簱璺緞涓嶅瓨鍦�
+            }
+
+            //鑾峰彇鍑哄簱绔欑偣
+            BasDevp basDevp = basDevpService.selectById(wrkMast.getStaNo());
+            if (basDevp == null) {
+                return false;//鍑哄簱绔欑偣涓嶅瓨鍦�
+            }
+
+            if (!basDevp.getOutEnable().equals("Y")) {
+                return false;//鍑哄簱绔欑偣涓嶅彲鍑�
+            }
+
+            //鍒ゆ柇鍚勬ゼ灞傚唴閮ㄨ緭閫佺珯鐐规槸鍚︾┖闂叉棤鐗�
+            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, basDevp.getLiftNo());
+            if (liftThread == null) {
+                return false;
+            }
+            //鑾峰彇鎻愬崌鏈虹珯鐐筶ist
+            List<LiftStaProtocol> liftStaProtocols = liftThread.getLiftStaProtocols();
+            if (liftStaProtocols.isEmpty()) {
+                return false;
+            }
+
+            for (LiftStaProtocol liftStaProtocol : liftStaProtocols) {
+                //鍒ゆ柇褰撳墠鍑哄簱浠诲姟瀵瑰簲妤煎眰鐨勬彁鍗囨満绔欑偣鐘舵��
+                if (liftStaProtocol.getLev() == Utils.getLev(wrkMast.getSourceLocNo())) {
+                    if (liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && !liftStaProtocol.getHasTray()) {
+                        return false;//绔欑偣蹇呴』鑷姩銆佺┖闂层�佹病鏈夋墭鐩�
+                    }
+                }
+            }
+
+
             if (wrkMast.getShuttleNo() == null) {//娌℃湁缁戝畾灏忚溅锛岃繘琛岃皟搴�
                 shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo());//璋冨害灏忚溅鍒拌揣鐗╂墍鍦ㄥ簱浣嶈繘琛屽彇璐�
                 return false;
@@ -805,12 +845,6 @@
                 return false;//灏忚溅宸茶鐙崰锛岀姝㈠啀娲惧彂浠诲姟
             }
 
-            //鑾峰彇鐩爣绔欏搴旂殑杈撻�佺珯鐐�
-            BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getSourceLocNo()), wrkMast.getLiftNo());
-            if (targetBasDevp == null) {
-                return false;//缂哄皯绔欑偣淇℃伅
-            }
-
             //鍒ゆ柇灏忚溅鏄惁鍒拌揪璐х墿搴撲綅
             if (!shuttleProtocol.getCurrentLocNo().equals(wrkMast.getSourceLocNo())) {
                 //灏忚溅涓嶅湪杈撻�佺珯鐐逛綅缃�
@@ -819,7 +853,7 @@
             }
 
             //灏忚溅宸叉姷杈捐揣鐗╀綅缃紝杩涜鎼繍璐х墿
-            NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getSourceLocNo(), targetBasDevp.getLocNo());
+            NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getSourceLocNo(), null);
             if (result == null) {//鍑哄簱璺緞璁$畻澶辫触
                 return false;
             }
@@ -937,6 +971,11 @@
                 continue;
             }
 
+            //鍒ゆ柇鎻愬崌鏈轰护鐗屾槸鍚﹁鍗犵敤
+            if (liftProtocol.getToken() != 0) {
+                continue;
+            }
+
             //鎼滅储鏄惁鏈夊緟澶勭悊鐨勪换鍔�
             List<WrkMast> wrkMasts = wrkMastMapper.selectLiftStep223103();
             if (wrkMasts.isEmpty()) {
@@ -998,15 +1037,25 @@
 
             //鑾峰彇婧愮珯瀵瑰簲鐨勮緭閫佺珯鐐�
             BasDevp sourceBasDevp = basDevpService.selectById(wrkMast.getSourceStaNo());
-            //鑾峰彇鐩爣绔欏搴旂殑杈撻�佺珯鐐�
-            BasDevp targetBasDevp = basDevpService.selectById(wrkMast.getStaNo());
-            if (sourceBasDevp == null || targetBasDevp == null) {
-                return false;//缂哄皯绔欑偣淇℃伅
+            if (sourceBasDevp == null) {
+                return false;//绔欑偣涓嶅瓨鍦�
+            }
+            //鑾峰彇婧愮珯瀵瑰簲鐨勭墰鐪兼彁鍗囨満绔欑偣缂栧彿(璧风偣缂栧彿)
+            Integer startSta = Integer.parseInt(sourceBasDevp.getQrCodeValue());
+            Integer targetSta = null;
+            //鑾峰彇鐗涚溂鎻愬崌鏈虹珯鐐圭紪鍙�(鐩爣缂栧彿)
+            for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) {
+                if (liftStaProtocol.getLev() == Utils.getLev(wrkMast.getLocNo())) {
+                    targetSta = liftStaProtocol.getStaNo();
+                }
+            }
+
+            if (targetSta == null) {
+                return false;//绔欑偣缂栧彿涓嶅瓨鍦�
             }
 
             //鑾峰彇鎻愬崌鏈哄懡浠�
-            NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, sourceBasDevp.getDevNo(), targetBasDevp.getDevNo(), wrkMast.getWrkNo());
-
+            NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, startSta, targetSta, wrkMast.getWrkNo());
             ArrayList<NyLiftCommand> commands = new ArrayList<>();
             commands.add(liftCommand);
 
@@ -1063,16 +1112,28 @@
                 return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇�
             }
 
-            //鑾峰彇婧愮珯瀵瑰簲鐨勮緭閫佺珯鐐�
-            BasDevp sourceBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getSourceLocNo()), liftProtocol.getLiftNo().intValue());
-            //鑾峰彇鐩爣绔欏搴旂殑杈撻�佺珯鐐�
-            BasDevp targetBasDevp = basDevpService.selectById(wrkMast.getSourceStaNo());
-            if (sourceBasDevp == null || targetBasDevp == null) {
-                return false;//缂哄皯绔欑偣淇℃伅
+            //鑾峰彇婧愮珯瀵瑰簲鐨勭墰鐪兼彁鍗囨満绔欑偣缂栧彿(璧风偣缂栧彿)
+            Integer startSta = null;
+            for (LiftStaProtocol liftStaProtocol : liftThread.getLiftStaProtocols()) {
+                if (liftStaProtocol.getLev() == Utils.getLev(wrkMast.getLocNo())) {
+                    startSta = liftStaProtocol.getStaNo();
+                }
             }
 
+            if (startSta == null) {
+                return false;//绔欑偣缂栧彿涓嶅瓨鍦�
+            }
+
+            //鑾风洰鏍囩珯婧愮珯瀵瑰簲鐨勮緭閫佺珯鐐�
+            BasDevp targetBasDevp = basDevpService.selectById(wrkMast.getStaNo());
+            if (targetBasDevp == null) {
+                return false;//绔欑偣涓嶅瓨鍦�
+            }
+            //鑾峰彇鐗涚溂鎻愬崌鏈虹珯鐐圭紪鍙�(鐩爣缂栧彿)
+            Integer targetSta = Integer.parseInt(targetBasDevp.getQrCodeValue());
+
             //鑾峰彇鎻愬崌鏈哄懡浠�
-            NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, sourceBasDevp.getDevNo(), targetBasDevp.getDevNo(), wrkMast.getWrkNo());
+            NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, startSta, targetSta, wrkMast.getWrkNo());
 
             ArrayList<NyLiftCommand> commands = new ArrayList<>();
             commands.add(liftCommand);
@@ -1996,6 +2057,10 @@
             }
 
             if (wrkCharge.getWrkSts() == 51) {
+                if (!shuttleProtocol.isIdleNoCharge()) {
+                    continue;
+                }
+
                 if (!shuttleProtocol.getCurrentLocNo().equals(wrkCharge.getLocNo())) {
                     //灏忚溅涓嶅湪鍏呯數妗╀綅缃�
                     shuttleDispatchUtils.dispatchShuttle(wrkCharge.getWrkNo(), wrkCharge.getLocNo(), shuttle.getId());//璋冨害灏忚溅鍘诲厖鐢垫々

--
Gitblit v1.9.1