From 99a13ac3e2c52881577cbf4a69ccc17f349eeec7 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 17 四月 2024 09:22:12 +0800
Subject: [PATCH] #
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java | 87 +++++++++++++++----------------------------
1 files changed, 31 insertions(+), 56 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 b805fc3..e799b7b 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
@@ -1,10 +1,12 @@
package com.zy.asrs.wcs.core.kernel.command;
+import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.core.action.LiftAction;
import com.zy.asrs.wcs.core.action.ShuttleAction;
+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.ShuttleAssignCommand;
@@ -28,10 +30,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
+import java.util.*;
/**
* Created by vincent on 2023/10/23
@@ -70,10 +69,7 @@
if (null == shuttleProtocol) {
return false;
}
- if (!shuttleProtocol.getIdle()) {//璁惧涓嶇┖闂�
- return false;
- }
- if (!shuttleProtocol.getPakMk()) {
+ if (!shuttleThread.isIdle()) {//璁惧涓嶇┖闂�
return false;
}
if (motionService.count(new LambdaQueryWrapper<Motion>()
@@ -85,9 +81,11 @@
ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
assignCommand.setShuttleNo(deviceNo);
- assignCommand.setTaskNo(motion.getWrkNo());
+ assignCommand.setTaskNo(motion.getTaskNo());
+ assignCommand.setDeviceTaskNo(shuttleThread.generateDeviceTaskNo(motion.getTaskNo(), MotionCtgType.get(motion.getMotionCtgEl())));
assignCommand.setSourceLocNo(motion.getOrigin());
assignCommand.setLocNo(motion.getTarget());
+ assignCommand.setDeviceId(Integer.parseInt(motion.getDevice()));
List<ShuttleCommand> shuttleCommands = new ArrayList<>();
ShuttleTaskModeType shuttleTaskModeType = null;
@@ -95,20 +93,12 @@
LiftThread liftThread = null;
LiftProtocol liftProtocol = null;
- //鍒ゆ柇灏忚溅鐘舵��
- if (shuttleProtocol.getIdle()
- && shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.IDLE)
- && shuttleProtocol.getTaskNo() != 0
- ) {
- return false;
- }
-
switch (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl()))){
case SHUTTLE_MOVE:
// 濡傛灉宸茬粡鍦ㄥ綋鍓嶆潯鐮佸垯杩囨护
if (String.valueOf(shuttleProtocol.getCurrentCode()).equals(locService.getOne(new LambdaQueryWrapper<Loc>()
.eq(Loc::getLocNo, motion.getTarget())
- .eq(Loc::getHostId, motion.getHostId())).getCode())) {
+ .eq(Loc::getHostId, motion.getHostId())).getCode())) {
return true;
}
shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
@@ -117,12 +107,12 @@
case SHUTTLE_MOVE_LIFT_PALLET://绌挎杞﹂《鍗囧苟绉诲姩
shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
shuttleTaskModeType = ShuttleTaskModeType.PAK_IN;
- shuttleCommands.add(0, shuttleThread.getLiftCommand(motion.getWrkNo(), true));
+ shuttleCommands.add(0, shuttleThread.getLiftCommand(motion.getTaskNo(), true));
break;
case SHUTTLE_MOVE_DOWN_PALLET://绌挎杞︾Щ鍔ㄥ苟鎵樼洏涓嬮檷
shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
shuttleTaskModeType = ShuttleTaskModeType.PAK_IN;
- shuttleCommands.add(shuttleCommands.size(), shuttleThread.getLiftCommand(motion.getWrkNo(), false));
+ shuttleCommands.add(shuttleCommands.size(), shuttleThread.getLiftCommand(motion.getTaskNo(), false));
break;
case SHUTTLE_MOVE_FROM_LIFT://鍑烘彁鍗囨満
// 鍒ゆ柇鎻愬崌鏈虹姸鎬�
@@ -162,7 +152,7 @@
// }
//鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚�
- if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) {
+ if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
return false;
}
@@ -199,7 +189,7 @@
// }
//鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚�
- if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) {
+ if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
return false;
}
@@ -208,21 +198,21 @@
break;
case SHUTTLE_CHARGE_ON://鍏呯數寮�
shuttleTaskModeType = ShuttleTaskModeType.CHARGE;
- shuttleCommands.add(shuttleThread.getChargeCommand(motion.getWrkNo(), true));
+ shuttleCommands.add(shuttleThread.getChargeCommand(motion.getTaskNo(), true));
assignCommand.setCharge(Boolean.TRUE);
break;
case SHUTTLE_CHARGE_OFF://鍏呯數鍏�
shuttleTaskModeType = ShuttleTaskModeType.CHARGE;
- shuttleCommands.add(shuttleThread.getChargeCommand(motion.getWrkNo(), false));
+ shuttleCommands.add(shuttleThread.getChargeCommand(motion.getTaskNo(), false));
assignCommand.setCharge(Boolean.TRUE);
break;
case SHUTTLE_PALLET_LIFT://鎵樼洏椤跺崌
shuttleTaskModeType = ShuttleTaskModeType.PALLET_LIFT;
- shuttleCommands.add(shuttleThread.getLiftCommand(motion.getWrkNo(), true));
+ shuttleCommands.add(shuttleThread.getLiftCommand(motion.getTaskNo(), true));
break;
case SHUTTLE_PALLET_DOWN://鎵樼洏涓嬮檷
shuttleTaskModeType = ShuttleTaskModeType.PALLET_DOWN;
- shuttleCommands.add(shuttleThread.getLiftCommand(motion.getWrkNo(), false));
+ shuttleCommands.add(shuttleThread.getLiftCommand(motion.getTaskNo(), false));
break;
default:
throw new CoolException(motion.getMotionCtgEl() + "娌℃湁鎸囧畾浠诲姟浣滀笟娴佺▼锛侊紒锛�");
@@ -256,16 +246,16 @@
return false;
}
- if (shuttleProtocol.getTaskNo() != 0 && shuttleProtocol.getTaskNo().intValue() != motion.getWrkNo()) {
+ if (shuttleProtocol.getTaskNo() != 0 && shuttleProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
return false;
}
//鍏呯數浠诲姟
if (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl())).equals(MotionCtgType.SHUTTLE_CHARGE_ON)) {
// 澶嶄綅绌挎杞�
- shuttleProtocol.setTaskNo(0);
- shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE);
- shuttleProtocol.setPakMk(true);
+ shuttleThread.setSyncTaskNo(0);
+ shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.IDLE);
+ shuttleThread.setPakMk(true);
return true;
}
@@ -319,7 +309,7 @@
// }
//鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚�
- if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) {
+ if (liftProtocol.getTaskNo().intValue() != motion.getTaskNo()) {
return false;
}
@@ -334,23 +324,27 @@
}
// 澶嶄綅绌挎杞�
- shuttleProtocol.setTaskNo(0);
- shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE);
- shuttleProtocol.setPakMk(true);
+ shuttleThread.setSyncTaskNo(0);
+ shuttleThread.setProtocolStatus(ShuttleProtocolStatusType.IDLE);
+ shuttleThread.setPakMk(true);
return true;
}
public synchronized List<ShuttleCommand> shuttleAssignCommand(String startLocNo, String endLocNo, Integer mapType, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) {
//鑾峰彇灏忚溅绉诲姩閫熷害
- Integer runSpeed = Optional.ofNullable(basShuttleService.getById(assignCommand.getShuttleNo()).getRunSpeed()).orElse(1000);
+ Integer runSpeed = Optional.ofNullable(basShuttleService.getOne(new LambdaQueryWrapper<BasShuttle>().eq(BasShuttle::getDeviceId, assignCommand.getDeviceId())).getRunSpeed()).orElse(1000);
Long hostId = shuttleThread.getDevice().getHostId();
List<NavigateNode> nodeList = NavigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(Integer.parseInt(shuttleThread.getDevice().getDeviceNo()), Utils.getLev(startLocNo)));
if (nodeList == null) {
News.error("{} dash {} can't find navigate path!", startLocNo, endLocNo);
return null;
}
- List<NavigateNode> allNode = new ArrayList<>(nodeList);
+
+ List<NavigateNode> allNode = new ArrayList<>();
+ for (NavigateNode node : nodeList) {
+ allNode.add(node.clone());
+ }
List<ShuttleCommand> commands = new ArrayList<>();
//鑾峰彇鍒嗘璺緞
@@ -360,25 +354,6 @@
//寮�濮嬭矾寰�
NavigateNode startPath = nodes.get(0);
- //涓棿璺緞
- NavigateNode middlePath = null;
- //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
- String middleCodeNum = null;
- Integer middleToDistDistance = null;//璁$畻涓棿鐐瑰埌鐩爣鐐硅璧拌窛绂�
- if (nodes.size() > 10) {//涓鐮佷紶鍊掓暟绗笁涓�
- //涓棿璺緞
- middlePath = nodes.get(nodes.size() - 3);
- //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
- middleCodeNum = NavigatePositionConvert.xyToPosition(middlePath.getX(), middlePath.getY(), middlePath.getZ(), hostId);
- middleToDistDistance = NavigateUtils.getMiddleToDistDistance(nodes, middlePath);//璁$畻涓棿鐐瑰埌鐩爣鐐硅璧拌窛绂�
- } else if (nodes.size() > 5) {//涓鐮佷紶鍊掓暟绗簩涓�
- //涓棿璺緞
- middlePath = nodes.get(nodes.size() - 2);
- //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
- middleCodeNum = NavigatePositionConvert.xyToPosition(middlePath.getX(), middlePath.getY(), middlePath.getZ(), hostId);
- middleToDistDistance = NavigateUtils.getMiddleToDistDistance(nodes, middlePath);//璁$畻涓棿鐐瑰埌鐩爣鐐硅璧拌窛绂�
- }
-
//鐩爣璺緞
NavigateNode endPath = nodes.get(nodes.size() - 1);
Integer allDistance = NavigateUtils.getCurrentPathAllDistance(nodes);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
@@ -387,7 +362,7 @@
//閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮�
String distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ(), hostId);
//鑾峰彇绉诲姩鍛戒护
- ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getTaskNo().intValue(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed);
+ ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed);
command.setNodes(nodes);//灏嗚璧拌妭鐐规坊鍔犲埌姣忎竴姝ュ懡浠や腑
commands.add(command);
}
--
Gitblit v1.9.1