From 80f5003a640db7795d69c5e3a73caa685c289b80 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@gmail.com>
Date: 星期三, 14 一月 2026 16:27:38 +0800
Subject: [PATCH] #
---
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java | 177 +++++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 119 insertions(+), 58 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 c6c48e3..5e7058c 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
@@ -936,7 +936,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++) {
@@ -945,75 +944,118 @@
String next = pathListPart.get(i);
Code nextCode = codeService.getCacheByData(next);
+ // 杞﹀ご鏈濆墠鐨勪笅涓�涓璧版柟鍚�
Double nextDirection = mapService.calculateDirection(lastCode, nextCode, angleOffsetVal);
// 鍙嶅悜瑙�
final double oppLastDir = (lastDirection + 180) % 360;
+ // 鏄惁鍊掗��琛岃蛋
+ boolean reverse = false;
// 宸烽亾閫昏緫
if (!laneBuilder.isInitialized()) {
- throw new BusinessException("lanes are not initialized");
+ throw new CoolException("lanes are not initialized");
}
LaneDto lastLaneDto = laneBuilder.search(lastCode.getData());
LaneDto nextLaneDto = laneBuilder.search(nextCode.getData());
// 杩涘叆宸烽亾瑙掑害
- Double laneDir = laneService.getLaneDirection(nextLaneDto);
- // 绗竴娆¤繘鍏ユ宸烽亾
- boolean firstEnteringLane = null != laneDir && (
- lastLaneDto == null
- || !Objects.equals(lastLaneDto.getHashCode(), nextLaneDto.getHashCode())
- );
+ Double lastLaneDir = laneService.getLaneDirection(lastLaneDto);
+ Double nextLaneDir = laneService.getLaneDirection(nextLaneDto);
+ // 宸烽亾寮哄埗杞集锛屼紭鍏堢骇 > workDirection
+ if (null != nextLaneDir) {
+ final double oppNextLaneDir = (nextLaneDir + 180) % 360;
-
- // 濡傛灉涓嬩竴涓柟鍚戞濂芥槸浣滀笟鏂瑰悜鐨勭浉鍙嶆柟鍚戯紝鍒欓噸缃笅涓�涓柟鍚戜负浣滀笟鏂瑰悜锛屾爣璁� reverse = true
- boolean reverse = false;
- if (nextDirection.equals(oppWorkDir)) {
- nextDirection = workDirection;
- reverse = true;
- }
-
- // 鍒ゆ柇褰撳墠鑺傜偣鏄惁鍙互鏃嬭浆
- if (!lastCode.getCornerBool()) {
- // 濡傛灉鏄綔涓氭柟鍚戯紝浣嗘槸灏忚溅鍦ㄥ贩閬撳唴鏂瑰悜閿欒锛屽垯鍋滄
- if (reverse && !lastDirection.equals(nextDirection)) {
- throw new CoolException(agvNo + "鍙峰皬杞︽柟鍚戦敊璇紝璇锋帹鑷宠浆寮偣鎵嬪姩璋冩暣");
+ if (!lastDirection.equals(nextLaneDir)) {
+ if (!lastCode.getCornerBool()) {
+ throw new CoolException(agvNo + "鍙峰皬杞﹁繘鍏ュ贩閬撻渶璋冩暣鏂瑰悜涓� " + nextLaneDir + "掳锛岃鎺ㄨ嚦杞集鐐规墜鍔ㄨ皟鏁�");
+ }
+ // turn
+ actionList.add(new Action(
+ null, // 缂栧彿s
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.TurnCorner.desc, // 鍚嶇О
+ (double) MapService.calcSpinDirection(lastCode, lastDirection, nextLaneDir).val, // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(nextLaneDir), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+ lastDirection = nextLaneDir;
}
- // 濡傛灉涓嶆槸浣滀笟鏂瑰悜锛堝彟涓�缁勭浉鍙嶆柟鍚戯級锛屽垽鏂槸鍚︾浉鍙嶆柟鍚戯紝濡傛灉鍙嶆柟鍚戝垯鍊掗��琛岃蛋
- if (nextDirection.equals(oppLastDir)) {
- // 鍊掗��鏃讹紝鍥犱负agv鏂瑰悜娌″彉锛屾墍浠ヤ笅涓�涓柟鍚戣繕鏄痑gv鏂瑰悜锛屾晠nextDirection = lastDirection;
- nextDirection = lastDirection;
+
+ if (nextDirection.equals(oppNextLaneDir)) {
reverse = true;
}
- // 鎬荤粨锛�1.濡傛灉鏄綔涓氱粍锛堝樊180掳锛夋柟鍚戯紝閭d箞agv鏂瑰悜蹇呴』鏄綔涓氭柟鍚戯紝濡傛灉 reverse 鍒欒鏄庡�掗��锛岃繖鏃跺�檔extDirection鑲畾浼氱瓑浜庝綔涓氭柟鍚戯紙鍓嶉潰璧嬪�间簡锛夛紝濡傛灉涓嶇浉鍚岋紝鍒欐姤閿�
- // 2.濡傛灉涓嶆槸浣滀笟缁勬柟鍚戯紙鍙︿竴缁勭浉鍙嶆柟鍚戝樊180掳锛夛紝鍥犱负姝ゅ嚱鏁颁笉鑳芥棆杞紝鎵�浠ュ樊180掳鏃跺彧鑳藉�掗��锛屽�掗��鐨勬椂鍊欏洜涓篴gv涓嶄細鏃嬭浆锛屾墍浠extDirection瑕佸彉鎴恆gv鏂瑰悜
+ nextDirection = nextLaneDir; // 闃叉 绗竴涓姩浣滀竴瀹氭槸 turn 鍑洪棶棰�
+ } else if (null != lastLaneDir) { // todo turn 鐜舰鐩磋
+ final double oppLastLaneDir = (lastLaneDir + 180) % 360;
+
+ if (!lastDirection.equals(nextDirection)) { // lastLaneDir
+ if (!lastCode.getCornerBool()) {
+ throw new CoolException(agvNo + "鍙峰皬杞︾寮�宸烽亾闇�璋冩暣鏂瑰悜涓� " + nextDirection + "掳锛岃鎺ㄨ嚦杞集鐐规墜鍔ㄨ皟鏁�");
+ }
+ }
+
+ if (nextDirection.equals(oppLastLaneDir)) {
+ reverse = true;
+ }
+ nextDirection = lastLaneDir; // 闃叉 绗竴涓姩浣滀竴瀹氭槸 turn 鍑洪棶棰�
} else {
- if (!lastDirection.equals(nextDirection)) {
- // 濡傛灉涓嬩竴涓柟鍚戜笌agv鏂瑰悜鐩稿弽锛屽垯鍊掗��琛岃蛋锛岄伩鍏嶈繘琛屾鏃犳剰涔夌殑杞集鍔ㄤ綔銆�
- // 浣嗘槸瑕佹敞鎰忥細濡傛灉agv鏂瑰悜涓庡伐浣滄柟鍚戞濂界浉鍙嶏紝鍒欓渶瑕佹棆杞嚦宸ヤ綔鏂瑰悜锛屼篃灏辨槸涓轰粈涔堣鍔�!workDirection.equals(oppLastDir)鍒ゆ柇
- if (nextDirection.equals(oppLastDir) && !workDirection.equals(oppLastDir)) {
+
+ // 濡傛灉涓嬩竴涓柟鍚戞濂芥槸浣滀笟鏂瑰悜鐨勭浉鍙嶆柟鍚戯紝鍒欓噸缃笅涓�涓柟鍚戜负浣滀笟鏂瑰悜锛屾爣璁� reverse = true
+ if (nextDirection.equals(oppWorkDir)) {
+ nextDirection = workDirection;
+ reverse = true;
+ }
+
+ // 鍒ゆ柇褰撳墠鑺傜偣鏄惁鍙互鏃嬭浆
+ if (!lastCode.getCornerBool()) {
+ // 濡傛灉鏄綔涓氭柟鍚戯紝浣嗘槸灏忚溅鍦ㄥ贩閬撳唴鏂瑰悜閿欒锛屽垯鍋滄
+ if (reverse && !lastDirection.equals(nextDirection)) {
+ throw new CoolException(agvNo + "鍙峰皬杞︽柟鍚戦敊璇紝璇锋帹鑷宠浆寮偣鎵嬪姩璋冩暣");
+ }
+ // 濡傛灉涓嶆槸浣滀笟鏂瑰悜锛堝彟涓�缁勭浉鍙嶆柟鍚戯級锛屽垽鏂槸鍚︾浉鍙嶆柟鍚戯紝濡傛灉鍙嶆柟鍚戝垯鍊掗��琛岃蛋
+ if (nextDirection.equals(oppLastDir)) {
// 鍊掗��鏃讹紝鍥犱负agv鏂瑰悜娌″彉锛屾墍浠ヤ笅涓�涓柟鍚戣繕鏄痑gv鏂瑰悜锛屾晠nextDirection = lastDirection;
nextDirection = lastDirection;
reverse = true;
- } else {
- // turn
- actionList.add(new Action(
- null, // 缂栧彿s
- task.getBusId(), // 鎬荤嚎
- task.getId(), // 浠诲姟
- null, // 鍔ㄤ綔鍙�
- null, // 浼樺厛绾�
- ActionTypeType.TurnCorner.desc, // 鍚嶇О
- (double) mapService.spinDirection(lastCode).val, // 灞炴�у��
- lastCode.getData(), // 鍦伴潰鐮�
- String.valueOf(nextDirection), // 鍔ㄤ綔鍙傛暟
- ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
- actionPrepareSts, // 鍔ㄤ綔杩涘害
- agvId, // AGV
- now // 宸ヤ綔鏃堕棿
- ));
+ }
+ // 鎬荤粨锛�1.濡傛灉鏄綔涓氱粍锛堝樊180掳锛夋柟鍚戯紝閭d箞agv鏂瑰悜蹇呴』鏄綔涓氭柟鍚戯紝濡傛灉 reverse 鍒欒鏄庡�掗��锛岃繖鏃跺�檔extDirection鑲畾浼氱瓑浜庝綔涓氭柟鍚戯紙鍓嶉潰璧嬪�间簡锛夛紝濡傛灉涓嶇浉鍚岋紝鍒欐姤閿�
+ // 2.濡傛灉涓嶆槸浣滀笟缁勬柟鍚戯紙鍙︿竴缁勭浉鍙嶆柟鍚戝樊180掳锛夛紝鍥犱负姝ゅ嚱鏁颁笉鑳芥棆杞紝鎵�浠ュ樊180掳鏃跺彧鑳藉�掗��锛屽�掗��鐨勬椂鍊欏洜涓篴gv涓嶄細鏃嬭浆锛屾墍浠extDirection瑕佸彉鎴恆gv鏂瑰悜
+ } else {
+ if (!lastDirection.equals(nextDirection)) {
+ // 濡傛灉涓嬩竴涓柟鍚戜笌agv鏂瑰悜鐩稿弽锛屽垯鍊掗��琛岃蛋锛岄伩鍏嶈繘琛屾鏃犳剰涔夌殑杞集鍔ㄤ綔銆�
+ // 浣嗘槸瑕佹敞鎰忥細濡傛灉agv鏂瑰悜涓庡伐浣滄柟鍚戞濂界浉鍙嶏紝鍒欓渶瑕佹棆杞嚦宸ヤ綔鏂瑰悜锛屼篃灏辨槸涓轰粈涔堣鍔�!workDirection.equals(oppLastDir)鍒ゆ柇
+ if (nextDirection.equals(oppLastDir) && !workDirection.equals(oppLastDir)) {
+ // 鍊掗��鏃讹紝鍥犱负agv鏂瑰悜娌″彉锛屾墍浠ヤ笅涓�涓柟鍚戣繕鏄痑gv鏂瑰悜锛屾晠nextDirection = lastDirection;
+ nextDirection = lastDirection;
+ reverse = true;
+ } else {
+ // turn
+ actionList.add(new Action(
+ null, // 缂栧彿s
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.TurnCorner.desc, // 鍚嶇О
+ (double) MapService.calcSpinDirection(lastCode, lastDirection, nextDirection).val, // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(nextDirection), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
- lastDirection = nextDirection;
+ lastDirection = nextDirection;
+ }
}
}
}
@@ -1028,7 +1070,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(), // 鍔ㄤ綔绫诲瀷
@@ -1068,6 +1110,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, // 缂栧彿
@@ -1076,16 +1137,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;
@@ -1202,7 +1263,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(), // 鍔ㄤ綔绫诲瀷
@@ -1266,7 +1327,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(), // 鍔ㄤ綔绫诲瀷
@@ -1325,7 +1386,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(), // 鍔ㄤ綔绫诲瀷
@@ -1838,8 +1899,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(success ? 1 : 0);
+ agv_06_down.setResult(1);
redis.push(RedisConstant.AGV_PATH_DOWN_FLAG, AgvProtocol.build(protocol.getAgvNo()).setMessageBody(agv_06_down));
}
--
Gitblit v1.9.1