From 05f8bdf7e09849c1db885b6c996ad18280d130b3 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期一, 18 十二月 2023 16:18:25 +0800
Subject: [PATCH] #map latest test
---
src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java | 368 ++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 308 insertions(+), 60 deletions(-)
diff --git a/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java b/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java
index 917c4cd..d4f60b1 100644
--- a/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java
+++ b/src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java
@@ -1,12 +1,15 @@
package com.zy.common.utils;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.core.common.SpringUtils;
import com.core.exception.CoolException;
-import com.zy.asrs.entity.BasDevp;
+import com.zy.asrs.entity.BasShuttle;
import com.zy.asrs.entity.WrkCharge;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.mapper.WrkChargeMapper;
import com.zy.asrs.mapper.WrkMastMapper;
-import com.zy.asrs.service.BasDevpService;
+import com.zy.asrs.service.BasShuttleService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.NavigateNode;
@@ -14,21 +17,23 @@
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;
import com.zy.core.thread.NyShuttleThread;
+import com.zy.system.entity.Config;
+import com.zy.system.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
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.*;
/**
* 鍥涘悜绌挎杞﹁皟搴﹀伐鍏�
@@ -46,13 +51,15 @@
private WrkChargeMapper wrkChargeMapper;
@Autowired
private CommonService commonService;
- @Autowired
- private BasDevpService basDevpService;
/**
* 璋冨害杞﹁締-璋冨害鎸囧畾绌挎杞�
*/
public boolean dispatchShuttle(Integer wrkNo, String locNo, Integer shuttleNo) {
+ if (!checkCharge(shuttleNo, locNo)) {
+ News.info("{}鍙峰皬杞︼紝瀛樺湪鍏呯數浠诲姟绂佹灏忚溅绉诲姩浠诲姟璋冨害", shuttleNo);
+ return false;//瀛樺湪鍏呯數浠诲姟鏆傚仠璋冨害
+ }
return shuttleMoveGenerate(wrkNo, locNo, shuttleNo);
}
@@ -60,6 +67,18 @@
* 璋冨害杞﹁締
*/
public boolean dispatchShuttle(Integer wrkNo, String locNo) {
+ //妫�娴嬬洰鏍囧簱浣嶇粍鏄惁瀛樺湪灏忚溅锛屽瀛樺湪灏忚溅鍒欑洿鎺ユ寚瀹氳杞�
+ WrkMast wrkMast = wrkMastMapper.selectByWorkNo(wrkNo);
+ if (wrkMast != null) {
+ String targetLocNo = wrkMast.getIoType() < 100 ? wrkMast.getLocNo() : wrkMast.getSourceLocNo();
+ List<String> groupLoc = Utils.getGroupLoc(targetLocNo);
+ Integer groupShuttleNo = Utils.checkGroupLocHasShuttle(groupLoc);
+ if (groupShuttleNo != null) {
+ //瀛樺湪灏忚溅锛岀洿鎺ヨ皟搴﹁杞�
+ return shuttleMoveGenerate(wrkNo, locNo, groupShuttleNo);
+ }
+ }
+
ArrayList<NyShuttleThread> sameLev = new ArrayList<>();//鐩稿悓妤煎眰鐨勭┛姊溅
ArrayList<NyShuttleThread> diffLev = new ArrayList<>();//涓嶅悓妤煎眰鐨勭┛姊溅
@@ -71,7 +90,16 @@
continue;
}
+ if (checkChargeWrk(shuttle.getId())) {
+ continue;//瀛樺湪鍏呯數浠诲姟锛岃繃婊ゅ皬杞�
+ }
+
if (!shuttleProtocol.isIdle()) {
+ continue;//灏忚溅蹇欑涓�
+ }
+
+ if (shuttleProtocol.getSuspendState() == 1) {
+ //灏忚溅澶勪簬绠″埗涓�
continue;
}
@@ -80,7 +108,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;
}
@@ -94,59 +128,79 @@
}
- 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();
//褰撳墠绌挎杞︾嚎绋嬪埌鐩爣鍦扮偣璺濈
- List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleThread.getSlave().getId(), Utils.getLev(currentLocNo)));//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘
+ List<NavigateNode> currentShuttlePath = NavigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleThread.getSlave().getId(), Utils.getLev(currentLocNo)), null);//鎼滅储绌洪棽绌挎杞︼紝浣跨敤姝e父閫氶亾鍦板浘
if (currentShuttlePath == null) {
continue;
}
Integer currentAllDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
- if (currentAllDistance < recentAllDistance) {
- //濡傛灉褰撳墠妤煎眰鐨勮溅璺緞鏇村皬锛屽垯鏇存柊鏈�杩戠┛姊溅
- recentShuttle = shuttleThread;
- }
+ sameShuttles.put(currentAllDistance, shuttleThread);
}
- }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;
- }
-
- //褰撳墠绌挎杞︾嚎绋嬪埌褰撳墠杞﹀瓙鎵�鍦ㄦゼ灞傜殑鎻愬崌鏈哄彛璺濈
- 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;
+ //灏濊瘯璋冨害鍚屾ゼ灞傚皬杞�
+ for (Map.Entry<Integer, NyShuttleThread> entry : sameShuttles.entrySet()) {
+ NyShuttleThread shuttleThread = entry.getValue();
+ //灏濊瘯璋冨害灏忚溅
+ boolean result = shuttleMoveGenerate(wrkNo, locNo, shuttleThread.getSlave().getId());
+ if (result) {
+ return true;//璋冨害鎴愬姛
}
}
}
- if (recentShuttle == null) {//娌℃湁鎼滅储鍒板彲鐢ㄧ┛姊溅
- return false;
+ //鎵ц鍒版澶勶紝鍚屾ゼ灞傛棤璋冨害鎴愬姛灏忚溅銆傞渶瑕佽繘琛岃法妤煎眰璋冨害灏忚溅
+ //瀵绘壘绂讳换鍔℃ゼ灞傛渶杩戠殑绌挎杞�(涓嶈�冭檻璺ㄦゼ灞傚皬杞︾Щ鍔ㄨ窛绂�)
+ 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);//鐩爣妤煎眰
+
+ //妫�娴嬬洰鏍囨ゼ灞傝溅鏁伴噺鏄惁灏忎簬鍏佽鐨勬渶澶ф暟閲�
+ boolean checkDispatchMaxNum = checkDispatchMaxNum(lev);
+ if (!checkDispatchMaxNum) {
+ News.info("{}浠诲姟锛寋}灞傦紝宸茬粡杈惧埌褰撳墠妤煎眰璋冨害杞﹁締鏈�澶у��", wrkMast1.getWrkNo(), lev);
+ return false;
+ }
+
+ for (NyShuttleThread shuttleThread : diffLev) {
+ //褰撳墠绌挎杞﹀簱浣嶅彿
+ String currentLocNo = shuttleThread.getShuttleProtocol().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);
+ 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;//璋冨害鎴愬姛
+ }
+ }
+ }
}
- //鎼滅储鍒板彲鐢ㄧ┛姊溅锛岃皟搴﹁杞�
- return shuttleMoveGenerate(wrkNo, locNo, recentShuttle.getSlave().getId());
+ News.info("{}鐩爣搴撲綅娌℃湁鎼滅储鍒板彲鐢ㄧ┛姊溅", locNo);
+ return false;
}
/**
@@ -158,45 +212,48 @@
//鑾峰彇鍥涘悜绌挎杞︾嚎绋�
NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
if (shuttleThread == null) {
+ News.info("{}鍙峰皬杞︼紝绾跨▼涓嶅瓨鍦�", shuttleNo);
return false;
}
NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
if (shuttleProtocol == null) {
+ News.info("{}鍙峰皬杞︼紝绾跨▼涓嶅瓨鍦�", shuttleNo);
return false;
}
//灏忚溅澶勪簬绌洪棽鐘舵��
if (!shuttleProtocol.isIdleNoCharge()) {
+ News.info("{}鍙峰皬杞︼紝蹇欑涓�", shuttleNo);
return false;
}
//鍒ゆ柇绌挎杞︽槸鍚﹀瓨鍦ㄦ湭瀹屾垚鐨勫皬杞︾Щ搴撲换鍔�
WrkMast hasMoveWorking = wrkMastMapper.selectShuttleHasMoveWorking(shuttleNo);
if (hasMoveWorking != null) {//灏忚溅瀛樺湪绉诲簱浠诲姟锛岀瓑寰呮墽琛屽畬鎴愬悗鍐嶇敓鎴愭柊鐨勪换鍔�
+ News.info("{}鍙峰皬杞︼紝瀛樺湪绉诲姩浠诲姟锛岀瓑寰呮墽琛屽畬鎴愬悗鍐嶇敓鎴愭柊鐨勪换鍔�", shuttleNo);
return false;
}
//鍒ゆ柇鏄惁鏈夊叾浠栦换鍔℃鍦ㄤ娇鐢ㄧ┛姊溅
WrkMast wrkMast2 = wrkMastMapper.selectShuttleWorking(shuttleNo);
if (wrkMast2 != null) {//灏忚溅瀛樺湪鍏朵粬宸ヤ綔妗d换鍔★紝绛夊緟鎵ц瀹屾垚鍚庡啀鐢熸垚鏂扮殑浠诲姟
+ News.info("{}鍙峰皬杞︼紝瀛樺湪鍏朵粬宸ヤ綔妗d换鍔★紝绛夊緟鎵ц瀹屾垚鍐嶇敓鎴愭柊鐨勪换鍔�", shuttleNo);
return false;
}
- //鍒ゆ柇鏄惁鏈夊厖鐢典换鍔℃鍦ㄤ娇鐢ㄧ┛姊溅
- WrkCharge wrkCharge = wrkChargeMapper.selectWorking(shuttleNo);
- if (wrkCharge != null) {//灏忚溅瀛樺湪鍏呯數浠诲姟锛岀瓑寰呮墽琛屽畬鎴愬悗鍐嶇敓鎴愭柊鐨勪换鍔�
- return false;
- }
-
- Integer staNo = null;
- if (Utils.getLev(locNo) == shuttleProtocol.getPoint().getZ()) {
+ Integer sourceStaNo = null;//灏忚溅鎹㈠眰婧愮珯鐐�
+ Integer staNo = null;//灏忚溅鎹㈠眰鐩爣绔欑偣
+ if (Utils.getLev(locNo) != shuttleProtocol.getPoint().getZ()) {
//鐩爣搴撲綅鍜屽皬杞﹀簱浣嶅浜庝笉鍚屼竴妤煎眰锛岄渶瑕侀�氳繃鎻愬崌鏈鸿皟搴�
//鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満杈撻�佺珯鐐�
- BasDevp liftSta = this.getRecentLiftSta(shuttleNo);
+ LiftStaProtocol liftSta = this.getRecentLiftSta(shuttleNo, Utils.getLev(locNo));
if (liftSta == null) {
+ News.info("{}鍙峰皬杞︼紝{}鐩爣搴撲綅锛屾病鏈夊彲鐢ㄧ┖闂茶緭閫佺珯鐐�", shuttleNo, locNo);
return false;//娌℃湁鍙敤涓旂┖闂茬殑杈撻�佺珯鐐�
}
- staNo = liftSta.getDevNo();
+ sourceStaNo = liftSta.getStaNo();//婧愮珯鐐�
+ //鎻愬崌鏈哄彿*100+鐩爣妤煎眰=鐩爣绔欑偣
+ staNo = liftSta.getLiftNo() * 100 + Utils.getLev(locNo);//鐩爣绔�
}
// 鑾峰彇宸ヤ綔鍙�
@@ -211,6 +268,7 @@
wrkMast.setShuttleNo(shuttleNo);//绌挎杞﹀彿
wrkMast.setSourceLocNo(shuttleProtocol.getCurrentLocNo()); // 婧愬簱浣� => 灏忚溅褰撳墠搴撲綅鍙�
wrkMast.setLocNo(locNo); // 鐩爣搴撲綅
+ wrkMast.setSourceStaNo(sourceStaNo);//婧愮珯
wrkMast.setStaNo(staNo);//鐩爣绔�
wrkMast.setPicking("N"); // 鎷f枡
wrkMast.setExitMk("N"); // 閫�鍑�
@@ -234,9 +292,78 @@
}
/**
+ * 妫�娴嬬洰鏍囨ゼ灞傝溅鏁伴噺鏄惁灏忎簬鍏佽鐨勬渶澶ф暟閲�
+ * true: 灏忎簬鏈�澶ф暟閲� false: 澶т簬鎴栫瓑浜庢渶澶ф暟閲�
+ */
+ public boolean checkDispatchMaxNum(Integer lev) {
+ BasShuttleService basShuttleService = SpringUtils.getBean(BasShuttleService.class);
+ ConfigService configService = SpringUtils.getBean(ConfigService.class);
+ EntityWrapper<Config> wrapper = new EntityWrapper<>();
+ wrapper.eq("code", "dispatchShuttleMaxNum");
+ Config config = configService.selectOne(wrapper);
+ if (config == null) {
+ return false;
+ }
+
+ int levCount = 0;//鐩爣妤煎眰杞﹁締鏁伴噺
+ for (ShuttleSlave shuttle : slaveProperties.getShuttle()) {
+ //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
+ NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId());
+ NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+ if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
+ continue;
+ }
+
+ NyShuttleProtocol.NyShuttlePointClass point = null;
+ if (shuttleProtocol.getPoint() == null) {
+ BasShuttle basShuttle = basShuttleService.selectById(shuttle.getId());//灏忚溅濡傛灉娌℃湁鏁版嵁锛屼粠鏁版嵁搴撳彇鏁版嵁
+ if (basShuttle == null || basShuttle.getPoint() == null) {
+ continue;
+ }
+ point = JSON.parseObject(basShuttle.getPoint(), NyShuttleProtocol.NyShuttlePointClass.class);
+ }else {
+ point = shuttleProtocol.getPoint();
+ }
+
+ if (point.getZ().equals(lev)) {
+ if (shuttleProtocol.getChargState() == 1) {
+ continue;//鍏呯數涓�
+ }
+
+ if (shuttleProtocol.getSuspendState() == 1) {
+ continue;//绠″埗涓�
+ }
+
+ levCount++;//鐩爣妤煎眰鏈夎溅锛屾暟閲忓鍔�
+ }
+ }
+
+ //鎼滅储鏄惁瀛樺湪鍓嶅線鐩爣妤煎眰鐨勫皬杞︾Щ鍔ㄥ伐浣滄。
+ for (WrkMast wrkMast : wrkMastMapper.selectShuttleMoveWrk()) {
+ if (wrkMast.getSourceLocNo() == null || wrkMast.getLocNo() == null) {
+ continue;
+ }
+
+ int sourceLev = Utils.getLev(wrkMast.getSourceLocNo());//宸ヤ綔妗f簮妤煎眰
+ int targetLev = Utils.getLev(wrkMast.getLocNo());//宸ヤ綔妗g洰鏍囨ゼ灞�
+ if (sourceLev == lev) {
+ continue;//宸ヤ綔妗fゼ灞傚拰鐩爣妤煎眰鐩稿悓锛岃烦杩�
+ }
+
+ if (targetLev == lev) {
+ levCount++;//宸ヤ綔妗g洰鏍囨ゼ灞傚拰瀹為檯妤煎眰鐩稿悓锛屾暟閲忓鍔�
+ continue;
+ }
+ }
+
+
+ return levCount < Integer.parseInt(config.getValue());
+ }
+
+ /**
* 鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満杈撻�佺珯鐐�
*/
- public BasDevp getRecentLiftSta(Integer shuttleNo) {
+ public LiftStaProtocol getRecentLiftSta(Integer shuttleNo, Integer targetLev) {
//鑾峰彇鍥涘悜绌挎杞︾嚎绋�
NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
if (shuttleThread == null) {
@@ -247,6 +374,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 +390,132 @@
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;
+
+ //鍒ゆ柇鐩爣妤煎眰绔欑偣鏄惁鏃犳墭鐩�
+ LiftStaProtocol targetLiftStaProtocol = NyLiftUtils.getLiftStaByLev(slave.getId(), targetLev);
+ if (targetLiftStaProtocol == null) {
+ continue;
+ }
+
+ if (targetLiftStaProtocol.getHasTray()) {
+ continue;//鏈夋墭鐩樿烦杩�
+ }
+
+ 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)), null);//浣跨敤姝e父閫氶亾鍦板浘
+ if (currentShuttlePath == null) {
+ continue;
+ }
+ Integer currentAllDistance = NavigateUtils.getOriginPathAllDistance(currentShuttlePath);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
+ if (currentAllDistance < recentAllDistance) {
+ //濡傛灉褰撳墠妤煎眰鐨勮溅璺緞鏇村皬锛屽垯鏇存柊鏈�杩戠珯鐐�
+ recentSta = liftStaProtocol;
+ recentAllDistance = currentAllDistance;
+ }
+ }
+
+ return recentSta;
+ }
+
+ /**
+ * 妫�娴嬫槸鍚︾┛姊溅鏄惁鏈夊厖鐢典换鍔�
+ */
+ public boolean checkChargeWrk(int shuttleNo) {
+ //鍒ゆ柇鏄惁鏈夊厖鐢典换鍔℃鍦ㄤ娇鐢ㄧ┛姊溅
+ WrkCharge wrkCharge = wrkChargeMapper.selectWorking(shuttleNo);
+ if (wrkCharge != null) {
+ return true;//鏈夊厖鐢典换鍔�
+ }
+ return false;//鏃犲厖鐢典换鍔�
+ }
+
+ /**
+ * 妫�娴嬬┛姊溅鏄惁鏈夊厖鐢典换鍔★紝鐩爣鐐规槸鍚︿负鍏呯數妗╀綅缃�
+ * @param shuttleNo 灏忚溅鍙�
+ * @param locNo 鐩爣浣嶇疆
+ */
+ public boolean checkCharge(int shuttleNo, String locNo) {
+ //鍒ゆ柇鏄惁鏈夊厖鐢典换鍔℃鍦ㄤ娇鐢ㄧ┛姊溅
+ WrkCharge wrkCharge = wrkChargeMapper.selectWorking(shuttleNo);
+ if (wrkCharge != null) {//灏忚溅瀛樺湪鍏呯數浠诲姟锛岀瓑寰呮墽琛屽畬鎴愬悗鍐嶇敓鎴愭柊鐨勪换鍔�
+ //鍒ゆ柇鐩爣鐐规槸鍚︿负鍏呯數妗╋紝濡傛灉鏄幓鍏呯數鍒欐斁琛�
+ 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;
+ }
+ }
+
+ return true;//鏃犲厖鐢典换鍔℃斁琛� || 鍘诲厖鐢垫々涓斁琛�
+ }
+
+ /**
+ * 鑾峰彇妤煎眰鍙敤灏忚溅鏁伴噺
+ */
+ public int getShuttleCountByLev(int lev) {
+ int count = 0;
+ for (ShuttleSlave slave : slaveProperties.getShuttle()) {
+ //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
+ NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId());
+ if (shuttleThread == null) {
+ continue;
+ }
+
+ NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+ if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
+ continue;
+ }
+
+ if (checkChargeWrk(slave.getId())) {
+ continue;//瀛樺湪鍏呯數浠诲姟锛岃繃婊ゅ皬杞�
+ }
+
+ if (shuttleProtocol.getWorkingMode() == 0) {
+ continue;//鎵嬪姩鐘舵��
+ }
+
+ if (shuttleProtocol.getSuspendState() == 1) {
+ //灏忚溅澶勪簬绠″埗涓�
+ continue;
+ }
+
+ if (shuttleProtocol.getPoint().getZ() == lev) {
+ //鍚屼竴妤煎眰鍙敤灏忚溅
+ count++;
+ continue;
+ }
+ }
+ return count;
}
}
--
Gitblit v1.9.1