From ea9b2ddb6c523088b4800337478ffa0bac880766 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 26 十月 2023 15:50:03 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 731 ++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 547 insertions(+), 184 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 3476c4a..e6dcfca 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -3,6 +3,7 @@
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.*;
@@ -24,6 +25,8 @@
import com.zy.core.model.protocol.*;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.*;
+import com.zy.system.entity.Config;
+import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -101,6 +104,12 @@
private RedisUtil redisUtil;
@Autowired
private WrkMastLocMapper wrkMastLocMapper;
+ @Autowired
+ private BasLiftOptService basLiftOptService;
+ @Autowired
+ private ConfigService configService;
+ @Autowired
+ private NavigateMapUtils navigateMapUtils;
/**
@@ -224,7 +233,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")
@@ -238,14 +247,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());
@@ -267,10 +276,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) {
@@ -405,8 +414,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()){
// 鑾峰彇鏉$爜鎵弿浠俊鎭�
@@ -507,14 +516,21 @@
}
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.setLiftNo(null);// 鎻愬崌鏈烘竻绌�
wrkMast.setModiTime(new Date());
if (wrkMastMapper.updateById(wrkMast) == 0) {
throw new CoolException(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
@@ -531,14 +547,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) {
@@ -549,10 +567,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) {
@@ -689,38 +707,6 @@
continue;
}
}
-
-
-
-
- // 鏍规嵁杈撻�佺嚎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;
- }
-
-
-
- }
- }
-
}
// /**
@@ -794,6 +780,12 @@
return false;//灏忚溅宸茶鐙崰锛岀姝㈠啀娲惧彂浠诲姟
}
+ //鍒ゆ柇灏忚溅鏄惁瀛樺湪绉诲姩浠诲姟
+ WrkMast hasMoveWorking = wrkMastMapper.selectShuttleHasMoveWorking(wrkMast.getShuttleNo());
+ if (hasMoveWorking != null) {
+ return false;//瀛樺湪绉诲姩浠诲姟锛岀姝㈡墽琛屽叆搴撲换鍔�
+ }
+
//鍒ゆ柇灏忚溅鏄惁鍒拌揪杈撻�佺珯鐐瑰簱浣�
if (!shuttleProtocol.getCurrentLocNo().equals(liftStaProtocol.getLocNo())) {
//灏忚溅涓嶅湪杈撻�佺珯鐐逛綅缃�
@@ -863,8 +855,18 @@
return false;//鍑哄簱绔欑偣涓嶅瓨鍦�
}
+ if (!basDevp.getAutoing().equals("Y")) {
+ return false;//涓嶆槸鑷姩鐘舵��
+ }
+
if (!basDevp.getOutEnable().equals("Y")) {
return false;//鍑哄簱绔欑偣涓嶅彲鍑�
+ }
+
+ Integer liftNo = basDevp.getLiftNo();//鎼滅储鍑哄簱鎻愬崌鏈烘槸鍚﹀瓨鍦ㄥ叆搴撲换鍔★紝濡傚瓨鍦ㄧ姝㈠嚭搴�
+ List<WrkMast> liftWrkMasts = wrkMastMapper.selectInWrkMastByLiftNo(liftNo);
+ if (!liftWrkMasts.isEmpty()) {
+ return false;//瀛樺湪鍏ュ簱浠诲姟锛岀姝㈠嚭搴�
}
//鑾峰彇婧愮珯
@@ -873,7 +875,7 @@
return false;//鎵句笉鍒扮珯鐐�
}
- if (liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && !liftStaProtocol.getHasTray()) {
+ if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && !liftStaProtocol.getHasTray())) {
return false;//绔欑偣蹇呴』鑷姩銆佺┖闂层�佹病鏈夋墭鐩�
}
@@ -1113,6 +1115,18 @@
return false;//绔欑偣涓嶅彲鍏�
}
+ //鍒ゆ柇鎻愬崌鏈烘暣涓笁妤兼槸鍚﹂兘澶勪簬鍏ュ簱妯″紡
+ Integer outInModel1 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 1);
+ Integer outInModel2 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 5);
+ Integer outInModel3 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 8);
+ if (outInModel1 == null || outInModel2 == null || outInModel3 == null) {
+ return false;//涓嶅瓨鍦ㄥ嚭鍏ュ簱妯″紡
+ }
+
+ if (outInModel1 == 2 || outInModel2 == 2 && outInModel3 == 2) {
+ return false;//鍙鏈変竴涓浜庡嚭搴撴ā寮忥紝绂佹鍏ュ簱
+ }
+
LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, sourceBasDevp.getLiftNo());
if (liftThread == null) {
return false;
@@ -1161,6 +1175,12 @@
//鑾峰彇鎻愬崌鏈哄懡浠�
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);
@@ -1196,10 +1216,32 @@
//23.灏忚溅鎼繍瀹屾垚 ==> 24.鎻愬崌鏈烘惉杩愪腑
if (wrkMast.getWrkSts() == 23) {
+ NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
+ if (shuttleThread == null) {
+ return false;
+ }
+
//鑾峰彇鍑哄簱绔欑偣(鐩爣绔�)
BasDevp basDevp = basDevpService.selectById(wrkMast.getStaNo());
if (basDevp == null) {
return false;//鍑哄簱绔欑偣涓嶅瓨鍦�
+ }
+
+ //鑾峰彇婧愮珯瀵瑰簲鐨勭墰鐪兼彁鍗囨満绔欑偣缂栧彿(璧风偣缂栧彿)
+ LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(basDevp.getLiftNo(), Utils.getLev(wrkMast.getSourceLocNo()));
+ if (liftStaProtocol == null) {
+ return false;//鎵句笉鍒扮珯鐐�
+ }
+ Integer startSta = liftStaProtocol.getStaNo();
+
+ NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+ if (shuttleProtocol.getCurrentLocNo().equals(liftStaProtocol.getLocNo())) {
+ //灏忚溅杩樺湪杈撻�佺珯鐐�
+ //璋冨害灏忚溅閬胯
+ boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkMast.getSourceLocNo()), wrkMast.getShuttleNo(), shuttleThread);
+ if (!result) {
+ return false;
+ }
}
if (!basDevp.getOutEnable().equals("Y")) {
@@ -1214,6 +1256,7 @@
if (liftProtocol == null) {
return false;
}
+
if (!liftProtocol.isIdle()) {
return false;
}
@@ -1226,13 +1269,6 @@
if (liftWrkMast != 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());
@@ -1286,15 +1322,20 @@
&& liftProtocol.getTaskNo() != 0
&& !liftProtocol.getBusy()
) {
- boolean clearTaskNoFlag = false;//娓呴浂宸ヤ綔鍙锋爣璁�
+ BasLiftOpt basLiftOpt = basLiftOptService.selectByDeviceWrk(liftProtocol.getTaskNo().toString());
+ int taskNo = liftProtocol.getTaskNo().intValue();
+ if (basLiftOpt != null) {
+ taskNo = basLiftOpt.getWrkNo();
+ }
+
//灏嗕换鍔℃。鏍囪涓哄畬鎴�
- WrkMast wrkMast = wrkMastMapper.selectByWorkNo324104(liftProtocol.getTaskNo().intValue());
+ WrkMast wrkMast = wrkMastMapper.selectByWorkNo324104(taskNo);
if (wrkMast != null) {
switch (wrkMast.getWrkSts().intValue()) {
case 3://3.鎻愬崌鏈烘惉杩愪腑 ==> 4.鎻愬崌鏈烘惉杩愬畬鎴�
wrkMast.setWrkSts(4L);
wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈�
- if (liftProtocol.getToken() == wrkMast.getWrkNo()) {
+ if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) {
//閲婃斁鎻愬崌鏈轰护鐗�
liftProtocol.setToken(0);
}
@@ -1303,25 +1344,28 @@
wrkMast.setWrkSts(25L);
if (wrkMast.getIoType() == 11) {//搴撲綅绉昏浆
wrkMast.setWrkSts(4L);//4.鎻愬崌鏈烘惉杩愬畬鎴�
+ }else {
+ if (wrkMast.getMk() == null || !wrkMast.getMk().equals("Y")) {
+ //涓嶉渶瑕佺敤鍒版満姊拌噦锛岀洿鎺ヨ浆29.鍑哄簱瀹屾垚
+ wrkMast.setWrkSts(29L);
+ wrkMast.setShuttleNo(null);//閲婃斁灏忚溅
+ wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈�
+ }
}
+
if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) {
//閲婃斁鎻愬崌鏈轰护鐗�
liftProtocol.setToken(0);
}
+
break;
case 106://106.鎻愬崌鏈烘惉杩愪腑 ==> 107.鎻愬崌鏈烘惉杩愬畬鎴�
wrkMast.setWrkSts(107L);
-// //娓呴浂宸ヤ綔鍙�
-// clearTaskNoFlag = true;
break;
default:
}
if (wrkMastMapper.updateById(wrkMast) > 0) {
- if (clearTaskNoFlag) {
- //娓呴浂宸ヤ綔鍙�
- MessageQueue.offer(SlaveType.Lift, liftSlave.getId(), new Task(4, null));
- }
//璁剧疆鎻愬崌鏈轰负绌洪棽鐘舵��
liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE);
//浠诲姟鎸囦护娓呴浂
@@ -1330,8 +1374,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());
+ }
+ }
}
-
}
}
}
@@ -1367,7 +1422,7 @@
continue;
}
- boolean step4 = this.locToLocExecuteStep4(wrkMast);//璋冨害杞﹁締鍙栬揣骞惰繍閫佸埌鍑哄簱鍙�
+ boolean step4 = this.locToLocExecuteStep4(wrkMast);//璋冨害杞﹁締鍙栬揣骞惰繍閫佸埌鐩爣搴撲綅
if (!step4) {
continue;
}
@@ -1469,7 +1524,7 @@
}
//鑾峰彇绌挎杞︽渶杩戜笖绌洪棽鐨勬彁鍗囨満杈撻�佺珯鐐�
- LiftStaProtocol liftSta = shuttleDispatchUtils.getRecentLiftSta(shuttleThread.getSlave().getId());
+ LiftStaProtocol liftSta = shuttleDispatchUtils.getRecentLiftSta(shuttleThread.getSlave().getId(), Utils.getLev(wrkMast.getLocNo()));
if (liftSta == null) {
return false;//娌℃湁鍙敤涓旂┖闂茬殑杈撻�佺珯鐐�
}
@@ -1515,14 +1570,47 @@
private boolean locToLocExecuteStep3(WrkMast wrkMast) {
Date now = new Date();
if (wrkMast.getWrkSts() == 23) {//23.灏忚溅鎼繍瀹屾垚
+ //婧愮珯
+ Integer sourceStaNo = wrkMast.getSourceStaNo();
+ //鐩爣绔�
+ Integer staNo = wrkMast.getStaNo();
+ if (sourceStaNo == null || staNo == null) {
+ return false;//婧愮珯鎴栫洰鏍囩珯涓虹┖
+ }
+
+ int liftNo = staNo / 100;//鑾峰彇鎻愬崌鏈哄彿
+
//鑾峰彇鎻愬崌鏈虹嚎绋�
- LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, wrkMast.getLiftNo());
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo);
if (liftThread == null) {
return false;
}
LiftProtocol liftProtocol = liftThread.getLiftProtocol();
if (liftProtocol == null) {
return false;
+ }
+
+ //鑾峰彇婧愮珯瀵瑰簲鐨勮緭閫佺珯鐐�
+ LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(liftNo, Utils.getLev(wrkMast.getSourceLocNo()));
+ if (liftStaProtocol == null) {
+ return false;//鎵句笉鍒扮珯鐐�
+ }
+
+ if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && liftStaProtocol.getHasTray())) {
+ return false;//绔欑偣蹇呴』鑷姩銆佺┖闂层�佹湁鎵樼洏
+ }
+ NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
+ if (shuttleThread == null) {
+ return false;
+ }
+ NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+ if (shuttleProtocol.getCurrentLocNo().equals(liftStaProtocol.getLocNo())) {
+ //灏忚溅杩樺湪杈撻�佺珯鐐�
+ //璋冨害灏忚溅閬胯
+ boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkMast.getSourceLocNo()), wrkMast.getShuttleNo(), shuttleThread);
+ if (!result) {
+ return false;
+ }
}
if (!liftProtocol.isIdle()) {
@@ -1533,14 +1621,6 @@
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;//婧愮珯鎴栫洰鏍囩珯涓虹┖
}
//鑾峰彇鎻愬崌鏈哄懡浠�
@@ -1577,13 +1657,17 @@
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;//缂哄皯绔欑偣淇℃伅
+ LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(wrkMast.getLiftNo(), Utils.getLev(wrkMast.getLocNo()));
+ if (liftStaProtocol == null) {
+ return false;//鎵句笉鍒扮珯鐐�
+ }
+
+ if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && liftStaProtocol.getHasTray())) {
+ return false;//绔欑偣蹇呴』鑷姩銆佺┖闂层�佹湁鎵樼洏
}
if (wrkMast.getShuttleNo() == null) {
- shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), targetBasDevp.getLocNo());//璋冨害灏忚溅鍒扮洰鏍囪緭閫佺珯鐐硅繘琛屽彇璐�
+ shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), liftStaProtocol.getLocNo());//璋冨害灏忚溅鍒扮洰鏍囪緭閫佺珯鐐硅繘琛屽彇璐�
return false;
}
@@ -1601,14 +1685,14 @@
}
//鍒ゆ柇灏忚溅鏄惁鍒拌揪鐩爣杈撻�佺珯鐐�
- if (!shuttleProtocol.getCurrentLocNo().equals(targetBasDevp.getLocNo())) {
+ if (!shuttleProtocol.getCurrentLocNo().equals(liftStaProtocol.getLocNo())) {
//灏忚溅涓嶅湪鐩爣杈撻�佺珯鐐�
- shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), targetBasDevp.getLocNo(), wrkMast.getShuttleNo());//璋冨害灏忚溅鍒扮洰鏍囪緭閫佺珯鐐硅繘琛屽彇璐�
+ shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), liftStaProtocol.getLocNo(), wrkMast.getShuttleNo());//璋冨害灏忚溅鍒扮洰鏍囪緭閫佺珯鐐硅繘琛屽彇璐�
return false;
}
//灏忚溅宸叉姷杈剧洰鏍囪緭閫佺珯鐐癸紝灏嗚揣鐗╂惉杩愬埌鐩爣搴撲綅
- NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), targetBasDevp.getLocNo(), wrkMast.getLocNo());
+ NyShuttleOperaResult result = NyShuttleOperaUtils.getShuttleTransportCommands(wrkMast.getShuttleNo(), wrkMast.getWrkNo(), liftStaProtocol.getLocNo(), wrkMast.getLocNo());
if (result == null) {//璺緞璁$畻澶辫触
return false;
}
@@ -1889,6 +1973,13 @@
}
}
+ if (!Cools.isEmpty(barcode)) {
+ WrkMast wrkMast = wrkMastMapper.selectByBarcode(barcode);//鏉$爜瀛樺湪宸ヤ綔妗�
+ if (wrkMast != null) {
+ continue;
+ }
+ }
+
LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed());
try {
@@ -1911,15 +2002,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");
@@ -1937,6 +2028,253 @@
}
+ }
+ }
+ }
+
+ /**
+ * 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;//娌℃湁绌洪棽绔欑偣
+ }
+
+ if (wrkMast.getStaNo() != 303 && wrkMast.getStaNo() != 317) {
+ //鍚慉GV鍙戣捣缁勬墭璇锋眰
+ try {
+ HashMap<String, Object> param = new HashMap<>();
+ param.put("wrkNo", wrkMast.getWrkNo());
+ String response = new HttpHandler.Builder()
+ .setUri(wmsUrl)
+ .setPath("/rpc/replenishment")
+ .setJson(JSON.toJSONString(param))
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ Integer code = jsonObject.getInteger("code");
+ if (code.equals(200)) {//AGV缁勬墭鎴愬姛
+ //瑕嗙洊宸ヤ綔妗g洰鏍囩珯
+ wrkMast.setStaNo(targetSta.intValue());
+ wrkMast.setShuttleNo(null);//閲婃斁灏忚溅
+ wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈�
+ 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;
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ }
+
+// //瑕嗙洊宸ヤ綔妗g洰鏍囩珯
+// wrkMast.setStaNo(targetSta.intValue());
+// wrkMast.setShuttleNo(null);//閲婃斁灏忚溅
+// wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈�
+// 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;
+ }
+ List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
+ if (wrkDetls.isEmpty()) {
+ continue;
+ }
+
+ if (wrkMast.getInvWh() == null) {
+ wrkMast.setInvWh("Y");//鏍囪宸茬粡涓嬪彂鏈烘鑷備换鍔�
+ if (wrkMastMapper.updateById(wrkMast) > 0) {
+ RobotUtils.sendTask(staProtocol303.getWorkNo().toString(), wrkDetls.size(), "303");
+ }
+ }
+ }else if (staProtocol317.isAutoing() && staProtocol317.isLoading() && staProtocol317.getWorkNo() != 0) {
+ //璋冨害鏈烘鑷�
+ //鏌ヨ鏄惁鏈夊伐浣滄。
+ WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol317.getWorkNo().intValue());
+ if (wrkMast == null) {
+ continue;
+ }
+ List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
+ if (wrkDetls.isEmpty()) {
+ continue;
+ }
+ if (wrkMast.getInvWh() == null) {
+ wrkMast.setInvWh("Y");//鏍囪宸茬粡涓嬪彂鏈烘鑷備换鍔�
+ if (wrkMastMapper.updateById(wrkMast) > 0) {
+ RobotUtils.sendTask(staProtocol317.getWorkNo().toString(), wrkDetls.size(), "317");
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * AGV琛ヨ揣(閫氱煡AGV鍙栬揣)
+ */
+ public void agvRestockInto() {
+ //妫�娴�309鍜�312绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗�
+ for (DevpSlave devp : slaveProperties.getDevp()) {
+ // 鑾峰彇鍏ュ簱绔欎俊鎭�
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+ StaProtocol staProtocol309 = devpThread.getStation().get(309);
+ StaProtocol staProtocol312 = devpThread.getStation().get(312);
+ if (staProtocol309 == null || staProtocol312 == null) {
+ continue;
+ }
+
+ if (staProtocol309.isAutoing() && staProtocol309.isLoading() && staProtocol309.isInEnable()) {
+ // 鑾峰彇鏉$爜鎵弿浠俊鎭�
+ BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 9);//308绔欐潯鐮佸櫒
+ if (barcodeThread == null) {
+ continue;
+ }
+ String barcode = barcodeThread.getBarcode();
+ if(!Cools.isEmpty(barcode)) {
+ //閫氱煡AGV鍙栬揣
+ agvRestockCall("CS-301-001-01@3", barcode);
+ log.info("閫氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode);
+ }
+ }
+
+ if (staProtocol312.isAutoing() && staProtocol312.isLoading() && staProtocol312.isInEnable()) {
+ // 鑾峰彇鏉$爜鎵弿浠俊鎭�
+ BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 10);//311绔欐潯鐮佸櫒
+ if (barcodeThread == null) {
+ continue;
+ }
+ String barcode = barcodeThread.getBarcode();
+ if(!Cools.isEmpty(barcode)) {
+ //閫氱煡AGV鍙栬揣
+ agvRestockCall("CS-302-001-01@3", barcode);
+ log.info("閫氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode);
+ }
+ }
+ }
+ }
+
+ //閫氱煡AGV鍙栬揣
+ private boolean agvRestockCall(String staNo, String barcode) {
+ try {
+ HashMap<String, Object> param = new HashMap<>();
+ param.put("devNo", staNo);
+ param.put("containerCode", barcode);
+ String response = new HttpHandler.Builder()
+ .setUri(wmsUrl)
+ .setPath("/rpc/start")
+ .setJson(JSON.toJSONString(param))
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ Integer code = jsonObject.getInteger("code");
+ if (code.equals(200)) {//鍛煎彨AGV
+ return true;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+ }
+ return false;
+ }
+
+ // 300绔欐嫞鏂�
+ public void pick300() {
+ //妫�娴�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() != 29) {//29.鍑哄簱瀹屾垚
+ continue;
+ }
+
+ if (wrkMast.getMk() == null) {
+ Integer sourceStaNo = wrkMast.getSourceStaNo();//婧愮珯
+ Integer staNo = wrkMast.getStaNo();//鐩爣绔�
+ //瑕嗙洊宸ヤ綔妗g洰鏍囩珯
+ wrkMast.setStaNo(sourceStaNo);
+ wrkMast.setSourceStaNo(staNo);
+ wrkMast.setMk("N");
+ if (wrkMastMapper.updateById(wrkMast) > 0) {
+ //鍚�300绔欏啓鍏ョ洰鏍囩珯
+ staProtocol = staProtocol.clone();
+ staProtocol.setStaNo(wrkMast.getStaNo().shortValue());//绉诲姩鍒扮洰鏍囩珯
+ boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+ try {
+ Thread.sleep(500);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
}
}
}
@@ -2236,7 +2574,17 @@
}
} else if (wrkCharge.getWrkSts() == 52) {
//妫�娴嬪皬杞︽槸鍚︽弧鐢�
- if (shuttleProtocol.getPowerPercent() < 100) {
+
+ //鑾峰彇婊$數闃堝��
+ int maxPower = 95;
+ EntityWrapper<Config> wrapper = new EntityWrapper<>();
+ wrapper.eq("code", "chargeMaxValue");
+ Config config = configService.selectOne(wrapper);
+ if (config != null) {
+ maxPower = Integer.parseInt(config.getValue());
+ }
+
+ if (shuttleProtocol.getPowerPercent() < maxPower) {
continue;
}
@@ -2252,21 +2600,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) {
+
+ }
+ }
}
}
@@ -2304,8 +2665,6 @@
if (!stepMoveLoc) {
continue;
}
-
-// this.shuttleMoveExecuteStepClearWrkMast(wrkMast);//娓呯悊111.灏忚溅绉诲姩瀹屾垚
}
}
@@ -2353,6 +2712,22 @@
return false;
}
+ //*************灏濊瘯閿佸畾鐩爣绔欒矾寰�***************
+ List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(wrkMast.getStaNo());
+ if (targetNodes == null) {
+ return false;//鏈幏鍙栧埌鑺傜偣
+ }
+ boolean checkPathIsAvailable = NavigateUtils.checkPathIsAvailable(targetNodes, shuttleProtocol.getShuttleNo().intValue(), Utils.getLev(wrkMast.getLocNo()), null);
+ if (!checkPathIsAvailable) {
+ return false;//妫�娴嬬洰鏍囩珯鐐硅矾寰勬槸鍚︽湭琚崰鐢�
+ }
+ //灏濊瘯閿佸畾鐩爣绔欒矾寰�
+ boolean result2 = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), targetNodes, true);//鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢�
+ if (!result2) {
+ return false;//璺緞閿佸畾澶辫触
+ }
+ //*************灏濊瘯閿佸畾鐩爣绔欒矾寰�***************
+
//鑾峰彇婧愯緭閫佺珯
LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo());
if (liftSta == null) {
@@ -2366,7 +2741,7 @@
}
//鑾峰彇灏忚溅鍒拌緭閫佺珯鐐硅璧板懡浠�
- NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo());
+ NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id);
List<NyShuttleHttpCommand> commands = result.getCommands();
ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
@@ -2478,7 +2853,8 @@
NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_CAR.id, sourceLiftSta.getStaNo(), sourceLiftSta.getStaNo(), wrkMast.getWrkNo());
Random random = new Random();
- liftCommand.setTaskNo((short) Math.abs((liftCommand.getTaskNo().intValue() + random.nextInt(9999))));//鏇存崲闅忔満浠诲姟鍙�
+ int deviceWrk = Math.abs((liftCommand.getTaskNo().intValue() + random.nextInt(9999)));//鑾峰彇璁惧宸ヤ綔鍙�
+ liftCommand.setTaskNo((short) deviceWrk);//鏇存崲闅忔満浠诲姟鍙�
ArrayList<NyLiftCommand> commands = new ArrayList<>();
commands.add(liftCommand);
@@ -2489,6 +2865,7 @@
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);
@@ -2718,6 +3095,7 @@
if (basLift.getPoint() == null) {
return false;//娌℃湁璁剧疆鎻愬崌鏈虹偣浣嶅潗鏍�
}
+
NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY());
liftNode.setZ(liftSta.getLev());
@@ -2782,6 +3160,27 @@
return false;
}
+ //璺ㄦゼ灞傜Щ鍔ㄤ换鍔�
+ if (Utils.getLev(wrkMast.getSourceLocNo()) != Utils.getLev(wrkMast.getLocNo())) {
+ //鑾峰彇鐩爣绔�
+ LiftStaProtocol liftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
+ if (liftSta == null) {
+ return false;//鎵句笉鍒扮珯鐐�
+ }
+
+ //*************灏濊瘯瑙i攣鐩爣绔欒矾寰�***************
+ List<NavigateNode> targetNodes = NyLiftUtils.getLiftStaNodes(liftSta.getStaNo());
+ if (targetNodes == null) {
+ return false;//鏈幏鍙栧埌鑺傜偣
+ }
+ //灏濊瘯瑙i攣鐩爣绔欒矾寰�
+ boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), targetNodes, false);//鎵�浣跨敤鐨勮矾寰勮繘琛岃В閿�
+ if (!result) {
+ return false;//璺緞瑙i攣澶辫触
+ }
+ //*************灏濊瘯瑙i攣鐩爣绔欒矾寰�***************
+ }
+
// //鑾峰彇鐩爣绔欏搴旂殑杈撻�佺珯鐐�
// BasDevp targetBasDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(wrkMast.getLocNo()), wrkMast.getLiftNo());
// if (targetBasDevp == null) {
@@ -2799,8 +3198,35 @@
// NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY());
// liftNode.setZ(basLift.getPoint$().getZ());
+ //灏忚溅宸茬粡鍦ㄧ洰鏍囧簱浣嶏紝鐩存帴璁ゅ畾灏忚溅绉诲姩浠诲姟瀹屾垚
+ 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);
+
+ shuttleProtocol.setShuttleNo((short) 0);//閲婃斁灏忚溅
+ shuttleProtocol.setToken(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());
+ }
+ }
+ return false;
+ }
+
//鑾峰彇灏忚溅鍒扮洰鏍囧簱浣嶅懡浠�
- NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo());
+ NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id);
if (result == null) {
return false;//璺緞璁$畻澶辫触
}
@@ -2839,69 +3265,6 @@
MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand));
}
}
- return true;
- }
-
- /**
- * 灏忚溅杩佺Щ-娓呯悊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;
}
--
Gitblit v1.9.1