From 74e0eb7a7e84b5006903e79554c007d9d5fbbcbc Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 05 十月 2023 17:04:32 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 1570 +++++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 1,275 insertions(+), 295 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 8d4bafe..293d0d1 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -2,6 +2,8 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.mapper.Wrapper;
import com.core.common.Cools;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
@@ -69,6 +71,8 @@
@Autowired
private BasShuttleErrLogService basShuttleErrLogService;
@Autowired
+ private BasLiftErrLogService basLiftErrLogService;
+ @Autowired
private BasShuttleErrService basShuttleErrService;
@Autowired
private BasCrnErrorMapper basCrnErrorMapper;
@@ -96,6 +100,9 @@
private ShuttleDispatchUtils shuttleDispatchUtils;
@Autowired
private RedisUtil redisUtil;
+ @Autowired
+ private WrkMastLocMapper wrkMastLocMapper;
+
/**
* 缁勬墭
@@ -218,7 +225,7 @@
param.setBarcode(barcode);
param.setIoType(1);
param.setSourceStaNo(inSta.getStaNo());
-// param.setLocType1(locTypeDto.getLocType1());
+ param.setLocType1(locTypeDto.getLocType1());
String response = new HttpHandler.Builder()
.setUri(wmsUrl)
.setPath("/rpc/pakin/loc/v1")
@@ -232,14 +239,14 @@
StartupDto dto = jsonObject.getObject("data", StartupDto.class);
// plc 澶勭悊
barcodeThread.setBarcode("");
- staProtocol.setWorkNo(dto.getWorkNo().shortValue());
- staProtocol.setStaNo(dto.getStaNo().shortValue());
- devpThread.setPakMk(staProtocol.getSiteId(), false);
-
- boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
- if (!result) {
- throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
- }
+// staProtocol.setWorkNo(dto.getWorkNo().shortValue());
+// staProtocol.setStaNo(dto.getStaNo().shortValue());
+// devpThread.setPakMk(staProtocol.getSiteId(), false);
+//
+// boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+// if (!result) {
+// throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+// }
// 鍒ゆ柇閲嶅宸ヤ綔妗�
WrkMast wrkMast = wrkMastMapper.selectPakInStep11(inSta.getStaNo());
@@ -261,10 +268,10 @@
}
News.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
} else if (code == 700) {
- staProtocol.setWorkNo((short) 32002);
- staProtocol.setRollback102(1);//102绔欏洖閫�淇″彿
- devpThread.setPakMk(staProtocol.getSiteId(), false);
- MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(5, staProtocol));
+// staProtocol.setWorkNo((short) 32002);
+// staProtocol.setRollback102(1);//102绔欏洖閫�淇″彿
+// devpThread.setPakMk(staProtocol.getSiteId(), false);
+// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(5, staProtocol));
// led 寮傚父鏄剧ず
if (ledThread != null) {
@@ -399,8 +406,8 @@
}
if (staProtocol.isAutoing()
&& staProtocol.isLoading()
- && (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9999)
- && staProtocol.getStaNo().equals(staProtocol.getSiteId().shortValue())
+// && (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9999)
+// && staProtocol.getStaNo().equals(staProtocol.getSiteId().shortValue())
&& staProtocol.isPakMk()){
// 鑾峰彇鏉$爜鎵弿浠俊鎭�
@@ -501,12 +508,18 @@
}
String sourceLocNo = wrkMast.getSourceLocNo().trim();
+ LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//鑾峰彇鍥炲簱鎻愬崌鏈虹洰鏍囩珯
+ if (liftStaProtocol == null) {
+ continue;
+ }
+
// 鏇存柊宸ヤ綔妗f暟鎹姸鎬�
wrkMast.setIoType(wrkMast.getIoType() - 50); // 鍏ュ嚭搴撶被鍨�: 103->53,104->54,107->57
wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵��: 2.璁惧涓婅蛋
wrkMast.setSourceStaNo(pickSta.getStaNo()); // 婧愮珯
- wrkMast.setStaNo(dto.getStaNo()); // 鐩爣绔�
- wrkMast.setCrnNo(dto.getCrnNo());
+// wrkMast.setStaNo(dto.getStaNo()); // 鐩爣绔�
+// wrkMast.setCrnNo(dto.getCrnNo());
+ wrkMast.setStaNo(liftStaProtocol.getStaNo());//鐩爣绔�
wrkMast.setLocNo(sourceLocNo); // 鐩爣搴撲綅 = 鍑哄簱鏃剁殑婧愬簱浣�
wrkMast.setShuttleNo(null); // 绌挎杞︽竻绌�
wrkMast.setModiTime(new Date());
@@ -525,14 +538,16 @@
throw new CoolException("淇敼搴撲綅鐘舵�佸け璐�");
}
- // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
- staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
- staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
- devpThread.setPakMk(staProtocol.getSiteId(), false);
- boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
- if (!result) {
- News.error("鍙戝竷鍛戒护鑷宠緭閫佺嚎闃熷垪澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId());
- }
+// // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
+// staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
+// staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
+// devpThread.setPakMk(staProtocol.getSiteId(), false);
+// boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+// if (!result) {
+// News.error("鍙戝竷鍛戒护鑷宠緭閫佺嚎闃熷垪澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId());
+// }
+
+ barcodeThread.setBarcode("");//娓呯悊鏉$爜
} else if (code == 500){
if (ledThread != null) {
@@ -543,10 +558,10 @@
}
News.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
} else {
- staProtocol.setWorkNo((short) 32002);
- staProtocol.setStaNo(pickSta.getBackSta().shortValue());
- devpThread.setPakMk(staProtocol.getSiteId(), false);
- MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+// staProtocol.setWorkNo((short) 32002);
+// staProtocol.setStaNo(pickSta.getBackSta().shortValue());
+// devpThread.setPakMk(staProtocol.getSiteId(), false);
+// MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
// led 寮傚父鏄剧ず
if (ledThread != null) {
@@ -659,53 +674,83 @@
* 鍏ュ簱 ===>> 鍥涘悜绌挎杞﹀叆搴撲綔涓氫笅鍙�
*/
public synchronized void shuttleInExecute() {
- // 鏍规嵁杈撻�佺嚎plc閬嶅巻
- for (DevpSlave devp : slaveProperties.getDevp()) {
- // 閬嶅巻鍏ュ簱绔�
- for (DevpSlave.StaRack staRack : devp.getRackInStn()) {
- // 鑾峰彇鍏ュ簱绔欎俊鎭�
- DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
- StaProtocol staProtocol = devpThread.getStation().get(staRack.getStaNo());
- if (staProtocol == null) {
- continue;
- } else {
- staProtocol = staProtocol.clone();
- }
- Short workNo = staProtocol.getWorkNo();
- BasDevp basDevp = basDevpService.selectById(staProtocol.getSiteId());
- if (basDevp == null) {
- continue;//绔欑偣淇℃伅涓嶅瓨鍦�
- }
+ List<WrkMast> wrkMasts = wrkMastMapper.selectInStep4();
+ for (WrkMast wrkMast : wrkMasts) {
+ //鑾峰彇婧愮珯
+ BasDevp sourceBasDevp = basDevpService.selectById(wrkMast.getSourceStaNo());
+ if (sourceBasDevp == null) {
+ continue;//绔欑偣涓嶅瓨鍦�
+ }
- // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢锛岃嚜鍔ㄣ�佹湁鐗┿�佸洓鍚戠┛姊溅鍙彇淇″彿
- if (!(staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isShuttleTakeEnable())) {
- continue;
- }
+ //鑾峰彇鐩爣绔�
+ LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(sourceBasDevp.getLiftNo(), Utils.getLev(wrkMast.getLocNo()));
+ if (liftStaProtocol == null) {
+ continue;//绔欑偣涓嶅瓨鍦�
+ }
- WrkMast wrkMast = wrkMastMapper.selectRackInStep4(workNo, staProtocol.getSiteId());
- if (wrkMast == null) {
- continue;
- }
+ // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢锛岃嚜鍔ㄣ�佺┖闂层�佹湁鐗�
+ if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && liftStaProtocol.getHasTray())) {
+ continue;
+ }
- boolean step1 = this.shuttleInExecuteStep1(wrkMast, basDevp);//灏忚溅鎼叆搴撲腑
- if (!step1) {
- continue;
- }
-
+ boolean step1 = this.shuttleInExecuteStep1(wrkMast, liftStaProtocol);//灏忚溅鎼叆搴撲腑
+ if (!step1) {
+ continue;
}
}
-
}
+
+// /**
+// * 鍏ュ簱 ===>> 鍥涘悜绌挎杞﹀叆搴撲綔涓氫笅鍙�
+// */
+// public synchronized void shuttleInExecute() {
+// // 鏍规嵁杈撻�佺嚎plc閬嶅巻
+// for (DevpSlave devp : slaveProperties.getDevp()) {
+// // 閬嶅巻鍏ュ簱绔�
+// for (DevpSlave.StaRack staRack : devp.getRackInStn()) {
+// // 鑾峰彇鍏ュ簱绔欎俊鎭�
+// DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+// StaProtocol staProtocol = devpThread.getStation().get(staRack.getStaNo());
+// if (staProtocol == null) {
+// continue;
+// } else {
+// staProtocol = staProtocol.clone();
+// }
+// Short workNo = staProtocol.getWorkNo();
+// BasDevp basDevp = basDevpService.selectById(staProtocol.getSiteId());
+// if (basDevp == null) {
+// continue;//绔欑偣淇℃伅涓嶅瓨鍦�
+// }
+//
+// // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢锛岃嚜鍔ㄣ�佹湁鐗┿�佸洓鍚戠┛姊溅鍙彇淇″彿
+// if (!(staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isShuttleTakeEnable())) {
+// continue;
+// }
+//
+// WrkMast wrkMast = wrkMastMapper.selectRackInStep4(workNo, staProtocol.getSiteId());
+// if (wrkMast == null) {
+// continue;
+// }
+//
+// boolean step1 = this.shuttleInExecuteStep1(wrkMast, basDevp);//灏忚溅鎼叆搴撲腑
+// if (!step1) {
+// continue;
+// }
+//
+// }
+// }
+//
+// }
/**
* 鍏ュ簱-灏忚溅鎼叆搴撲腑
* 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false
* ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue
*/
- public boolean shuttleInExecuteStep1(WrkMast wrkMast, BasDevp basDevp) {
+ public boolean shuttleInExecuteStep1(WrkMast wrkMast, LiftStaProtocol liftStaProtocol) {
if (wrkMast.getWrkSts() == 4) {
if (wrkMast.getShuttleNo() == null) {//娌℃湁缁戝畾灏忚溅锛岃繘琛岃皟搴�
- shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), basDevp.getLocNo());//璋冨害灏忚溅鍒拌揣鐗╂墍鍦ㄨ緭閫佺珯鐐硅繘琛屽彇璐�
+ shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), liftStaProtocol.getLocNo());//璋冨害灏忚溅鍒拌揣鐗╂墍鍦ㄨ緭閫佺珯鐐硅繘琛屽彇璐�
return false;
}
@@ -721,16 +766,26 @@
if (!shuttleProtocol.isIdle()) {
return false;
}
+ //鍒ゆ柇灏忚溅浠ょ墝鏄惁鏈鍗犻
+ if (shuttleProtocol.getToken() != 0) {
+ return false;//灏忚溅宸茶鐙崰锛岀姝㈠啀娲惧彂浠诲姟
+ }
+
+ //鍒ゆ柇灏忚溅鏄惁瀛樺湪绉诲姩浠诲姟
+ WrkMast hasMoveWorking = wrkMastMapper.selectShuttleHasMoveWorking(wrkMast.getShuttleNo());
+ if (hasMoveWorking != null) {
+ return false;//瀛樺湪绉诲姩浠诲姟锛岀姝㈡墽琛屽叆搴撲换鍔�
+ }
//鍒ゆ柇灏忚溅鏄惁鍒拌揪杈撻�佺珯鐐瑰簱浣�
- if (!shuttleProtocol.getCurrentLocNo().equals(basDevp.getLocNo())) {
+ if (!shuttleProtocol.getCurrentLocNo().equals(liftStaProtocol.getLocNo())) {
//灏忚溅涓嶅湪杈撻�佺珯鐐逛綅缃�
- shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), basDevp.getLocNo(), wrkMast.getShuttleNo());//璋冨害灏忚溅鍒拌揣鐗╂墍鍦ㄨ緭閫佺珯鐐硅繘琛屽彇璐�
+ shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), liftStaProtocol.getLocNo(), wrkMast.getShuttleNo());//璋冨害灏忚溅鍒拌揣鐗╂墍鍦ㄨ緭閫佺珯鐐硅繘琛屽彇璐�
return false;
}
//灏忚溅宸叉姷杈捐緭閫佺珯鐐逛綅缃紝杩涜鎼繍璐х墿
- NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), basDevp.getLocNo(), wrkMast.getLocNo());
+ NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo());
if (result == null) {//璺緞璁$畻澶辫触
return false;
}
@@ -746,6 +801,7 @@
wrkMast.setWrkSts(5L);//4.鎻愬崌鏈烘惉杩愬畬鎴� => 5.灏忚溅鎼繍涓�
wrkMast.setModiTime(new Date());
+ shuttleProtocol.setToken(wrkMast.getWrkNo());//鐙崰灏忚溅浠ょ墝
if (wrkMastMapper.updateById(wrkMast) > 0) {
//涓嬪彂浠诲姟
MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand));
@@ -776,6 +832,34 @@
public boolean shuttleOutExecuteStep1(WrkMast wrkMast) {
//21.鐢熸垚鍑哄簱浠诲姟 => 22.灏忚溅鎼繍涓�
if (wrkMast.getWrkSts() == 21) {
+ EntityWrapper<StaDesc> wrapper = new EntityWrapper<>();
+ wrapper.eq("type_no", wrkMast.getIoType());//璺緞绫诲瀷
+ wrapper.eq("stn_no", wrkMast.getStaNo());//鍑哄簱绔欑偣缂栧彿
+ StaDesc staDesc = staDescService.selectOne(wrapper);
+ if (staDesc == null) {
+ return false;//鍑哄簱璺緞涓嶅瓨鍦�
+ }
+
+ //鑾峰彇鍑哄簱绔欑偣
+ BasDevp basDevp = basDevpService.selectById(wrkMast.getStaNo());
+ if (basDevp == null) {
+ return false;//鍑哄簱绔欑偣涓嶅瓨鍦�
+ }
+
+ if (!basDevp.getOutEnable().equals("Y")) {
+ return false;//鍑哄簱绔欑偣涓嶅彲鍑�
+ }
+
+ //鑾峰彇婧愮珯
+ LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(basDevp.getLiftNo(), Utils.getLev(wrkMast.getSourceLocNo()));
+ if (liftStaProtocol == null) {
+ return false;//鎵句笉鍒扮珯鐐�
+ }
+
+ if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && !liftStaProtocol.getHasTray())) {
+ return false;//绔欑偣蹇呴』鑷姩銆佺┖闂层�佹病鏈夋墭鐩�
+ }
+
if (wrkMast.getShuttleNo() == null) {//娌℃湁缁戝畾灏忚溅锛岃繘琛岃皟搴�
shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo());//璋冨害灏忚溅鍒拌揣鐗╂墍鍦ㄥ簱浣嶈繘琛屽彇璐�
return false;
@@ -793,22 +877,20 @@
if (!shuttleProtocol.isIdle()) {
return false;
}
-
- //鑾峰彇鐩爣绔欏搴旂殑杈撻�佺珯鐐�
- BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getSourceLocNo()), wrkMast.getLiftNo());
- if (targetBasDevp == null) {
- return false;//缂哄皯绔欑偣淇℃伅
+ //鍒ゆ柇灏忚溅浠ょ墝鏄惁鏈鍗犻
+ if (shuttleProtocol.getToken() != 0) {
+ return false;//灏忚溅宸茶鐙崰锛岀姝㈠啀娲惧彂浠诲姟
}
//鍒ゆ柇灏忚溅鏄惁鍒拌揪璐х墿搴撲綅
if (!shuttleProtocol.getCurrentLocNo().equals(wrkMast.getSourceLocNo())) {
//灏忚溅涓嶅湪杈撻�佺珯鐐逛綅缃�
- shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getShuttleNo());//璋冨害灏忚溅鍒拌揣鐗╂墍鍦ㄨ緭閫佺珯鐐硅繘琛屽彇璐�
+ shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getShuttleNo());//璋冨害灏忚溅鍒拌揣鐗╂墍鍦ㄥ簱浣嶈繘琛屽彇璐�
return false;
}
//灏忚溅宸叉姷杈捐揣鐗╀綅缃紝杩涜鎼繍璐х墿
- NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getSourceLocNo(), targetBasDevp.getLocNo());
+ NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), liftStaProtocol.getLocNo());//灏嗚揣鐗╂惉杩愯嚦鎻愬崌鏈鸿緭閫佺珯鐐�
if (result == null) {//鍑哄簱璺緞璁$畻澶辫触
return false;
}
@@ -824,6 +906,7 @@
wrkMast.setWrkSts(22L);//21.鐢熸垚鍑哄簱浠诲姟 => 22.灏忚溅鎼繍涓�
wrkMast.setModiTime(new Date());
+ shuttleProtocol.setToken(wrkMast.getWrkNo());//鐙崰灏忚溅浠ょ墝
if (wrkMastMapper.updateById(wrkMast) > 0) {
//涓嬪彂浠诲姟
MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand));
@@ -846,35 +929,65 @@
}
//鍥涘悜绌挎杞︾姸鎬佷负绛夊緟纭銆佸皬杞﹀浜庣┖闂茬姸鎬�
+
+
if (shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.WAITING.id //浠诲姟瀹屾垚绛夊緟纭
&& shuttleProtocol.getTaskNo() != 0
&& shuttleProtocol.getFree() == ShuttleStatusType.IDLE.id
) {
//灏嗕换鍔℃。鏍囪涓哄畬鎴�
- WrkMast wrkMast = wrkMastMapper.selectByWorkNo(shuttleProtocol.getTaskNo().intValue());
+ WrkMast wrkMast = wrkMastMapper.selectByWorkNo(shuttleProtocol.getTaskNo());
if (wrkMast != null) {
switch (wrkMast.getWrkSts().intValue()) {
case 5://5.灏忚溅鎼繍涓� ==> 9.鍏ュ簱瀹屾垚
wrkMast.setWrkSts(9L);
- //浠诲姟鍙锋竻闆�
shuttleProtocol.setTaskNo(0);
+ if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) {
+ //閲婃斁灏忚溅浠ょ墝
+ shuttleProtocol.setToken(0);
+ }
break;
case 22://22.灏忚溅鎼繍涓� ==> 23.灏忚溅鎼繍瀹屾垚
wrkMast.setWrkSts(23L);
+ shuttleProtocol.setTaskNo(0);
+ if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) {
+ //閲婃斁灏忚溅浠ょ墝
+ shuttleProtocol.setToken(0);
+ }
break;
- case 102://102.灏忚溅鍒版彁鍗囨満涓� ==> 103.灏忚溅鍒版彁鍗囨満瀹屾垚
+ case 102://102.灏忚溅绉诲姩鑷崇珯鐐� ==> 103.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴�
wrkMast.setWrkSts(103L);
break;
- case 106://106.灏忚溅杩佸嚭鎻愬崌鏈轰腑 ==> 107.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴�
- wrkMast.setWrkSts(107L);
+ case 104://104.灏忚溅杩佸叆鎻愬崌鏈轰腑 ==> 105.灏忚溅杩佸叆鎻愬崌鏈哄畬鎴�
+ wrkMast.setWrkSts(105L);
+ shuttleProtocol.setTaskNo(0);//娓呯悊宸ヤ綔鍙�
break;
- case 108://108.灏忚溅绉诲姩涓� ==> 109.灏忚溅绉诲姩瀹屾垚
+ case 108://108.灏忚溅杩佸嚭鎻愬崌鏈轰腑 ==> 109.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴�
wrkMast.setWrkSts(109L);
+ break;
+ case 110://110.灏忚溅绉诲姩涓� ==> 111.灏忚溅绉诲姩瀹屾垚
+ wrkMast.setWrkSts(111L);
+ shuttleProtocol.setTaskNo(0);
+ if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) {
+ //閲婃斁灏忚溅浠ょ墝
+ shuttleProtocol.setToken(0);
+ }
break;
default:
}
if (wrkMastMapper.updateById(wrkMast) > 0) {
+ if (wrkMast.getWrkSts() == 111) {
+ // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗�
+ if (wrkMastLocMapper.save(wrkMast.getWrkNo()) <= 0) {
+ log.info("淇濆瓨宸ヤ綔鍘嗗彶妗workNo={0}]澶辫触", wrkMast.getWrkNo());
+ }
+ // 鍒犻櫎宸ヤ綔涓绘。
+ if (!wrkMastService.deleteById(wrkMast)) {
+ log.info("鍒犻櫎宸ヤ綔涓绘。[workNo={0}]澶辫触", wrkMast.getWrkNo());
+ }
+ }
+
//璁剧疆鍥涘悜绌挎杞︿负绌洪棽鐘舵��
shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE);
//婧愬簱浣嶆竻闆�
@@ -886,6 +999,24 @@
News.info("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅銆傚洓鍚戠┛姊溅鍙�={}", shuttleProtocol.getShuttleNo());
} else {
News.error("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅澶辫触锛屼絾鏈壘鍒板伐浣滄。銆傚洓鍚戠┛姊溅鍙�={}锛屽伐浣滃彿={}", shuttleProtocol.getShuttleNo(), shuttleProtocol.getTaskNo());
+ }
+ }else {
+ ShuttleAssignCommand assignCommand = shuttleProtocol.getAssignCommand();
+ if (!assignCommand.getAuto()) {
+ //鎵嬪姩妯″紡
+ //宸ヤ綔鍙锋竻闆�
+ shuttleProtocol.setTaskNo(0);
+ //璁剧疆鍥涘悜绌挎杞︿负绌洪棽鐘舵��
+ shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE);
+ //婧愬簱浣嶆竻闆�
+ shuttleProtocol.setSourceLocNo(null);
+ //鐩爣搴撲綅娓呴浂
+ shuttleProtocol.setLocNo(null);
+ //浠诲姟鎸囦护娓呴浂
+ shuttleProtocol.setAssignCommand(null);
+ //娓呴浂浠ょ墝
+ shuttleProtocol.setToken(0);
+ News.info("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅銆傚洓鍚戠┛姊溅鍙�={}", shuttleProtocol.getShuttleNo());
}
}
@@ -909,6 +1040,11 @@
}
if (!liftProtocol.isIdle()) {
+ continue;
+ }
+
+ //鍒ゆ柇鎻愬崌鏈轰护鐗屾槸鍚﹁鍗犵敤
+ if (liftProtocol.getToken() != 0) {
continue;
}
@@ -950,7 +1086,17 @@
//2.璁惧涓婅蛋 ==> 3.鎻愬崌鏈烘惉杩愪腑
if (wrkMast.getWrkSts() == 2) {
- LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo());
+ //鑾峰彇婧愮珯
+ BasDevp sourceBasDevp = basDevpService.selectById(wrkMast.getSourceStaNo());
+ if (sourceBasDevp == null) {
+ return false;//鎵句笉鍒扮珯鐐�
+ }
+
+ if (!sourceBasDevp.getInEnable().equals("Y")) {
+ return false;//绔欑偣涓嶅彲鍏�
+ }
+
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, sourceBasDevp.getLiftNo());
if (liftThread == null) {
return false;
}
@@ -958,26 +1104,52 @@
if (liftProtocol == null) {
return false;
}
- if (!liftProtocol.isIdle(wrkMast.getWrkNo().shortValue())) {
+ if (!liftProtocol.isIdle()) {
return false;
}
+ //鍒ゆ柇鎻愬崌鏈轰护鐗屾槸鍚︽湭琚崰棰�
+ if (liftProtocol.getToken() != 0) {
+ return false;//鎻愬崌鏈哄凡琚嫭鍗狅紝绂佹鍐嶆淳鍙戜换鍔�
+ }
+
+ //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夊皬杞�
+ if (liftProtocol.getHasCar()) {
+ return false;//鏈夊皬杞︼紝绂佹娲惧彂
+ }
+
+ //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夋墭鐩�
+ if (liftProtocol.getHasTray()) {
+ return false;//鏈夋墭鐩橈紝绂佹娲惧彂
+ }
+
//鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟
WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(liftThread.getSlave().getId());
if (liftWrkMast != null) {
return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇�
}
- //鑾峰彇婧愮珯瀵瑰簲鐨勮緭閫佺珯鐐�
- BasDevp sourceBasDevp = basDevpService.selectById(wrkMast.getSourceStaNo());
- //鑾峰彇鐩爣绔欏搴旂殑杈撻�佺珯鐐�
- BasDevp targetBasDevp = basDevpService.selectById(wrkMast.getStaNo());
- if (sourceBasDevp == null || targetBasDevp == null) {
- return false;//缂哄皯绔欑偣淇℃伅
+ //鑾峰彇婧愮珯瀵瑰簲鐨勭墰鐪兼彁鍗囨満绔欑偣缂栧彿(璧风偣缂栧彿)
+ Integer startSta = Integer.parseInt(sourceBasDevp.getQrCodeValue());
+ //鑾峰彇鎻愬崌鏈虹珯鐐�
+ LiftStaProtocol targetStaProtocol = NyLiftUtils.getLiftStaByLev(liftThread.getSlave().getId(), Utils.getLev(wrkMast.getLocNo()));
+ if (targetStaProtocol == null) {
+ return false;//绔欑偣涓嶅瓨鍦�
}
- //鑾峰彇鎻愬崌鏈哄懡浠�
- NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, sourceBasDevp.getDevNo(), targetBasDevp.getDevNo(), wrkMast.getWrkNo());
+ if (targetStaProtocol.getHasTray()) {
+ return false;//鎻愬崌鏈虹珯鐐规湁鎵樼洏锛岀姝㈡淳鍙�
+ }
+ Integer targetSta = targetStaProtocol.getStaNo();
+
+ //鑾峰彇鎻愬崌鏈哄懡浠�
+ NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, startSta, targetSta, wrkMast.getWrkNo());
+ if (wrkMast.getIoType() == 53) {
+ //鎷f枡鍐嶅洖搴擄紝閲嶆柊鍒嗛厤璁惧宸ヤ綔鍙�
+ Random random = new Random();
+ int deviceWrk = Math.abs((liftCommand.getTaskNo().intValue() + random.nextInt(9999)));//鑾峰彇璁惧宸ヤ綔鍙�
+ liftCommand.setTaskNo((short) deviceWrk);
+ }
ArrayList<NyLiftCommand> commands = new ArrayList<>();
commands.add(liftCommand);
@@ -991,6 +1163,7 @@
wrkMast.setWrkSts(3L);//2.璁惧涓婅蛋 ==> 3.鎻愬崌鏈烘惉杩愪腑
wrkMast.setLiftNo(liftThread.getSlave().getId());//浠诲姟妗g粦瀹氭彁鍗囨満鍙�
wrkMast.setModiTime(now);
+ liftProtocol.setToken(wrkMast.getWrkNo());//鐙崰鎻愬崌鏈轰护鐗�
if (wrkMastMapper.updateById(wrkMast) > 0) {
//涓嬪彂浠诲姟
MessageQueue.offer(SlaveType.Lift, liftProtocol.getLiftNo().intValue(), new Task(3, assignCommand));
@@ -1012,7 +1185,28 @@
//23.灏忚溅鎼繍瀹屾垚 ==> 24.鎻愬崌鏈烘惉杩愪腑
if (wrkMast.getWrkSts() == 23) {
- LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo());
+ NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
+ if (shuttleThread == null) {
+ return false;
+ }
+
+ //璋冨害灏忚溅閬胯
+ boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkMast.getSourceLocNo()), wrkMast.getShuttleNo(), shuttleThread);
+ if (!result) {
+ return false;
+ }
+
+ //鑾峰彇鍑哄簱绔欑偣(鐩爣绔�)
+ BasDevp basDevp = basDevpService.selectById(wrkMast.getStaNo());
+ if (basDevp == null) {
+ return false;//鍑哄簱绔欑偣涓嶅瓨鍦�
+ }
+
+ if (!basDevp.getOutEnable().equals("Y")) {
+ return false;//鍑哄簱绔欑偣涓嶅彲鍑�
+ }
+
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, basDevp.getLiftNo());
if (liftThread == null) {
return false;
}
@@ -1020,8 +1214,12 @@
if (liftProtocol == null) {
return false;
}
- if (!liftProtocol.isIdle(wrkMast.getWrkNo().shortValue())) {
+ if (!liftProtocol.isIdle()) {
return false;
+ }
+ //鍒ゆ柇鎻愬崌鏈轰护鐗屾槸鍚︽湭琚崰棰�
+ if (liftProtocol.getToken() != 0) {
+ return false;//鎻愬崌鏈哄凡琚嫭鍗狅紝绂佹鍐嶆淳鍙戜换鍔�
}
//鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟
WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(liftThread.getSlave().getId());
@@ -1029,16 +1227,23 @@
return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇�
}
- //鑾峰彇婧愮珯瀵瑰簲鐨勮緭閫佺珯鐐�
- BasDevp sourceBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getSourceLocNo()), liftProtocol.getLiftNo().intValue());
- //鑾峰彇鐩爣绔欏搴旂殑杈撻�佺珯鐐�
- BasDevp targetBasDevp = basDevpService.selectById(wrkMast.getSourceStaNo());
- if (sourceBasDevp == null || targetBasDevp == null) {
- return false;//缂哄皯绔欑偣淇℃伅
+ //鑾峰彇婧愮珯瀵瑰簲鐨勭墰鐪兼彁鍗囨満绔欑偣缂栧彿(璧风偣缂栧彿)
+ LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(liftThread.getSlave().getId(), Utils.getLev(wrkMast.getSourceLocNo()));
+ if (liftStaProtocol == null) {
+ return false;//鎵句笉鍒扮珯鐐�
}
+ Integer startSta = liftStaProtocol.getStaNo();
+
+ //鑾风洰鏍囩珯婧愮珯瀵瑰簲鐨勮緭閫佺珯鐐�
+ BasDevp targetBasDevp = basDevpService.selectById(wrkMast.getStaNo());
+ if (targetBasDevp == null) {
+ return false;//绔欑偣涓嶅瓨鍦�
+ }
+ //鑾峰彇鐗涚溂鎻愬崌鏈虹珯鐐圭紪鍙�(鐩爣缂栧彿)
+ Integer targetSta = Integer.parseInt(targetBasDevp.getQrCodeValue());
//鑾峰彇鎻愬崌鏈哄懡浠�
- NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, sourceBasDevp.getDevNo(), targetBasDevp.getDevNo(), wrkMast.getWrkNo());
+ NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftThread.getSlave().getId(), NyLiftTaskModelType.MOVE_TRAY.id, startSta, targetSta, wrkMast.getWrkNo());
ArrayList<NyLiftCommand> commands = new ArrayList<>();
commands.add(liftCommand);
@@ -1053,6 +1258,7 @@
wrkMast.setWrkSts(24L);//23.灏忚溅鎼繍瀹屾垚 ==> 24.鎻愬崌鏈烘惉杩愪腑
wrkMast.setLiftNo(liftThread.getSlave().getId());//浠诲姟妗g粦瀹氭彁鍗囨満鍙�
wrkMast.setModiTime(now);
+ liftProtocol.setToken(wrkMast.getWrkNo());//鐙崰鎻愬崌鏈轰护鐗�
if (wrkMastMapper.updateById(wrkMast) > 0) {
//涓嬪彂浠诲姟
MessageQueue.offer(SlaveType.Lift, liftProtocol.getLiftNo().intValue(), new Task(3, assignCommand));
@@ -1080,7 +1286,6 @@
&& liftProtocol.getTaskNo() != 0
&& !liftProtocol.getBusy()
) {
-
//灏嗕换鍔℃。鏍囪涓哄畬鎴�
WrkMast wrkMast = wrkMastMapper.selectByWorkNo324104(liftProtocol.getTaskNo().intValue());
if (wrkMast != null) {
@@ -1088,12 +1293,29 @@
case 3://3.鎻愬崌鏈烘惉杩愪腑 ==> 4.鎻愬崌鏈烘惉杩愬畬鎴�
wrkMast.setWrkSts(4L);
wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈�
+ if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) {
+ //閲婃斁鎻愬崌鏈轰护鐗�
+ liftProtocol.setToken(0);
+ }
break;
case 24://24.鎻愬崌鏈烘惉杩愪腑 ==> 25.鎻愬崌鏈烘惉杩愬畬鎴�
wrkMast.setWrkSts(25L);
+ if (wrkMast.getIoType() == 11) {//搴撲綅绉昏浆
+ wrkMast.setWrkSts(4L);//4.鎻愬崌鏈烘惉杩愬畬鎴�
+ }
+ if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) {
+ //閲婃斁鎻愬崌鏈轰护鐗�
+ liftProtocol.setToken(0);
+ }
+
+ if (wrkMast.getMk() == null || !wrkMast.getMk().equals("Y")) {
+ //涓嶉渶瑕佺敤鍒版満姊拌噦锛岀洿鎺ヨ浆29.鍑哄簱瀹屾垚
+ wrkMast.setWrkSts(29L);
+ }
+
break;
- case 104://104.鎻愬崌鏈烘惉杩愪腑 ==> 105.鎻愬崌鏈烘惉杩愬畬鎴�
- wrkMast.setWrkSts(105L);
+ case 106://106.鎻愬崌鏈烘惉杩愪腑 ==> 107.鎻愬崌鏈烘惉杩愬畬鎴�
+ wrkMast.setWrkSts(107L);
break;
default:
}
@@ -1107,8 +1329,19 @@
} else {
News.error("鎻愬崌鏈哄凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅澶辫触锛屼絾鏈壘鍒板伐浣滄。銆傛彁鍗囨満鍙�={}锛屽伐浣滃彿={}", liftProtocol.getLiftNo(), liftProtocol.getTaskNo());
}
+ }else {
+ LiftAssignCommand assignCommand = liftProtocol.getAssignCommand();
+ if (assignCommand != null) {
+ if (!assignCommand.getAuto()) {
+ //鎵嬪姩鎿嶄綔
+ //璁剧疆鎻愬崌鏈轰负绌洪棽鐘舵��
+ liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE);
+ //浠诲姟鎸囦护娓呴浂
+ liftProtocol.setAssignCommand(null);
+ News.info("鎻愬崌鏈哄凡纭鎵嬪姩鎿嶄綔銆傛彁鍗囨満鍙�={}", liftProtocol.getLiftNo());
+ }
+ }
}
-
}
}
}
@@ -1127,67 +1360,288 @@
//鏌ヨ搴撲綅绉昏浆宸ヤ綔妗�
List<WrkMast> wrkMasts1 = wrkMastMapper.selectLocToLocWrkMast();
for (WrkMast wrkMast : wrkMasts1) {
- boolean step1 = this.locToLocExecuteStep1(wrkMast);//搴撲綅绉昏浆
- if (!step1) {
- continue;
+ if (Utils.getLev(wrkMast.getSourceLocNo()) == Utils.getLev(wrkMast.getLocNo())) {
+ boolean step1 = this.locToLocExecuteStep1(wrkMast);//鍚屾ゼ灞傚簱浣嶇Щ杞�
+ if (!step1) {
+ continue;
+ }
+ }else {
+ //璺ㄦゼ灞傚簱浣嶇Щ杞�
+ boolean step2 = this.locToLocExecuteStep2(wrkMast);//璋冨害杞﹁締鍙栬揣骞惰繍閫佸埌鍑哄簱鍙�
+ if (!step2) {
+ continue;
+ }
+
+ boolean step3 = this.locToLocExecuteStep3(wrkMast);//鎻愬崌鏈烘惉杩愯揣鐗�
+ if (!step3) {
+ continue;
+ }
+
+ boolean step4 = this.locToLocExecuteStep4(wrkMast);//璋冨害杞﹁締鍙栬揣骞惰繍閫佸埌鍑哄簱鍙�
+ if (!step4) {
+ continue;
+ }
+
}
}
}
/**
- * 搴撲綅绉昏浆
+ * 鍚屾ゼ灞傚簱浣嶇Щ杞�
* 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false
* ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue
*/
private boolean locToLocExecuteStep1(WrkMast wrkMast) {
- if (wrkMast.getShuttleNo() == null) {
- shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo());//璋冨害灏忚溅鍒版簮搴撲綅杩涜鍙栬揣
+ if (wrkMast.getWrkSts() == 21) {//21.鐢熸垚鍑哄簱浠诲姟
+ 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(), 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);//21.鐢熸垚鍑哄簱浠诲姟 => 5.灏忚溅鎼繍涓�
+ wrkMast.setModiTime(new Date());
+ if (wrkMastMapper.updateById(wrkMast) > 0) {
+ //涓嬪彂浠诲姟
+ MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand));
+ }
+
return false;
}
+ return true;
+ }
- //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
- NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
- if (shuttleThread == null) {
+ /**
+ * 璺ㄦゼ灞傚簱浣嶇Щ杞�-璋冨害杞﹁締鍙栬揣骞惰繍閫佸埌鍑哄簱鍙�
+ * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false
+ * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue
+ */
+ private boolean locToLocExecuteStep2(WrkMast wrkMast) {
+ if (wrkMast.getWrkSts() == 21) {//21.鐢熸垚鍑哄簱浠诲姟
+ 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;
+ }
+
+ //鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満杈撻�佺珯鐐�
+ LiftStaProtocol liftSta = shuttleDispatchUtils.getRecentLiftSta(shuttleThread.getSlave().getId());
+ if (liftSta == null) {
+ return false;//娌℃湁鍙敤涓旂┖闂茬殑杈撻�佺珯鐐�
+ }
+ //婧愮珯
+ Integer sourceStaNo = liftSta.getStaNo();
+ //鎻愬崌鏈哄彿*100+鐩爣妤煎眰=鐩爣绔欑偣
+ Integer staNo = liftSta.getLiftNo() * 100 + Utils.getLev(wrkMast.getLocNo());//鐩爣绔�
+
+ //灏忚溅宸叉姷杈炬簮搴撲綅锛屽皢璐х墿鎼繍鍒拌緭閫佺珯鐐�
+ NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), liftSta.getLocNo());
+ if (result == null) {//璺緞璁$畻澶辫触
+ return false;
+ }
+
+ //鍒涘缓鍒嗛厤鍛戒护
+ ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
+ assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//鍥涘悜绌挎杞﹀彿
+ assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());//浠诲姟鍙�
+ assignCommand.setTaskMode(ShuttleTaskModeType.SHUTTLE_LOC_TO_LOC.id.shortValue());//搴撲綅绉昏浆妯″紡
+ assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣�(灏忚溅褰撳墠浣嶇疆)
+ assignCommand.setCommands(result.getCommands());//杩愯鍛戒护
+ assignCommand.setNodes(result.getNodes());//璺緞鑺傜偣
+
+ wrkMast.setWrkSts(22L);//21.鐢熸垚鍑哄簱浠诲姟 => 22.灏忚溅鎼繍涓�
+ wrkMast.setSourceStaNo(sourceStaNo);//婧愮珯
+ wrkMast.setStaNo(staNo);//鐩爣绔�
+ wrkMast.setModiTime(new Date());
+ if (wrkMastMapper.updateById(wrkMast) > 0) {
+ //涓嬪彂浠诲姟
+ MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand));
+ }
+
return false;
}
- NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
- if (shuttleProtocol == null) {
+ return true;
+ }
+
+ /**
+ * 璺ㄦゼ灞傚簱浣嶇Щ杞�-鎻愬崌鏈烘惉杩愯揣鐗�
+ * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false
+ * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue
+ */
+ private boolean locToLocExecuteStep3(WrkMast wrkMast) {
+ Date now = new Date();
+ if (wrkMast.getWrkSts() == 23) {//23.灏忚溅鎼繍瀹屾垚
+ //鑾峰彇鎻愬崌鏈虹嚎绋�
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo());
+ if (liftThread == null) {
+ return false;
+ }
+ LiftProtocol liftProtocol = liftThread.getLiftProtocol();
+ if (liftProtocol == null) {
+ return false;
+ }
+
+ if (!liftProtocol.isIdle()) {
+ return false;
+ }
+
+ //鎼滅储鏄惁鏈夊叾浠栦换鍔″崰鐢ㄤ簡鎻愬崌鏈猴紝濡傛灉鍗犵敤鎻愬崌鏈虹殑浠诲姟鍜屽綋鍓嶄换鍔$浉鍚岋紝鍒欒繍琛屾墽琛�
+ WrkMast wrkMast1 = wrkMastMapper.selectLiftWrkMast(liftProtocol.getLiftNo().intValue());
+ if (wrkMast1 != null && wrkMast1.getWrkNo().intValue() != wrkMast.getWrkNo().intValue()) {
+ return false;
+ }
+
+ //婧愮珯
+ Integer sourceStaNo = wrkMast.getSourceStaNo();
+ //鐩爣绔�
+ Integer staNo = wrkMast.getStaNo();
+ if (sourceStaNo == null || staNo == null) {
+ return false;//婧愮珯鎴栫洰鏍囩珯涓虹┖
+ }
+
+ //鑾峰彇鎻愬崌鏈哄懡浠�
+ NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, sourceStaNo, staNo, wrkMast.getWrkNo());
+
+ ArrayList<NyLiftCommand> commands = new ArrayList<>();
+ commands.add(liftCommand);
+
+ //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔
+ LiftAssignCommand assignCommand = new LiftAssignCommand();
+ assignCommand.setCommands(commands);
+ assignCommand.setLiftNo(liftProtocol.getLiftNo());
+ assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());
+ assignCommand.setTaskMode(NyLiftTaskModelType.MOVE_TRAY.id.shortValue());
+
+ wrkMast.setWrkSts(24L);//23.灏忚溅鎼繍瀹屾垚 ==> 24.鎻愬崌鏈烘惉杩愪腑
+ wrkMast.setLiftNo(liftThread.getSlave().getId());//浠诲姟妗g粦瀹氭彁鍗囨満鍙�
+ wrkMast.setShuttleNo(null);//娓呯┖灏忚溅鍙凤紝绛夎揣鐗╂惉杩愬畬鎴愬悗锛屽埌鐩爣妤煎眰閲嶆柊鎼滅储灏忚溅
+ wrkMast.setModiTime(now);
+ if (wrkMastMapper.updateById(wrkMast) > 0) {
+ //涓嬪彂浠诲姟
+ MessageQueue.offer(SlaveType.Lift, liftProtocol.getLiftNo().intValue(), new Task(3, assignCommand));
+ }
return false;
}
- if (!shuttleProtocol.isIdle()) {
+ return true;
+ }
+
+ /**
+ * 璺ㄦゼ灞傚簱浣嶇Щ杞�-璋冨害杞﹁締鍙栬揣骞惰繍閫佸埌鐩爣搴撲綅
+ * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false
+ * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue
+ */
+ private boolean locToLocExecuteStep4(WrkMast wrkMast) {
+ if (wrkMast.getWrkSts() == 4) {//4.鎻愬崌鏈烘惉杩愬畬鎴�
+ //鑾峰彇鐩爣绔欏搴旂殑杈撻�佺珯鐐�
+ BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), wrkMast.getLiftNo());
+ if (targetBasDevp == null) {
+ return false;//缂哄皯绔欑偣淇℃伅
+ }
+
+ if (wrkMast.getShuttleNo() == null) {
+ shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), targetBasDevp.getLocNo());//璋冨害灏忚溅鍒扮洰鏍囪緭閫佺珯鐐硅繘琛屽彇璐�
+ 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(targetBasDevp.getLocNo())) {
+ //灏忚溅涓嶅湪鐩爣杈撻�佺珯鐐�
+ shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), targetBasDevp.getLocNo(), wrkMast.getShuttleNo());//璋冨害灏忚溅鍒扮洰鏍囪緭閫佺珯鐐硅繘琛屽彇璐�
+ return false;
+ }
+
+ //灏忚溅宸叉姷杈剧洰鏍囪緭閫佺珯鐐癸紝灏嗚揣鐗╂惉杩愬埌鐩爣搴撲綅
+ NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), targetBasDevp.getLocNo(), wrkMast.getLocNo());
+ if (result == null) {//璺緞璁$畻澶辫触
+ return false;
+ }
+
+ //鍒涘缓鍒嗛厤鍛戒护
+ ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
+ assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//鍥涘悜绌挎杞﹀彿
+ assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());//浠诲姟鍙�
+ assignCommand.setTaskMode(ShuttleTaskModeType.SHUTTLE_LOC_TO_LOC.id.shortValue());//搴撲綅绉昏浆妯″紡
+ assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣�(灏忚溅褰撳墠浣嶇疆)
+ assignCommand.setCommands(result.getCommands());//杩愯鍛戒护
+ assignCommand.setNodes(result.getNodes());//璺緞鑺傜偣
+
+ wrkMast.setWrkSts(5L);//4.鎻愬崌鏈烘惉杩愬畬鎴� => 5.灏忚溅鎼繍涓�
+ wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈�
+ wrkMast.setModiTime(new Date());
+ if (wrkMastMapper.updateById(wrkMast) > 0) {
+ //涓嬪彂浠诲姟
+ MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand));
+ }
+
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;
}
@@ -1197,6 +1651,7 @@
public void recErr() {
try {
this.recShuttleErr();
+ this.recLiftErr();
} catch (Exception e) {
News.error("recErr fail", e);
}
@@ -1228,7 +1683,7 @@
if (wrkMast == null) {
continue;
}
- BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(shuttleProtocol.getErrCode().get(0));
+ BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(shuttleProtocol.getErrCode());
String errName = basShuttleErr==null? "鏈煡寮傚父":basShuttleErr.getErrName();
BasShuttleErrLog basShuttleErrLog = new BasShuttleErrLog(
null, // 缂栧彿
@@ -1244,14 +1699,15 @@
wrkMast.getSourceStaNo(), // 婧愮珯
wrkMast.getSourceLocNo(), // 婧愬簱浣�
wrkMast.getBarcode(), // 鏉$爜
- shuttleProtocol.getErrCode().get(0), // 寮傚父鐮�
+ shuttleProtocol.getErrCode(), // 寮傚父鐮�
errName, // 寮傚父
1, // 寮傚父鎯呭喌
now, // 娣诲姞鏃堕棿
null, // 娣诲姞浜哄憳
now, // 淇敼鏃堕棿
null, // 淇敼浜哄憳
- "浠诲姟涓紓甯�" // 澶囨敞
+ "浠诲姟涓紓甯�", // 澶囨敞
+ JSON.toJSONString(shuttleProtocol) // 绯荤粺鐘舵�佹暟鎹�
);
if (!basShuttleErrLogService.insert(basShuttleErrLog)) {
News.error("鍥涘悜绌挎杞lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", shuttleSlave.getId(), errName);
@@ -1320,6 +1776,91 @@
}
}
+ /**
+ * 鎻愬崌鏈哄紓甯镐俊鎭褰�
+ */
+ private void recLiftErr() {
+ Date now = new Date();
+ for (LiftSlave liftSlave : slaveProperties.getLift()) {
+ // 鑾峰彇鎻愬崌鏈轰俊鎭�
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId());
+ if (liftThread == null) {
+ continue;
+ }
+ LiftProtocol liftProtocol = liftThread.getLiftProtocol();
+ if (liftProtocol == null) {
+ continue;
+ }
+
+ if (liftProtocol.getTaskNo() != 0) {
+ //鏈変换鍔�
+ BasLiftErrLog latest = basLiftErrLogService.findLatestByTaskNo(liftSlave.getId(), liftProtocol.getTaskNo().intValue());
+ // 鏈夊紓甯�
+ if (latest == null) {
+ if (liftProtocol.getDeviceError() != null && liftProtocol.getDeviceError()) {
+ WrkMast wrkMast = wrkMastMapper.selectById(liftProtocol.getTaskNo());
+ if (wrkMast == null) {
+ continue;
+ }
+
+ String errName = "";
+ if (liftProtocol.getFrontOverrun()) {
+ errName = "鍓嶈秴闄�";
+ } else if (liftProtocol.getBackOverrun()) {
+ errName = "鍚庤秴闄�";
+ } else if (liftProtocol.getLeftOverrun()) {
+ errName = "宸﹁秴闄�";
+ } else if (liftProtocol.getRightOverrun()) {
+ errName = "鍙宠秴闄�";
+ } else if (liftProtocol.getOverHeight()) {
+ errName = "瓒呴珮";
+ } else if (liftProtocol.getOverWeight()) {
+ errName = "瓒呴噸";
+ }
+
+ BasLiftErrLog basLiftErrLog = new BasLiftErrLog(
+ null, // 缂栧彿
+ wrkMast.getWrkNo(), // 宸ヤ綔鍙�
+ now, // 鍙戠敓鏃堕棿
+ null, // 缁撴潫鏃堕棿
+ wrkMast.getWrkSts(), // 宸ヤ綔鐘舵��
+ wrkMast.getIoType(), // 鍏ュ嚭搴撶被鍨�
+ liftSlave.getId(), // 鎻愬崌鏈�
+ null, // plc
+ wrkMast.getLocNo(), // 鐩爣搴撲綅
+ wrkMast.getStaNo(), // 鐩爣绔�
+ wrkMast.getSourceStaNo(), // 婧愮珯
+ wrkMast.getSourceLocNo(), // 婧愬簱浣�
+ wrkMast.getBarcode(), // 鏉$爜
+ null, // 寮傚父鐮�
+ errName, // 寮傚父
+ 1, // 寮傚父鎯呭喌
+ now, // 娣诲姞鏃堕棿
+ null, // 娣诲姞浜哄憳
+ now, // 淇敼鏃堕棿
+ null, // 淇敼浜哄憳
+ "浠诲姟涓紓甯�", // 澶囨敞
+ JSON.toJSONString(liftProtocol) // 绯荤粺鐘舵�佹暟鎹�
+ );
+ if (!basLiftErrLogService.insert(basLiftErrLog)) {
+ News.error("鎻愬崌鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", liftSlave.getId(), errName);
+ }
+ }
+ } else {
+ // 寮傚父淇
+ if (liftProtocol.getDeviceError() == null || !liftProtocol.getDeviceError()) {
+ latest.setEndTime(now);
+ latest.setUpdateTime(now);
+ latest.setStatus(2);
+ if (!basLiftErrLogService.updateById(latest)) {
+ News.error("鎻愬崌鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", liftSlave.getId(), latest.getId());
+ }
+ }
+ }
+ }
+ }
+ }
+
// -------------------------------------------------------------------------------
/**
@@ -1358,6 +1899,13 @@
}
}
+ if (!Cools.isEmpty(barcode)) {
+ WrkMast wrkMast = wrkMastMapper.selectByBarcode(barcode);//鏉$爜瀛樺湪宸ヤ綔妗�
+ if (wrkMast != null) {
+ continue;
+ }
+ }
+
LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed());
try {
@@ -1380,15 +1928,15 @@
Integer code = jsonObject.getInteger("code");
if (code.equals(200)) {
StartupDto dto = jsonObject.getObject("data", StartupDto.class);
-
- // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
- staProtocol.setWorkNo(dto.getWorkNo().shortValue());
- staProtocol.setStaNo(dto.getStaNo().shortValue());
- devpThread.setPakMk(staProtocol.getSiteId(), false);
- boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
- if (!result) {
- throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
- }
+ barcodeThread.setBarcode("");
+// // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
+// staProtocol.setWorkNo(dto.getWorkNo().shortValue());
+// staProtocol.setStaNo(dto.getStaNo().shortValue());
+// devpThread.setPakMk(staProtocol.getSiteId(), false);
+// boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+// if (!result) {
+// throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+// }
} else {
if (ledThread != null) {
String errorMsg = jsonObject.getString("msg");
@@ -1406,6 +1954,97 @@
}
+ }
+ }
+ }
+
+ /**
+ * AGV琛ヨ揣 => 鏈烘鑷傛嫞鏂�
+ */
+ public void agvRestockByRobot() {
+ //妫�娴�300绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗┿�佸伐浣滃彿
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ // 鑾峰彇鍏ュ簱绔欎俊鎭�
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ StaProtocol staProtocol = devpThread.getStation().get(300);
+ if (staProtocol == null) {
+ continue;
+ }
+ if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() != 0) {
+ //鏌ヨ鏄惁鏈夊伐浣滄。
+ WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue());
+ if (wrkMast == null) {
+ continue;
+ }
+
+ if (wrkMast.getWrkSts() != 25) {//25.鎻愬崌鏈烘惉杩愬畬鎴�
+ continue;
+ }
+
+ if (wrkMast.getMk() != null && wrkMast.getMk().equals("Y")) {//鏍囪涓篩琛ㄧず闇�瑕佺敤鍒版満姊拌噦鎷f枡
+ Short targetSta = null;//鐩爣绔�
+ //鍒ゆ柇鏈烘鑷傛嫞鏂欑珯鏄惁绌洪棽
+ StaProtocol staProtocol303 = devpThread.getStation().get(303);
+ StaProtocol staProtocol317 = devpThread.getStation().get(317);
+ if (staProtocol303.isAutoing() && !staProtocol303.isLoading()) {
+ //鑷姩銆佹棤鐗�
+ targetSta = (short) 303;
+ } else if (staProtocol317.isAutoing() && !staProtocol317.isLoading()) {
+ //鑷姩銆佹棤鐗�
+ targetSta = (short) 317;
+ }else {
+ continue;//娌℃湁绌洪棽绔欑偣
+ }
+
+ targetSta = (short) 317;
+
+ if (wrkMast.getStaNo() != 303 && wrkMast.getStaNo() != 317) {
+ //瑕嗙洊宸ヤ綔妗g洰鏍囩珯
+ wrkMast.setStaNo(targetSta.intValue());
+ if (wrkMastMapper.updateById(wrkMast) > 0) {
+ //鍚�300绔欏啓鍏ョ洰鏍囩珯
+ staProtocol = staProtocol.clone();
+ staProtocol.setStaNo(targetSta);//绉诲姩鍒扮洰鏍囩珯
+ boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ try {
+ Thread.sleep(500);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ continue;
+ }
+ }
+ }
+ }
+
+ StaProtocol staProtocol303 = devpThread.getStation().get(303);
+ StaProtocol staProtocol317 = devpThread.getStation().get(317);
+ if (staProtocol303.isAutoing() && staProtocol303.isLoading() && staProtocol303.getWorkNo() != 0) {
+ //璋冨害鏈烘鑷�
+// //鏌ヨ鏄惁鏈夊伐浣滄。
+// WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol303.getWorkNo().intValue());
+// if (wrkMast == null) {
+// continue;
+// }
+// WrkDetl wrkDetl = wrkDetlService.selectById(wrkMast.getWrkNo());
+// if (wrkDetl == null) {
+// continue;
+// }
+// RobotUtils.sendTask(staProtocol303.getWorkNo().toString(), wrkDetl.getAnfme().intValue(), "303");
+ RobotUtils.sendTask(staProtocol303.getWorkNo().toString(), -1, "303");
+ }else if (staProtocol317.isAutoing() && staProtocol317.isLoading() && staProtocol317.getWorkNo() != 0) {
+ //璋冨害鏈烘鑷�
+// //鏌ヨ鏄惁鏈夊伐浣滄。
+// WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol317.getWorkNo().intValue());
+// if (wrkMast == null) {
+// continue;
+// }
+// WrkDetl wrkDetl = wrkDetlService.selectById(wrkMast.getWrkNo());
+// if (wrkDetl == null) {
+// continue;
+// }
+// RobotUtils.sendTask(staProtocol303.getWorkNo().toString(), wrkDetl.getAnfme().intValue(), "317");
+ RobotUtils.sendTask(staProtocol303.getWorkNo().toString(), -1, "317");
}
}
}
@@ -1596,11 +2235,39 @@
continue;
}
+ //灏忚溅鎵�鍦ㄦゼ灞�
+ int lev = Utils.getLev(shuttleProtocol.getCurrentLocNo());
ShuttleChargeType shuttleCharge = null;
+
+ //鎼滅储灏忚溅鎵�鍦ㄦゼ灞傛湁娌℃湁鍏呯數妗�
for (ShuttleChargeType chargeType : ShuttleChargeType.values()) {
+ if (lev != Utils.getLev(chargeType.locNo)) {
+ continue;//灏忚溅鍜屽厖鐢垫々涓嶅湪鍚屼竴灞�
+ }
+
+ //灏忚溅鍜屽厖鐢垫々鍦ㄥ悓涓�灞�
if (wrkChargeService.selectWorkingOfCharge(chargeType.id) == null) {
shuttleCharge = chargeType;
break;
+ }
+ }
+
+ if (shuttleCharge == null) {
+ //鍚屾ゼ灞傛病鏈夋壘鍒板厖鐢垫々锛屾壘鍙敤鍏呯數妗�
+ //灏忚溅鍚屾ゼ灞傛病鏈夊厖鐢垫々锛屽彧瑕佸厖鐢垫々鍙敤灏辩敓鎴愬厖鐢典换鍔�
+ for (ShuttleChargeType chargeType : ShuttleChargeType.values()) {
+ if (wrkChargeService.selectWorkingOfCharge(chargeType.id) == null) {
+ //鍒ゆ柇褰撳墠鍏呯數妗╂ゼ灞傛槸鍚︽湁灏忚溅锛屽鏈夊皬杞︼紝涓嶅垎閰嶈鍏呯數妗�
+ int chargeLev = Utils.getLev(chargeType.locNo);//鍏呯數妗╂ゼ灞�
+ boolean checkLevHasShuttle = Utils.checkLevHasShuttle(chargeLev);//妫�娴嬫ゼ灞傛槸鍚︽湁绌挎杞�
+ if (checkLevHasShuttle) {
+ //褰撳墠鍏呯數妗╂ゼ灞傛湁绌挎杞︼紝涓嶅垎閰嶈鍏呯數妗�
+ continue;
+ }
+
+ shuttleCharge = chargeType;
+ break;
+ }
}
}
@@ -1623,7 +2290,6 @@
continue;
}
- shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.CHARGING);//鍏呯數涓�
News.info("淇濆瓨{}鍙峰洓鍚戠┛姊溅鍏呯數浠诲姟鎴愬姛!!!", shuttle.getId());
}
}
@@ -1648,6 +2314,10 @@
}
if (wrkCharge.getWrkSts() == 51) {
+ if (!shuttleProtocol.isIdleNoCharge()) {
+ continue;
+ }
+
if (!shuttleProtocol.getCurrentLocNo().equals(wrkCharge.getLocNo())) {
//灏忚溅涓嶅湪鍏呯數妗╀綅缃�
shuttleDispatchUtils.dispatchShuttle(wrkCharge.getWrkNo(), wrkCharge.getLocNo(), shuttle.getId());//璋冨害灏忚溅鍘诲厖鐢垫々
@@ -1674,7 +2344,8 @@
}
} else if (wrkCharge.getWrkSts() == 52) {
//妫�娴嬪皬杞︽槸鍚︽弧鐢�
- if (shuttleProtocol.getPowerPercent() < 100) {
+ int maxPower = 95;
+ if (shuttleProtocol.getPowerPercent() < maxPower) {
continue;
}
@@ -1690,21 +2361,34 @@
assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣�(灏忚溅褰撳墠浣嶇疆)
assignCommand.setCommands(commands);//杩愯鍛戒护
+ //涓嬪彂浠诲姟
+ MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand));
+ try {
+ Thread.sleep(3000);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
wrkCharge.setWrkSts(53L);//52.灏忚溅鍘诲厖鐢典腑 => 53.灏忚溅鍏呯數瀹屾垚
wrkCharge.setModiTime(new Date());
if (wrkChargeMapper.updateById(wrkCharge) > 0) {
- //涓嬪彂浠诲姟
- MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand));
+ shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE.id);
+ shuttleProtocol.setTaskNo(0);
+ shuttleProtocol.setPakMk(false);
}
} else if (wrkCharge.getWrkSts() == 53) {
- boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkCharge.getLocNo()), shuttleThread.getSlave().getId(), shuttleThread);
- if (!result) {
- continue;
- }
+ if (shuttleProtocol.getChargState() == 0) {//灏忚溅澶勪簬鏈厖鐢电姸鎬�
+ boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkCharge.getLocNo()), shuttleThread.getSlave().getId(), shuttleThread);
+ if (!result) {
+ continue;
+ }
- wrkCharge.setWrkSts(60L);//53.灏忚溅鍏呯數瀹屾垚 => 60.鍏呯數浠诲姟瀹屾垚
- wrkCharge.setModiTime(new Date());
- wrkChargeMapper.updateById(wrkCharge);
+ wrkCharge.setWrkSts(60L);//53.灏忚溅鍏呯數瀹屾垚 => 60.鍏呯數浠诲姟瀹屾垚
+ wrkCharge.setModiTime(new Date());
+ if (wrkChargeMapper.updateById(wrkCharge) > 0) {
+
+ }
+ }
}
}
@@ -1718,38 +2402,46 @@
//鏌ヨ灏忚溅绉诲簱浠诲姟
List<WrkMast> wrkMasts = wrkMastMapper.selectShuttleMoveWrk();
for (WrkMast wrkMast : wrkMasts) {
- boolean step1 = this.shuttleMoveExecuteStep1(wrkMast);//灏忚溅绉诲姩鍒版彁鍗囨満涓�
- if (!step1) {
+ boolean stepMoveSta = this.shuttleMoveExecuteStepMoveSta(wrkMast);//灏忚溅绉诲姩鍒扮珯鐐�
+ if (!stepMoveSta) {
continue;
}
- boolean step2 = this.shuttleMoveExecuteStep2(wrkMast);//鎻愬崌鏈烘惉杩愪腑
- if (!step2) {
+ boolean stepIntoLift = this.shuttleMoveExecuteStepIntoLift(wrkMast);//灏忚溅杩佸叆鎻愬崌鏈�
+ if (!stepIntoLift) {
continue;
}
- boolean step3 = this.shuttleMoveExecuteStep3(wrkMast);//灏忚溅杩佸嚭鎻愬崌鏈轰腑
- if (!step3) {
+ boolean stepLiftMove = this.shuttleMoveExecuteStepLiftMove(wrkMast);//鎻愬崌鏈烘惉杩愪腑
+ if (!stepLiftMove) {
continue;
}
- boolean step4 = this.shuttleMoveExecuteStep4(wrkMast);//灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑
- if (!step4) {
+ boolean stepOutLift = this.shuttleMoveExecuteStepOutLift(wrkMast);//灏忚溅杩佸嚭鎻愬崌鏈�
+ if (!stepOutLift) {
continue;
}
+
+ boolean stepMoveLoc = this.shuttleMoveExecuteStepMoveLoc(wrkMast);//灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑
+ if (!stepMoveLoc) {
+ continue;
+ }
+
+// this.shuttleMoveExecuteStepClearWrkMast(wrkMast);//娓呯悊111.灏忚溅绉诲姩瀹屾垚
+
}
}
/**
- * 灏忚溅杩佺Щ-灏忚溅绉诲姩鍒版彁鍗囨満涓�
+ * 灏忚溅杩佺Щ-灏忚溅绉诲姩鍒扮珯鐐�
* 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false
* ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue
*/
- private boolean shuttleMoveExecuteStep1(WrkMast wrkMast) {
- //--------------------------------------灏忚溅绉诲姩鍒版彁鍗囨満涓�-----------------------------------------//
+ private boolean shuttleMoveExecuteStepMoveSta(WrkMast wrkMast) {
+ //--------------------------------------灏忚溅绉诲姩鑷崇珯鐐�-----------------------------------------//
Date now = new Date();
- //灏忚溅绉诲姩鍒版彁鍗囨満涓� 101.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 102.灏忚溅鍒版彁鍗囨満涓�
+ //灏忚溅绉诲姩鑷崇珯鐐� 101.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 102.灏忚溅绉诲姩鑷崇珯鐐逛腑
if (wrkMast.getWrkSts() == 101) {
//鑾峰彇鍥涘悜绌挎杞︾嚎绋�
NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
@@ -1762,76 +2454,42 @@
}
//灏忚溅澶勪簬绌洪棽鐘舵��
- if (!shuttleProtocol.isIdleNoCharge()) {
+ if (!shuttleProtocol.isIdleNoCharge(wrkMast.getWrkNo())) {
return false;
}
+ //鍒ゆ柇灏忚溅浠ょ墝鏄惁鏈鍗犻
+ if (shuttleProtocol.getToken() != 0) {
+ return false;//灏忚溅宸茶鐙崰锛岀姝㈠啀娲惧彂浠诲姟
+ }
+
if (Utils.getLev(wrkMast.getLocNo()) == shuttleProtocol.getPoint().getZ()) {
- //鐩爣搴撲綅鍜屽皬杞﹀簱浣嶅浜庡悓涓�妤煎眰锛岄渶瑕侀�氳繃鎻愬崌鏈鸿皟搴�
- return true;//鐩存帴杩涘叆108.灏忚溅绉诲姩涓�
+ //鐩爣搴撲綅鍜屽皬杞﹀簱浣嶅浜庡悓涓�妤煎眰锛屼笉闇�瑕侀�氳繃鎻愬崌鏈鸿皟搴�
+ wrkMast.setWrkSts(109L);// 109.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� ==> 110.灏忚溅绉诲姩涓�
+ wrkMast.setModiTime(now);
+ shuttleProtocol.setToken(wrkMast.getWrkNo());//鐙崰璇ュ皬杞︿护鐗�
+ if (wrkMastMapper.updateById(wrkMast) > 0) {
+ //涓嬪彂浠诲姟
+ return true;//鐩存帴杩涘叆109.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� ==> 110.灏忚溅绉诲姩涓�
+ }
+ return false;
}
- //璁$畻璺濈灏忚溅鏈�杩戠殑鎻愬崌鏈虹珯鐐�
- //鏌ヨ灏忚溅鎵�鍦ㄦゼ灞傛彁鍗囨満杈撻�佺珯鐐�
- int recentAllDistance = 9999999;//榛樿鏈�杩戣窛绂�
- BasDevp recentDevp = null;//鏈�杩戠珯鐐�
- List<BasDevp> basDevps = basDevpService.selectHasLiftNoByLev(shuttleProtocol.getPoint().getZ());
- for (BasDevp basDevp : basDevps) {
- LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, basDevp.getLiftNo());
- if (liftThread == null) {
- continue;
- }
- LiftProtocol liftProtocol = liftThread.getLiftProtocol();
- if (liftProtocol == null) {
- continue;
- }
- if (!liftProtocol.isIdle()) {
- continue;
- }
-
- //璁$畻璺緞
- List<NavigateNode> calc = NavigateUtils.calc(shuttleProtocol.getCurrentLocNo(), basDevp.getLocNo(), NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleThread.getSlave().getId(), Utils.getLev(shuttleProtocol.getCurrentLocNo())));
- if (calc == null) {
- continue;//璁$畻澶辫触锛屾壘涓嬩竴涓珯鐐�
- }
-
- Integer allDistance = NavigateUtils.getOriginPathAllDistance(calc);//鏍规嵁鍘熷鑺傜偣缁撴灉锛岃绠楁�昏璧拌窛绂�
- if (recentAllDistance > allDistance) {
- recentAllDistance = allDistance;//鏇存柊璺濈
- recentDevp = basDevp;//鏇存柊杈撻�佺珯鐐�
- }
+ //鑾峰彇婧愯緭閫佺珯
+ LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo());
+ if (liftSta == null) {
+ return false;//鎵句笉鍒扮珯鐐�
}
- if (recentDevp == null) {
- //娌℃湁鎵惧埌鍙敤杈撻�佺珯鐐�
- return false;//绛夊緟涓嬩竴娆¤疆璇�
- }
-
- //鑾峰彇鎻愬崌鏈烘暟鎹�
- BasLift basLift = basLiftService.selectById(recentDevp.getLiftNo());
- if (basLift == null) {
- return false;//娌℃湁鎻愬崌鏈烘暟鎹�
- }
- if (basLift.getPoint() == null) {
- return false;//娌℃湁璁剧疆鎻愬崌鏈虹偣浣嶅潗鏍�
- }
- //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟
- WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(basLift.getLiftNo());
+ //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟(璇ヤ换鍔¢渶瑕佹崲灞傚繀椤绘彁鍓嶇嫭鍗犳彁鍗囨満)
+ WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(liftSta.getLiftNo());
if (liftWrkMast != null) {
return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇�
}
- NavigateNode liftNode = new NavigateNode(basLift.getPoint().getX(), basLift.getPoint().getY());
- liftNode.setZ(basLift.getPoint().getZ());
//鑾峰彇灏忚溅鍒拌緭閫佺珯鐐硅璧板懡浠�
- NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), recentDevp.getLocNo());
- //鑾峰彇灏忚溅杩涙彁鍗囨満琛岃蛋鍛戒护
- NyShuttleHttpCommand moveCommand = NyHttpUtils.getInOutLiftCommand(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), NavigatePositionConvert.locNoToNode(recentDevp.getLocNo()), liftNode, true);
- if (result.getCommands() == null) {
- return false;//璺緞璁$畻澶辫触
- }
+ NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id);
List<NyShuttleHttpCommand> commands = result.getCommands();
- commands.add(moveCommand);//娣诲姞灏忚溅杩佸叆鎻愬崌鏈哄懡浠�
ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙�
@@ -1841,30 +2499,62 @@
assignCommand.setCommands(commands);
assignCommand.setNodes(result.getNodes());
- wrkMast.setWrkSts(102L);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 101.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 102.灏忚溅鍒版彁鍗囨満涓�
- wrkMast.setLiftNo(basLift.getLiftNo());//鎻愬崌鏈哄彿(閿佸畾鎻愬崌鏈洪槻姝㈣鍏朵粬浠诲姟鎶㈠崰)
+ wrkMast.setWrkSts(102L);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 101.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 102.灏忚溅绉诲姩鑷崇珯鐐�
wrkMast.setModiTime(now);
+ wrkMast.setLiftNo(liftSta.getLiftNo());//鎻愬墠閿佸畾鎻愬崌鏈�
+ shuttleProtocol.setToken(wrkMast.getWrkNo());//鐙崰璇ュ皬杞︿护鐗�
if (wrkMastMapper.updateById(wrkMast) > 0) {
//涓嬪彂浠诲姟
MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand));
+ return false;
}
+ return false;
}
return true;
}
/**
- * 灏忚溅杩佺Щ-鎻愬崌鏈烘惉杩愪腑
+ * 灏忚溅杩佺Щ-灏忚溅杩佸叆鎻愬崌鏈�
* 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false
* ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue
*/
- private boolean shuttleMoveExecuteStep2(WrkMast wrkMast) {
- //--------------------------------------鎻愬崌鏈烘惉杩愪腑-----------------------------------------//
+ private boolean shuttleMoveExecuteStepIntoLift(WrkMast wrkMast) {
+ //--------------------------------------灏忚溅杩佸叆鎻愬崌鏈�-----------------------------------------//
Date now = new Date();
- //鎻愬崌鏈烘惉杩愪腑 103.灏忚溅鍒版彁鍗囨満瀹屾垚 ==> 104.鎻愬崌鏈烘惉杩愪腑
+ //灏忚溅绉诲姩鍒版彁鍗囨満涓� 103.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 104.灏忚溅杩佸叆鎻愬崌鏈轰腑
if (wrkMast.getWrkSts() == 103) {
+ //鑾峰彇婧愮珯
+ LiftStaProtocol sourceLiftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo());
+ if (sourceLiftSta == null) {
+ return false;//鎵句笉鍒扮珯鐐�
+ }
- LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo());
+ //鑾峰彇鐩爣杈撻�佺珯
+ LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
+ if (liftSta == null) {
+ return false;//鎵句笉鍒扮珯鐐�
+ }
+
+ //鑾峰彇鎻愬崌鏈烘暟鎹�
+ BasLift basLift = basLiftService.selectById(liftSta.getLiftNo());
+ if (basLift == null) {
+ return false;//娌℃湁鎻愬崌鏈烘暟鎹�
+ }
+
+ if (basLift.getPoint() == null) {
+ return false;//娌℃湁璁剧疆鎻愬崌鏈虹偣浣嶅潗鏍�
+ }
+
+ //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟
+ WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(basLift.getLiftNo());
+ if (liftWrkMast != null) {
+ if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚�
+ return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇�
+ }
+ }
+
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSta.getLiftNo());
if (liftThread == null) {
return false;
}
@@ -1872,6 +2562,7 @@
if (liftProtocol == null) {
return false;
}
+
if (!liftProtocol.isIdle(wrkMast.getWrkNo().shortValue())) {
return false;
}
@@ -1887,53 +2578,116 @@
}
//灏忚溅澶勪簬绌洪棽鐘舵��
- if (!shuttleProtocol.isIdleNoCharge()) {
+ if (!shuttleProtocol.isIdleNoCharge(wrkMast.getWrkNo())) {
return false;
}
- //鑾峰彇婧愮珯瀵瑰簲鐨勮緭閫佺珯鐐�
- BasDevp sourceBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getSourceLocNo()), liftProtocol.getLiftNo().intValue());
- //鑾峰彇鐩爣绔欏搴旂殑杈撻�佺珯鐐�
- BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), liftProtocol.getLiftNo().intValue());
- if (sourceBasDevp == null || targetBasDevp == null) {
- return false;//缂哄皯绔欑偣淇℃伅
+ //灏忚溅浠ょ墝鏄惁琚换鍔$嫭鍗�
+ if (!shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) {
+ return false;
}
- //鑾峰彇鎻愬崌鏈哄懡浠�
- NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_CAR.id, sourceBasDevp.getDevNo(), targetBasDevp.getDevNo(), wrkMast.getWrkNo());
+ //鍒ゆ柇鎻愬崌鏈烘ゼ灞�
+ if (liftProtocol.getLev().intValue() != shuttleProtocol.getPoint().getZ()) {
+ //鎻愬崌鏈轰笉鍦ㄥ皬杞︽ゼ灞�
+ //璋冨害鎻愬崌鏈�
- ArrayList<NyLiftCommand> commands = new ArrayList<>();
- commands.add(liftCommand);
+ if (liftProtocol.getToken() != 0) {
+ return false;//鎻愬崌鏈轰护鐗岃鍗犵敤
+ }
- //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔
- LiftAssignCommand assignCommand = new LiftAssignCommand();
+ //鑾峰彇鎻愬崌鏈哄懡浠わ紝璋冨害鎻愬崌鏈哄埌婧愮珯浣嶇疆
+ NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_CAR.id, sourceLiftSta.getStaNo(), sourceLiftSta.getStaNo(), wrkMast.getWrkNo());
+
+ Random random = new Random();
+ int deviceWrk = Math.abs((liftCommand.getTaskNo().intValue() + random.nextInt(9999)));//鑾峰彇璁惧宸ヤ綔鍙�
+ liftCommand.setTaskNo((short) deviceWrk);//鏇存崲闅忔満浠诲姟鍙�
+
+ ArrayList<NyLiftCommand> commands = new ArrayList<>();
+ commands.add(liftCommand);
+
+ //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔
+ LiftAssignCommand assignCommand = new LiftAssignCommand();
+ assignCommand.setCommands(commands);
+ assignCommand.setLiftNo(liftProtocol.getLiftNo());
+ assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());
+ assignCommand.setTaskMode(NyLiftTaskModelType.MOVE_CAR.id.shortValue());
+ assignCommand.setAuto(false);
+
+ wrkMast.setLiftNo(liftThread.getSlave().getId());//閿佸畾鎻愬崌鏈洪槻姝㈣鍗犵敤
+ wrkMast.setModiTime(now);
+ liftProtocol.setToken(wrkMast.getShuttleNo());//鎻愬崌鏈轰护鐗岀粦瀹氬綋鍓嶅皬杞�
+ if (wrkMastMapper.updateById(wrkMast) > 0) {
+ //涓嬪彂浠诲姟
+ MessageQueue.offer(SlaveType.Lift, liftProtocol.getLiftNo().intValue(), new Task(3, assignCommand));
+ }
+ return false;//绛夊緟鎻愬崌鏈哄埌灏忚溅妤煎眰
+ }
+
+ if (liftProtocol.getToken() == 0) {//鎻愬崌鏈轰护鐗屾湭琚崰鐢�
+ //鐙崰鎻愬崌鏈�
+ liftProtocol.setToken(wrkMast.getShuttleNo());
+ return false;//绛夊緟涓嬩竴娆℃墽琛�
+ }
+
+ //鍒ゆ柇鎻愬崌鏈轰护鐗屾槸鍚︿负褰撳墠灏忚溅
+ if (!liftProtocol.getToken().equals(wrkMast.getShuttleNo())) {
+ return false;//鎻愬崌鏈哄凡琚嫭鍗狅紝绂佹鍐嶆淳鍙戜换鍔�
+ }
+
+ //鍒ゆ柇灏忚溅鏄惁涓哄綋鍓嶄换鍔$嫭鍗�
+ if (!shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) {
+ return false;
+ }
+
+ //绔欑偣鑺傜偣
+ NavigateNode staNode = NavigatePositionConvert.locNoToNode(sourceLiftSta.getLocNo());
+
+ //鎻愬崌鏈鸿妭鐐�
+ NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY());
+ liftNode.setZ(staNode.getZ());
+
+ //鑾峰彇灏忚溅杩涙彁鍗囨満琛岃蛋鍛戒护
+ NyShuttleHttpCommand moveCommand = NyHttpUtils.getInOutLiftCommand(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), staNode, liftNode, true);
+ List<NyShuttleHttpCommand> commands = new ArrayList<>();
+ commands.add(moveCommand);
+ List<NavigateNode> nodes = new ArrayList<>();//琛岃蛋鑺傜偣璺緞
+ nodes.add(staNode);
+ nodes.add(liftNode);
+
+ ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
+ assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙�
+ assignCommand.setTaskMode(ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO.id.shortValue());//灏忚溅绉诲簱浠诲姟
+ assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());//浠诲姟鍙�
+ assignCommand.setAuto(true);//鑷姩妯″紡
assignCommand.setCommands(commands);
- assignCommand.setLiftNo(liftProtocol.getLiftNo());
- assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());
- assignCommand.setTaskMode(NyLiftTaskModelType.MOVE_CAR.id.shortValue());
+ assignCommand.setNodes(nodes);
- wrkMast.setWrkSts(104L);//鎻愬崌鏈烘惉杩愪腑 103.灏忚溅鍒版彁鍗囨満瀹屾垚 ==> 104.鎻愬崌鏈烘惉杩愪腑
- wrkMast.setLiftNo(liftThread.getSlave().getId());//閿佸畾鎻愬崌鏈洪槻姝㈣鍗犵敤
+ wrkMast.setWrkSts(104L);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 103.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 104.灏忚溅杩佸叆鎻愬崌鏈轰腑
wrkMast.setModiTime(now);
+ wrkMast.setLiftNo(liftThread.getSlave().getId());//閿佸畾鎻愬崌鏈洪槻姝㈣鍗犵敤
+ liftProtocol.setToken(wrkMast.getShuttleNo());//鎻愬崌鏈轰护鐗岀粦瀹氬綋鍓嶅皬杞�
if (wrkMastMapper.updateById(wrkMast) > 0) {
//涓嬪彂浠诲姟
- MessageQueue.offer(SlaveType.Lift, liftProtocol.getLiftNo().intValue(), new Task(3, assignCommand));
+ MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand));
+ return false;
}
-
+ return false;
}
+
return true;
}
/**
- * 灏忚溅杩佺Щ-灏忚溅杩佸嚭鎻愬崌鏈轰腑
+ * 灏忚溅杩佺Щ-鎻愬崌鏈烘惉杩愪腑
* 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false
* ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue
*/
- private boolean shuttleMoveExecuteStep3(WrkMast wrkMast) {
- //--------------------------------------灏忚溅杩佸嚭鎻愬崌鏈轰腑-----------------------------------------//
+ private boolean shuttleMoveExecuteStepLiftMove(WrkMast wrkMast) {
+ //--------------------------------------鎻愬崌鏈烘惉杩愪腑-----------------------------------------//
Date now = new Date();
- //灏忚溅杩佸嚭鎻愬崌鏈轰腑 105.鎻愬崌鏈烘惉杩愬畬鎴� ==> 106.灏忚溅杩佸嚭鎻愬崌鏈轰腑
+ //鎻愬崌鏈烘惉杩愪腑 105.灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� ==> 106.鎻愬崌鏈烘惉杩愪腑
if (wrkMast.getWrkSts() == 105) {
LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo());
@@ -1947,6 +2701,23 @@
if (!liftProtocol.isIdle(wrkMast.getWrkNo().shortValue())) {
return false;
}
+ //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟
+ WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(liftThread.getSlave().getId());
+ if (liftWrkMast != null) {
+ if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚�
+ return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇�
+ }
+ }
+
+ //鍒ゆ柇鎻愬崌鏈轰护鐗屾槸鍚︿负褰撳墠灏忚溅
+ if (!liftProtocol.getToken().equals(wrkMast.getShuttleNo())) {
+ return false;//鎻愬崌鏈轰护鐗屽拰褰撳墠灏忚溅涓嶄竴鑷达紝绂佹娲惧彂
+ }
+
+ //鍒ゆ柇鎻愬崌鏈哄唴鏄惁鏈夊皬杞�
+ if (!liftProtocol.getHasCar()) {
+ return false;//鎻愬崌鏈哄唴鏃犲皬杞�
+ }
//鑾峰彇鍥涘悜绌挎杞︾嚎绋�
NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
@@ -1963,26 +2734,124 @@
return false;
}
- //鑾峰彇鐩爣绔欏搴旂殑杈撻�佺珯鐐�
- BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), liftProtocol.getLiftNo().intValue());
- if (targetBasDevp == null) {
+ //鍒ゆ柇灏忚溅鏄惁涓哄綋鍓嶄换鍔$嫭鍗�
+ if (!shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) {
+ return false;
+ }
+
+ //鑾峰彇婧愮珯
+ LiftStaProtocol sourceLiftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo());
+ //鑾峰彇鐩爣绔�
+ LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
+ if (sourceLiftSta == null || liftSta == null) {
return false;//缂哄皯绔欑偣淇℃伅
}
+ //鑾峰彇鎻愬崌鏈哄懡浠�
+ NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_CAR.id, sourceLiftSta.getStaNo(), liftSta.getStaNo(), wrkMast.getWrkNo());
+
+ ArrayList<NyLiftCommand> commands = new ArrayList<>();
+ commands.add(liftCommand);
+
+ //鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔
+ LiftAssignCommand assignCommand = new LiftAssignCommand();
+ assignCommand.setCommands(commands);
+ assignCommand.setLiftNo(liftProtocol.getLiftNo());
+ assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());
+ assignCommand.setTaskMode(NyLiftTaskModelType.MOVE_CAR.id.shortValue());
+
+ wrkMast.setWrkSts(106L);//鎻愬崌鏈烘惉杩愪腑 105.灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� ==> 106.鎻愬崌鏈烘惉杩愪腑
+ wrkMast.setLiftNo(liftThread.getSlave().getId());//閿佸畾鎻愬崌鏈洪槻姝㈣鍗犵敤
+ wrkMast.setModiTime(now);
+ if (wrkMastMapper.updateById(wrkMast) > 0) {
+ //涓嬪彂浠诲姟
+ MessageQueue.offer(SlaveType.Lift, liftProtocol.getLiftNo().intValue(), new Task(3, assignCommand));
+ }
+
+ }
+ return true;
+ }
+
+ /**
+ * 灏忚溅杩佺Щ-灏忚溅杩佸嚭鎻愬崌鏈�
+ * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false
+ * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue
+ */
+ private boolean shuttleMoveExecuteStepOutLift(WrkMast wrkMast) {
+ //--------------------------------------灏忚溅杩佸嚭鎻愬崌鏈�-----------------------------------------//
+ Date now = new Date();
+ //灏忚溅绉诲姩鍒版彁鍗囨満涓� 107.鎻愬崌鏈烘惉杩愬畬鎴� ==> 108.灏忚溅杩佸嚭鎻愬崌鏈轰腑
+ if (wrkMast.getWrkSts() == 107) {
+
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo());
+ if (liftThread == null) {
+ return false;
+ }
+ LiftProtocol liftProtocol = liftThread.getLiftProtocol();
+ if (liftProtocol == null) {
+ return false;
+ }
+ if (!liftProtocol.isIdle(wrkMast.getWrkNo().shortValue())) {
+ return false;
+ }
+
+ //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟
+ WrkMast liftWrkMast = wrkMastMapper.selectLiftWrkMast(liftThread.getSlave().getId());
+ if (liftWrkMast != null) {
+ if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚�
+ return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇�
+ }
+ }
+
+ //鍒ゆ柇鎻愬崌鏈轰护鐗屾槸鍚︿负褰撳墠灏忚溅
+ if (!liftProtocol.getToken().equals(wrkMast.getShuttleNo())) {
+ 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.isIdleNoCharge()) {
+ return false;
+ }
+
+ //鍒ゆ柇灏忚溅鏄惁涓哄綋鍓嶄换鍔$嫭鍗�
+ if (!shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) {
+ return false;
+ }
+
+ //鑾峰彇鐩爣绔�
+ LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
+ if (liftSta == null) {
+ return false;//鎵句笉鍒扮珯鐐�
+ }
+
//鑾峰彇鎻愬崌鏈烘暟鎹�
- BasLift basLift = basLiftService.selectById(targetBasDevp.getLiftNo());
+ BasLift basLift = basLiftService.selectById(liftProtocol.getLiftNo().intValue());
if (basLift == null) {
return false;//娌℃湁鎻愬崌鏈烘暟鎹�
}
if (basLift.getPoint() == null) {
return false;//娌℃湁璁剧疆鎻愬崌鏈虹偣浣嶅潗鏍�
}
- NavigateNode liftNode = new NavigateNode(basLift.getPoint().getX(), basLift.getPoint().getY());
- liftNode.setZ(basLift.getPoint().getZ());
+ NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY());
+ liftNode.setZ(liftSta.getLev());
List<NyShuttleHttpCommand> commands = new ArrayList<>();
+ //鑾峰彇灏忚溅鏇存柊妤煎眰鍛戒护
+ NyShuttleHttpCommand updateZCommand = NyHttpUtils.getUpdateZCommand(shuttleThread.getSlave().getId(), liftProtocol.getLev().intValue(), wrkMast.getWrkNo());
+ commands.add(updateZCommand);
+
//鑾峰彇灏忚溅鍑烘彁鍗囨満琛岃蛋鍛戒护
- NyShuttleHttpCommand moveCommand = NyHttpUtils.getInOutLiftCommand(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), liftNode, NavigatePositionConvert.locNoToNode(targetBasDevp.getLocNo()), false);
+ NyShuttleHttpCommand moveCommand = NyHttpUtils.getInOutLiftCommand(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), liftNode, NavigatePositionConvert.locNoToNode(liftSta.getLocNo()), false);
commands.add(moveCommand);//娣诲姞灏忚溅杩佸嚭鎻愬崌鏈哄懡浠�
ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
@@ -1993,12 +2862,14 @@
assignCommand.setCommands(commands);
assignCommand.setNodes(null);
- wrkMast.setWrkSts(106L);//灏忚溅杩佸嚭鎻愬崌鏈轰腑 105.鎻愬崌鏈烘惉杩愬畬鎴� ==> 106.灏忚溅杩佸嚭鎻愬崌鏈轰腑
+ wrkMast.setWrkSts(108L);//灏忚溅杩佸嚭鎻愬崌鏈轰腑 107.鎻愬崌鏈烘惉杩愬畬鎴� ==> 108.灏忚溅杩佸嚭鎻愬崌鏈轰腑
wrkMast.setModiTime(now);
if (wrkMastMapper.updateById(wrkMast) > 0) {
//涓嬪彂浠诲姟
MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand));
+ return false;
}
+ return false;
}
return true;
}
@@ -2008,12 +2879,12 @@
* 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false
* ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue
*/
- private boolean shuttleMoveExecuteStep4(WrkMast wrkMast) {
+ private boolean shuttleMoveExecuteStepMoveLoc(WrkMast wrkMast) {
//--------------------------------------灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑-----------------------------------------//
Date now = new Date();
- //灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑 107.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� ==> 108.灏忚溅绉诲姩涓�
- if (wrkMast.getWrkSts() == 107) {
+ //灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑 109.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� ==> 110.灏忚溅绉诲姩涓�
+ if (wrkMast.getWrkSts() == 109) {
//鑾峰彇鍥涘悜绌挎杞︾嚎绋�
NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
@@ -2026,30 +2897,59 @@
}
//灏忚溅澶勪簬绌洪棽鐘舵��
- if (!shuttleProtocol.isIdleNoCharge()) {
+ if (!shuttleProtocol.isIdleNoCharge(wrkMast.getWrkNo())) {
return false;
}
- //鑾峰彇鐩爣绔欏搴旂殑杈撻�佺珯鐐�
- BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), wrkMast.getLiftNo());
- if (targetBasDevp == null) {
- return false;//缂哄皯绔欑偣淇℃伅
+ //鍒ゆ柇灏忚溅浠ょ墝鏄惁涓哄綋鍓嶄换鍔�
+ if (shuttleProtocol.getToken() != 0 && !shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) {
+ return false;
}
- //鑾峰彇鎻愬崌鏈烘暟鎹�
- BasLift basLift = basLiftService.selectById(targetBasDevp.getLiftNo());
- if (basLift == null) {
- return false;//娌℃湁鎻愬崌鏈烘暟鎹�
- }
- if (basLift.getPoint() == null) {
- return false;//娌℃湁璁剧疆鎻愬崌鏈虹偣浣嶅潗鏍�
- }
- NavigateNode liftNode = new NavigateNode(basLift.getPoint().getX(), basLift.getPoint().getY());
- liftNode.setZ(basLift.getPoint().getZ());
+// //鑾峰彇鐩爣绔欏搴旂殑杈撻�佺珯鐐�
+// BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), wrkMast.getLiftNo());
+// if (targetBasDevp == null) {
+// return false;//缂哄皯绔欑偣淇℃伅
+// }
+//
+// //鑾峰彇鎻愬崌鏈烘暟鎹�
+// BasLift basLift = basLiftService.selectById(targetBasDevp.getLiftNo());
+// if (basLift == null) {
+// return false;//娌℃湁鎻愬崌鏈烘暟鎹�
+// }
+// if (basLift.getPoint() == null) {
+// return false;//娌℃湁璁剧疆鎻愬崌鏈虹偣浣嶅潗鏍�
+// }
+// NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY());
+// liftNode.setZ(basLift.getPoint$().getZ());
- //鑾峰彇灏忚溅浠庤緭閫佺珯鍒扮洰鏍囧簱浣嶅懡浠�
- NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), targetBasDevp.getLocNo(), wrkMast.getLocNo());
- if (result.getCommands() == null) {
+ //灏忚溅宸茬粡鍦ㄧ洰鏍囧簱浣嶏紝鐩存帴璁ゅ畾灏忚溅绉诲姩浠诲姟瀹屾垚
+ if (shuttleProtocol.getCurrentLocNo().equals(wrkMast.getLocNo())) {
+ if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) {
+ //閲婃斁灏忚溅浠ょ墝
+ shuttleProtocol.setToken(0);
+ }
+ wrkMast.setWrkSts(111L);//111.灏忚溅绉诲姩瀹屾垚
+ wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈�
+ wrkMast.setModiTime(now);
+ wrkMastMapper.updateById(wrkMast);
+
+ if (wrkMast.getWrkSts() == 111) {
+ // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗�
+ if (wrkMastLocMapper.save(wrkMast.getWrkNo()) <= 0) {
+ log.info("淇濆瓨宸ヤ綔鍘嗗彶妗workNo={0}]澶辫触", wrkMast.getWrkNo());
+ }
+ // 鍒犻櫎宸ヤ綔涓绘。
+ if (!wrkMastService.deleteById(wrkMast)) {
+ log.info("鍒犻櫎宸ヤ綔涓绘。[workNo={0}]澶辫触", wrkMast.getWrkNo());
+ }
+ }
+ return false;
+ }
+
+ //鑾峰彇灏忚溅鍒扮洰鏍囧簱浣嶅懡浠�
+ NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id);
+ if (result == null) {
return false;//璺緞璁$畻澶辫触
}
List<NyShuttleHttpCommand> commands = result.getCommands();
@@ -2061,10 +2961,27 @@
assignCommand.setAuto(true);//鑷姩妯″紡
assignCommand.setCommands(commands);
assignCommand.setNodes(result.getNodes());
+ assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣�
+ assignCommand.setLocNo(wrkMast.getLocNo());//鐩爣搴撲綅
- wrkMast.setWrkSts(108L);//灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑 107.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� ==> 108.灏忚溅绉诲姩涓�
+ if (wrkMast.getLiftNo() != null) {
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo());
+ if (liftThread == null) {
+ return false;
+ }
+ LiftProtocol liftProtocol = liftThread.getLiftProtocol();
+ if (liftProtocol == null) {
+ return false;
+ }
+ if (liftProtocol.getToken().equals(shuttleProtocol.getShuttleNo().intValue())) {
+ liftProtocol.setToken(0);//閲婃斁鎻愬崌鏈轰护鐗�
+ }
+ }
+
+ wrkMast.setWrkSts(110L);//灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑 109.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� ==> 110.灏忚溅绉诲姩涓�
wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈�
wrkMast.setModiTime(now);
+
if (wrkMastMapper.updateById(wrkMast) > 0) {
//涓嬪彂浠诲姟
MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand));
@@ -2074,6 +2991,69 @@
}
/**
+ * 灏忚溅杩佺Щ-娓呯悊111.灏忚溅绉诲姩瀹屾垚
+ */
+ private boolean shuttleMoveExecuteStepClearWrkMast(WrkMast wrkMast) {
+ if (wrkMast.getWrkSts() == 111) {
+ //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
+ 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.isIdleNoCharge(wrkMast.getWrkNo())) {
+ return false;
+ }
+
+ Object o = redisUtil.get("shuttle_wrk_no_" + shuttleProtocol.getTaskNo());
+ if (o != null) {
+ ShuttleRedisCommand redisCommand = JSON.parseObject(o.toString(), ShuttleRedisCommand.class);
+ ShuttleAssignCommand assignCommand = redisCommand.getAssignCommand();
+ int size = assignCommand.getCommands().size();
+ NyShuttleHttpCommand command = assignCommand.getCommands().get(size - 1);//鑾峰彇鏈�鍚庝竴娈靛懡浠�
+ if (!command.getComplete()) {
+ return false;//鏈�鍚庝竴娈靛懡浠よ繕鏈畬鎴愶紝涓嶅仛鎿嶄綔
+ }
+ NavigateMapData navigateMapData = new NavigateMapData(Utils.getLev(shuttleProtocol.getCurrentLocNo()));
+ navigateMapData.writeNavigateNodeToRedisMap(assignCommand.getNodes(), false);//瑙i攣璺緞
+
+ //鍒犻櫎redis
+ redisUtil.del("shuttle_wrk_no_" + redisCommand.getWrkNo());
+ }
+
+ // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗�
+ if (wrkMastLocMapper.save(wrkMast.getWrkNo()) <= 0) {
+ log.info("淇濆瓨宸ヤ綔鍘嗗彶妗workNo={0}]澶辫触", wrkMast.getWrkNo());
+ }
+ // 鍒犻櫎宸ヤ綔涓绘。
+ if (!wrkMastService.deleteById(wrkMast)) {
+ log.info("鍒犻櫎宸ヤ綔涓绘。[workNo={0}]澶辫触", wrkMast.getWrkNo());
+ }
+
+ //璁剧疆鍥涘悜绌挎杞︿负绌洪棽鐘舵��
+ shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE);
+ //婧愬簱浣嶆竻闆�
+ shuttleProtocol.setSourceLocNo(null);
+ //鐩爣搴撲綅娓呴浂
+ shuttleProtocol.setLocNo(null);
+ //浠诲姟鎸囦护娓呴浂
+ shuttleProtocol.setAssignCommand(null);
+ //宸ヤ綔鍙锋竻闆�
+ shuttleProtocol.setTaskNo(0);
+ //娓呴櫎浠ょ墝
+ shuttleProtocol.setToken(0);
+ News.info("鍥涘悜绌挎杞﹀凡纭涓旂Щ鍔ㄤ换鍔″畬鎴愮姸鎬�,澶嶄綅銆傚洓鍚戠┛姊溅鍙�={}", shuttleProtocol.getShuttleNo());
+ }
+
+ return true;
+ }
+
+ /**
* 鍑哄叆搴撴ā寮忓垏鎹�
*/
public synchronized void outAndIn() {
--
Gitblit v1.9.1