From 2acd428a1254175dbf6f0cdb1bdb9772a4f4f938 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 19 六月 2023 17:33:18 +0800
Subject: [PATCH] 提升机状态6,8迁移小车问题

---
 src/main/java/com/zy/core/thread/LiftThread.java            |    3 -
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |   71 ++++++++++++++++++-----------------
 src/main/java/com/zy/core/thread/ShuttleThread.java         |   13 +++---
 3 files changed, 44 insertions(+), 43 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 45040ef..28d2612 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -695,7 +695,7 @@
                                     continue;//鎻愬崌鏈轰笉鍦ㄧ洰鏍囨ゼ灞傝烦杩�
                                 }
 
-                                Integer staNo = Utils.levToOutInStaNo(lev);
+                                Integer staNo = Utils.levToOutInStaNo(lev >= 2 ? lev + 1 : lev);
                                 //鑾峰彇鐩爣绔欎俊鎭�
                                 StaProtocol staProtocol1 = devpThread.getStation().get(staNo);
                                 if (staProtocol1 == null) {
@@ -743,9 +743,12 @@
                                 //鍚屼竴灞傜洿鎺ュ彇璐ф棤闇�缁忚繃鎻愬崌鏈�
                                 //鐩存帴璁$畻杞﹀埌鎻愬崌鏈哄彇璐у啀鍒板簱浣嶈矾寰勬寚浠�
                                 List<ShuttleCommand> commands = this.shuttleAssignCommand(wrkMast.getWrkSts() == 4 ? currentLocNo : liftSiteLocNo, liftSiteLocNo, locNo, assignCommand, shuttleThread);
+                                if (commands == null) {
+                                    continue;//鎵句笉鍒拌矾寰勭瓑寰呬笅涓�娆�
+                                }
                                 if (wrkMast.getWrkSts() == 8) {
                                     //姝ゆ椂杞﹀湪鎻愬崌鏈哄唴閮紝涓嬭揪涓�姝ユ寚浠よ杞︾Щ鍔ㄥ埌鎻愬崌鏈哄彛
-                                    Integer staNo = Utils.levToOutInStaNo(currentLev);//绔欑偣鍙�
+                                    Integer staNo = Utils.levToOutInStaNo(currentLev >= 2 ? currentLev + 1 : currentLev);//绔欑偣鍙�
                                     BasDevp basDevp = basDevpService.selectById(staNo);
 
                                     short startCode = liftProtocol.getBarcode();//鎻愬崌鏈哄唴閮ㄤ簩缁寸爜
@@ -1447,16 +1450,36 @@
                 command4.setOperaStaNo(distStaNo.shortValue());//鎿嶄綔鐩爣妤煎眰绔欑偣
                 command4.setRotationDire(1);//缁欒緭閫佺嚎涓嬪彂閾炬潯杞姩淇″彿锛屾杞�
                 command4.setDevpId(devpId);
+                command4.setStaNo(distStaNo.shortValue());//璁剧疆鐩爣绔�
                 commands.add(command4);//灏嗗懡浠ゆ坊鍔犺繘list
 
                 wrkMast.setWrkSts(3L);//3.鎻愬崌鏈烘惉杩愪腑
             } else if (wrkMast.getWrkSts() == 6) {//6.杩佺Щ灏忚溅鑷虫彁鍗囨満鍙e畬鎴� => 7.鎻愬崌鏈鸿縼绉诲皬杞︿腑
                 liftProtocol.setShuttleNo(wrkMast.getShuttleNo().shortValue());//璁剧疆鍥涘悜绌挎杞﹀彿
 
+                //鍒ゆ柇灏忚溅鏄惁鍦ㄦ彁鍗囨満鍐咃紝涓斿浜庣┖闂茬姸鎬�
+                ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
+                if (shuttleThread == null) {
+                    continue;
+                }
+                ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+                if (shuttleProtocol == null) {
+                    continue;
+                }
+                if (!shuttleProtocol.isIdle()) {
+                    continue;//灏忚溅鐘舵�佸繖
+                }
+                if (shuttleProtocol.getCurrentCode().intValue() != liftProtocol.getBarcode().intValue()) {
+                    continue;//灏忚溅褰撳墠浜岀淮鐮佸拰鎻愬崌鏈哄唴閮ㄤ簩缁寸爜涓嶄竴鑷达紝涓嶅厑璁告墽琛�
+                }
+
                 //宸ヤ綔妗g洰鏍囧簱浣嶅彿
                 String wrkMastLocNo = wrkMast.getIoType() == 101 ? wrkMast.getSourceLocNo() : wrkMast.getLocNo();
                 //宸ヤ綔妗g洰鏍囧簱浣嶆ゼ灞�
                 int wrkMastLocNoLey = Utils.getLev(wrkMastLocNo);
+                if (wrkMastLocNoLey >= 2) {
+                    wrkMastLocNoLey++;
+                }
 
                 //鎻愬崌鏈哄墠寰�鐩爣妤煎眰(宸ヤ綔妗g洰鏍囨ゼ灞�)
                 LiftCommand command1 = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), wrkMastLocNoLey);
