From e8280967b8c3aa885e442f6add0d5a8b89eeabf0 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期三, 02 八月 2023 09:25:30 +0800
Subject: [PATCH] 库位移转
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 195 +++++++++++++-----------------------------------
1 files changed, 52 insertions(+), 143 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 398e5e0..7ebe117 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -710,11 +710,11 @@
}
//鑾峰彇鍥涘悜绌挎杞︾嚎绋�
- ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
+ NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
if (shuttleThread == null) {
return false;
}
- ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+ NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
if (shuttleProtocol == null) {
return false;
}
@@ -782,11 +782,11 @@
}
//鑾峰彇鍥涘悜绌挎杞︾嚎绋�
- ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
+ NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
if (shuttleThread == null) {
return false;
}
- ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+ NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
if (shuttleProtocol == null) {
return false;
}
@@ -831,132 +831,6 @@
return false;
}
return true;
- }
-
- /**
- * 鎼滅储绌洪棽涓旀渶杩戠殑鍥涘悜绌挎杞�(浠ュ伐浣滄。鐩爣搴撲綅涓哄熀鐐硅绠楁渶杩戜笖绌洪棽鐨勮溅)
- */
- public HashMap<String,Object> searchIdleShuttle(WrkMast wrkMast) {
- HashMap<String, Object> map = new HashMap<>();
- String locNo = wrkMast.getIoType() < 101 ? wrkMast.getLocNo() : wrkMast.getSourceLocNo();//搴撲綅鍙�
- LocMast locMast = locMastService.queryByLoc(locNo);//鎵惧埌搴撲綅璁板綍
- int lev = Utils.getLev(locNo);//褰撳墠宸ヤ綔妗e簱浣嶅眰楂�
- ShuttleThread recentShuttle = null;//褰撳墠璺濈鏈�杩戠殑鍥涘悜绌挎杞︾嚎绋�
-
- ArrayList<ShuttleThread> sameLev = new ArrayList<>();//鐩稿悓妤煎眰鐨勭┛姊溅
- ArrayList<ShuttleThread> diffLev = new ArrayList<>();//涓嶅悓妤煎眰鐨勭┛姊溅
-
- //鍒ゆ柇鍏朵粬绌洪棽绌挎杞︽槸鍚︾浠诲姟鏈�杩�
- String distLocNo = null;//鐩爣鍦扮偣锛屽叆搴�=銆嬫彁鍗囨満鍙o紝鍑哄簱=銆嬭揣鐗╁簱浣嶅彿
- if (wrkMast.getIoType() < 101 && wrkMast.getIoType() != 11) {
- //鍏ュ簱
- distLocNo = Utils.levToOutInStaLocNo(lev);
- }else if(wrkMast.getIoType() >= 101){
- //鍑哄簱
- distLocNo = locNo;
- } else if (wrkMast.getIoType() == 11) {
- //搴撲綅绉昏浆
- distLocNo = wrkMast.getSourceLocNo();
- }
-
- //鍒ゆ柇褰撳墠浠诲姟鎵�鍦ㄦゼ灞傛槸鍚︽湁鍏朵粬浠诲姟宸茬粡鍒嗛厤浜嗗皬杞︼紝濡傛湁鍒欑洿鎺ョ敤璇ュ皬杞�(涓�灞傛ゼ浠呭垎閰嶄竴鍙拌溅)
- List<WrkMast> wrkMasts = wrkMastService.selectShuttleWrkByLev(lev);//鍒ゆ柇褰撳墠绌挎杞︽ゼ灞傛槸鍚﹀凡鏈夊垎閰嶈溅杈嗙殑浠诲姟锛屽鏋滄湁鍒欏垎閰嶈繖杈嗚溅
- if (wrkMasts.size() > 0) {
- //瀛樺湪鍏朵粬浠诲姟锛屽垎閰嶈繖杈嗚溅
- WrkMast wrkMast1 = wrkMasts.get(0);
- ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast1.getShuttleNo());
-
- map.put("sameLay", true);//鍚屽眰
- map.put("result", shuttleThread);
- return map;
- }
-
- for (ShuttleSlave shuttle : slaveProperties.getShuttle()) {
- //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
- ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId());
- ShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
- if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
- continue;
- }
- if (!shuttleProtocol.isIdle()) {
- continue;
- }
-
- String shuttleLocNo = shuttleProtocol.getCurrentLocNo();//浜岀淮鐮佸搴斿簱浣嶅彿
- if (shuttleLocNo == null) {
- continue;
- }
-
- if (shuttleLocNo.equals(distLocNo)) {
- //杞﹁締褰撳墠浣嶇疆宸茬粡鏄洰鏍囧簱浣嶏紝鏃犻渶璁$畻
- map.put("sameLay", true);//鍚屽眰
- map.put("result", shuttleThread);
- return map;
- }
-
- int shuttleLocNoLey = Utils.getLev(shuttleLocNo);//搴撲綅鍙峰搴斿眰楂�
- if (lev == shuttleLocNoLey) {
- //宸ヤ綔妗fゼ灞傜浉鍚岀殑绌挎杞�
- sameLev.add(shuttleThread);
- }else {
- //宸ヤ綔妗d笉鍚屾ゼ灞傜殑绌挎杞�
- diffLev.add(shuttleThread);
- }
-
- }
-
- Integer recentAllDistance = 9999999;
- if (sameLev.size() > 0) {
- //鍚屼竴妤煎眰鏈夌┖闂茬┛姊溅锛屽垯鍙湪宸ヤ綔妗fゼ灞傚鎵�
- //瀵绘壘绂讳换鍔℃渶杩戠殑绌挎杞�
- for (ShuttleThread shuttleThread : sameLev) {
- //褰撳墠绌挎杞﹀簱浣嶅彿
- String currentLocNo = shuttleThread.getShuttleProtocol().getCurrentLocNo();
- //褰撳墠绌挎杞︾嚎绋嬪埌鐩爣鍦扮偣璺濈
- List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, distLocNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleThread.getSlave().getId(), Utils.getLev(currentLocNo)));//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘
- if (currentShuttlePath == null) {
- continue;
- }
- Integer currentAllDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
- if (currentAllDistance < recentAllDistance) {
- //濡傛灉褰撳墠妤煎眰鐨勮溅璺緞鏇村皬锛屽垯鏇存柊鏈�杩戠┛姊溅
- recentShuttle = shuttleThread;
- }
- }
-
- map.put("sameLay", true);//鍚屽眰
- map.put("result", recentShuttle);
- }else {
- //鍚屼竴妤煎眰锛屾病鏈夌┖闂茬┛姊溅锛屽彧鑳戒粠鍏朵粬妤煎眰璋冨害
- //瀵绘壘绂讳换鍔℃渶杩戠殑绌挎杞�
- for (ShuttleThread shuttleThread : diffLev) {
-
- //褰撳墠绌挎杞﹀簱浣嶅彿
- String currentLocNo = shuttleThread.getShuttleProtocol().getCurrentLocNo();
- int currentLev = Utils.getLev(currentLocNo);
- List<WrkMast> wrkMasts1 = wrkMastService.selectNoShuttleWrkByLev(currentLev);//鍒ゆ柇褰撳墠绌挎杞︽ゼ灞傛槸鍚︽湁寰呭垎閰嶈溅杈嗙殑浠诲姟锛屽鏋滄湁鍒欎笉鍒嗛厤杩欒締杞�
- if (wrkMasts1.size() > 0) {
- //瀛樺湪鍏朵粬浠诲姟锛岃烦杩囪繖杈嗚溅
- continue;
- }
-
- //褰撳墠绌挎杞︾嚎绋嬪埌褰撳墠杞﹀瓙鎵�鍦ㄦゼ灞傜殑鎻愬崌鏈哄彛璺濈
- List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, Utils.levToOutInStaLocNo(currentLev), NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleThread.getSlave().getId(), currentLev));//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘
- if (currentShuttlePath == null) {
- continue;
- }
-
- Integer currentAllDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
- if (currentAllDistance < recentAllDistance) {
- //濡傛灉褰撳墠妤煎眰鐨勮溅璺緞鏇村皬锛屽垯鏇存柊鏈�杩戠┛姊溅
- recentShuttle = shuttleThread;
- }
- }
-
- map.put("sameLay", false);//涓嶅悓灞�
- map.put("result", recentShuttle);
- }
- return map;
}
/**
@@ -1253,8 +1127,7 @@
//鏌ヨ搴撲綅绉昏浆宸ヤ綔妗�
List<WrkMast> wrkMasts1 = wrkMastMapper.selectLocToLocWrkMast();
for (WrkMast wrkMast : wrkMasts1) {
-
- boolean step1 = this.locToLocExecuteStep1(wrkMast);//缁戝畾灏忚溅
+ boolean step1 = this.locToLocExecuteStep1(wrkMast);//搴撲綅绉昏浆
if (!step1) {
continue;
}
@@ -1263,22 +1136,58 @@
}
/**
- * 缁戝畾灏忚溅骞惰皟搴﹁溅
+ * 搴撲綅绉昏浆
* 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false
* ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue
*/
private boolean locToLocExecuteStep1(WrkMast wrkMast) {
- if (wrkMast.getShuttleNo() == null) {//缁欏簱浣嶇Щ杞粦瀹氱┛姊溅鍙�
- //瀵绘壘鏈�杩戜笖绌洪棽鐨勫洓鍚戠┛姊溅
- HashMap<String,Object> searchIdleShuttle = this.searchIdleShuttle(wrkMast);
- ShuttleThread shuttleThread = (ShuttleThread) searchIdleShuttle.get("result");
- if (shuttleThread == null) {
- //娌℃湁鎵惧埌绌洪棽绌挎杞�
- return false;
- }
- wrkMast.setShuttleNo(shuttleThread.getSlave().getId());//缁欏伐浣滄。鍒嗛厤鍥涘悜绌挎杞﹀彿
- wrkMastMapper.updateById(wrkMast);
+ if (wrkMast.getShuttleNo() == null) {
+ shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo());//璋冨害灏忚溅鍒版簮搴撲綅杩涜鍙栬揣
+ return false;
}
+
+ //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
+ NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
+ if (shuttleThread == null) {
+ return false;
+ }
+ NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+ if (shuttleProtocol == null) {
+ return false;
+ }
+ if (!shuttleProtocol.isIdle()) {
+ return false;
+ }
+
+ //鍒ゆ柇灏忚溅鏄惁鍒拌揪婧愬簱浣�
+ if (!shuttleProtocol.getCurrentLocNo().equals(wrkMast.getSourceLocNo())) {
+ //灏忚溅涓嶅湪婧愬簱浣嶄綅缃�
+ shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getShuttleNo());//璋冨害灏忚溅鍒版簮搴撲綅杩涜鍙栬揣
+ return false;
+ }
+
+ //灏忚溅宸叉姷杈炬簮搴撲綅锛岃繘琛屾惉杩愯揣鐗�
+ NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getSourceLocNo(), wrkMast.getLocNo());
+ if (result == null) {//璺緞璁$畻澶辫触
+ return false;
+ }
+
+ //鍒涘缓鍒嗛厤鍛戒护
+ ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
+ assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//鍥涘悜绌挎杞﹀彿
+ assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());//浠诲姟鍙�
+ assignCommand.setTaskMode(ShuttleTaskModeType.PAK_IN.id.shortValue());//鍏ュ簱妯″紡
+ assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣�(灏忚溅褰撳墠浣嶇疆)
+ assignCommand.setCommands(result.getCommands());//杩愯鍛戒护
+ assignCommand.setNodes(result.getNodes());//璺緞鑺傜偣
+
+ wrkMast.setWrkSts(5L);//1.鐢熸垚鍏ュ簱浠诲姟 => 5.灏忚溅鎼繍涓�
+ wrkMast.setModiTime(new Date());
+ if (wrkMastMapper.updateById(wrkMast) > 0) {
+ //涓嬪彂浠诲姟
+ MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand));
+ }
+
return true;
}
--
Gitblit v1.9.1