From 9af152509959409830bf542f147aca01d7616221 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期六, 02 八月 2025 13:48:41 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 677 +++++++++++++++++++++++++++++--------------------------
1 files changed, 358 insertions(+), 319 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 c21959d..63ca0b6 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -17,10 +17,8 @@
import com.zy.core.cache.SlaveConnection;
import com.zy.core.dispatcher.ShuttleDispatchUtils;
import com.zy.core.enums.*;
-import com.zy.core.model.*;
import com.zy.core.model.command.*;
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;
@@ -38,8 +36,6 @@
@Service("mainService")
public class MainServiceImpl {
- @Autowired
- private SlaveProperties slaveProperties;
@Autowired
private WrkMastService wrkMastService;
@Autowired
@@ -76,6 +72,8 @@
private NotifyUtils notifyUtils;
@Autowired
private BasShuttleChargeService basShuttleChargeService;
+ @Autowired
+ private DeviceConfigService deviceConfigService;
/**
* 鍒濆鍖栧疄鏃跺湴鍥�
@@ -89,7 +87,7 @@
Object data = redisUtil.get(RedisKeyType.MAP.key + lev);
if (data == null) {//redis鍦板浘鏁版嵁涓虹┖
//杞藉叆鍦板浘
- List<List<MapNode>> lists = navigateMapData.getJsonData(lev, -1, null, null);//鑾峰彇瀹屾暣鍦板浘(鍖呮嫭鍏ュ簱鍑哄簱)
+ List<List<MapNode>> lists = navigateMapData.getJsonOriginData(lev, NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null);//鑾峰彇瀹屾暣鍦板浘(鍖呮嫭鍏ュ簱鍑哄簱)
//瀛樺叆鏁版嵁搴�
basMap.setData(JSON.toJSONString(lists));
@@ -198,7 +196,7 @@
assignCommand.setAuto(true);//鑷姩妯″紡
//鑾峰彇灏忚溅鍒拌緭閫佺珯鐐硅璧板懡浠�
- List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(liftSta.getLocNo(), wrkMast.getLocNo(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
+ List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(liftSta.getLocNo(), wrkMast.getLocNo(), NavigationMapType.getDfxWithDevice(), assignCommand, shuttleThread);
if (commands == null) {
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
return false;
@@ -309,6 +307,23 @@
return false;
}
+ List<WrkMast> shuttleMoveList = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+ .eq("io_type", 200)
+ );
+ for (WrkMast moveWrkMast : shuttleMoveList) {
+ if(Utils.getLev(moveWrkMast.getLocNo()) != Utils.getLev(wrkMast.getSourceLocNo())) {
+ continue;
+ }
+
+ if(Utils.getLev(moveWrkMast.getLocNo()) == Utils.getLev(moveWrkMast.getSourceLocNo())) {
+ continue;
+ }
+
+ //瀛樺湪鎹㈠眰浠诲姟锛屽嚭搴撲换鍔℃殏鏃朵笉鎵ц
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽瓨鍦ㄦ崲灞備换鍔★紝鍑哄簱浠诲姟绛夊緟涓�", wrkMast.getWrkNo());
+ return false;
+ }
+
boolean checkLocPathIsAvailable = navigateUtils.checkLocPathIsAvailable(wrkMast.getSourceLocNo(), liftSta.getLocNo());
if(!checkLocPathIsAvailable) {
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾湭璁$畻鍒板彲鎵ц璺緞锛岀瓑寰呬腑", wrkMast.getWrkNo());
@@ -319,7 +334,7 @@
//寮哄埗棰勭暀涓�鍙板皬杞︾粰鍏ュ簱浠诲姟
int lev = Utils.getLev(wrkMast.getSourceLocNo());
//鑾峰彇褰撳墠妤煎眰鏈夊嚑鍙板彲鐢ㄥ皬杞�
- int shuttleCount = shuttleDispatchUtils.getShuttleCountByLev(lev);
+ int shuttleCount = shuttleDispatchUtils.getShuttleEnableUseCountByLev(lev);
if (shuttleCount >= 2) {//鍙湁鍙敤灏忚溅鏁伴噺澶т簬2锛屾墠杩涜鍏ュ簱浠诲姟棰勭暀灏忚溅
int shuttleWrkInObligateCount = 1;//棰勭暀灏忚溅鏁伴噺
Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "shuttleWrkInObligateCount").eq("status", 1));
@@ -371,6 +386,13 @@
return false;
}
+ //妫�娴嬫槸鍚﹀瓨鍦ㄧЩ鍔ㄤ换鍔�
+ WrkMast moveWorking = wrkMastService.selectShuttleHasMoveWorking(wrkMast.getShuttleNo());
+ if (moveWorking != null) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽皬杞﹀瓨鍦ㄧЩ鍔ㄤ换鍔�", wrkMast.getWrkNo());
+ return false;
+ }
+
ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙�
assignCommand.setTaskMode(ShuttleTaskModeType.TRANSPORT.id);//灏忚溅绉诲簱浠诲姟
@@ -378,7 +400,7 @@
assignCommand.setAuto(true);//鑷姩妯″紡
//鑾峰彇灏忚溅鍒拌緭閫佺珯鐐硅璧板懡浠�
- List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), liftSta.getLocNo(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
+ List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), liftSta.getLocNo(), NavigationMapType.getDfxWithDevice(), assignCommand, shuttleThread);
if (commands == null) {
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
return false;
@@ -414,93 +436,6 @@
return false;
}
return true;
- }
-
- /**
- * 鍥涘悜绌挎杞︿换鍔″畬鎴�
- */
- public synchronized void shuttleFinished() {
- try {
- for (ShuttleSlave shuttle : slaveProperties.getShuttle()) {
- //鑾峰彇鍥涘悜绌挎杞︿俊鎭�
- ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId());
- ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
- if (shuttleProtocol == null) {
- continue;
- }
-
- //鍥涘悜绌挎杞︾姸鎬佷负绛夊緟纭銆佸皬杞﹀浜庣┖闂茬姸鎬�
- if (shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.WAITING.id //浠诲姟瀹屾垚绛夊緟纭
- && shuttleProtocol.getTaskNo() != 0
- ) {
- //灏嗕换鍔℃。鏍囪涓哄畬鎴�
- WrkMast wrkMast = wrkMastService.selectByWorkNo(shuttleProtocol.getTaskNo());
- if (wrkMast != null) {
- if (wrkMast.getWrkSts() == WrkStsType.INBOUND_SHUTTLE_RUN.sts) {
- //5.灏忚溅鎼繍涓� ==> 9.鍏ュ簱瀹屾垚
- wrkMast.setWrkSts(WrkStsType.COMPLETE_INBOUND.sts);
- shuttleThread.setSyncTaskNo(0);
- } else if (wrkMast.getWrkSts() == WrkStsType.OUTBOUND_SHUTTLE_RUN.sts) {
- //102.灏忚溅鎼繍涓� ==> 103.灏忚溅鎼繍瀹屾垚
- wrkMast.setWrkSts(WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts);
- shuttleThread.setSyncTaskNo(0);
- } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_SITE.sts) {
- //302.灏忚溅绉诲姩鑷崇珯鐐� ==> 303.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴�
- wrkMast.setWrkSts(WrkStsType.MOVE_SITE_COMPLETE.sts);
- shuttleThread.setSyncTaskNo(0);
- } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_OUT_LIFT.sts) {
- //308.灏忚溅杩佸嚭鎻愬崌鏈轰腑 ==> 309.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴�
- if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) != Utils.getLev(wrkMast.getLocNo())) {
- continue;//灏忚溅鏈埌杈剧洰鏍囧眰
- }
- wrkMast.setWrkSts(WrkStsType.MOVE_OUT_LIFT_COMPLETE.sts);
- shuttleThread.setSyncTaskNo(0);
- } else if (wrkMast.getWrkSts() == WrkStsType.MOVE_SHUTTLE.sts) {
- //310.灏忚溅绉诲姩涓� ==> 311.灏忚溅绉诲姩瀹屾垚
- wrkMast.setWrkSts(WrkStsType.COMPLETE_MOVE.sts);
- shuttleThread.setSyncTaskNo(0);
- notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVE_COMPLETE);//瑙﹀彂閫氱煡
- } else if (wrkMast.getWrkSts() == WrkStsType.CHARGE_SHUTTLE_WORKING.sts) {
- //204.灏忚溅鍏呯數涓� ==> 205.灏忚溅鍏呯數瀹屾垚
- wrkMast.setWrkSts(WrkStsType.CHARGE_SHUTTLE_COMPLETE.sts);
- shuttleThread.setSyncTaskNo(0);
- notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_POWER_COMPLETE);//瑙﹀彂閫氱煡
- } else if (wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_SHUTTLE_RUN.sts) {
- //502.灏忚溅鎼繍涓� ==> 509.绉诲簱瀹屾垚
- wrkMast.setWrkSts(WrkStsType.COMPLETE_LOC_MOVE.sts);
- shuttleThread.setSyncTaskNo(0);
- notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_DELIVERY);//瑙﹀彂閫氱煡
- } else {
- continue;
- }
-
- if (wrkMastService.updateById(wrkMast)) {
- //璁剧疆鍥涘悜绌挎杞︿负绌洪棽鐘舵��
- shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.IDLE);
- News.info("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅銆傚洓鍚戠┛姊溅鍙�={}", shuttleProtocol.getShuttleNo());
- } else {
- News.error("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅澶辫触锛屼絾鏈壘鍒板伐浣滄。銆傚洓鍚戠┛姊溅鍙�={}锛屽伐浣滃彿={}", shuttleProtocol.getShuttleNo(), shuttleProtocol.getTaskNo());
- }
- } else {
- Object object = redisUtil.get(RedisKeyType.SHUTTLE_WORK_FLAG.key + shuttleProtocol.getTaskNo());
- if(object != null){
- ShuttleAssignCommand assignCommand = JSON.parseObject(object.toString(), ShuttleAssignCommand.class);
- if (!assignCommand.getAuto()) {
- //鎵嬪姩妯″紡
- //宸ヤ綔鍙锋竻闆�
- shuttleThread.setTaskNo(0);
- //璁剧疆鍥涘悜绌挎杞︿负绌洪棽鐘舵��
- shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.IDLE);
- News.info("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅銆傚洓鍚戠┛姊溅鍙�={}", shuttleProtocol.getShuttleNo());
- }
- }
- }
- }
-
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
}
/**
@@ -559,8 +494,22 @@
return false;
}
+ if (shuttleProtocol.getCurrentLocNo() == null) {
+ return false;
+ }
+
+ //鍒ゆ柇灏忚溅鏄惁鍒拌揪璐х墿搴撲綅
if (!shuttleProtocol.getCurrentLocNo().equals(wrkMast.getSourceLocNo())) {
+ //灏忚溅鏈埌杈惧彇璐т綅缃�
+ shuttleDispatchUtils.dispatchShuttle(wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getShuttleNo());//璋冨害灏忚溅鍒拌揣鐗╂墍鍦ㄥ簱浣嶈繘琛屽彇璐�
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽皬杞︽湭鍒拌揪鍙栬揣浣嶇疆", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
+ return false;
+ }
+
+ //妫�娴嬫槸鍚﹀瓨鍦ㄧЩ鍔ㄤ换鍔�
+ WrkMast moveWorking = wrkMastService.selectShuttleHasMoveWorking(wrkMast.getShuttleNo());
+ if (moveWorking != null) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽皬杞﹀瓨鍦ㄧЩ鍔ㄤ换鍔�", wrkMast.getWrkNo());
return false;
}
@@ -578,9 +527,10 @@
assignCommand.setTaskMode(ShuttleTaskModeType.TRANSPORT.id);//灏忚溅绉诲簱浠诲姟
assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙�
assignCommand.setAuto(true);//鑷姩妯″紡
+ assignCommand.setLocNo(wrkMast.getLocNo());
//鑾峰彇灏忚溅鍒拌緭閫佺珯鐐硅璧板懡浠�
- List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), wrkMast.getLocNo(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
+ List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(wrkMast.getSourceLocNo(), wrkMast.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.DFX), assignCommand, shuttleThread);
if (commands == null) {
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
return false;
@@ -672,45 +622,6 @@
return false;
}
- Integer liftNo = wrkMast.getLiftNo();
- if (liftNo == null) {
- //鏈垎閰嶆彁鍗囨満
- Integer staNo = wrkMast.getSourceStaNo();
- liftNo = ForkLiftUtils.getConveyorBindLiftNo(staNo);
- if(liftNo == null) {
- News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾湭鎵惧埌鍖归厤鐨勬彁鍗囨満", wrkMast.getWrkNo());
- return false;
- }
- }
-
- ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo);
- if (forkLiftThread == null) {
- return false;
- }
- ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus();
- if (forkLiftProtocol == null) {
- return false;
- }
- if (!forkLiftThread.isIdle()) {
- News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屽繖纰屼腑", wrkMast.getWrkNo(), liftSta.getLiftNo());
- return false;
- }
-
- //鍒ゆ柇鎻愬崌鏈烘槸鍚﹀浜庡叆搴撴ā寮�
- if (!forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.IN)) {
- News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾彁鍗囨満涓嶅浜庡叆搴撴ā寮忥紝绂佹鍏ュ簱", wrkMast.getWrkNo());
- return false;
- }
-
- //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟
- WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo());
- if (liftWrkMast != null) {
- if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚�
- News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo());
- return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇�
- }
- }
-
//妫�娴嬫ゼ灞傛槸鍚︽湁鍙敤绌挎杞�
boolean checkLevHasShuttle = Utils.checkLevHasShuttle(liftSta.getLev());
if (!checkLevHasShuttle) {
@@ -734,6 +645,44 @@
return false;
}
+ Integer liftNo = wrkMast.getLiftNo();
+ if (liftNo == null) {
+ //鏈垎閰嶆彁鍗囨満
+ Integer staNo = wrkMast.getSourceStaNo();
+ liftNo = ForkLiftUtils.getConveyorBindLiftNo(staNo);
+ if(liftNo == null) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾湭鎵惧埌鍖归厤鐨勬彁鍗囨満", wrkMast.getWrkNo());
+ return false;
+ }
+
+ //鐢宠鎻愬崌鏈鸿祫婧�
+ boolean applyForkLift = forkLiftAction.applyForkLift(liftNo, wrkMast.getWrkNo());
+ if(!applyForkLift) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀敵璇锋彁鍗囨満璧勬簮澶辫触锛岀姝㈠叆搴�", wrkMast.getWrkNo());
+ return false;
+ }
+ return false;
+ }
+
+ ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo);
+ if (forkLiftThread == null) {
+ return false;
+ }
+ ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus();
+ if (forkLiftProtocol == null) {
+ return false;
+ }
+ if (!forkLiftThread.isIdle()) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屽繖纰屼腑", wrkMast.getWrkNo(), liftSta.getLiftNo());
+ return false;
+ }
+
+ //鍒ゆ柇鎻愬崌鏈烘槸鍚﹀浜庡叆搴撴ā寮�
+ if (!forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.IN)) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾彁鍗囨満涓嶅浜庡叆搴撴ā寮忥紝绂佹鍏ュ簱", wrkMast.getWrkNo());
+ return false;
+ }
+
//璇锋眰涓婄骇绯荤粺锛屾槸鍚﹀厑璁稿叆搴�
boolean inMission = ForkLiftUtils.queryInMission(wrkMast.getSourceStaNo(), liftSta.getLiftNo(), wrkMast.getWmsWrkNo());
if (!inMission) {
@@ -742,9 +691,9 @@
}
//鑾峰彇鎻愬崌鏈哄懡浠�
- List<ForkLiftCommand> liftCommands = forkLiftThread.getPickAndPutCommand(wrkMast.getWrkNo(), wrkMast.getSourceStaNo(), liftSta.getLev());
+ ForkLiftCommand liftCommand = forkLiftThread.getPickAndPutCommand(wrkMast.getWrkNo(), wrkMast.getSourceStaNo(), liftSta.getLev());
ArrayList<ForkLiftCommand> commands = new ArrayList<>();
- commands.addAll(liftCommands);
+ commands.add(liftCommand);
//鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔
LiftAssignCommand assignCommand = new LiftAssignCommand();
@@ -754,7 +703,6 @@
assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id.shortValue());
wrkMast.setWrkSts(WrkStsType.INBOUND_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 1.鐢熸垚鍏ュ簱浠诲姟 ==> 3.鎻愬崌鏈烘惉杩愪腑
- wrkMast.setLiftNo(liftNo);
wrkMast.setSystemMsg("");//娓呯┖娑堟伅
wrkMast.setModiTime(now);
if (wrkMastService.updateById(wrkMast)) {
@@ -835,6 +783,13 @@
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屾湭鎵惧埌鍖归厤鐨勬彁鍗囨満", wrkMast.getWrkNo());
return false;
}
+ //鐢宠鎻愬崌鏈鸿祫婧�
+ boolean applyForkLift = forkLiftAction.applyForkLift(liftSta.getLiftNo(), wrkMast.getWrkNo());
+ if(!applyForkLift) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀敵璇锋彁鍗囨満璧勬簮澶辫触锛岀姝㈡墽琛屽嚭搴�", wrkMast.getWrkNo());
+ return false;
+ }
+ return false;
}
ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo);
@@ -856,15 +811,6 @@
return false;
}
- //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟
- WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo());
- if (liftWrkMast != null) {
- if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚�
- News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo());
- return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇�
- }
- }
-
//璇锋眰涓婄骇绯荤粺锛屾槸鍚﹀厑璁稿嚭搴�
boolean outMission = ForkLiftUtils.queryOutMission(wrkMast.getStaNo());
if (!outMission) {
@@ -873,9 +819,9 @@
}
//鑾峰彇鎻愬崌鏈哄懡浠�
- List<ForkLiftCommand> liftCommands = forkLiftThread.getPickAndPutCommand(wrkMast.getWrkNo(), liftSta.getLev(), wrkMast.getStaNo());
+ ForkLiftCommand liftCommand = forkLiftThread.getPickAndPutCommand(wrkMast.getWrkNo(), liftSta.getLev(), wrkMast.getStaNo());
ArrayList<ForkLiftCommand> commands = new ArrayList<>();
- commands.addAll(liftCommands);
+ commands.add(liftCommand);
//鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔
LiftAssignCommand assignCommand = new LiftAssignCommand();
@@ -885,7 +831,6 @@
assignCommand.setTaskMode(ForkLiftTaskModeType.PICK_PUT.id.shortValue());
wrkMast.setWrkSts(WrkStsType.OUTBOUND_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 103.鐢熸垚鍏ュ簱浠诲姟 ==> 104.鎻愬崌鏈烘惉杩愪腑
- wrkMast.setLiftNo(liftNo);
wrkMast.setShuttleNo(null);//閲婃斁灏忚溅
wrkMast.setSystemMsg("");//娓呯┖娑堟伅
wrkMast.setModiTime(new Date());
@@ -903,9 +848,14 @@
*/
public synchronized void forkLiftFinished() {
try {
- for (ForkLiftSlave forkLiftSlave : slaveProperties.getForkLift()) {
+ List<DeviceConfig> forkliftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.ForkLift)));
+ for (DeviceConfig device : forkliftList) {
//鑾峰彇鎻愬崌鏈轰俊鎭�
- ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, forkLiftSlave.getId());
+ ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, device.getDeviceNo());
+ if(forkLiftThread == null) {
+ continue;
+ }
ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus();
if (forkLiftProtocol == null) {
continue;
@@ -975,9 +925,11 @@
*/
private void recShuttleErr() {
Date now = new Date();
- for (ShuttleSlave shuttleSlave : slaveProperties.getShuttle()) {
+ List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Shuttle)));
+ for (DeviceConfig device : shuttleList) {
// 鑾峰彇鍥涘悜绌挎杞︿俊鎭�
- ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleSlave.getId());
+ ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo());
if (shuttleThread == null) {
continue;
}
@@ -988,7 +940,7 @@
if (shuttleProtocol.getTaskNo() != 0) {
//鏈変换鍔�
- BasShuttleErrLog latest = basShuttleErrLogService.findLatestByTaskNo(shuttleSlave.getId(), shuttleProtocol.getTaskNo());
+ BasShuttleErrLog latest = basShuttleErrLogService.findLatestByTaskNo(device.getDeviceNo(), shuttleProtocol.getTaskNo());
// 鏈夊紓甯�
if (latest == null) {
if (shuttleProtocol.getErrorCode() != null && Integer.parseInt(shuttleProtocol.getErrorCode()) != 0) {
@@ -1006,7 +958,7 @@
null, // 缁撴潫鏃堕棿
wrkMast.getWrkSts(), // 宸ヤ綔鐘舵��
wrkMast.getIoType(), // 鍏ュ嚭搴撶被鍨�
- shuttleSlave.getId(), // 鍥涘悜绌挎杞�
+ device.getDeviceNo(), // 鍥涘悜绌挎杞�
null, // plc
wrkMast.getLocNo(), // 鐩爣搴撲綅
wrkMast.getStaNo(), // 鐩爣绔�
@@ -1024,7 +976,7 @@
JSON.toJSONString(shuttleProtocol) // 绯荤粺鐘舵�佹暟鎹�
);
if (!basShuttleErrLogService.insert(basShuttleErrLog)) {
- News.error("鍥涘悜绌挎杞lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", shuttleSlave.getId(), errName);
+ News.error("鍥涘悜绌挎杞lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", device.getDeviceNo(), errName);
}
}
} else {
@@ -1034,7 +986,7 @@
latest.setUpdateTime(now);
latest.setStatus(2);
if (!basShuttleErrLogService.updateById(latest)) {
- News.error("鍥涘悜绌挎杞lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", shuttleSlave.getId(), latest.getId());
+ News.error("鍥涘悜绌挎杞lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", device.getDeviceNo(), latest.getId());
}
}
}
@@ -1047,9 +999,11 @@
*/
private void recLiftErr() {
Date now = new Date();
- for (ForkLiftSlave forkLiftSlave : slaveProperties.getForkLift()) {
+ List<DeviceConfig> forkliftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.ForkLift)));
+ for (DeviceConfig device : forkliftList) {
// 鑾峰彇鎻愬崌鏈轰俊鎭�
- ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, forkLiftSlave.getId());
+ ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, device.getDeviceNo());
if (forkLiftThread == null) {
continue;
}
@@ -1060,7 +1014,7 @@
if (forkLiftProtocol.getTaskNo() != 0) {
//鏈変换鍔�
- BasLiftErrLog latest = basLiftErrLogService.findLatestByTaskNo(forkLiftSlave.getId(), forkLiftProtocol.getTaskNo());
+ BasLiftErrLog latest = basLiftErrLogService.findLatestByTaskNo(device.getDeviceNo(), forkLiftProtocol.getTaskNo());
// 鏈夊紓甯�
if (latest == null) {
if (forkLiftProtocol.getErrorCode() != null && forkLiftProtocol.getErrorCode() != 0) {
@@ -1079,7 +1033,7 @@
null, // 缁撴潫鏃堕棿
wrkMast.getWrkSts(), // 宸ヤ綔鐘舵��
wrkMast.getIoType(), // 鍏ュ嚭搴撶被鍨�
- forkLiftSlave.getId(), // 鎻愬崌鏈�
+ device.getDeviceNo(), // 鎻愬崌鏈�
null, // plc
wrkMast.getLocNo(), // 鐩爣搴撲綅
wrkMast.getStaNo(), // 鐩爣绔�
@@ -1097,7 +1051,7 @@
JSON.toJSONString(forkLiftProtocol) // 绯荤粺鐘舵�佹暟鎹�
);
if (!basLiftErrLogService.insert(basLiftErrLog)) {
- News.error("鎻愬崌鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", forkLiftSlave.getId(), errName);
+ News.error("鎻愬崌鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", device.getDeviceNo(), errName);
}
}
} else {
@@ -1107,7 +1061,7 @@
latest.setUpdateTime(now);
latest.setStatus(2);
if (!basLiftErrLogService.updateById(latest)) {
- News.error("鎻愬崌鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", forkLiftSlave.getId(), latest.getId());
+ News.error("鎻愬崌鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", device.getDeviceNo(), latest.getId());
}
}
}
@@ -1126,9 +1080,11 @@
return;//鏃犲厖鐢垫々
}
- for (ShuttleSlave shuttle : slaveProperties.getShuttle()) {
+ List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Shuttle)));
+ for (DeviceConfig device : shuttleList) {
//鑾峰彇鍥涘悜绌挎杞︾嚎绋�
- ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId());
+ ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo());
ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
if (shuttleProtocol == null) {
continue;
@@ -1136,6 +1092,16 @@
//鍒ゆ柇褰撳墠灏忚溅鏄惁婊¤冻闇�瑕佸厖鐢佃姹�
if (!shuttleThread.isRequireCharge()) {
+ continue;
+ }
+
+ WrkMast wrkMast1 = wrkMastService.selectShuttleWorking(shuttleProtocol.getShuttleNo());
+ if (wrkMast1 != null) {
+ continue;
+ }
+
+ WrkMast wrkMast2 = wrkMastService.selectShuttleHasMoveWorking(shuttleProtocol.getShuttleNo());
+ if (wrkMast2 != null) {
continue;
}
@@ -1201,15 +1167,15 @@
wrkMast.setIoType(WrkIoType.SHUTTLE_CHARGE.id);//300.鍏呯數
wrkMast.setIoPri((double) 999);
wrkMast.setLocNo(chargeLocNo);
- wrkMast.setShuttleNo(shuttle.getId());
+ wrkMast.setShuttleNo(device.getDeviceNo());
wrkMast.setMemo("charge");
wrkMast.setAppeTime(new Date());
if (!wrkMastService.insert(wrkMast)) {
- News.error("淇濆瓨{}鍙峰洓鍚戠┛姊溅鍏呯數浠诲姟澶辫触!!!", shuttle.getId());
+ News.error("淇濆瓨{}鍙峰洓鍚戠┛姊溅鍏呯數浠诲姟澶辫触!!!", device.getDeviceNo());
continue;
}
- News.info("淇濆瓨{}鍙峰洓鍚戠┛姊溅鍏呯數浠诲姟鎴愬姛!!!", shuttle.getId());
+ News.info("淇濆瓨{}鍙峰洓鍚戠┛姊溅鍏呯數浠诲姟鎴愬姛!!!", device.getDeviceNo());
}
} catch (Exception e) {
e.printStackTrace();
@@ -1222,8 +1188,10 @@
public synchronized void executeShuttleCharge() {
try {
//鏌ヨ灏忚溅鍏呯數浠诲姟
- for (ShuttleSlave shuttle : slaveProperties.getShuttle()) {
- WrkMast wrkMast = wrkMastService.selectChargeWorking(shuttle.getId());
+ List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Shuttle)));
+ for (DeviceConfig device : shuttleList) {
+ WrkMast wrkMast = wrkMastService.selectChargeWorking(device.getDeviceNo());
if(wrkMast == null) {
continue;
}
@@ -1272,7 +1240,7 @@
return false;
}
- if (shuttleProtocol.getCurrentLocNo().equals(wrkMast.getLocNo())) {
+ if (wrkMast.getLocNo().equals(shuttleProtocol.getCurrentLocNo())) {
//灏忚溅鍦ㄥ厖鐢垫々浣嶇疆
wrkMast.setWrkSts(WrkStsType.CHARGE_SHUTTLE_RUN_COMPLETE.sts);
wrkMast.setModiTime(new Date());
@@ -1344,7 +1312,7 @@
ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//鍥涘悜绌挎杞﹀彿
assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙�
- assignCommand.setTaskMode(ShuttleTaskModeType.CHARGE.id);//鍑哄簱妯″紡
+ assignCommand.setTaskMode(ShuttleTaskModeType.CHARGE_ON.id);//鍏呯數寮�
assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣�(灏忚溅褰撳墠浣嶇疆)
List<ShuttleCommand> commands = shuttleOperaUtils.getShuttleChargeCommand(assignCommand, shuttleThread, true);
@@ -1385,7 +1353,7 @@
ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//鍥涘悜绌挎杞﹀彿
assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙�
- assignCommand.setTaskMode(ShuttleTaskModeType.CHARGE.id);//鍑哄簱妯″紡
+ assignCommand.setTaskMode(ShuttleTaskModeType.CHARGE_OFF.id);//鍏呯數鍏�
assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣�(灏忚溅褰撳墠浣嶇疆)
List<ShuttleCommand> commands = shuttleOperaUtils.getShuttleChargeCommand(assignCommand, shuttleThread, false);
@@ -1448,8 +1416,13 @@
//鏌ヨ灏忚溅绉诲簱浠诲姟
List<WrkMast> wrkMasts = wrkMastService.selectShuttleMoveWrk();
for (WrkMast wrkMast : wrkMasts) {
- boolean stepMoveSta = this.shuttleMoveExecuteStepMoveSta(wrkMast);//灏忚溅绉诲姩鍒扮珯鐐�
- if (!stepMoveSta) {
+ boolean stepMoveNearby = this.shuttleMoveExecuteStepMoveNearby(wrkMast);//灏忚溅绉诲姩鍒拌繎鐐�
+ if (!stepMoveNearby) {
+ continue;
+ }
+
+ boolean stepMoveInLift = this.shuttleMoveExecuteStepMoveInLift(wrkMast);//灏忚溅杩佸叆鎻愬崌鏈轰腑
+ if (!stepMoveInLift) {
continue;
}
@@ -1475,15 +1448,15 @@
}
/**
- * 灏忚溅杩佺Щ-灏忚溅绉诲姩鍒扮珯鐐�
+ * 灏忚溅杩佺Щ-灏忚溅绉诲姩鍒拌繎鐐逛腑
* 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false
* ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue
*/
- private boolean shuttleMoveExecuteStepMoveSta(WrkMast wrkMast) {
- //--------------------------------------灏忚溅绉诲姩鑷崇珯鐐�-----------------------------------------//
+ private boolean shuttleMoveExecuteStepMoveNearby(WrkMast wrkMast) {
+ //--------------------------------------灏忚溅绉诲姩鍒拌繎鐐逛腑-----------------------------------------//
Date now = new Date();
- //灏忚溅绉诲姩鑷崇珯鐐� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 302.灏忚溅绉诲姩鑷崇珯鐐逛腑
+ //灏忚溅绉诲姩鍒拌繎鐐� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 302.灏忚溅绉诲姩鑷崇珯鐐逛腑
if (wrkMast.getWrkSts() == WrkStsType.NEW_MOVE.sts) {
//鑾峰彇鍥涘悜绌挎杞︾嚎绋�
ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
@@ -1544,38 +1517,136 @@
return false;
}
- if (wrkMast.getLiftNo() == null) {
- //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟(璇ヤ换鍔¢渶瑕佹崲灞傚繀椤绘彁鍓嶇嫭鍗犳彁鍗囨満)
- WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(liftSta.getLiftNo());
- if (liftWrkMast != null) {
- News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), liftSta.getLiftNo());
- return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇�
- }
+ ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
+ assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙�
+ assignCommand.setTaskMode(ShuttleTaskModeType.MOVE_LOC_NO.id);//灏忚溅绉诲簱浠诲姟
+ assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙�
+ assignCommand.setAuto(true);//鑷姩妯″紡
- wrkMast.setModiTime(now);
- wrkMast.setLiftNo(liftSta.getLiftNo());//鎻愬墠閿佸畾鎻愬崌鏈�
- wrkMast.setSystemMsg("");//娓呯┖娑堟伅
- wrkMastService.updateById(wrkMast);
+ //璁$畻杩戠偣浣嶇疆
+ String endLocation = navigateUtils.calcEndLocation(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.NORMAL, NavigationMapType.PATH_LOCK), null, null, 1);
+ if (endLocation == null) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽皬杞﹁繎鐐逛綅缃绠楀け璐�", wrkMast.getWrkNo());
return false;
}
- //*************灏濊瘯閿佸畾鐩爣绔欒矾寰�***************
- List<NavigateNode> targetNodes = ForkLiftUtils.getLiftStaNodes(wrkMast.getStaNo());
- if (targetNodes == null) {
- return false;//鏈幏鍙栧埌鑺傜偣
+ //灏忚溅宸插湪杩戠偣浣嶇疆鏃犻渶鍓嶅線
+ if (shuttleProtocol.getCurrentLocNo().equals(endLocation)) {
+ wrkMast.setWrkSts(WrkStsType.MOVE_NEARBY_COMPLETE.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 303.灏忚溅绉诲姩鑷宠繎鐐瑰畬鎴�
+ wrkMast.setModiTime(now);
+ wrkMast.setSystemMsg("");//娓呯┖娑堟伅
+ wrkMastService.updateById(wrkMast);
+ return true;
}
- boolean checkPathIsAvailable = navigateUtils.checkPathIsAvailable(targetNodes, shuttleProtocol.getShuttleNo(), Utils.getLev(wrkMast.getLocNo()));
- if (!checkPathIsAvailable) {
- News.info("{}浠诲姟锛寋}灏忚溅锛岀洰鏍囩珯鐐硅矾寰勮鍗犵敤锛岀姝㈡淳鍙�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
- return false;//妫�娴嬬洰鏍囩珯鐐硅矾寰勬槸鍚︽湭琚崰鐢�
+
+ //鑾峰彇灏忚溅鍒拌繎鐐硅璧板懡浠�
+ List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), endLocation, NavigationMapType.getMapTypes(NavigationMapType.NORMAL, NavigationMapType.SHUTTLE), assignCommand, shuttleThread);
+ if (commands == null) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
+ return false;//璺緞瑙i攣澶辫触
}
- //灏濊瘯閿佸畾鐩爣绔欒矾寰�
- boolean result2 = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), shuttleProtocol.getShuttleNo(), targetNodes, true);//鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢�
- if (!result2) {
- News.info("{}浠诲姟锛寋}灏忚溅锛岃矾寰勯攣瀹氬け璐ワ紝绂佹娲惧彂", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
- return false;//璺緞閿佸畾澶辫触
+
+ assignCommand.setCommands(commands);
+
+ wrkMast.setWrkSts(WrkStsType.MOVE_NEARBY.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 302.灏忚溅绉诲姩鑷宠繎鐐逛腑
+ wrkMast.setModiTime(now);
+ wrkMast.setSystemMsg("");//娓呯┖娑堟伅
+ if (wrkMastService.updateById(wrkMast)) {
+ //涓嬪彂浠诲姟
+ shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand);
+ notifyUtils.notify(String.valueOf(SlaveType.Shuttle), shuttleProtocol.getShuttleNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.SHUTTLE_MOVING);
+ //瑙﹀彂閫氱煡
+ return false;
}
- //*************灏濊瘯閿佸畾鐩爣绔欒矾寰�***************
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * 灏忚溅杩佺Щ-灏忚溅杩佸叆鎻愬崌鏈轰腑
+ * 濡傞渶涓绘柟娉曟墽琛宑ontinue锛岃杩斿洖false
+ * ps:杩斿洖鍊紅rue骞朵笉浠h〃璇ユ柟娉曟墽琛屾垚鍔燂紝杩斿洖鍊间粎鍋氭爣璁扮敤浜庝富鏂规硶鏄惁鎵цcontinue
+ */
+ private boolean shuttleMoveExecuteStepMoveInLift(WrkMast wrkMast) {
+ //--------------------------------------灏忚溅杩佸叆鎻愬崌鏈轰腑-----------------------------------------//
+ Date now = new Date();
+
+ //灏忚溅杩佸叆鎻愬崌鏈� 303.灏忚溅绉诲姩鑷宠繎鐐瑰畬鎴� ==> 304.灏忚溅杩佸叆鎻愬崌鏈轰腑
+ if (wrkMast.getWrkSts() == WrkStsType.MOVE_NEARBY_COMPLETE.sts) {
+ //鑾峰彇鍥涘悜绌挎杞︾嚎绋�
+ ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkMast.getShuttleNo());
+ if (shuttleThread == null) {
+ return false;
+ }
+ ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
+ if (shuttleProtocol == null) {
+ return false;
+ }
+
+ //灏忚溅澶勪簬绌洪棽鐘舵��
+ if (!shuttleThread.isIdle()) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛屽皬杞﹀繖纰屼腑", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
+ return false;
+ }
+
+ //鑾峰彇婧愯緭閫佺珯
+ ForkLiftStaProtocol liftSta = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getSourceStaNo());
+ 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;
+ }
+
+ //鑾峰彇鐩爣杈撻�佺珯
+ ForkLiftStaProtocol liftStaTarget = ForkLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
+ if (liftStaTarget == null) {
+ return false;//鎵句笉鍒扮珯鐐�
+ }
+
+ if (liftStaTarget.getHasTray()) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀洰鏍囩珯瀛樺湪鎵樼洏", wrkMast.getWrkNo());
+ return false;
+ }
+
+ if (liftStaTarget.getHasCar()) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀洰鏍囩珯瀛樺湪灏忚溅", wrkMast.getWrkNo());
+ return false;
+ }
+
+ List<WrkMast> outWrkMastList = wrkMastService.selectList(new EntityWrapper<WrkMast>()
+ .eq("io_type", 101)
+ .in("wrk_sts"
+ , WrkStsType.OUTBOUND_SHUTTLE_RUN.sts
+ , WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts
+ , WrkStsType.OUTBOUND_LIFT_RUN.sts
+ , WrkStsType.OUTBOUND_LIFT_RUN_COMPLETE.sts
+ )
+ );
+ for (WrkMast outWrkMast : outWrkMastList) {
+ if(Utils.getLev(outWrkMast.getSourceLocNo()) == Utils.getLev(wrkMast.getLocNo())) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛屽瓨鍦ㄦ鍦ㄦ墽琛岀殑灏忚溅鍑哄簱浠诲姟锛岀姝㈢Щ鍔ㄨ嚦绔欑偣", wrkMast.getWrkNo());
+ return false;
+ }
+ }
+
+ if (wrkMast.getLiftNo() == null) {
+ //鐢宠鎻愬崌鏈鸿祫婧�(璇ヤ换鍔¢渶瑕佹崲灞傚繀椤绘彁鍓嶇嫭鍗犳彁鍗囨満)
+ boolean applyForkLift = forkLiftAction.applyForkLift(liftSta.getLiftNo(), wrkMast.getWrkNo());
+ if(!applyForkLift) {
+ News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛岀敵璇锋彁鍗囨満璧勬簮澶辫触锛岀姝㈢Щ鍔ㄨ嚦绔欑偣", wrkMast.getWrkNo());
+ return false;
+ }
+ return false;
+ }
ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo()); // 鍥涘悜绌挎杞︾紪鍙�
@@ -1583,19 +1654,16 @@
assignCommand.setTaskNo(wrkMast.getWrkNo());//浠诲姟鍙�
assignCommand.setAuto(true);//鑷姩妯″紡
- //鑾峰彇灏忚溅鍒拌緭閫佺珯鐐硅璧板懡浠�
- List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
+ //鑾峰彇灏忚溅鍒版彁鍗囨満琛岃蛋鍛戒护
+ List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), liftSta.getLocNo(), NavigationMapType.getNormalWithDevice(), assignCommand, shuttleThread);
if (commands == null) {
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
-
- //鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢�
- navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(wrkMast.getLocNo()), shuttleProtocol.getShuttleNo(), targetNodes, false);
return false;//璺緞瑙i攣澶辫触
}
assignCommand.setCommands(commands);
- wrkMast.setWrkSts(WrkStsType.MOVE_SITE.sts);//灏忚溅绉诲姩鍒版彁鍗囨満涓� 301.鐢熸垚灏忚溅绉诲簱浠诲姟 ==> 302.灏忚溅绉诲姩鑷崇珯鐐�
+ wrkMast.setWrkSts(WrkStsType.MOVE_IN_LIFT.sts);//303.灏忚溅绉诲姩鑷宠繎鐐瑰畬鎴� ==> 304.灏忚溅杩佸叆鎻愬崌鏈轰腑
wrkMast.setModiTime(now);
wrkMast.setSystemMsg("");//娓呯┖娑堟伅
if (wrkMastService.updateById(wrkMast)) {
@@ -1619,8 +1687,8 @@
//--------------------------------------鎻愬崌鏈烘惉杩愪腑-----------------------------------------//
Date now = new Date();
- //鎻愬崌鏈烘惉杩愪腑 303.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 306.鎻愬崌鏈烘惉杩愪腑
- if (wrkMast.getWrkSts() == WrkStsType.MOVE_SITE_COMPLETE.sts) {
+ //鎻愬崌鏈烘惉杩愪腑 305.灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� ==> 306.鎻愬崌鏈烘惉杩愪腑
+ if (wrkMast.getWrkSts() == WrkStsType.MOVE_IN_LIFT_COMPLETE.sts) {
ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, wrkMast.getLiftNo());
if (forkLiftThread == null) {
return false;
@@ -1632,14 +1700,6 @@
if (!forkLiftThread.isIdle()) {
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満蹇欑涓紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo());
return false;
- }
- //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟
- WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo());
- if (liftWrkMast != null) {
- if (!liftWrkMast.getWrkNo().equals(wrkMast.getWrkNo())) {//鎻愬崌鏈轰换鍔″拰褰撳墠浠诲姟涓嶇浉鍚�
- News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}鍙锋彁鍗囨満锛屾彁鍗囨満瀛樺湪鏈畬鎴愪换鍔★紝绂佹娲惧彂", wrkMast.getWrkNo(), wrkMast.getLiftNo());
- return false;//褰撳墠鎻愬崌鏈哄瓨鍦ㄦ湭瀹屾垚浠诲姟锛岀瓑寰呬笅涓�娆¤疆璇�
- }
}
//鑾峰彇婧愮珯
@@ -1657,9 +1717,9 @@
}
//鑾峰彇鎻愬崌鏈哄懡浠�
- List<ForkLiftCommand> liftCommands = forkLiftThread.getShuttleSwitchCommand(wrkMast.getWrkNo(), sourceLiftSta.getLev(), liftSta.getLev());
+ ForkLiftCommand liftCommand = forkLiftThread.getShuttleSwitchCommand(wrkMast.getWrkNo(), sourceLiftSta.getLev(), liftSta.getLev());
ArrayList<ForkLiftCommand> commands = new ArrayList<>();
- commands.addAll(liftCommands);
+ commands.add(liftCommand);
//鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔
LiftAssignCommand assignCommand = new LiftAssignCommand();
@@ -1668,7 +1728,7 @@
assignCommand.setTaskNo(wrkMast.getWrkNo().shortValue());
assignCommand.setTaskMode(ForkLiftTaskModeType.SHUTTLE_SWITCH.id.shortValue());
- wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 303.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� ==> 306.鎻愬崌鏈烘惉杩愪腑
+ wrkMast.setWrkSts(WrkStsType.MOVE_LIFT_RUN.sts);//鎻愬崌鏈烘惉杩愪腑 305.灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� ==> 306.鎻愬崌鏈烘惉杩愪腑
wrkMast.setSystemMsg("");//娓呯┖娑堟伅
wrkMast.setModiTime(now);
if (wrkMastService.updateById(wrkMast)) {
@@ -1778,30 +1838,8 @@
assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣�
assignCommand.setLocNo(wrkMast.getLocNo());//鐩爣搴撲綅
- List<ShuttleCommand> commands = null;
- //璺ㄦゼ灞傜Щ鍔ㄤ换鍔�
- if (Utils.getLev(wrkMast.getSourceLocNo()) != Utils.getLev(wrkMast.getLocNo())) {
- if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) != Utils.getLev(wrkMast.getLocNo())) {
- return false;//灏忚溅鏈埌杈剧洰鏍囧眰
- }
-
- //闇�瑕佸皢鍓嶄袱涓妭鐐逛綔涓虹櫧鍚嶅崟鑺傜偣浼犲叆
- List<NavigateNode> targetNodes = ForkLiftUtils.getLiftStaNodes(wrkMast.getStaNo());
- if (targetNodes == null) {
- return false;//鏈幏鍙栧埌鑺傜偣
- }
-
- //璁剧疆璁$畻鑺傜偣鐨勭櫧鍚嶅崟
- ArrayList<int[]> whiteList = new ArrayList<>();//璁剧疆璁$畻鑺傜偣鐨勭櫧鍚嶅崟
- for (NavigateNode node : targetNodes) {
- whiteList.add(new int[]{node.getX(), node.getY()});
- }
- commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id, whiteList, assignCommand, shuttleThread);
- }else {
- //鑾峰彇灏忚溅鍒扮洰鏍囧簱浣嶅懡浠�
- commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
- }
-
+ //鑾峰彇灏忚溅鍒扮洰鏍囧簱浣嶅懡浠�
+ List<ShuttleCommand> commands = shuttleOperaUtils.getStartToTargetCommands(shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.getMapTypes(NavigationMapType.NORMAL), assignCommand, shuttleThread);
if (commands == null) {
News.taskInfo(wrkMast.getWrkNo(), "{}浠诲姟锛寋}灏忚溅锛岃矾寰勮绠楀け璐�", wrkMast.getWrkNo(), shuttleProtocol.getShuttleNo());
return false;//璺緞璁$畻澶辫触
@@ -1813,7 +1851,6 @@
wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈�
wrkMast.setSystemMsg("");//娓呯┖娑堟伅
wrkMast.setModiTime(now);
-
if (wrkMastService.updateById(wrkMast)) {
//涓嬪彂浠诲姟
shuttleAction.assignWork(shuttleProtocol.getShuttleNo(), assignCommand);
@@ -1824,71 +1861,73 @@
//鑷姩鍒囨崲鍑哄叆搴撴ā寮�
public void autoSwitchForkLiftIOMode() {
- for (ForkLiftSlave forkLiftSlave : slaveProperties.getForkLift()) {
- Integer liftNo = forkLiftSlave.getId();
- ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo);
- if (forkLiftThread == null) {
- continue;
- }
- ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus();
- if (forkLiftProtocol == null) {
- continue;
- }
-
- List<Integer> liftAllStaNo = ForkLiftUtils.getLiftAllStaNo(liftNo);
- if (liftAllStaNo.isEmpty()) {
- continue;
- }
-
- List<Integer> conveyorBindLiftAllStaNo = ForkLiftUtils.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 (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.NONE)) {
- //鏈煡妯″紡
- if (!inWrkMasts.isEmpty()) {
- forkLiftThread.switchIOMode(ForkLiftIoModeType.IN);
- } else if (!outWrkMasts.isEmpty()) {
- forkLiftThread.switchIOMode(ForkLiftIoModeType.OUT);
- }else {
- forkLiftThread.switchIOMode(ForkLiftIoModeType.IN);
- }
- } else if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.IN)) {
- //鍏ュ簱妯″紡
- if (inWrkMasts.isEmpty() && !outWrkMasts.isEmpty()) {
- forkLiftThread.switchIOMode(ForkLiftIoModeType.OUT);
- }
- } else if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.OUT)) {
- //鍑哄簱妯″紡
- if (outWrkMasts.isEmpty() && !inWrkMasts.isEmpty()) {
- forkLiftThread.switchIOMode(ForkLiftIoModeType.IN);
- }
- }
- }
+// List<DeviceConfig> forkliftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+// .eq("device_type", String.valueOf(SlaveType.ForkLift)));
+// for (DeviceConfig device : forkliftList) {
+// Integer liftNo = device.getDeviceNo();
+// ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, liftNo);
+// if (forkLiftThread == null) {
+// continue;
+// }
+// ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus();
+// if (forkLiftProtocol == null) {
+// continue;
+// }
+//
+// List<Integer> liftAllStaNo = ForkLiftUtils.getLiftAllStaNo(liftNo);
+// if (liftAllStaNo.isEmpty()) {
+// continue;
+// }
+//
+// List<Integer> conveyorBindLiftAllStaNo = ForkLiftUtils.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 (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.NONE)) {
+// //鏈煡妯″紡
+// if (!inWrkMasts.isEmpty()) {
+// forkLiftThread.switchIOMode(ForkLiftIoModeType.IN);
+// } else if (!outWrkMasts.isEmpty()) {
+// forkLiftThread.switchIOMode(ForkLiftIoModeType.OUT);
+// }else {
+// forkLiftThread.switchIOMode(ForkLiftIoModeType.IN);
+// }
+// } else if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.IN)) {
+// //鍏ュ簱妯″紡
+// if (inWrkMasts.isEmpty() && !outWrkMasts.isEmpty()) {
+// forkLiftThread.switchIOMode(ForkLiftIoModeType.OUT);
+// }
+// } else if (forkLiftProtocol.getIOModeType().equals(ForkLiftIoModeType.OUT)) {
+// //鍑哄簱妯″紡
+// if (outWrkMasts.isEmpty() && !inWrkMasts.isEmpty()) {
+// forkLiftThread.switchIOMode(ForkLiftIoModeType.IN);
+// }
+// }
+// }
}
//鍑哄簱浠诲姟棰勮皟搴︽彁鍗囨満
@@ -1940,9 +1979,9 @@
continue;
}
- //鍒ゆ柇鎻愬崌鏈烘槸鍚︽湁鍏朵粬浠诲姟
- WrkMast liftWrkMast = wrkMastService.selectLiftWrkMast(wrkMast.getLiftNo());
- if (liftWrkMast != null) {
+ //鐢宠鎻愬崌鏈鸿祫婧�
+ boolean applyForkLift = forkLiftAction.applyForkLift(liftNo, null);
+ if(!applyForkLift) {
continue;//鎻愬崌鏈哄凡琚粦瀹氾紝涓嶅啀鎵ц棰勮皟搴︿换鍔�
}
@@ -1959,9 +1998,9 @@
int workNo = commonService.getWorkNo(WrkIoType.FORKLIFT_MOVE.id);//鑾峰彇浠诲姟鍙�
//鑾峰彇鎻愬崌鏈哄懡浠�
- List<ForkLiftCommand> liftCommand = forkLiftThread.getMoveCommand(workNo, forkLiftProtocol.getLev(), Utils.getLev(wrkMast.getSourceLocNo()));
+ ForkLiftCommand liftCommand = forkLiftThread.getMoveCommand(workNo, forkLiftProtocol.getLev(), Utils.getLev(wrkMast.getSourceLocNo()));
ArrayList<ForkLiftCommand> commands = new ArrayList<>();
- commands.addAll(liftCommand);
+ commands.add(liftCommand);
//鎻愪氦鍒扮嚎绋嬪幓宸ヤ綔
LiftAssignCommand assignCommand = new LiftAssignCommand();
--
Gitblit v1.9.1