From 3b64c807f60e5d6b71deca3f79c9be4be19abfaa Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期五, 23 二月 2024 10:47:58 +0800 Subject: [PATCH] #显示器更新 --- src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java | 72 +++++++++++++++++++++--------------- 1 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java b/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java index 6006693..d4f60b1 100644 --- a/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java +++ b/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java @@ -33,9 +33,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; /** * 鍥涘悜绌挎杞﹁皟搴﹀伐鍏� @@ -130,11 +128,9 @@ } - Integer recentAllDistance = 9999999; - NyShuttleThread recentShuttle = null;//褰撳墠璺濈鏈�杩戠殑鍥涘悜绌挎杞︾嚎绋� - if (sameLev.size() > 0) { - //鍚屼竴妤煎眰鏈夌┖闂茬┛姊溅锛屽垯鍙湪宸ヤ綔妗fゼ灞傚鎵� - //瀵绘壘绂讳换鍔℃渶杩戠殑绌挎杞� + //浼樺厛璋冨害鍚屾ゼ灞傚皬杞︼紝瀵绘壘绂讳换鍔℃渶杩戠殑绌挎杞� + if (!sameLev.isEmpty()) { + Map<Integer, NyShuttleThread> sameShuttles = new TreeMap<>();//鑷劧鎺掑簭灏忚溅Map for (NyShuttleThread shuttleThread : sameLev) { //褰撳墠绌挎杞﹀簱浣嶅彿 String currentLocNo = shuttleThread.getShuttleProtocol().getCurrentLocNo(); @@ -144,19 +140,26 @@ continue; } Integer currentAllDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂� - if (currentAllDistance < recentAllDistance) { - //濡傛灉褰撳墠妤煎眰鐨勮溅璺緞鏇村皬锛屽垯鏇存柊鏈�杩戠┛姊溅 - recentShuttle = shuttleThread; - recentAllDistance = currentAllDistance; + sameShuttles.put(currentAllDistance, shuttleThread); + } + + //灏濊瘯璋冨害鍚屾ゼ灞傚皬杞� + for (Map.Entry<Integer, NyShuttleThread> entry : sameShuttles.entrySet()) { + NyShuttleThread shuttleThread = entry.getValue(); + //灏濊瘯璋冨害灏忚溅 + boolean result = shuttleMoveGenerate(wrkNo, locNo, shuttleThread.getSlave().getId()); + if (result) { + return true;//璋冨害鎴愬姛 } } - }else { - //鍚屼竴妤煎眰锛屾病鏈夌┖闂茬┛姊溅锛屽彧鑳戒粠鍏朵粬妤煎眰璋冨害 - //瀵绘壘绂讳换鍔℃ゼ灞傛渶杩戠殑绌挎杞�(涓嶈�冭檻璺ㄦゼ灞傚皬杞︾Щ鍔ㄨ窛绂�) + } + //鎵ц鍒版澶勶紝鍚屾ゼ灞傛棤璋冨害鎴愬姛灏忚溅銆傞渶瑕佽繘琛岃法妤煎眰璋冨害灏忚溅 + //瀵绘壘绂讳换鍔℃ゼ灞傛渶杩戠殑绌挎杞�(涓嶈�冭檻璺ㄦゼ灞傚皬杞︾Щ鍔ㄨ窛绂�) + if (!diffLev.isEmpty()) { + Map<Integer, NyShuttleThread> diffShuttles = new TreeMap<>();//鑷劧鎺掑簭灏忚溅Map //鑾峰彇浠诲姟 WrkMast wrkMast1 = wrkMastMapper.selectByWorkNo(wrkNo); - if (wrkMast1 != null) { String targetLoc = wrkMast1.getIoType() < 100 ? wrkMast1.getLocNo() : wrkMast1.getSourceLocNo(); int lev = Utils.getLev(targetLoc);//鐩爣妤煎眰 @@ -168,35 +171,36 @@ return false; } - 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) { - //瀛樺湪鍏朵粬浠诲姟锛岃烦杩囪繖杈嗚溅 + int shuttleCount = this.getShuttleCountByLev(currentLev);//鑾峰彇绌挎杞︽ゼ灞傝溅杈嗘暟閲� + if (!wrkMasts1.isEmpty() && shuttleCount <= 1) { + //瀛樺湪鍏朵粬浠诲姟涓斿彲鐢ㄥ皬杞︽暟閲忓皬浜庣瓑浜�1锛岃烦杩囪繖杈嗚溅 continue; } //ABS(鐩爣妤煎眰 - 褰撳墠妤煎眰) 寰楀埌宸窛锛屽彇鏈�灏忓樊鍊� int currentValue = Math.abs(lev - currentLev); - if (currentValue < recentValue) { - //濡傛灉褰撳墠妤煎眰鐨勮溅璺緞鏇村皬锛屽垯鏇存柊鏈�杩戠┛姊溅 - recentShuttle = shuttleThread; - recentValue = currentValue; + diffShuttles.put(currentValue, shuttleThread); + } + + //灏濊瘯璋冨害璺ㄦゼ灞傚皬杞� + for (Map.Entry<Integer, NyShuttleThread> entry : diffShuttles.entrySet()) { + NyShuttleThread shuttleThread = entry.getValue(); + //灏濊瘯璋冨害灏忚溅 + boolean result = shuttleMoveGenerate(wrkNo, locNo, shuttleThread.getSlave().getId()); + if (result) { + return true;//璋冨害鎴愬姛 } } } } - if (recentShuttle == null) {//娌℃湁鎼滅储鍒板彲鐢ㄧ┛姊溅 - News.info("{}鐩爣搴撲綅娌℃湁鎼滅储鍒板彲鐢ㄧ┛姊溅", locNo); - return false; - } - - //鎼滅储鍒板彲鐢ㄧ┛姊溅锛岃皟搴﹁杞� - return shuttleMoveGenerate(wrkNo, locNo, recentShuttle.getSlave().getId()); + News.info("{}鐩爣搴撲綅娌℃湁鎼滅储鍒板彲鐢ㄧ┛姊溅", locNo); + return false; } /** @@ -322,6 +326,14 @@ } if (point.getZ().equals(lev)) { + if (shuttleProtocol.getChargState() == 1) { + continue;//鍏呯數涓� + } + + if (shuttleProtocol.getSuspendState() == 1) { + continue;//绠″埗涓� + } + levCount++;//鐩爣妤煎眰鏈夎溅锛屾暟閲忓鍔� } } -- Gitblit v1.9.1