From c5244cbb8e98b5b3f2e6306ebfabf0333d76c6d6 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期五, 26 九月 2025 11:17:55 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 239 +++++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 180 insertions(+), 59 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 9f5533e..1a31154 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -75,6 +75,8 @@
private DeviceConfigService deviceConfigService;
@Autowired
private LiftDispatchUtils liftDispatchUtils;
+ @Autowired
+ private BasShuttleService basShuttleService;
/**
* 鍒濆鍖栧疄鏃跺湴鍥�
@@ -99,7 +101,7 @@
}
//灏嗘暟鎹簱鍦板浘鏁版嵁瀛樺叆redis
- redisUtil.set(RedisKeyType.MAP.key + lev, JSON.toJSONString(basMap));
+ redisUtil.set(RedisKeyType.MAP.key + lev, lists);
}
}
@@ -140,7 +142,7 @@
public synchronized boolean shuttleInExecuteStep1(WrkMast wrkMast) {
if (wrkMast.getWrkSts() == WrkStsType.INBOUND_LIFT_RUN_COMPLETE.sts) {
//鑾峰彇鐩爣绔�
- ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
+ LiftStaProtocol liftSta = LiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
if (liftSta == null) {
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀己灏戠珯鐐逛俊鎭紝绂佹娲惧彂", wrkMast.getWrkNo());
return false;
@@ -269,42 +271,42 @@
Integer liftNo = wrkMast.getLiftNo();
if (liftNo == null) {
//閫氳繃杈撻�佺嚎绔欏彿鑾峰彇鎻愬崌鏈哄彿
- liftNo = ForkLiftUtils.getConveyorBindLiftNo(wrkMast.getStaNo());
+ liftNo = LiftUtils.getConveyorBindLiftNo(wrkMast.getStaNo());
if (liftNo == null) {
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾湭鎵惧埌鍖归厤鐨勬彁鍗囨満", wrkMast.getWrkNo());
return false;
}
}
- ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo);
- if (forkLiftThread == null) {
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo);
+ if (liftThread == null) {
return false;
}
- ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus();
- if (forkLiftProtocol == null) {
+ LiftProtocol liftProtocol = liftThread.getStatus();
+ if (liftProtocol == null) {
return false;
}
//鍒ゆ柇鎻愬崌鏈烘槸鍚﹀浜庡嚭搴撴ā寮�
- if (!forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.OUT)) {
+ if (!liftProtocol.getIOModeType().equals(LiftIoModeType.OUT)) {
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾彁鍗囨満涓嶅浜庡嚭搴撴ā寮忥紝绂佹鍑哄簱", wrkMast.getWrkNo());
return false;
}
//鑾峰彇婧愮珯
- ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByLev(liftNo, Utils.getLev(wrkMast.getSourceLocNo()));
+ LiftStaProtocol liftSta = LiftUtils.getLiftStaByLev(liftNo, Utils.getLev(wrkMast.getSourceLocNo()));
if (liftSta == null) {
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀己灏戠珯鐐逛俊鎭紝绂佹娲惧彂", wrkMast.getWrkNo());
return false;
}
if (liftSta.getHasCar()) {
- News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}绔欑偣瀛樺湪灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftSta.getStaNo());
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}绔欑偣瀛樺湪灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftSta.getSiteId());
return false;
}
if (liftSta.getHasTray()) {
- News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}绔欑偣鏈夋墭鐩橈紝绂佹娲惧彂", wrkMast.getWrkNo(), liftSta.getStaNo());
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}绔欑偣鏈夋墭鐩橈紝绂佹娲惧彂", wrkMast.getWrkNo(), liftSta.getSiteId());
return false;
}
@@ -424,7 +426,7 @@
assignCommand.setCommands(commands);
wrkMast.setWrkSts(WrkStsType.OUTBOUND_SHUTTLE_RUN.sts);//灏忚溅鎼繍涓� 101.鐢熸垚鍑哄簱浠诲姟 ==> 102.灏忚溅鎼繍涓�
- wrkMast.setSourceStaNo(liftSta.getStaNo());
+ wrkMast.setSourceStaNo(liftSta.getSiteId());
wrkMast.setModiTime(new Date());
wrkMast.setSystemMsg("");//娓呯┖娑堟伅
if (wrkMastService.updateById(wrkMast)) {
@@ -501,6 +503,12 @@
//鍒ゆ柇灏忚溅鏄惁鍒拌揪璐х墿搴撲綅
if (!shuttleProtocol.getCurrentLocNo().equals(wrkMast.getSourceLocNo())) {
+ //浠诲姟琚伩闅滃彇娑�
+ Object cancelLock = redisUtil.get(RedisKeyType.TRAFFIC_CONTROL_SHUTTLE_OBSTACLE_CANCEL_TASK_LOCK.key + wrkMast.getShuttleNo());
+ if(cancelLock != null) {
+ return false;
+ }
+
//灏忚溅鏈埌杈惧彇璐т綅缃�
shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getShuttleNo());//璋冨害灏忚溅鍒拌揣鐗╂墍鍦ㄥ簱浣嶈繘琛屽彇璐�
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽皬杞︽湭鍒拌揪鍙栬揣浣嶇疆", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
@@ -608,18 +616,13 @@
//1.鐢熸垚鍏ュ簱浠诲姟 ==> 3.鎻愬崌鏈烘惉杩愪腑
if (wrkMast.getWrkSts() == WrkStsType.NEW_INBOUND.sts) {
//鑾峰彇鐩爣杈撻�佺珯
- ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
+ LiftStaProtocol liftSta = LiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
if (liftSta == null) {
return false;//鎵句笉鍒扮珯鐐�
}
if (liftSta.getHasTray()) {
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀洰鏍囩珯瀛樺湪鎵樼洏", wrkMast.getWrkNo());
- return false;
- }
-
- if (liftSta.getHasCar()) {
- News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀洰鏍囩珯瀛樺湪灏忚溅", wrkMast.getWrkNo());
return false;
}
@@ -692,7 +695,7 @@
}
//鑾峰彇鎻愬崌鏈哄懡浠�
- LiftCommand liftCommand = liftThread.getPickAndPutCommand(wrkMast.getWrkNo(), wrkMast.getSourceStaNo(), liftSta.getLev());
+ LiftCommand liftCommand = liftThread.getPickAndPutCommand(wrkMast.getWrkNo(), wrkMast.getSourceStaNo(), liftSta.getSiteId());
ArrayList<LiftCommand> commands = new ArrayList<>();
commands.add(liftCommand);
@@ -701,7 +704,7 @@
assignCommand.setCommands(commands);
assignCommand.setLiftNo(liftNo);
assignCommand.setTaskNo(wrkMast.getWrkNo());
- assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id);
+ assignCommand.setTaskMode(LiftTaskModeType.PICK_PUT.id);
wrkMast.setWrkSts(WrkStsType.INBOUND_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 1.鐢熸垚鍏ュ簱浠诲姟 ==> 3.鎻愬崌鏈烘惉杩愪腑
wrkMast.setSystemMsg("");//娓呯┖娑堟伅
@@ -765,13 +768,8 @@
return false;
}
- if (liftSta.getHasCar()) {
- News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}绔欑偣瀛樺湪灏忚溅锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), liftSta.getStaNo());
- return false;
- }
-
if (!liftSta.getHasTray()) {
- News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}绔欑偣鏃犳墭鐩橈紝绂佹娲惧彂", wrkMast.getWrkNo(), liftSta.getStaNo());
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}绔欑偣鏃犳墭鐩橈紝绂佹娲惧彂", wrkMast.getWrkNo(), liftSta.getSiteId());
return false;
}
@@ -779,7 +777,7 @@
if (liftNo == null) {
//鏈垎閰嶆彁鍗囨満
Integer staNo = wrkMast.getStaNo();
- liftNo = ForkLiftUtils.getConveyorBindLiftNo(staNo);
+ liftNo = LiftUtils.getConveyorBindLiftNo(staNo);
if(liftNo == null) {
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾湭鎵惧埌鍖归厤鐨勬彁鍗囨満", wrkMast.getWrkNo());
return false;
@@ -829,7 +827,7 @@
assignCommand.setCommands(commands);
assignCommand.setLiftNo(liftNo);
assignCommand.setTaskNo(wrkMast.getWrkNo());
- assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id);
+ assignCommand.setTaskMode(LiftTaskModeType.PICK_PUT.id);
wrkMast.setWrkSts(WrkStsType.OUTBOUND_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 103.鐢熸垚鍏ュ簱浠诲姟 ==> 104.鎻愬崌鏈烘惉杩愪腑
wrkMast.setShuttleNo(null);//閲婃斁灏忚溅
@@ -895,8 +893,8 @@
News.error("鎻愬崌鏈哄凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅澶辫触锛屼絾鏈壘鍒板伐浣滄。銆傛彁鍗囨満鍙�={}锛屽伐浣滃彿={}", liftProtocol.getLiftNo(), liftProtocol.getTaskNo());
}
}else {
- boolean checkPreviewDispatchForkLift = commonService.checkWorkNoContainMk(liftProtocol.getTaskNo(), WrkIoType.PREVIEW_LIFT_MOVE.id);
- if (checkPreviewDispatchForkLift) {
+ boolean checkPreviewDispatchLift = commonService.checkWorkNoContainMk(liftProtocol.getTaskNo(), WrkIoType.PREVIEW_LIFT_MOVE.id);
+ if (checkPreviewDispatchLift) {
//灞炰簬鎻愬崌鏈洪璋冨害绉诲姩浠诲姟
//鏃犲伐浣滄。鏀拺锛岀洿鎺ョ‘璁ゅ畬鎴�
liftThread.setSyncTaskNo(0);
@@ -1002,31 +1000,31 @@
*/
private void recLiftErr() {
Date now = new Date();
- List<DeviceConfig> forkliftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
- .eq("device_type", String.valueOf(SlaveType.ForkLift)));
- for (DeviceConfig device : forkliftList) {
+ List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Lift)));
+ for (DeviceConfig device : liftList) {
// 鑾峰彇鎻愬崌鏈轰俊鎭�
- ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, device.getDeviceNo());
- if (forkLiftThread == null) {
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getDeviceNo());
+ if (liftThread == null) {
continue;
}
- ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus();
- if (forkLiftProtocol == null) {
+ LiftProtocol liftProtocol = liftThread.getStatus();
+ if (liftProtocol == null) {
continue;
}
- if (forkLiftProtocol.getTaskNo() != 0) {
+ if (liftProtocol.getTaskNo() != 0) {
//鏈変换鍔�
- BasLiftErrLog latest = basLiftErrLogService.findLatestByTaskNo(device.getDeviceNo(), forkLiftProtocol.getTaskNo());
+ BasLiftErrLog latest = basLiftErrLogService.findLatestByTaskNo(device.getDeviceNo(), liftProtocol.getTaskNo());
// 鏈夊紓甯�
if (latest == null) {
- if (forkLiftProtocol.getErrorCode() != null && forkLiftProtocol.getErrorCode() != 0) {
- WrkMast wrkMast = wrkMastService.selectByWorkNo(forkLiftProtocol.getWrkNo());
+ if (liftProtocol.getErrorCode() != null && liftProtocol.getErrorCode() != 0) {
+ WrkMast wrkMast = wrkMastService.selectByWorkNo(liftProtocol.getTaskNo());
if (wrkMast == null) {
continue;
}
- BasLiftErr basLiftErr = basLiftErrService.queryByCode(forkLiftProtocol.getErrorCode());
+ BasLiftErr basLiftErr = basLiftErrService.queryByCode(liftProtocol.getErrorCode());
String errName = basLiftErr==null? "鏈煡寮傚父":basLiftErr.getErrName();
BasLiftErrLog basLiftErrLog = new BasLiftErrLog(
@@ -1051,7 +1049,7 @@
now, // 淇敼鏃堕棿
null, // 淇敼浜哄憳
"浠诲姟涓紓甯�", // 澶囨敞
- JSON.toJSONString(forkLiftProtocol) // 绯荤粺鐘舵�佹暟鎹�
+ JSON.toJSONString(liftProtocol) // 绯荤粺鐘舵�佹暟鎹�
);
if (!basLiftErrLogService.insert(basLiftErrLog)) {
News.error("鎻愬崌鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", device.getDeviceNo(), errName);
@@ -1059,7 +1057,7 @@
}
} else {
// 寮傚父淇
- if (forkLiftProtocol.getErrorCode() == null || forkLiftProtocol.getErrorCode() == 0) {
+ if (liftProtocol.getErrorCode() == null || liftProtocol.getErrorCode() == 0) {
latest.setEndTime(now);
latest.setUpdateTime(now);
latest.setStatus(2);
@@ -1094,8 +1092,26 @@
}
//鍒ゆ柇褰撳墠灏忚溅鏄惁婊¤冻闇�瑕佸厖鐢佃姹�
- if (!shuttleThread.isRequireCharge()) {
- continue;
+ if (shuttleThread.isRequireCharge().equals(ShuttleRequireChargeType.NONE)) {
+ continue;//鏃犻渶鍏呯數
+ }
+
+ boolean forceCharge = true;
+ if (shuttleThread.isRequireCharge().equals(ShuttleRequireChargeType.SUGGEST_CHARGE)) {
+ BasShuttle basShuttle = basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", device.getDeviceNo()));
+ if (basShuttle != null) {
+ Integer suggestChargeLine = basShuttle.getSuggestChargeLine();
+ boolean chargeSuggestResult = Integer.parseInt(shuttleProtocol.getBatteryPower()) < suggestChargeLine;
+ if (chargeSuggestResult) {
+ //妫�娴嬬郴缁熸槸鍚︽湁浠诲姟
+ List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("io_type", 1, 101, 201));
+ if (wrkMasts.isEmpty()) {
+ forceCharge = false;
+ }else {
+ continue;
+ }
+ }
+ }
}
WrkMast wrkMast1 = wrkMastService.selectShuttleWorking(shuttleProtocol.getShuttleNo());
@@ -1171,7 +1187,7 @@
wrkMast.setIoPri((double) 999);
wrkMast.setLocNo(chargeLocNo);
wrkMast.setShuttleNo(device.getDeviceNo());
- wrkMast.setMemo("charge");
+ wrkMast.setMemo(forceCharge ? "forceCharge" : "suggestCharge");
wrkMast.setAppeTime(new Date());
if (!wrkMastService.insert(wrkMast)) {
News.error("淇濆瓨{}鍙峰洓鍚戠┛姊溅鍏呯數浠诲姟澶辫触!!!", device.getDeviceNo());
@@ -1321,7 +1337,7 @@
List<ShuttleCommand> commands = shuttleOperaUtils.getShuttleChargeCommand(assignCommand, shuttleThread, true);
assignCommand.setCommands(commands);//杩愯鍛戒护
- wrkMast.setWrkSts(WrkStsType.CHARGE_SHUTTLE_WORKING.sts);
+ wrkMast.setWrkSts(WrkStsType.CHARGE_SHUTTLE_START_CHARGING.sts);
wrkMast.setModiTime(new Date());
if (!wrkMastService.updateById(wrkMast)) {
return false;
@@ -1338,7 +1354,7 @@
//灏忚溅鍋滄鍏呯數
private synchronized boolean executeShuttleChargeStepStopCharge(WrkMast wrkMast) {
- if (wrkMast.getWrkSts() == WrkStsType.CHARGE_SHUTTLE_WORKING.sts) {
+ if (wrkMast.getWrkSts() == WrkStsType.CHARGE_SHUTTLE_CHARGING.sts) {
ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
if (shuttleThread == null) {
return false;
@@ -1348,7 +1364,21 @@
return false;
}
- if (!shuttleThread.isChargingCompleted()) {
+ boolean stopCharge = false;
+ if (wrkMast.getMemo().equals("suggestChargeTaskStop")) {
+ stopCharge = true;
+ }else {
+ if (shuttleThread.isChargingCompleted()) {
+ stopCharge = true;
+ }
+ }
+
+ if (!stopCharge) {
+ return false;
+ }
+
+ Object limitObj = redisUtil.get(RedisKeyType.TASK_RUN_LIMIT.key + wrkMast.getWrkNo());
+ if (limitObj != null) {
return false;
}
@@ -1364,6 +1394,7 @@
//涓嬪彂浠诲姟
shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand);
+ redisUtil.set(RedisKeyType.TASK_RUN_LIMIT.key + wrkMast.getWrkNo(), "limit", 10);
return false;
}
return true;
@@ -1371,7 +1402,7 @@
//灏忚溅绂诲紑鍏呯數妗�
private synchronized boolean executeShuttleChargeStepLeaveCharge(WrkMast wrkMast) {
- if (wrkMast.getWrkSts() == WrkStsType.CHARGE_SHUTTLE_COMPLETE.sts) {
+ if (wrkMast.getWrkSts() == WrkStsType.CHARGE_SHUTTLE_CHARGING_COMPLETE.sts) {
ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
if (shuttleThread == null) {
return false;
@@ -1510,8 +1541,8 @@
//灏忚溅宸插湪杩戠偣浣嶇疆鏃犻渶鍓嶅線
if (shuttleProtocol.getCurrentLocNo().equals(endLocation)) {
wrkMast.setWrkSts(WrkStsType.MOVE_NEARBY_COMPLETE.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 303.灏忚溅绉诲姩鑷宠繎鐐瑰畬鎴�
- wrkMast.setSourceStaNo(recentLiftStation.getStaNo());
- wrkMast.setStaNo(targetLiftSta.getStaNo());
+ wrkMast.setSourceStaNo(recentLiftStation.getSiteId());
+ wrkMast.setStaNo(targetLiftSta.getSiteId());
wrkMast.setModiTime(now);
wrkMast.setSystemMsg("");//娓呯┖娑堟伅
wrkMastService.updateById(wrkMast);
@@ -1536,8 +1567,8 @@
assignCommand.setCommands(commands);
wrkMast.setWrkSts(WrkStsType.MOVE_NEARBY.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 302.灏忚溅绉诲姩鑷宠繎鐐逛腑
- wrkMast.setSourceStaNo(recentLiftStation.getStaNo());
- wrkMast.setStaNo(targetLiftSta.getStaNo());
+ wrkMast.setSourceStaNo(recentLiftStation.getSiteId());
+ wrkMast.setStaNo(targetLiftSta.getSiteId());
wrkMast.setModiTime(now);
wrkMast.setSystemMsg("");//娓呯┖娑堟伅
if (wrkMastService.updateById(wrkMast)) {
@@ -1630,7 +1661,13 @@
int targetLev = Utils.getLev(shuttleProtocol.getCurrentLocNo());
if (object == null || liftProtocol.getLev() != targetLev) {
//鑾峰彇鎻愬崌鏈哄懡浠�
- LiftCommand liftCommand = liftThread.getMoveCommand(wrkMast.getWrkNo(), liftProtocol.getLev(), targetLev);
+ LiftStaProtocol startSta = LiftUtils.getLiftStaByLev(liftProtocol.getLiftNo(), liftProtocol.getLev());
+ LiftStaProtocol targetSta = LiftUtils.getLiftStaByLev(liftProtocol.getLiftNo(), targetLev);
+ if (startSta == null || targetSta == null) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛岀珯鐐规暟鎹笉瀛樺湪", wrkMast.getWrkNo(), wrkMast.getLiftNo());
+ return false;
+ }
+ LiftCommand liftCommand = liftThread.getMoveCommand(commonService.getWorkNo(WrkIoType.PREVIEW_LIFT_MOVE.id), startSta.getSiteId(), targetSta.getSiteId());
ArrayList<LiftCommand> commands = new ArrayList<>();
commands.add(liftCommand);
@@ -1644,6 +1681,12 @@
liftAction.assignWork(wrkMast.getLiftNo(), assignCommand);
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満鍦▄}灞傦紝鎻愬崌鏈轰笉鍦ㄥ皬杞﹀眰锛岃皟搴︾Щ鍔ㄤ腑", wrkMast.getWrkNo(), liftProtocol.getLev(), wrkMast.getLiftNo());
redisUtil.set(RedisKeyType.LIFT_MOVE_TO_SHUTTLE_LIMIT.key + wrkMast.getWrkNo(), "lift_moving", 60 * 3);
+ redisUtil.set(RedisKeyType.TASK_RUN_LIMIT.key + wrkMast.getWrkNo(), "lock", 8);
+ return false;
+ }
+
+ Object limitObj = redisUtil.get(RedisKeyType.TASK_RUN_LIMIT.key + wrkMast.getWrkNo());
+ if (limitObj != null) {
return false;
}
@@ -1658,7 +1701,7 @@
assignCommand.setAuto(true);//鑷姩妯″紡
//鑾峰彇灏忚溅鍒版彁鍗囨満琛岃蛋鍛戒护
- List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftLocNo, NavigationMapType.getNormalWithDevice(), assignCommand, shuttleThread, "inLift");
+ List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftLocNo, NavigationMapType.getMapTypes(NavigationMapType.NORMAL), assignCommand, shuttleThread, "inLift");
if (commands == null) {
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
return false;//璺緞瑙i攣澶辫触
@@ -1720,7 +1763,7 @@
}
//鑾峰彇鎻愬崌鏈哄懡浠�
- LiftCommand liftCommand = liftThread.getShuttleSwitchCommand(wrkMast.getWrkNo(), sourceLiftSta.getLev(), liftSta.getLev());
+ LiftCommand liftCommand = liftThread.getShuttleSwitchCommand(wrkMast.getWrkNo(), sourceLiftSta.getSiteId(), liftSta.getSiteId());
ArrayList<LiftCommand> commands = new ArrayList<>();
commands.add(liftCommand);
@@ -1795,7 +1838,14 @@
return false;
}
- String targetLocNo = navigateUtils.calcFirstLocation(shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.NORMAL), null, null, 5);
+ //灏忚溅鍑烘彁鍗囨満杩戠偣璺濈
+ int shuttleOutLiftLocationDistance = 2;
+ Config shuttleOutLiftLocationDistanceConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "shuttleOutLiftLocationDistance"));
+ if (shuttleOutLiftLocationDistanceConfig != null) {
+ shuttleOutLiftLocationDistance = Integer.parseInt(shuttleOutLiftLocationDistanceConfig.getValue());
+ }
+
+ String targetLocNo = navigateUtils.calcFirstLocation(shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.NORMAL), null, null, shuttleOutLiftLocationDistance);
if (targetLocNo == null) {//鍑烘彁鍗囨満杩戠偣璁$畻澶辫触
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛屽嚭鎻愬崌鏈鸿繎鐐硅绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
return false;
@@ -1894,4 +1944,75 @@
return true;
}
+ //鑷姩鍒囨崲鍑哄叆搴撴ā寮�
+ public void autoSwitchLiftIOMode() {
+ List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Lift)));
+ for (DeviceConfig device : liftList) {
+ Integer liftNo = device.getDeviceNo();
+ LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftNo);
+ if (liftThread == null) {
+ continue;
+ }
+ LiftProtocol liftProtocol = liftThread.getStatus();
+ if (liftProtocol == null) {
+ continue;
+ }
+
+ List<Integer> liftAllStaNo = LiftUtils.getLiftAllStaNo(liftNo);
+ if (liftAllStaNo.isEmpty()) {
+ continue;
+ }
+
+ List<Integer> conveyorBindLiftAllStaNo = LiftUtils.getConveyorBindLiftAllStaNo(liftNo);
+ if (conveyorBindLiftAllStaNo.isEmpty()) {
+ continue;
+ }
+
+ //鑾峰彇鍏ュ簱浠诲姟
+ List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+ .in("sta_no", liftAllStaNo)
+ .in("wrk_sts"
+ , WrkStsType.NEW_INBOUND.sts
+ , WrkStsType.INBOUND_DEVICE_RUN.sts
+ , WrkStsType.INBOUND_LIFT_RUN.sts
+ , WrkStsType.INBOUND_LIFT_RUN_COMPLETE.sts
+ , WrkStsType.INBOUND_SHUTTLE_RUN.sts
+ , WrkStsType.INBOUND_SHUTTLE_RUN_COMPLETE.sts
+ ));
+
+ //鑾峰彇鍑哄簱浠诲姟
+ List<WrkMast> outWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+ .in("sta_no", conveyorBindLiftAllStaNo)
+ .in("wrk_sts"
+ , WrkStsType.NEW_OUTBOUND.sts
+ , WrkStsType.OUTBOUND_SHUTTLE_RUN.sts
+ , WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts
+ , WrkStsType.OUTBOUND_LIFT_RUN.sts
+ , WrkStsType.OUTBOUND_LIFT_RUN_COMPLETE.sts
+ ));
+
+ if (liftProtocol.getIOModeType().equals(LiftIoModeType.NONE)) {
+ //鏈煡妯″紡
+ if (!inWrkMasts.isEmpty()) {
+ liftThread.switchIOMode(LiftIoModeType.IN);
+ } else if (!outWrkMasts.isEmpty()) {
+ liftThread.switchIOMode(LiftIoModeType.OUT);
+ }else {
+ liftThread.switchIOMode(LiftIoModeType.IN);
+ }
+ } else if (liftProtocol.getIOModeType().equals(LiftIoModeType.IN)) {
+ //鍏ュ簱妯″紡
+ if (inWrkMasts.isEmpty() && !outWrkMasts.isEmpty()) {
+ liftThread.switchIOMode(LiftIoModeType.OUT);
+ }
+ } else if (liftProtocol.getIOModeType().equals(LiftIoModeType.OUT)) {
+ //鍑哄簱妯″紡
+ if (outWrkMasts.isEmpty() && !inWrkMasts.isEmpty()) {
+ liftThread.switchIOMode(LiftIoModeType.IN);
+ }
+ }
+ }
+ }
+
}
--
Gitblit v1.9.1