From 1a518d788ee36886af92b2adfcbe9e79e83ef08e Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期四, 22 一月 2026 09:44:51 +0800
Subject: [PATCH] #
---
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java | 74 ++++++++++++++++++++++++++----------
1 files changed, 53 insertions(+), 21 deletions(-)
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
index 41386e6..d7754a8 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
@@ -11,6 +11,7 @@
import com.zy.acs.common.domain.protocol.*;
import com.zy.acs.common.domain.protocol.action.*;
import com.zy.acs.common.enums.*;
+import com.zy.acs.common.utils.Base62;
import com.zy.acs.common.utils.GsonUtils;
import com.zy.acs.common.utils.RedisSupport;
import com.zy.acs.common.utils.Utils;
@@ -788,7 +789,8 @@
task.setAgvId(agvId);
task.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
List<Task> lastTasks = taskService.list(new LambdaQueryWrapper<Task>().orderByDesc(Task::getId));
- task.setSeqNum(Utils.generateSeqNum(Cools.isEmpty(lastTasks)?null:lastTasks.get(0).getSeqNum()));
+// task.setSeqNum(Utils.generateSeqNum(Cools.isEmpty(lastTasks)?null:lastTasks.get(0).getSeqNum()));
+ task.setSeqNum(Base62.encode(snowflakeIdWorker.nextId()));
task.setOriCode(agvDetail.getCode());
task.setDestCode(endCode.getId());
// lane
@@ -936,7 +938,6 @@
if (!lastCode.getData().equals(code.getData())) {
// 璧拌璺緞鑺傜偣
-// List<String> pathList = mapService.checkoutPath(agv.getUuid(), lastCode, code);
List<String> pathListPart = pathList.subList(pathList.indexOf(lastCode.getData()), pathList.indexOf(code.getData()) + 1);
for (int i = 0; i < pathListPart.size(); i++) {
@@ -965,11 +966,11 @@
// 宸烽亾寮哄埗杞集锛屼紭鍏堢骇 > workDirection
if (null != nextLaneDir) {
- nextDirection = nextLaneDir;
+ final double oppNextLaneDir = (nextLaneDir + 180) % 360;
- if (!lastDirection.equals(nextDirection)) {
+ if (!lastDirection.equals(nextLaneDir)) {
if (!lastCode.getCornerBool()) {
- throw new CoolException(agvNo + "鍙峰皬杞﹁繘鍏ュ贩閬撻渶璋冩暣鏂瑰悜涓� " + nextDirection + "掳锛岃鎺ㄨ嚦杞集鐐规墜鍔ㄨ皟鏁�");
+ throw new CoolException(agvNo + "鍙峰皬杞﹁繘鍏ュ贩閬撻渶璋冩暣鏂瑰悜涓� " + nextLaneDir + "掳锛岃鎺ㄨ嚦杞集鐐规墜鍔ㄨ皟鏁�");
}
// turn
actionList.add(new Action(
@@ -979,24 +980,34 @@
null, // 鍔ㄤ綔鍙�
null, // 浼樺厛绾�
ActionTypeType.TurnCorner.desc, // 鍚嶇О
- (double) mapService.spinDirection(lastCode).val, // 灞炴�у��
+ (double) MapService.calcSpinDirection(lastCode, lastDirection, nextLaneDir).val, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
- String.valueOf(nextDirection), // 鍔ㄤ綔鍙傛暟
+ String.valueOf(nextLaneDir), // 鍔ㄤ綔鍙傛暟
ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
- lastDirection = nextDirection;
+ lastDirection = nextLaneDir;
}
- } else if (null != lastLaneDir) {
- nextDirection = lastLaneDir;
- if (!lastDirection.equals(nextDirection)) {
+ if (nextDirection.equals(oppNextLaneDir)) {
+ reverse = true;
+ }
+ nextDirection = nextLaneDir; // 闃叉 绗竴涓姩浣滀竴瀹氭槸 turn 鍑洪棶棰�
+ } else if (null != lastLaneDir) { // turn 鐜舰鐩磋涓嶅簲璇ュ瓨鍦ㄤ簬lane涓�
+ final double oppLastLaneDir = (lastLaneDir + 180) % 360;
+
+ if (!lastDirection.equals(lastLaneDir)) {
if (!lastCode.getCornerBool()) {
throw new CoolException(agvNo + "鍙峰皬杞︾寮�宸烽亾闇�璋冩暣鏂瑰悜涓� " + nextDirection + "掳锛岃鎺ㄨ嚦杞集鐐规墜鍔ㄨ皟鏁�");
}
}
+
+ if (nextDirection.equals(oppLastLaneDir)) {
+ reverse = true;
+ }
+ nextDirection = lastLaneDir; // 闃叉 绗竴涓姩浣滀竴瀹氭槸 turn 鍑洪棶棰�
} else {
// 濡傛灉涓嬩竴涓柟鍚戞濂芥槸浣滀笟鏂瑰悜鐨勭浉鍙嶆柟鍚戯紝鍒欓噸缃笅涓�涓柟鍚戜负浣滀笟鏂瑰悜锛屾爣璁� reverse = true
@@ -1036,7 +1047,7 @@
null, // 鍔ㄤ綔鍙�
null, // 浼樺厛绾�
ActionTypeType.TurnCorner.desc, // 鍚嶇О
- (double) mapService.spinDirection(lastCode).val, // 灞炴�у��
+ (double) MapService.calcSpinDirection(lastCode, lastDirection, nextDirection).val, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
String.valueOf(nextDirection), // 鍔ㄤ綔鍙傛暟
ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
@@ -1061,7 +1072,7 @@
null, // 鍔ㄤ綔鍙�
null, // 浼樺厛绾�
ActionTypeType.TurnCorner.desc, // 鍚嶇О
- (double) mapService.spinDirection(lastCode).val, // 灞炴�у��
+ (double) MapService.calcSpinDirection(lastCode, lastDirection, nextDirection).val, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
String.valueOf(nextDirection), // 鍔ㄤ綔鍙傛暟
ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
@@ -1101,6 +1112,25 @@
// 鍒濆鏂瑰悜鍊艰ˉ涓�
if (first) {
if (Cools.isEmpty(actionList) || !actionList.get(0).getActionType().equals(ActionTypeType.TurnCorner.val())) {
+ Double firstTurnDir = workDirection;
+
+ // 宸烽亾閫昏緫
+ if (!laneBuilder.isInitialized()) {
+ throw new CoolException("lanes are not initialized");
+ }
+ LaneDto lastLaneDto = laneBuilder.search(lastCode.getData());
+ // 杩涘叆宸烽亾瑙掑害
+ Double lastLaneDir = laneService.getLaneDirection(lastLaneDto);
+ if (lastLaneDir != null) {
+ firstTurnDir = lastLaneDir;
+ }
+
+ if (!lastDirection.equals(firstTurnDir)) {
+ if (!lastCode.getCornerBool()) {
+ throw new CoolException(agvNo + "鍙峰皬杞︽柟鍚戦敊璇紝璇锋帹鑷宠浆寮偣鎵嬪姩璋冩暣");
+ }
+ }
+
// turn
actionList.add(new Action(
null, // 缂栧彿
@@ -1109,16 +1139,16 @@
null, // 鍔ㄤ綔鍙�
null, // 浼樺厛绾�
ActionTypeType.TurnCorner.desc, // 鍚嶇О
- (double) mapService.spinDirection(lastCode).val, // 灞炴�у��
+ (double) MapService.calcSpinDirection(lastCode, lastDirection, firstTurnDir).val, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
- String.valueOf(workDirection), // 鍔ㄤ綔鍙傛暟
+ String.valueOf(firstTurnDir), // 鍔ㄤ綔鍙傛暟
ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
- lastDirection = workDirection;
+ lastDirection = firstTurnDir;
}
first = false;
@@ -1235,7 +1265,7 @@
null, // 鍔ㄤ綔鍙�
null, // 浼樺厛绾�
ActionTypeType.TurnCorner.desc, // 鍚嶇О
- (double) mapService.spinDirection(lastCode).val, // 灞炴�у��
+ (double) MapService.calcSpinDirection(lastCode, lastDirection, oriStaWorkDirection).val, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
String.valueOf(oriStaWorkDirection), // 鍔ㄤ綔鍙傛暟
ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
@@ -1299,7 +1329,7 @@
null, // 鍔ㄤ綔鍙�
null, // 浼樺厛绾�
ActionTypeType.TurnCorner.desc, // 鍚嶇О
- (double) mapService.spinDirection(lastCode).val, // 灞炴�у��
+ (double) MapService.calcSpinDirection(lastCode, lastDirection, destStaWorkDirection).val, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
String.valueOf(destStaWorkDirection), // 鍔ㄤ綔鍙傛暟
ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
@@ -1358,7 +1388,7 @@
null, // 鍔ㄤ綔鍙�
null, // 浼樺厛绾�
ActionTypeType.TurnCorner.desc, // 鍚嶇О
- (double) mapService.spinDirection(lastCode).val, // 灞炴�у��
+ (double) MapService.calcSpinDirection(lastCode, lastDirection, chargeDirection).val, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
String.valueOf(chargeDirection), // 鍔ㄤ綔鍙傛暟
ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
@@ -1840,6 +1870,7 @@
staReserveService.rollbackWaitingToReserved(sta, currTask, StaReserveType.OUT);
break;
}
+ log.info("AGV[{}] load permitted at conveyor station [{}]", protocol.getAgvNo(), sta.getStaNo());
success = true;
break;
case DEST_STA:
@@ -1855,6 +1886,7 @@
staReserveService.rollbackWaitingToReserved(sta, currTask, StaReserveType.IN);
break;
}
+ log.info("AGV[{}] unload permitted at conveyor station [{}]", protocol.getAgvNo(), sta.getStaNo());
success = true;
break;
default:
@@ -1871,8 +1903,8 @@
AGV_06_DOWN agv_06_down = new AGV_06_DOWN();
agv_06_down.setSerialNo(agv_06_up.getSerialNo());
agv_06_down.setActionCode(agv_06_up.getActionCode());
- //agv_06_down.setResult(success ? 1 : 0);
- agv_06_down.setResult(1);
+ agv_06_down.setResult(success ? 1 : 0);
+ //agv_06_down.setResult(0);
redis.push(RedisConstant.AGV_PATH_DOWN_FLAG, AgvProtocol.build(protocol.getAgvNo()).setMessageBody(agv_06_down));
}
--
Gitblit v1.9.1