@@ -1466,7 +1489,7 @@
             } else if(wrkMast.getWrkSts() == 23) {//23.杩佺Щ灏忚溅鑷虫彁鍗囨満鍙e畬鎴� => 24.鎻愬崌鏈鸿縼绉诲皬杞︿腑
                 liftProtocol.setShuttleNo(wrkMast.getShuttleNo().shortValue());//璁剧疆鍥涘悜绌挎杞﹀彿
 
-                //鎵惧埌鍥涘悜绌挎杞︾殑绾跨▼
+                //鍒ゆ柇灏忚溅鏄惁鍦ㄦ彁鍗囨満鍐咃紝涓斿浜庣┖闂茬姸鎬�
                 ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
                 if (shuttleThread == null) {
                     continue;
@@ -1476,44 +1499,24 @@
                     continue;
                 }
 
-                //褰撳墠绌挎杞﹀簱浣嶅彿
-                String currentLocNo = shuttleProtocol.getCurrentLocNo();
-                //褰撳墠绌挎杞︽ゼ灞�
-                int currentLocNoLey = Utils.getLev(currentLocNo);
+                if (!shuttleProtocol.isIdle()) {
+                    continue;//灏忚溅鐘舵�佸繖
+                }
+                if (shuttleProtocol.getCurrentCode().intValue() != liftProtocol.getBarcode().intValue()) {
+                    continue;//灏忚溅褰撳墠浜岀淮鐮佸拰鎻愬崌鏈哄唴閮ㄤ簩缁寸爜涓嶄竴鑷达紝涓嶅厑璁告墽琛�
+                }
 
                 //宸ヤ綔妗g洰鏍囧簱浣嶅彿
                 String wrkMastLocNo = wrkMast.getIoType() == 101 ? wrkMast.getSourceLocNo() : wrkMast.getLocNo();
                 //宸ヤ綔妗g洰鏍囧簱浣嶆ゼ灞�
                 int wrkMastLocNoLey = Utils.getLev(wrkMastLocNo);
-
-                //鎻愬崌鏈哄綋鍓嶆ゼ灞�
-                int liftLev = liftProtocol.getLev().intValue();
-                if (liftLev == 0) {//鎻愬崌鏈哄綋鍓嶆ゼ灞備负0锛屾彁鍗囨満澶卞幓浣嶇疆淇℃伅锛岃鎻愬崌鏈哄墠寰�涓�妤�
-                    LiftCommand command = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), LiftLevType.ONE.lev);
-                    commands.add(command);//灏嗗懡浠ゆ坊鍔犺繘list
+                if (wrkMastLocNoLey >= 2) {
+                    wrkMastLocNoLey++;
                 }
 
