From a18215c69379bbdaecd95e25812e0796c32f9a57 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 16 四月 2024 14:46:20 +0800
Subject: [PATCH] #
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java | 49 +++++++++++++++++--------------------------------
1 files changed, 17 insertions(+), 32 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 122398a..df7c5af 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
@@ -85,6 +84,7 @@
assignCommand.setTaskNo(motion.getWrkNo());
assignCommand.setSourceLocNo(motion.getOrigin());
assignCommand.setLocNo(motion.getTarget());
+ assignCommand.setDeviceId(Integer.parseInt(motion.getDevice()));
List<ShuttleCommand> shuttleCommands = new ArrayList<>();
ShuttleTaskModeType shuttleTaskModeType = null;
@@ -97,7 +97,7 @@
// 濡傛灉宸茬粡鍦ㄥ綋鍓嶆潯鐮佸垯杩囨护
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);
@@ -258,11 +258,11 @@
return true;
}
-// if (!shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.WAITING)
-// && !shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.CHARGING_WAITING)
-// ) {
-// return false;
-// }
+ if (!shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.WAITING)
+ && !shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.CHARGING_WAITING)
+ ) {
+ return false;
+ }
//鍒ゆ柇璁惧鏄惁绌洪棽
if (!shuttleThread.isIdle()) {
@@ -332,14 +332,18 @@
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<>();
//鑾峰彇鍒嗘璺緞
@@ -349,25 +353,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);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂�
@@ -376,7 +361,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.getTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed);
command.setNodes(nodes);//灏嗚璧拌妭鐐规坊鍔犲埌姣忎竴姝ュ懡浠や腑
commands.add(command);
}
--
Gitblit v1.9.1