From f510760823f431891a501cd556928e215702ddb7 Mon Sep 17 00:00:00 2001
From: zhangc <zc@123>
Date: 星期六, 19 四月 2025 13:36:11 +0800
Subject: [PATCH] 999
---
src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java | 203 ++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 179 insertions(+), 24 deletions(-)
diff --git a/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java b/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java
index 3c7c31d..a87747e 100644
--- a/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java
+++ b/src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java
@@ -14,21 +14,15 @@
import com.zy.common.model.NavigateNode;
import com.zy.common.model.enums.NavigationMapType;
import com.zy.common.service.CommonService;
-import com.zy.common.utils.ForkLiftUtils;
-import com.zy.common.utils.LiftUtils;
import com.zy.common.utils.NavigateUtils;
import com.zy.core.News;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
import com.zy.core.enums.WrkIoType;
import com.zy.core.enums.WrkStsType;
-import com.zy.core.model.ForkLiftSlave;
-import com.zy.core.model.LiftSlave;
import com.zy.core.model.ShuttleSlave;
-import com.zy.core.model.protocol.*;
+import com.zy.core.model.protocol.ShuttleProtocol;
import com.zy.core.properties.SlaveProperties;
-import com.zy.core.thread.ForkLiftThread;
-import com.zy.core.thread.LiftThread;
import com.zy.core.thread.ShuttleThread;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
@@ -74,7 +68,7 @@
/**
* 璋冨害杞﹁締
*/
- public boolean dispatchShuttle(Integer wrkNo, String locNo) {
+ public boolean searchDispatchShuttle(Integer wrkNo, String sourceLocNo, String locNo, String flag) {
ArrayList<ShuttleThread> sameLev = new ArrayList<>();//鐩稿悓妤煎眰鐨勭┛姊溅
ArrayList<ShuttleThread> diffLev = new ArrayList<>();//涓嶅悓妤煎眰鐨勭┛姊溅
@@ -119,7 +113,7 @@
if (currentLev == Utils.getLev(locNo)) {
//宸ヤ綔妗fゼ灞傜浉鍚岀殑绌挎杞�
sameLev.add(shuttleThread);
- }else {
+ } else {
//宸ヤ綔妗d笉鍚屾ゼ灞傜殑绌挎杞�
diffLev.add(shuttleThread);
}
@@ -134,6 +128,11 @@
Integer shuttleNo = shuttleProtocol.getShuttleNo();
//褰撳墠绌挎杞﹀簱浣嶅彿
String currentLocNo = shuttleProtocol.getCurrentLocNo();
+ if (currentLocNo.equals(locNo)) {
+ sameShuttles.put(-1, shuttleThread);
+ continue;
+ }
+
//褰撳墠绌挎杞︾嚎绋嬪埌鐩爣鍦扮偣璺濈
List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘
if (currentShuttlePath == null) {
@@ -149,7 +148,7 @@
ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
Integer shuttleNo = shuttleProtocol.getShuttleNo();
//灏濊瘯璋冨害灏忚溅
- boolean result = shuttleMoveGenerate(wrkNo, locNo, shuttleNo);
+ boolean result = shuttleMoveGenerate(wrkNo, sourceLocNo, locNo, shuttleNo, flag, false);
if (result) {
return true;//璋冨害鎴愬姛
}
@@ -178,16 +177,20 @@
//褰撳墠绌挎杞﹀簱浣嶅彿
String currentLocNo = shuttleProtocol.getCurrentLocNo();
int currentLev = Utils.getLev(currentLocNo);
- List<WrkMast> wrkMasts1 = wrkMastService.selectNoShuttleWrkByLev(currentLev);//鍒ゆ柇褰撳墠绌挎杞︽ゼ灞傛槸鍚︽湁寰呭垎閰嶈溅杈嗙殑浠诲姟锛屽鏋滄湁鍒欎笉鍒嗛厤杩欒締杞�
- int shuttleCount = this.getShuttleCountByLev(currentLev);//鑾峰彇绌挎杞︽ゼ灞傝溅杈嗘暟閲�
- if (!wrkMasts1.isEmpty() && shuttleCount <= 1) {
- //瀛樺湪鍏朵粬浠诲姟涓斿彲鐢ㄥ皬杞︽暟閲忓皬浜庣瓑浜�1锛岃烦杩囪繖杈嗚溅
- continue;
- }
+// List<WrkMast> wrkMasts1 = wrkMastService.selectNoShuttleWrkByLev(currentLev);//鍒ゆ柇褰撳墠绌挎杞︽ゼ灞傛槸鍚︽湁寰呭垎閰嶈溅杈嗙殑浠诲姟锛屽鏋滄湁鍒欎笉鍒嗛厤杩欒締杞�
+// int shuttleCount = this.getShuttleCountByLev(currentLev);//鑾峰彇绌挎杞︽ゼ灞傝溅杈嗘暟閲�
+// if (!wrkMasts1.isEmpty() && shuttleCount <= 1) {
+// //瀛樺湪鍏朵粬浠诲姟涓斿彲鐢ㄥ皬杞︽暟閲忓皬浜庣瓑浜�1锛岃烦杩囪繖杈嗚溅
+// continue;
+// }
//ABS(鐩爣妤煎眰 - 褰撳墠妤煎眰) 寰楀埌宸窛锛屽彇鏈�灏忓樊鍊�
int currentValue = Math.abs(lev - currentLev);
- diffShuttles.put(currentValue, shuttleThread);
+ if (diffShuttles.get(currentValue) != null) {
+ diffShuttles.put(currentValue + 1, shuttleThread);
+ } else {
+ diffShuttles.put(currentValue, shuttleThread);
+ }
}
//灏濊瘯璋冨害璺ㄦゼ灞傚皬杞�
@@ -196,7 +199,153 @@
ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
Integer shuttleNo = shuttleProtocol.getShuttleNo();
//灏濊瘯璋冨害灏忚溅
- boolean result = shuttleMoveGenerate(wrkNo, locNo, shuttleNo);
+ boolean result = shuttleMoveGenerate(wrkNo, sourceLocNo, locNo, shuttleNo, flag, false);
+ if (result) {
+ return true;//璋冨害鎴愬姛
+ }
+ }
+ }
+ }
+
+ News.info("{}鐩爣搴撲綅娌℃湁鎼滅储鍒板彲鐢ㄧ┛姊溅", locNo);
+ return false;
+ }
+
+ /**
+ * 璋冨害杞﹁締
+ */
+ public boolean searchDispatchShuttleS(Integer wrkNo, String sourceLocNo, String locNo, String flag) {
+ ArrayList<ShuttleThread> sameLev = new ArrayList<>();//鐩稿悓妤煎眰鐨勭┛姊溅
+ ArrayList<ShuttleThread> diffLev = new ArrayList<>();//涓嶅悓妤煎眰鐨勭┛姊溅
+
+ for (ShuttleSlave shuttle : slaveProperties.getShuttle()) {
+ //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
+ ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId());
+ ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+ if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
+ continue;
+ }
+
+ if (checkChargeWrk(shuttle.getId())) {
+ continue;//瀛樺湪鍏呯數浠诲姟锛岃繃婊ゅ皬杞�
+ }
+
+ if (!shuttleThread.isIdle()) {
+ continue;//灏忚溅蹇欑涓�
+ }
+
+ BasShuttle basShuttle = basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttle.getId()));
+ if (basShuttle != null) {
+ if (basShuttle.getStatus() == 0) {
+ continue;//灏忚溅琚鐢�
+ }
+ }
+
+ int currentLev = Utils.getLev(shuttleProtocol.getCurrentLocNo());//灏忚溅褰撳墠灞傞珮
+ String currentLocNo = shuttleProtocol.getCurrentLocNo();//灏忚溅褰撳墠搴撲綅鍙�
+
+ if (currentLocNo.equals(locNo)) {
+ //杞﹁締褰撳墠浣嶇疆宸茬粡鏄洰鏍囧簱浣嶏紝璋冨害璇ヨ溅
+ //缁欏伐浣滄。缁戝畾灏忚溅鍙�
+ WrkMast wrkMast1 = wrkMastService.selectByWorkNo(wrkNo);
+ if (wrkMast1 != null) {
+ wrkMast1.setShuttleNo(shuttleProtocol.getShuttleNo());
+ wrkMastService.updateById(wrkMast1);
+ return true;
+ }
+ break;
+ }
+ if (currentLev == Utils.getLev(sourceLocNo)) {
+ //宸ヤ綔妗fゼ灞傜浉鍚岀殑绌挎杞�
+ sameLev.add(shuttleThread);
+ } else {
+ //宸ヤ綔妗d笉鍚屾ゼ灞傜殑绌挎杞�
+ diffLev.add(shuttleThread);
+ }
+
+
+ }
+
+ //浼樺厛璋冨害鍚屾ゼ灞傚皬杞︼紝瀵绘壘绂讳换鍔℃渶杩戠殑绌挎杞�
+ if (!sameLev.isEmpty()) {
+ Map<Integer, ShuttleThread> sameShuttles = new TreeMap<>();//鑷劧鎺掑簭灏忚溅Map
+ for (ShuttleThread shuttleThread : sameLev) {
+ ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+ Integer shuttleNo = shuttleProtocol.getShuttleNo();
+ //褰撳墠绌挎杞﹀簱浣嶅彿
+ String currentLocNo = shuttleProtocol.getCurrentLocNo();
+ if (currentLocNo.equals(sourceLocNo)) {
+ sameShuttles.put(-1, shuttleThread);
+ continue;
+ }
+
+ //褰撳墠绌挎杞︾嚎绋嬪埌鐩爣鍦扮偣璺濈
+ List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(currentLocNo)), null);//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘
+ if (currentShuttlePath == null) {
+ continue;
+ }
+ Integer currentAllDistance = navigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
+ sameShuttles.put(currentAllDistance, shuttleThread);
+ }
+
+ //灏濊瘯璋冨害鍚屾ゼ灞傚皬杞�
+ for (Map.Entry<Integer, ShuttleThread> entry : sameShuttles.entrySet()) {
+ ShuttleThread shuttleThread = entry.getValue();
+ ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+ Integer shuttleNo = shuttleProtocol.getShuttleNo();
+ //灏濊瘯璋冨害灏忚溅
+ boolean result = shuttleMoveGenerate(wrkNo, sourceLocNo, locNo, shuttleNo, flag, false);
+ if (result) {
+ return true;//璋冨害鎴愬姛
+ }
+ }
+ }
+
+ //鎵ц鍒版澶勶紝鍚屾ゼ灞傛棤璋冨害鎴愬姛灏忚溅銆傞渶瑕佽繘琛岃法妤煎眰璋冨害灏忚溅
+ //瀵绘壘绂讳换鍔℃ゼ灞傛渶杩戠殑绌挎杞�(涓嶈�冭檻璺ㄦゼ灞傚皬杞︾Щ鍔ㄨ窛绂�)
+ if (!diffLev.isEmpty()) {
+ Map<Integer, ShuttleThread> diffShuttles = new TreeMap<>();//鑷劧鎺掑簭灏忚溅Map
+ //鑾峰彇浠诲姟
+ WrkMast wrkMast1 = wrkMastService.selectByWorkNo(wrkNo);
+ if (wrkMast1 != null) {
+ String targetLoc = wrkMast1.getIoType() < 100 ? wrkMast1.getLocNo() : wrkMast1.getSourceLocNo();
+ int lev = Utils.getLev(targetLoc);//鐩爣妤煎眰
+
+ //妫�娴嬬洰鏍囨ゼ灞傝溅鏁伴噺鏄惁灏忎簬鍏佽鐨勬渶澶ф暟閲�
+ boolean checkDispatchMaxNum = checkDispatchMaxNum(lev);
+ if (!checkDispatchMaxNum) {
+ News.info("{}浠诲姟锛寋}灞傦紝宸茬粡杈惧埌褰撳墠妤煎眰璋冨害杞﹁締鏈�澶у��", wrkMast1.getWrkNo(), lev);
+ return false;
+ }
+
+ for (ShuttleThread shuttleThread : diffLev) {
+ ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+ //褰撳墠绌挎杞﹀簱浣嶅彿
+ String currentLocNo = shuttleProtocol.getCurrentLocNo();
+ int currentLev = Utils.getLev(currentLocNo);
+// List<WrkMast> wrkMasts1 = wrkMastService.selectNoShuttleWrkByLev(currentLev);//鍒ゆ柇褰撳墠绌挎杞︽ゼ灞傛槸鍚︽湁寰呭垎閰嶈溅杈嗙殑浠诲姟锛屽鏋滄湁鍒欎笉鍒嗛厤杩欒締杞�
+// int shuttleCount = this.getShuttleCountByLev(currentLev);//鑾峰彇绌挎杞︽ゼ灞傝溅杈嗘暟閲�
+// if (!wrkMasts1.isEmpty() && shuttleCount <= 1) {
+// //瀛樺湪鍏朵粬浠诲姟涓斿彲鐢ㄥ皬杞︽暟閲忓皬浜庣瓑浜�1锛岃烦杩囪繖杈嗚溅
+// continue;
+// }
+
+ //ABS(鐩爣妤煎眰 - 褰撳墠妤煎眰) 寰楀埌宸窛锛屽彇鏈�灏忓樊鍊�
+ int currentValue = Math.abs(lev - currentLev);
+ if (diffShuttles.get(currentValue) != null) {
+ diffShuttles.put(currentValue + 1, shuttleThread);
+ } else {
+ diffShuttles.put(currentValue, shuttleThread);
+ }
+ }
+
+ //灏濊瘯璋冨害璺ㄦゼ灞傚皬杞�
+ for (Map.Entry<Integer, ShuttleThread> entry : diffShuttles.entrySet()) {
+ ShuttleThread shuttleThread = entry.getValue();
+ ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+ Integer shuttleNo = shuttleProtocol.getShuttleNo();
+ //灏濊瘯璋冨害灏忚溅
+ boolean result = shuttleMoveGenerate(wrkNo, sourceLocNo, locNo, shuttleNo, flag, false);
if (result) {
return true;//璋冨害鎴愬姛
}
@@ -246,18 +395,20 @@
News.info("{}鍙峰皬杞︼紝瀛樺湪绉诲姩浠诲姟锛岀瓑寰呮墽琛屽畬鎴愬悗鍐嶇敓鎴愭柊鐨勪换鍔�", shuttleNo);
return false;
}
-
+ WrkMast mainWrkMast = null;
//鑾峰彇涓诲伐浣滄。淇℃伅
- WrkMast mainWrkMast = wrkMastService.selectByWorkNo(wrkNo);
+ if (wrkNo != null) {
+ mainWrkMast = wrkMastService.selectByWorkNo(wrkNo);
+ }
//鍒ゆ柇鏄惁鏈夊叾浠栦换鍔℃鍦ㄤ娇鐢ㄧ┛姊溅
- WrkMast wrkMast2 = wrkMastService.selectShuttleWorking(shuttleNo);
+ WrkMast wrkMast2 = wrkMastService.selectShuttleWorking2(shuttleNo, wrkNo, mainWrkMast != null ? mainWrkMast.getMainWrkNo() : null);
if (wrkMast2 != null && !disableCheck) {//灏忚溅瀛樺湪鍏朵粬宸ヤ綔妗d换鍔★紝绛夊緟鎵ц瀹屾垚鍚庡啀鐢熸垚鏂扮殑浠诲姟
if (mainWrkMast == null) {
News.info("{}鍙峰皬杞︼紝瀛樺湪鍏朵粬宸ヤ綔妗d换鍔★紝绛夊緟鎵ц瀹屾垚鍐嶇敓鎴愭柊鐨勪换鍔�", shuttleNo);
return false;
} else {
- if (!mainWrkMast.getShuttleNo().equals(shuttleNo)) {
+ if (mainWrkMast.getShuttleNo() != null && !mainWrkMast.getShuttleNo().equals(shuttleNo)) {
News.info("{}鍙峰皬杞︼紝瀛樺湪鍏朵粬宸ヤ綔妗d换鍔★紝绛夊緟鎵ц瀹屾垚鍐嶇敓鎴愭柊鐨勪换鍔�", shuttleNo);
return false;
}
@@ -284,6 +435,11 @@
wrkMast.setLocNo(locNo); // 鐩爣搴撲綅
wrkMast.setAppeTime(now);
wrkMast.setModiTime(now);
+
+ if ("TRANSPORT_LIFT".equalsIgnoreCase(flag) || "TRANSPORT_DEVP".equalsIgnoreCase(flag)) {
+ wrkMast.setMainWrkNo(wrkNo);
+ }
+
boolean res = wrkMastService.insert(wrkMast);
if (!res) {
News.error("灏忚溅杩佺Щ --- 淇濆瓨宸ヤ綔妗eけ璐ワ紒 绌挎杞﹀彿锛�" + shuttleNo);
@@ -314,7 +470,7 @@
List<ShuttleGatherResult> list = new ArrayList<>();
for (BasShuttle basShuttle : basShuttles) {
String idleLoc = basShuttle.getIdleLoc();
- if(Cools.isEmpty(idleLoc)) {
+ if (Cools.isEmpty(idleLoc)) {
continue;
}
@@ -395,7 +551,6 @@
return levCount < Integer.parseInt(config.getValue());
}
-
/**
--
Gitblit v1.9.1