-                if (liftLev != currentLocNoLey) {
-                    //涓嶅悓妤煎眰
-                    //鑾峰彇鐩爣妤煎眰(绌挎杞︽墍鍦ㄦゼ灞�)鍛戒护
-                    LiftCommand command1 = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), currentLocNoLey);
-                    commands.add(command1);//灏嗗懡浠ゆ坊鍔犺繘list
-                }
-
-                //杈撻�佺嚎灏嗗洓鍚戠┛姊溅绉诲姩杩涙潵(鍙嶈浆)
-                LiftCommand command2 = liftThread.getLiftTurnCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), 4);
-                commands.add(command2);//灏嗗懡浠ゆ坊鍔犺繘list
-
-                if (liftLev != currentLocNoLey) {
-                    //鎻愬崌鏈哄墠寰�鐩爣妤煎眰(宸ヤ綔妗g洰鏍囨ゼ灞�)
-                    LiftCommand command3 = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), wrkMastLocNoLey);
-                    commands.add(command3);//灏嗗懡浠ゆ坊鍔犺繘list
-                }
-
-                //鎻愬崌鏈哄埌杈炬寚瀹氭ゼ灞傦紝杈撻�佺嚎灏嗗洓鍚戠┛姊溅绉诲嚭鍘�
-                //杈撻�佺嚎灏嗗洓鍚戠┛姊溅绉诲姩鍑哄幓(姝h浆)
-                LiftCommand command4 = liftThread.getLiftTurnCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), 1);
-                commands.add(command4);//灏嗗懡浠ゆ坊鍔犺繘list
+                //鎻愬崌鏈哄墠寰�鐩爣妤煎眰(宸ヤ綔妗g洰鏍囨ゼ灞�)
+                LiftCommand command1 = liftThread.getLiftUpDownCommand(liftProtocol.getLiftNo(), liftProtocol.getTaskNo(), wrkMastLocNoLey);
+                commands.add(command1);//灏嗗懡浠ゆ坊鍔犺繘list
 
                 wrkMast.setWrkSts(24L);//23.杩佺Щ灏忚溅鑷虫彁鍗囨満鍙e畬鎴� => 24.鎻愬崌鏈鸿縼绉诲皬杞︿腑
             } else if (wrkMast.getWrkSts() == 27) {//27.灏忚溅鍑哄簱鎼繍瀹屾垚
diff --git a/src/main/java/com/zy/core/thread/LiftThread.java b/src/main/java/com/zy/core/thread/LiftThread.java
index 194035a..c482b12 100644
--- a/src/main/java/com/zy/core/thread/LiftThread.java
+++ b/src/main/java/com/zy/core/thread/LiftThread.java
@@ -436,8 +436,7 @@
 
                 //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting
                 liftProtocol.setProtocolStatus(LiftProtocolStatusType.WAITING);
-                News.info("鎻愬崌鏈轰换鍔℃墽琛屽畬鎴愮瓑寰呯‘璁や腑锛屾彁鍗囨満鍙�={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command));
-
+                News.info("鎻愬崌鏈轰换鍔℃墽琛屼笅鍙戝畬鎴愮瓑寰呮墽琛岀粨鏉燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command));
             }
         }
 
diff --git a/src/main/java/com/zy/core/thread/ShuttleThread.java b/src/main/java/com/zy/core/thread/ShuttleThread.java
index 9aa000f..f8e571e 100644
--- a/src/main/java/com/zy/core/thread/ShuttleThread.java
+++ b/src/main/java/com/zy/core/thread/ShuttleThread.java
@@ -364,14 +364,13 @@
         //鎸囦护缁撴潫浣�
         array[16] = command.getCommandEnd();
 
-        try {
-            Thread.sleep(1000);//鍛戒护涓嬪彂鍓嶄紤鐪�1s
-        } catch (InterruptedException e) {
-            throw new RuntimeException(e);
-        }
-
         OperateResult result = modbusTcpNet.Write("0", array);;
         if (result != null && result.IsSuccess) {
+            try {
+                Thread.sleep(3000);//鍛戒护涓嬪彂鍚庝紤鐪�1s
+            } catch (InterruptedException e) {
+                throw new RuntimeException(e);
+            }
             News.info("鍥涘悜绌挎杞﹀懡浠や笅鍙慬id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
             OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
             return true;
@@ -856,7 +855,7 @@
                     }else {
                         shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.CHARGING_WAITING);
                     }
-                    News.info("鍥涘悜绌挎杞︿换鍔℃墽琛屽畬鎴愮瓑寰呯‘璁や腑锛岀┛姊溅鍙�={}锛屼换鍔℃暟鎹�={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command));
+                    News.info("鍥涘悜绌挎杞︿换鍔℃墽琛屼笅鍙戝畬鎴愮瓑寰呮墽琛岀粨鏉燂紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command));
                 }
 
             }

--
Gitblit v1.9.1