From 80523e92e25ba762a3fe737ef7997f7e831890a0 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期日, 01 十月 2023 09:49:19 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 207 +++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 167 insertions(+), 40 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..e071569 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -238,14 +238,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 +267,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) {
@@ -873,7 +873,7 @@
return false;//鎵句笉鍒扮珯鐐�
}
- if (liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && !liftStaProtocol.getHasTray()) {
+ if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && !liftStaProtocol.getHasTray())) {
return false;//绔欑偣蹇呴』鑷姩銆佺┖闂层�佹病鏈夋墭鐩�
}
@@ -1196,6 +1196,17 @@
//23.灏忚溅鎼繍瀹屾垚 ==> 24.鎻愬崌鏈烘惉杩愪腑
if (wrkMast.getWrkSts() == 23) {
+ 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) {
@@ -1286,7 +1297,6 @@
&& liftProtocol.getTaskNo() != 0
&& !liftProtocol.getBusy()
) {
- boolean clearTaskNoFlag = false;//娓呴浂宸ヤ綔鍙锋爣璁�
//灏嗕换鍔℃。鏍囪涓哄畬鎴�
WrkMast wrkMast = wrkMastMapper.selectByWorkNo324104(liftProtocol.getTaskNo().intValue());
if (wrkMast != null) {
@@ -1294,7 +1304,7 @@
case 3://3.鎻愬崌鏈烘惉杩愪腑 ==> 4.鎻愬崌鏈烘惉杩愬畬鎴�
wrkMast.setWrkSts(4L);
wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈�
- if (liftProtocol.getToken() == wrkMast.getWrkNo()) {
+ if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) {
//閲婃斁鎻愬崌鏈轰护鐗�
liftProtocol.setToken(0);
}
@@ -1308,20 +1318,20 @@
//閲婃斁鎻愬崌鏈轰护鐗�
liftProtocol.setToken(0);
}
+
+ if (wrkMast.getMk() == null || !wrkMast.getMk().equals("Y")) {
+ //涓嶉渶瑕佺敤鍒版満姊拌噦锛岀洿鎺ヨ浆29.鍑哄簱瀹屾垚
+ wrkMast.setWrkSts(29L);
+ }
+
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 +1340,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());
+ }
+ }
}
-
}
}
}
@@ -1912,14 +1933,14 @@
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绔欑偣淇℃伅澶辫触");
- }
+// // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂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 +1958,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");
}
}
}
@@ -2236,7 +2348,8 @@
}
} else if (wrkCharge.getWrkSts() == 52) {
//妫�娴嬪皬杞︽槸鍚︽弧鐢�
- if (shuttleProtocol.getPowerPercent() < 100) {
+ int maxPower = 95;
+ if (shuttleProtocol.getPowerPercent() < maxPower) {
continue;
}
@@ -2252,21 +2365,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) {
+
+ }
+ }
}
}
@@ -2489,6 +2615,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);
--
Gitblit v1.9.1