From 6cbb420754e6e29fa134a6afca4514b8dfd62918 Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期二, 13 一月 2026 16:14:49 +0800
Subject: [PATCH] #
---
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java | 174 +++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 125 insertions(+), 49 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 eee0e94..90f5fe9 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
@@ -21,7 +21,7 @@
import com.zy.acs.manager.common.domain.param.HandlerPublishParam;
import com.zy.acs.manager.common.exception.BusinessException;
import com.zy.acs.manager.core.domain.AgvBackpackDto;
-import com.zy.acs.manager.core.domain.Lane;
+import com.zy.acs.manager.core.domain.LaneDto;
import com.zy.acs.manager.core.domain.TaskPosDto;
import com.zy.acs.manager.core.integrate.conveyor.ConveyorStationService;
import com.zy.acs.manager.core.service.astart.MapDataDispatcher;
@@ -90,11 +90,11 @@
@Autowired
private SegmentService segmentService;
@Autowired
- private TrafficService trafficService;
+ private LaneService laneService;
@Autowired
private AgvModelService agvModelService;
@Autowired
- private LaneService laneService;
+ private LaneBuilder laneBuilder;
@Autowired
private ActionSorter actionSorter;
@Autowired
@@ -670,6 +670,7 @@
// generate travel
+ travelService.finishAll(agvId);
Travel travel = new Travel();
travel.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
travel.setTravelId(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
@@ -791,9 +792,9 @@
task.setOriCode(agvDetail.getCode());
task.setDestCode(endCode.getId());
// lane
- Lane destLane = laneService.search(endCode.getData());
- if (null != destLane) {
- task.setDestLaneHash(destLane.getHashCode());
+ LaneDto destLaneDto = laneBuilder.search(endCode.getData());
+ if (null != destLaneDto) {
+ task.setDestLaneHash(destLaneDto.getHashCode());
}
task.setPriority(taskType.equals(TaskTypeType.TO_CHARGE)?2:1);
task.setTaskSts(TaskStsType.ASSIGN.val());
@@ -805,6 +806,7 @@
}
// generate travel
+ travelService.finishAll(agvId);
Travel travel = new Travel();
travel.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
travel.setTravelId(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
@@ -905,6 +907,7 @@
AgvModel agvModel = agvModelService.getByAgvId(agvId);
Double workDirection = agvModel.getWorkDirection();
+ final double oppWorkDir = (workDirection + 180) % 360;
boolean backupAction = null != agvModel.getBackupAction() && agvModel.getBackupActionBool();
boolean needUndocking = null != agvModel.getNeedUndocking() && agvModel.getNeedUndockingBool();
AgvSpeedType agvSpeedType = AgvSpeedType.query(agvModel.getTravelSpeed());
@@ -942,51 +945,108 @@
String next = pathListPart.get(i);
Code nextCode = codeService.getCacheByData(next);
+ // 杞﹀ご鏈濆墠鐨勪笅涓�涓璧版柟鍚�
Double nextDirection = mapService.calculateDirection(lastCode, nextCode, angleOffsetVal);
- // 绗竴姝ワ細濡傛灉涓嬩竴涓柟鍚戞濂芥槸浣滀笟鏂瑰悜鐨勭浉鍙嶆柟鍚戯紝鍒欓噸缃笅涓�涓柟鍚戜负浣滀笟鏂瑰悜锛屾爣璁� reverse = true
+ // 鍙嶅悜瑙�
+ final double oppLastDir = (lastDirection + 180) % 360;
+ // 鏄惁鍊掗��琛岃蛋
boolean reverse = false;
- if (nextDirection.equals((workDirection + 180) % 360)) {
- nextDirection = workDirection;
- reverse = true;
- }
- // 绗簩姝ワ細鍒ゆ柇褰撳墠鑺傜偣鏄惁鍙互鏃嬭浆
- if (!lastCode.getCornerBool()) {
- // 濡傛灉鏄綔涓氭柟鍚戯紝浣嗘槸灏忚溅鍦ㄥ贩閬撳唴鏂瑰悜閿欒锛屽垯鍋滄
- if (reverse && !lastDirection.equals(nextDirection)) {
- throw new CoolException(agvNo + "鍙峰皬杞︽柟鍚戦敊璇紝璇锋帹鑷宠浆寮偣鎵嬪姩璋冩暣");
+ // 宸烽亾閫昏緫
+ if (!laneBuilder.isInitialized()) {
+ throw new CoolException("lanes are not initialized");
+ }
+ LaneDto lastLaneDto = laneBuilder.search(lastCode.getData());
+ LaneDto nextLaneDto = laneBuilder.search(nextCode.getData());
+ // 杩涘叆宸烽亾瑙掑害
+ Double lastLaneDir = laneService.getLaneDirection(lastLaneDto);
+ Double nextLaneDir = laneService.getLaneDirection(nextLaneDto);
+
+ // 宸烽亾寮哄埗杞集锛屼紭鍏堢骇 > workDirection
+ if (null != nextLaneDir) {
+ nextDirection = nextLaneDir;
+
+ if (!lastDirection.equals(nextDirection)) {
+ if (!lastCode.getCornerBool()) {
+ throw new CoolException(agvNo + "鍙峰皬杞﹁繘鍏ュ贩閬撻渶璋冩暣鏂瑰悜涓� " + nextDirection + "掳锛岃鎺ㄨ嚦杞集鐐规墜鍔ㄨ皟鏁�");
+ }
+ // 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 // 宸ヤ綔鏃堕棿
+ ));
+ lastDirection = nextDirection;
}
- // 濡傛灉涓嶆槸浣滀笟鏂瑰悜锛屽垽鏂槸鍚︾浉鍙嶆柟鍚戯紝濡傛灉鍙嶆柟鍚戝垯鍊掗��琛岃蛋
- if (nextDirection.equals((lastDirection + 180) % 360)) {
- nextDirection = lastDirection;
- reverse = true;
+ } else if (null != lastLaneDir) {
+ nextDirection = lastLaneDir;
+
+ if (!lastDirection.equals(nextDirection)) {
+ if (!lastCode.getCornerBool()) {
+ throw new CoolException(agvNo + "鍙峰皬杞︾寮�宸烽亾闇�璋冩暣鏂瑰悜涓� " + nextDirection + "掳锛岃鎺ㄨ嚦杞集鐐规墜鍔ㄨ皟鏁�");
+ }
}
} else {
- if (!lastDirection.equals(nextDirection)) {
- // 濡傛灉涓嬩釜鑺傜偣鏂瑰悜涓庡綋鍓峚gv鏂瑰悜鐩稿弽锛屽垯鍊掗��琛岃蛋锛屼絾鏄鏋滃綋鍓峚gv鏂瑰悜姝eソ涓庡伐浣滄柟鍚戠浉鍙嶏紝鍒欐棆杞嚦宸ヤ綔鏂瑰悜
- if (nextDirection.equals((lastDirection + 180) % 360) && !workDirection.equals((lastDirection + 180) % 360)) {
+
+ // 濡傛灉涓嬩竴涓柟鍚戞濂芥槸浣滀笟鏂瑰悜鐨勭浉鍙嶆柟鍚戯紝鍒欓噸缃笅涓�涓柟鍚戜负浣滀笟鏂瑰悜锛屾爣璁� 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.spinDirection(lastCode).val, // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(nextDirection), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
- lastDirection = nextDirection;
+ lastDirection = nextDirection;
+ }
}
}
}
@@ -1014,10 +1074,7 @@
}
// run
- ActionTypeType actionType = ActionTypeType.StraightAheadTurnable;
- if (reverse) {
- actionType = ActionTypeType.StraightBackTurnable;
- }
+ ActionTypeType actionType = reverse ? ActionTypeType.StraightBackTurnable : ActionTypeType.StraightAheadTurnable;
CodeGap gap = codeGapService.findByCodeOfBoth(lastCode.getId(), nextCode.getId());
actionList.add(new Action(
null, // 缂栧彿
@@ -1044,6 +1101,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, // 缂栧彿
@@ -1054,14 +1130,14 @@
ActionTypeType.TurnCorner.desc, // 鍚嶇О
(double) mapService.spinDirection(lastCode).val, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
- String.valueOf(workDirection), // 鍔ㄤ綔鍙傛暟
+ String.valueOf(firstTurnDir), // 鍔ㄤ綔鍙傛暟
ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
- lastDirection = workDirection;
+ lastDirection = firstTurnDir;
}
first = false;
@@ -1814,8 +1890,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