From 2cfa8856fb1fd1ad7f642fd998d1644879abcdb5 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期四, 25 七月 2024 10:02:24 +0800
Subject: [PATCH] #
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java | 192 +++++++++++++----------------------------------
1 files changed, 53 insertions(+), 139 deletions(-)
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java
index 62e16cb..71b7906 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java
@@ -10,10 +10,7 @@
import com.zy.asrs.wcs.core.entity.BasShuttle;
import com.zy.asrs.wcs.core.entity.Loc;
import com.zy.asrs.wcs.core.model.NavigateNode;
-import com.zy.asrs.wcs.core.model.command.LiftAssignCommand;
-import com.zy.asrs.wcs.core.model.command.LiftCommand;
-import com.zy.asrs.wcs.core.model.command.ShuttleAssignCommand;
-import com.zy.asrs.wcs.core.model.command.ShuttleCommand;
+import com.zy.asrs.wcs.core.model.command.*;
import com.zy.asrs.wcs.core.model.enums.*;
import com.zy.asrs.wcs.core.service.BasShuttleService;
import com.zy.asrs.wcs.core.service.LocService;
@@ -22,7 +19,6 @@
import com.zy.asrs.wcs.rcs.News;
import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
import com.zy.asrs.wcs.core.entity.Motion;
-import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant;
import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType;
import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
@@ -61,6 +57,8 @@
private ShuttleAction shuttleAction;
@Autowired
private LiftAction liftAction;
+ @Autowired
+ private LiftDispatcher liftDispatcher;
// 璁$畻
public Boolean accept(Motion motion) {
@@ -141,11 +139,11 @@
}
// 鍒ゆ柇鎻愬崌鏈烘槸鍚︾┖闂�
- if (!liftThread.isIdle()) {
+ if (!liftThread.isIdle(MotionCtgType.SHUTTLE_MOVE_FROM_LIFT)) {
return false;
}
- if (liftProtocol.getLev() != Utils.getLev(motion.getTarget())) {//鍒ゆ柇鎻愬崌鏈烘槸鍚﹁揪鍒扮洰鏍囧眰
+ if (liftProtocol.getLev() != liftDispatcher.getLiftLevOffset(liftThread.getDevice().getId().intValue(), Utils.getLev(motion.getTarget()))) {//鍒ゆ柇鎻愬崌鏈烘槸鍚﹁揪鍒扮洰鏍囧眰
return false;
}
@@ -156,24 +154,13 @@
return true;
}
})) {
- //閿佸畾鎻愬崌鏈�
- LiftCommand lockCommand = liftThread.getLockCommand(motion.getTaskNo(), true);//鑾峰彇鎻愬崌鏈洪攣瀹氬懡浠�
-
- LiftAssignCommand liftAssignCommand = new LiftAssignCommand();
- liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo());
- liftAssignCommand.setTaskNo(motion.getTaskNo());
- ArrayList<LiftCommand> list = new ArrayList<>();
- list.add(lockCommand);
- liftAssignCommand.setCommands(list);
-
- liftAction.assignWork(liftThread.getDevice(), liftAssignCommand);
- return false;//绛夊緟涓嬩竴娆¤疆璇�
- }
-
- //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚�
- if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
return false;
}
+
+// //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚�
+// if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
+// return false;
+// }
shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO;
@@ -189,11 +176,11 @@
return false;
}
// 鍒ゆ柇鎻愬崌鏈烘槸鍚︾┖闂�
- if (!liftThread.isIdle()) {
+ if (!liftThread.isIdle(MotionCtgType.SHUTTLE_MOVE_TO_LIFT)) {
return false;
}
- if (liftProtocol.getLev() != Utils.getLev(motion.getTarget())) {//鍒ゆ柇鎻愬崌鏈烘槸鍚﹁揪鍒扮洰鏍囧眰
+ if (liftProtocol.getLev() != liftDispatcher.getLiftLevOffset(liftThread.getDevice().getId().intValue(), Utils.getLev(motion.getTarget()))) {//鍒ゆ柇鎻愬崌鏈烘槸鍚﹁揪鍒扮洰鏍囧眰
return false;
}
@@ -201,30 +188,16 @@
if (!liftThread.isLock(new ExecuteSupport() {
@Override
public Boolean judgement() {
- return true;
+ return true;//鐗涚溂娌℃湁鎻愬崌鏈洪攣锛岀洿鎺ヨ繑鍥瀟rue
}
})) {
- //閿佸畾鎻愬崌鏈�
- LiftCommand lockCommand = liftThread.getLockCommand(motion.getTaskNo(), true);//鑾峰彇鎻愬崌鏈洪攣瀹氬懡浠�
- if (lockCommand == null) {
- return false;
- }
-
- LiftAssignCommand liftAssignCommand = new LiftAssignCommand();
- liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo());
- liftAssignCommand.setTaskNo(motion.getTaskNo());
- ArrayList<LiftCommand> list = new ArrayList<>();
- list.add(lockCommand);
- liftAssignCommand.setCommands(list);
-
- liftAction.assignWork(liftThread.getDevice(), liftAssignCommand);
- return false;//绛夊緟涓嬩竴娆¤疆璇�
- }
-
- //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚�
- if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
return false;
}
+
+// //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚�
+// if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
+// return false;
+// }
shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO;
@@ -247,6 +220,10 @@
shuttleTaskModeType = ShuttleTaskModeType.PALLET_DOWN;
shuttleCommands.add(shuttleThread.getLiftCommand(motion.getTaskNo(), false));
break;
+ case SHUTTLE_UPDATE_LOCATION://灏忚溅鍧愭爣鏇存柊
+ shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_UPDATE_LOCATION;
+ shuttleCommands.add(shuttleThread.getUpdateLocationCommand(motion.getTaskNo(), motion.getTarget()));
+ break;
default:
throw new CoolException(motion.getMotionCtgEl() + "娌℃湁鎸囧畾浠诲姟浣滀笟娴佺▼锛侊紒锛�");
}
@@ -261,7 +238,7 @@
if (motion.getOrigin() != null && motion.getTarget() != null) {
//鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢�
- boolean lockResult = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(motion.getTarget()), shuttleProtocol.getShuttleNo(), assignCommand.getNodes(), true);//鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢�
+ boolean lockResult = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(motion.getTarget()), shuttleProtocol.getShuttleNo(), assignCommand.getNodesDeepCopy(), true);//鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢�
if (!lockResult) {
return false;//閿佸畾澶辫触
}
@@ -330,53 +307,24 @@
}
//鍒ゆ柇鎻愬崌鏈烘槸鍚﹁閿佸畾
- if (liftThread.isLock(new ExecuteSupport() {
+ if (!liftThread.isLock(new ExecuteSupport() {
@Override
public Boolean judgement() {
return false;
}
})) {
- //瑙i攣鎻愬崌鏈�
- LiftCommand lockCommand = liftThread.getLockCommand(motion.getTaskNo(), false);//鑾峰彇鎻愬崌鏈鸿В閿佸懡浠�
-
- LiftAssignCommand liftAssignCommand = new LiftAssignCommand();
- liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo());
- liftAssignCommand.setTaskNo(motion.getTaskNo());
- ArrayList<LiftCommand> list = new ArrayList<>();
- list.add(lockCommand);
- liftAssignCommand.setCommands(list);
-
- liftAction.assignWork(liftThread.getDevice(), liftAssignCommand);
- return false;//绛夊緟涓嬩竴娆¤疆璇�
- }
-
- //鍒ゆ柇灏忚溅鏄惁宸插埌浣�
- if (liftProtocol.getHasCar()) {
- LiftCommand signalCommand = liftThread.getShuttleSignalCommand(motion.getTaskNo(), true);//鑾峰彇灏忚溅宸插埌浣嶅懡浠�
- if(signalCommand != null) {
- boolean hasKey = redisUtil.hasKey(DeviceRedisConstant.COMMAND_TMP + motion.getTaskNo());
- if (!hasKey) {
- LiftAssignCommand liftAssignCommand = new LiftAssignCommand();
- liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo());
- liftAssignCommand.setTaskNo(motion.getTaskNo());
- ArrayList<LiftCommand> list = new ArrayList<>();
- list.add(signalCommand);
- liftAssignCommand.setCommands(list);
- liftAction.assignWork(liftThread.getDevice(), liftAssignCommand);
- return false;
- }
- }
- }
-
- //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚�
- if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
return false;
}
- if (liftProtocol.getTaskNo() != 0) {
- //娓呯┖鎻愬崌鏈哄彿
- liftThread.setSyncTaskNo(0);
+ //鍒ゆ柇灏忚溅鏄惁宸插埌浣�
+ if (!liftProtocol.getHasCar()) {
+ return false;
}
+
+// //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚�
+// if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
+// return false;
+// }
break;
case SHUTTLE_MOVE_FROM_LIFT:
liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp()));
@@ -390,54 +338,24 @@
}
//鍒ゆ柇鎻愬崌鏈烘槸鍚﹁閿佸畾
- if (liftThread.isLock(new ExecuteSupport() {
+ if (!liftThread.isLock(new ExecuteSupport() {
@Override
public Boolean judgement() {
return false;
}
})) {
- //瑙i攣鎻愬崌鏈�
- LiftCommand lockCommand = liftThread.getLockCommand(motion.getTaskNo(), false);//鑾峰彇鎻愬崌鏈鸿В閿佸懡浠�
-
- LiftAssignCommand liftAssignCommand = new LiftAssignCommand();
- liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo());
- liftAssignCommand.setTaskNo(motion.getTaskNo());
- ArrayList<LiftCommand> list = new ArrayList<>();
- list.add(lockCommand);
- liftAssignCommand.setCommands(list);
-
- liftAction.assignWork(liftThread.getDevice(), liftAssignCommand);
- return false;//绛夊緟涓嬩竴娆¤疆璇�
- }
-
- //鍒ゆ柇灏忚溅鏄惁宸茬寮�
- if (!liftProtocol.getHasCar()) {
- LiftCommand signalCommand = liftThread.getShuttleSignalCommand(motion.getTaskNo(), false);//鑾峰彇灏忚溅宸查┚绂诲懡浠�
- if(signalCommand != null) {
- boolean hasKey = redisUtil.hasKey(DeviceRedisConstant.COMMAND_TMP + motion.getTaskNo());
- if (!hasKey) {
- redisUtil.set(DeviceRedisConstant.COMMAND_TMP + motion.getTaskNo(), JSON.toJSONString(signalCommand), 120);
- LiftAssignCommand liftAssignCommand = new LiftAssignCommand();
- liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo());
- liftAssignCommand.setTaskNo(motion.getTaskNo());
- ArrayList<LiftCommand> list = new ArrayList<>();
- list.add(signalCommand);
- liftAssignCommand.setCommands(list);
- liftAction.assignWork(liftThread.getDevice(), liftAssignCommand);
- return false;
- }
- }
- }
-
- //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚�
- if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
return false;
}
- if (liftProtocol.getTaskNo() != 0) {
- //娓呯┖鎻愬崌鏈哄彿
- liftThread.setSyncTaskNo(0);
+ //鍒ゆ柇灏忚溅鏄惁宸茬寮�
+ if (liftProtocol.getHasCar()) {
+ return false;
}
+
+// //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚�
+// if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
+// return false;
+// }
break;
case SHUTTLE_TRANSPORT_FROM_LIFT:
case SHUTTLE_TRANSPORT_TO_LIFT:
@@ -459,28 +377,24 @@
return false;
}
})) {
- //瑙i攣鎻愬崌鏈�
- LiftCommand lockCommand = liftThread.getLockCommand(motion.getTaskNo(), false);//鑾峰彇鎻愬崌鏈鸿В閿佸懡浠�
-
- LiftAssignCommand liftAssignCommand = new LiftAssignCommand();
- liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo());
- liftAssignCommand.setTaskNo(motion.getTaskNo());
- ArrayList<LiftCommand> list = new ArrayList<>();
- list.add(lockCommand);
- liftAssignCommand.setCommands(list);
-
- liftAction.assignWork(liftThread.getDevice(), liftAssignCommand);
- return false;//绛夊緟涓嬩竴娆¤疆璇�
+ return false;
}
//鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚�
if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
return false;
}
-
- if (liftProtocol.getTaskNo() != 0) {
- //娓呯┖鎻愬崌鏈哄彿
- liftThread.setSyncTaskNo(0);
+ break;
+ case SHUTTLE_UPDATE_LOCATION://灏忚溅鍧愭爣鏇存柊
+ break;
+ case SHUTTLE_PALLET_LIFT://鎵樼洏椤跺崌
+ if (!shuttleProtocol.getHasLift()) {
+ return false;
+ }
+ break;
+ case SHUTTLE_PALLET_DOWN://鎵樼洏涓嬮檷
+ if (shuttleProtocol.getHasLift()) {
+ return false;
}
break;
default:
--
Gitblit v1.9.1