From f63aa158cd182f1ab40fc475ca2944eacfc8705a Mon Sep 17 00:00:00 2001 From: 野心家 <1051256694@qq.com> Date: 星期二, 03 十月 2023 08:47:56 +0800 Subject: [PATCH] # --- src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java | 119 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 90 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java b/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java index 8ed3392..138a943 100644 --- a/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java +++ b/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java @@ -14,10 +14,12 @@ import com.zy.common.service.CommonService; import com.zy.core.News; import com.zy.core.cache.SlaveConnection; +import com.zy.core.enums.ShuttleChargeType; import com.zy.core.enums.SlaveType; import com.zy.core.model.LiftSlave; import com.zy.core.model.ShuttleSlave; import com.zy.core.model.protocol.LiftProtocol; +import com.zy.core.model.protocol.LiftStaProtocol; import com.zy.core.model.protocol.NyShuttleProtocol; import com.zy.core.properties.SlaveProperties; import com.zy.core.thread.LiftThread; @@ -80,7 +82,13 @@ if (currentLocNo.equals(locNo)) { //杞﹁締褰撳墠浣嶇疆宸茬粡鏄洰鏍囧簱浣嶏紝璋冨害璇ヨ溅 - shuttleMoveGenerate(wrkNo, locNo, shuttleProtocol.getShuttleNo().intValue()); + //缁欏伐浣滄。缁戝畾灏忚溅鍙� + WrkMast wrkMast1 = wrkMastMapper.selectByWorkNo(wrkNo); + if (wrkMast1 != null) { + wrkMast1.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); + wrkMastMapper.updateById(wrkMast1); + return true; + } break; } @@ -111,32 +119,36 @@ if (currentAllDistance < recentAllDistance) { //濡傛灉褰撳墠妤煎眰鐨勮溅璺緞鏇村皬锛屽垯鏇存柊鏈�杩戠┛姊溅 recentShuttle = shuttleThread; + recentAllDistance = currentAllDistance; } } }else { //鍚屼竴妤煎眰锛屾病鏈夌┖闂茬┛姊溅锛屽彧鑳戒粠鍏朵粬妤煎眰璋冨害 - //瀵绘壘绂讳换鍔℃渶杩戠殑绌挎杞� - for (NyShuttleThread shuttleThread : diffLev) { + //瀵绘壘绂讳换鍔℃ゼ灞傛渶杩戠殑绌挎杞�(涓嶈�冭檻璺ㄦゼ灞傚皬杞︾Щ鍔ㄨ窛绂�) - //褰撳墠绌挎杞﹀簱浣嶅彿 - String currentLocNo = shuttleThread.getShuttleProtocol().getCurrentLocNo(); - int currentLev = Utils.getLev(currentLocNo); - List<WrkMast> wrkMasts1 = wrkMastService.selectNoShuttleWrkByLev(currentLev);//鍒ゆ柇褰撳墠绌挎杞︽ゼ灞傛槸鍚︽湁寰呭垎閰嶈溅杈嗙殑浠诲姟锛屽鏋滄湁鍒欎笉鍒嗛厤杩欒締杞� - if (wrkMasts1.size() > 0) { - //瀛樺湪鍏朵粬浠诲姟锛岃烦杩囪繖杈嗚溅 - continue; - } + //鑾峰彇浠诲姟 + WrkMast wrkMast1 = wrkMastMapper.selectByWorkNo(wrkNo); - //褰撳墠绌挎杞︾嚎绋嬪埌褰撳墠杞﹀瓙鎵�鍦ㄦゼ灞傜殑鎻愬崌鏈哄彛璺濈 - List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, Utils.levToOutInStaLocNo(currentLev), NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleThread.getSlave().getId(), currentLev));//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘 - if (currentShuttlePath == null) { - continue; - } + if (wrkMast1 != null) { + int lev = Utils.getLev(wrkMast1.getLocNo());//鐩爣妤煎眰 + int recentValue = 99999;//鏈�灏忓樊鍊� + for (NyShuttleThread shuttleThread : diffLev) { + //褰撳墠绌挎杞﹀簱浣嶅彿 + String currentLocNo = shuttleThread.getShuttleProtocol().getCurrentLocNo(); + int currentLev = Utils.getLev(currentLocNo); + List<WrkMast> wrkMasts1 = wrkMastService.selectNoShuttleWrkByLev(currentLev);//鍒ゆ柇褰撳墠绌挎杞︽ゼ灞傛槸鍚︽湁寰呭垎閰嶈溅杈嗙殑浠诲姟锛屽鏋滄湁鍒欎笉鍒嗛厤杩欒締杞� + if (wrkMasts1.size() > 0) { + //瀛樺湪鍏朵粬浠诲姟锛岃烦杩囪繖杈嗚溅 + continue; + } - Integer currentAllDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂� - if (currentAllDistance < recentAllDistance) { - //濡傛灉褰撳墠妤煎眰鐨勮溅璺緞鏇村皬锛屽垯鏇存柊鏈�杩戠┛姊溅 - recentShuttle = shuttleThread; + //ABS(鐩爣妤煎眰 - 褰撳墠妤煎眰) 寰楀埌宸窛锛屽彇鏈�灏忓樊鍊� + int currentValue = Math.abs(lev - currentLev); + if (currentValue < recentValue) { + //濡傛灉褰撳墠妤煎眰鐨勮溅璺緞鏇村皬锛屽垯鏇存柊鏈�杩戠┛姊溅 + recentShuttle = shuttleThread; + recentValue = currentValue; + } } } } @@ -185,18 +197,37 @@ //鍒ゆ柇鏄惁鏈夊厖鐢典换鍔℃鍦ㄤ娇鐢ㄧ┛姊溅 WrkCharge wrkCharge = wrkChargeMapper.selectWorking(shuttleNo); if (wrkCharge != null) {//灏忚溅瀛樺湪鍏呯數浠诲姟锛岀瓑寰呮墽琛屽畬鎴愬悗鍐嶇敓鎴愭柊鐨勪换鍔� - return false; + //鍒ゆ柇鐩爣鐐规槸鍚︿负鍏呯數妗╋紝濡傛灉鏄幓鍏呯數鍒欐斁琛� + boolean toCharge = false;//鍘诲厖鐢电洰鏍� + for (ShuttleChargeType chargeType : ShuttleChargeType.values()) { + if (chargeType.locNo.equals(locNo)) { + toCharge = true;//鍘诲厖鐢垫々 + break; + } + } + + if (wrkCharge.getWrkSts() == 53) { + toCharge = true;//鍏呯數缁撴潫锛屽厑璁哥敓鎴愮Щ搴撲换鍔� + } + + if (!toCharge) { + //涓嶆槸鍘诲厖鐢垫々涓斿瓨鍦ㄥ厖鐢典换鍔★紝绂佹鐢熸垚鏂扮殑绉诲姩浠诲姟 + return false; + } } - Integer staNo = null; + Integer sourceStaNo = null;//灏忚溅鎹㈠眰婧愮珯鐐� + Integer staNo = null;//灏忚溅鎹㈠眰鐩爣绔欑偣 if (Utils.getLev(locNo) != shuttleProtocol.getPoint().getZ()) { //鐩爣搴撲綅鍜屽皬杞﹀簱浣嶅浜庝笉鍚屼竴妤煎眰锛岄渶瑕侀�氳繃鎻愬崌鏈鸿皟搴� //鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満杈撻�佺珯鐐� - BasDevp liftSta = this.getRecentLiftSta(shuttleNo); + LiftStaProtocol liftSta = this.getRecentLiftSta(shuttleNo); if (liftSta == null) { return false;//娌℃湁鍙敤涓旂┖闂茬殑杈撻�佺珯鐐� } - staNo = liftSta.getDevNo(); + sourceStaNo = liftSta.getStaNo();//婧愮珯鐐� + //鎻愬崌鏈哄彿*100+鐩爣妤煎眰=鐩爣绔欑偣 + staNo = liftSta.getLiftNo() * 100 + Utils.getLev(locNo);//鐩爣绔� } // 鑾峰彇宸ヤ綔鍙� @@ -211,6 +242,7 @@ wrkMast.setShuttleNo(shuttleNo);//绌挎杞﹀彿 wrkMast.setSourceLocNo(shuttleProtocol.getCurrentLocNo()); // 婧愬簱浣� => 灏忚溅褰撳墠搴撲綅鍙� wrkMast.setLocNo(locNo); // 鐩爣搴撲綅 + wrkMast.setSourceStaNo(sourceStaNo);//婧愮珯 wrkMast.setStaNo(staNo);//鐩爣绔� wrkMast.setPicking("N"); // 鎷f枡 wrkMast.setExitMk("N"); // 閫�鍑� @@ -236,7 +268,7 @@ /** * 鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満杈撻�佺珯鐐� */ - public BasDevp getRecentLiftSta(Integer shuttleNo) { + public LiftStaProtocol getRecentLiftSta(Integer shuttleNo) { //鑾峰彇鍥涘悜绌挎杞︾嚎绋� NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo); if (shuttleThread == null) { @@ -247,6 +279,9 @@ return null; } + //鑾峰彇灏忚溅鍚屼竴妤煎眰鐨勭珯鐐� + ArrayList<LiftStaProtocol> list = new ArrayList<>(); + int lev = Utils.getLev(shuttleProtocol.getCurrentLocNo());//灏忚溅妤煎眰 for (LiftSlave slave : slaveProperties.getLift()) { LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, slave.getId()); if (liftThread == null) { @@ -260,14 +295,40 @@ continue; } - BasDevp basDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(shuttleProtocol.getCurrentLocNo()), slave.getId()); - if (basDevp == null) { + LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(slave.getId(), lev); + if (liftStaProtocol == null) { continue; } - return basDevp; + + list.add(liftStaProtocol); } - return null; + if (list.isEmpty()) { + return null; + } + + String currentLocNo = shuttleProtocol.getCurrentLocNo();//灏忚溅浣嶇疆 + Integer recentAllDistance = 9999999; + LiftStaProtocol recentSta = null;//鏈�杩戠珯鐐� + //鎼滅储璺濈灏忚溅鏈�杩戠殑绔欑偣 + for (LiftStaProtocol liftStaProtocol : list) { + Integer staNo = liftStaProtocol.getStaNo();//绔欑偣鍙� + String locNo = liftStaProtocol.getLocNo();//绔欑偣搴撲綅鍙� + + //褰撳墠绌挎杞︾嚎绋嬪埌鐩爣鍦扮偣璺濈 + List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)));//浣跨敤姝e父閫氶亾鍦板浘 + if (currentShuttlePath == null) { + continue; + } + Integer currentAllDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂� + if (currentAllDistance < recentAllDistance) { + //濡傛灉褰撳墠妤煎眰鐨勮溅璺緞鏇村皬锛屽垯鏇存柊鏈�杩戠珯鐐� + recentSta = liftStaProtocol; + recentAllDistance = currentAllDistance; + } + } + + return recentSta; } } -- Gitblit v1.9.1