From dc83f329db32e38a8cbca04d07f24c4a789c6f74 Mon Sep 17 00:00:00 2001
From: zc <zyzc>
Date: 星期五, 07 十一月 2025 11:11:24 +0800
Subject: [PATCH] 希日多任务出库问题优化
---
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java | 678 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 665 insertions(+), 13 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 545ea54..005824e 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
@@ -205,11 +205,11 @@
break;
case STA_TO_LOC:
oriSta = staService.getById(task.getOriSta());
- if (oriSta.getStaTypeIsCheck() != 1) {
- if (locStaStatusCheck && !oriSta.getStaSts().equals(StaStsType.STOCK.val())) {
- throw new BusinessException("oriSta锛�" + task.getOriSta$() + " is not in STOCK status");
- }
- }
+// if (oriSta.getStaTypeIsCheck() != 1) {
+// if (locStaStatusCheck && !oriSta.getStaSts().equals(StaStsType.STOCK.val())) {
+// throw new BusinessException("oriSta锛�" + task.getOriSta$() + " is not in STOCK status");
+// }
+// }
oriSta.setStaSts(StaStsType.READY_TAKE.val());
oriSta.setUpdateTime(now);
if (!staService.updateById(oriSta)) {
@@ -788,8 +788,15 @@
// 绗竴姝ワ細濡傛灉涓嬩竴涓柟鍚戞濂芥槸浣滀笟鏂瑰悜鐨勭浉鍙嶆柟鍚戯紝鍒欓噸缃笅涓�涓柟鍚戜负浣滀笟鏂瑰悜锛屾爣璁� reverse = true
boolean reverse = false;
if (nextDirection.equals((workDirection + 180) % 360)) {
- nextDirection = workDirection;
- reverse = true;
+ List<String> list = Arrays.asList("00000051", "00000052", "00000053", "00000054");
+ if ((Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType())).equals(TaskPosDto.PosType.ORI_STA)
+ || Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType()))
+ .equals(TaskPosDto.PosType.DEST_STA)) && list.contains(lastCode.getData())) {
+ reverse = false;
+ } else {
+ nextDirection = workDirection;
+ reverse = true;
+ }
}
// 绗簩姝ワ細鍒ゆ柇褰撳墠鑺傜偣鏄惁鍙互鏃嬭浆
@@ -810,7 +817,55 @@
nextDirection = lastDirection;
reverse = true;
} else {
+ if ((Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType()))
+ .equals(TaskPosDto.PosType.ORI_STA) || Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType()))
+ .equals(TaskPosDto.PosType.DEST_STA)) && lastCode.getData().equals("00000050")) {
+ // turn
+ reverse = false;
+
+ actionList.add(new Action(
+ null, // 缂栧彿s
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.TurnCorner.desc, // 鍚嶇О
+ mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(180), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+ } else {
+ // turn
+ actionList.add(new Action(
+ null, // 缂栧彿s
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.TurnCorner.desc, // 鍚嶇О
+ mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(nextDirection), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+ }
+
+ lastDirection = nextDirection;
+ }
+ } else {
+ if ((Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType()))
+ .equals(TaskPosDto.PosType.ORI_STA) || Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType()))
+ .equals(TaskPosDto.PosType.DEST_STA)) && lastCode.getData().equals("00000050")) {
// turn
+ reverse = false;
+
actionList.add(new Action(
null, // 缂栧彿s
task.getBusId(), // 鎬荤嚎
@@ -820,17 +875,614 @@
ActionTypeType.TurnCorner.desc, // 鍚嶇О
mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
- String.valueOf(nextDirection), // 鍔ㄤ綔鍙傛暟
+ String.valueOf(180), // 鍔ㄤ綔鍙傛暟
ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
now // 宸ヤ綔鏃堕棿
));
-
- lastDirection = nextDirection;
}
}
}
+
+ // 绗竴涓姩浣滀竴瀹氭槸 turn
+ if (actionList.isEmpty()) {
+ // turn
+ actionList.add(new Action(
+ null, // 缂栧彿
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.TurnCorner.desc, // 鍚嶇О
+ mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(nextDirection), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+
+ lastDirection = nextDirection;
+ }
+
+ // run
+ ActionTypeType actionType = ActionTypeType.StraightAheadTurnable;
+ if (reverse) {
+ actionType = ActionTypeType.StraightBackTurnable;
+ }
+ CodeGap gap = codeGapService.findByCodeOfBoth(lastCode.getId(), nextCode.getId());
+ actionList.add(new Action(
+ null, // 缂栧彿
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ actionType.desc, // 鍚嶇О
+ (double) agvSpeedType.val, // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(gap.getDistance()), // 鍔ㄤ綔鍙傛暟
+ actionType.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+
+ lastCode = nextCode;
+
+ }
+
+ }
+
+ // 鍒濆鏂瑰悜鍊艰ˉ涓�
+ if (first) {
+ if (Cools.isEmpty(actionList) || !actionList.get(0).getActionType().equals(ActionTypeType.TurnCorner.val())) {
+ // turn
+ actionList.add(new Action(
+ null, // 缂栧彿
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.TurnCorner.desc, // 鍚嶇О
+ mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(workDirection), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+
+ lastDirection = workDirection;
+
+ }
+ first = false;
+ }
+
+ // 浣滀笟鐐瑰姩浣�
+ AgvDirectionType agvDirectionType;
+ Double staWorkDirection;
+ AgvBackpackType backpackType = AgvBackpackType.query(segment.getBackpack());
+ switch (Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType()))) {
+ case ORI_LOC:
+ assert backpackType != null;
+ // 妫�楠屾柟鍚�
+ if (!lastDirection.equals(workDirection)) {
+ throw new CoolException(agvNo + "鍙峰皬杞︽柟鍚戦敊璇紝璇锋帹鑷宠浆寮偣鎵嬪姩璋冩暣");
+ }
+ // 璐ф灦鍙栬揣
+ Loc oriLoc = locService.getById(task.getOriLoc());
+ // 璁$畻宸﹀彸鏂瑰悜
+ agvDirectionType = mapService.calculateAgvWorkDirectionByShelf(oriLoc, lastCode);
+ actionList.add(new Action(
+ null, // 缂栧彿
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.ReadyTakeFromShelvesLoc.desc, // 鍚嶇О
+ (double) agvDirectionType.val, // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(oriLoc.getOffset()), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.ReadyTakeFromShelvesLoc.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+ // 鏆傚瓨鐐规斁璐�
+ actionList.add(new Action(
+ null, // 缂栧彿
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.ReadyReleaseToAgvSite.desc, // 鍚嶇О
+ (double) backpackType.lev, // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(backpackType.height), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.ReadyReleaseToAgvSite.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+ break;
+ case DEST_LOC:
+ assert backpackType != null;
+ // 妫�楠屾柟鍚�
+ if (!lastDirection.equals(workDirection)) {
+ throw new CoolException(agvNo + "鍙峰皬杞︽柟鍚戦敊璇紝璇锋帹鑷宠浆寮偣鎵嬪姩璋冩暣");
+ }
+ // 鏆傚瓨鐐瑰彇璐ц揣
+ actionList.add(new Action(
+ null, // 缂栧彿
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.ReadyTakeFromAgvSite.desc, // 鍚嶇О
+ (double) backpackType.lev, // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(backpackType.height), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.ReadyTakeFromAgvSite.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+
+ // 璐ф灦鏀捐揣
+ Loc destLoc = locService.getById(task.getDestLoc());
+ // 璁$畻宸﹀彸鏂瑰悜
+ agvDirectionType = mapService.calculateAgvWorkDirectionByShelf(destLoc, lastCode);
+ actionList.add(new Action(
+ null, // 缂栧彿
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.ReadyReleaseToShelvesLoc.desc, // 鍚嶇О
+ (double) agvDirectionType.val, // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(destLoc.getOffset()), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.ReadyReleaseToShelvesLoc.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+ break;
+ case ORI_STA:
+ // 绔欑偣鍙栬揣
+ Sta oriSta = staService.getById(task.getOriSta());
+ Double oriStaWorkDirection = mapService.getStaAngle(oriSta, workDirection);
+ // 妫�楠屾柟鍚�
+// if (!lastDirection.equals(oriStaWorkDirection)) {
+// if (!lastCode.getCornerBool()) {
+// throw new CoolException(agvNo + "鍙峰皬杞︽柟鍚戦敊璇紝璇锋帹鑷宠浆寮偣鎵嬪姩璋冩暣");
+// }
+// // turn
+// actionList.add(new Action(
+// null, // 缂栧彿
+// task.getBusId(), // 鎬荤嚎
+// task.getId(), // 浠诲姟
+// null, // 鍔ㄤ綔鍙�
+// null, // 浼樺厛绾�
+// ActionTypeType.TurnCorner.desc, // 鍚嶇О
+// mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 灞炴�ш皰
+// lastCode.getData(), // 鍦伴潰鐮�
+// String.valueOf(oriStaWorkDirection), // 鍔ㄤ綔鍙傛暟
+// ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
+// actionPrepareSts, // 鍔ㄤ綔杩涘害
+// agvId, // AGV
+// now // 宸ヤ綔鏃堕棿
+// ));
+// lastDirection = oriStaWorkDirection;
+// }
+ // 璁$畻璐у弶宸ヤ綔鏂瑰悜
+ staWorkDirection = mapService.calculateAgvWorkDirectionByStation(oriStaWorkDirection, lastDirection);
+ actionList.add(new Action(
+ null, // 缂栧彿
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.ReadyTakeFromShelvesLoc.desc, // 鍚嶇О
+ Double.parseDouble("0"), // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(oriSta.getOffset()), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.ReadyTakeFromShelvesLoc.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now, // 宸ヤ綔鏃堕棿
+ oriSta.getStaTypeIsCheck() == 1 ? 1 : 0,
+ oriSta.getStaNo()
+ ));
+ // 鏆傚瓨鐐规斁璐�
+ assert backpackType != null;
+ actionList.add(new Action(
+ null, // 缂栧彿
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.ReadyReleaseToAgvSite.desc, // 鍚嶇О
+ (double) backpackType.lev, // 灞炴�ш皰
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(backpackType.height), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.ReadyReleaseToAgvSite.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+ break;
+ case DEST_STA:
+ // 绔欑偣鏀捐揣
+ Sta destSta = staService.getById(task.getDestSta());
+ Double destStaWorkDirection = mapService.getStaAngle(destSta, workDirection);
+// CodeGap gap = codeGapService.findByCodeOfBoth(lastCode.getId(), nextCode.getId());
+
+ // 妫�楠屾柟鍚�
+// if (!lastDirection.equals(destStaWorkDirection)) {
+// if (!lastCode.getCornerBool()) {
+// throw new CoolException(agvNo + "鍙峰皬杞︽柟鍚戦敊璇紝璇锋帹鑷宠浆寮偣鎵嬪姩璋冩暣");
+// }
+//
+// actionList.add(new Action(
+// null, // 缂栧彿
+// task.getBusId(), // 鎬荤嚎
+// task.getId(), // 浠诲姟
+// null, // 鍔ㄤ綔鍙�
+// null, // 浼樺厛绾�
+// actionType.desc, // 鍚嶇О
+// (double) agvSpeedType.val, // 灞炴�у��
+// lastCode.getData(), // 鍦伴潰鐮�
+// String.valueOf(gap.getDistance()), // 鍔ㄤ綔鍙傛暟
+// actionType.val(), // 鍔ㄤ綔绫诲瀷
+// actionPrepareSts, // 鍔ㄤ綔杩涘害
+// agvId, // AGV
+// now // 宸ヤ綔鏃堕棿
+// ));
+// // turn
+// actionList.add(new Action(
+// null, // 缂栧彿
+// task.getBusId(), // 鎬荤嚎
+// task.getId(), // 浠诲姟
+// null, // 鍔ㄤ綔鍙�
+// null, // 浼樺厛绾�
+// ActionTypeType.TurnCorner.desc, // 鍚嶇О
+// mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 灞炴�ш皰
+// lastCode.getData(), // 鍦伴潰鐮�
+// String.valueOf(destStaWorkDirection), // 鍔ㄤ綔鍙傛暟
+// ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
+// actionPrepareSts, // 鍔ㄤ綔杩涘害
+// agvId, // AGV
+// now // 宸ヤ綔鏃堕棿
+// ));
+// lastDirection = destStaWorkDirection;
+// }
+ // 鏆傚瓨鐐瑰彇璐�
+ assert backpackType != null;
+ actionList.add(new Action(
+ null, // 缂栧彿
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.ReadyTakeFromAgvSite.desc, // 鍚嶇О
+ (double) backpackType.lev, // 灞炴�ш皰
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(backpackType.height), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.ReadyTakeFromAgvSite.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+
+ ));
+ // 璁$畻璐у弶宸ヤ綔鏂瑰悜
+ staWorkDirection = mapService.calculateAgvWorkDirectionByStation(destStaWorkDirection, lastDirection);
+ actionList.add(new Action(
+ null, // 缂栧彿
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.ReadyReleaseToShelvesLoc.desc, // 鍚嶇О
+ Double.parseDouble("0"), // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(destSta.getOffset()), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.ReadyReleaseToShelvesLoc.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now, // 宸ヤ綔鏃堕棿
+ destSta.getStaTypeIsCheck() == 1 ? 2 : 0,
+ destSta.getStaNo()
+ ));
+ break;
+ case TO_CHARGE:
+ // 妫�楠屾柟鍚�
+ FuncSta chargeFuncSta = funcStaService.query(lastCode.getId(), FuncStaType.CHARGE.toString());
+ Double chargeDirection = Double.parseDouble(chargeFuncSta.getAngle());
+ if (!lastDirection.equals(chargeDirection)&&lastCode.getCornerBool()) {
+ actionList.add(new Action(
+ null, // 缂栧彿
+ null, // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.TurnCorner.desc, // 鍚嶇О
+ mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 灞炴�ш皰
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(chargeDirection), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+ lastDirection = chargeDirection;
+ }
+
+ // charge
+ actionList.add(new Action(
+ null, // 缂栧彿
+ null, // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.DockingCharge.desc, // 鍚嶇О
+ null, // 灞炴�ш皰
+ lastCode.getData(), // 鍦伴潰鐮�
+ null, // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.DockingCharge.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+ break;
+ case TO_STANDBY:
+// FuncSta standByFuncSta = funcStaService.query(agvId, lastCode.getId(), 2);
+// Double standByDirection = Double.parseDouble(standByFuncSta.getAngle());
+// if (!lastDirection.equals(standByDirection)) {
+// actionList.add(new Action(
+// null, // 缂栧彿
+// null, // 鎬荤嚎
+// task.getId(), // 浠诲姟
+// null, // 鍔ㄤ綔鍙�
+// null, // 浼樺厛绾�
+// ActionTypeType.TurnCorner.desc, // 鍚嶇О
+// null, // 灞炴�ш皰
+// lastCode.getData(), // 鍦伴潰鐮�
+// String.valueOf(standByDirection), // 鍔ㄤ綔鍙傛暟
+// ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
+// actionPrepareSts, // 鍔ㄤ綔杩涘害
+// agvId, // AGV
+// now // 宸ヤ綔鏃堕棿
+// ));
+// lastDirection = standByDirection;
+// }
+ String runToWaitHeightFlag = configService.getVal("RunToWaitHeightFlag", String.class);
+ if (!Cools.isEmpty(runToWaitHeightFlag) && runToWaitHeightFlag.contains(agvId.toString())) {
+ String runToWaitHeight = configService.getVal("RunToWaitHeight", String.class);
+ if (Cools.isEmpty(runToWaitHeight)) {
+ runToWaitHeight = "800";
+ }
+ Double runToWaitHeightValue = configService.getVal("RunToWaitHeightValue", Double.class);
+ if (runToWaitHeightValue == 0) {
+ runToWaitHeightValue = 1D;
+ }
+ // 淇绌烘寚閽堝紓甯革細妫�鏌astCode鏄惁涓簄ull
+ if (lastCode == null) {
+ throw new BusinessException("AGV瀹氫綅淇℃伅寮傚父锛屾棤娉曠敓鎴愬緟鏈哄姩浣�");
+ }
+ actionList.add(new Action(
+ null, // 缂栧彿
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.RunToWaitHeight.desc, // 鍚嶇О
+ runToWaitHeightValue, // 灞炴�ш皰
+ lastCode.getData(), // 鍦伴潰鐮�
+ runToWaitHeight, // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.RunToWaitHeight.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+ }
+ break;
+ case MOVE:
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ // finish
+ actionList.add(new Action(
+ null, // 缂栧彿
+ null, // 鎬荤嚎
+ null, // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.FinishPath.desc, // 鍚嶇О
+ null, // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ null, // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.FinishPath.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+
+ List<Action> newActionList = actionSorter.optimizeSort(actionList);
+ String groupId = String.valueOf(snowflakeIdWorker.nextId()).substring(3);
+
+ // save action
+ int i = newActionList.size();
+ for (Action action : newActionList) {
+// action.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
+ action.setGroupId(groupId);
+ action.setPriority(i);
+ i -= 1;
+ }
+ if (!actionService.saveBatch(newActionList)) {
+ throw new BusinessException("group[" + groupId + "] 鍔ㄤ綔淇濆瓨澶辫触");
+ }
+
+ // update segment
+ for (Segment item : segmentList) {
+ item.setGroupId(groupId);
+ item.setState(SegmentStateType.RUNNING.toString());
+ item.setUpdateTime(now);
+ if (null != algoStartTime) {
+ item.setAlgoTime((int) (now.getTime() - algoStartTime.getTime()));
+ }
+ if (!segmentService.updateById(item)) {
+ throw new CoolException("鏇存柊Segment澶辫触");
+ }
+ }
+
+ log.info("{}鍙稟gv鍔ㄤ綔缁勮瀹屾垚锛屾寚浠ゆ暟閲忥細{}", agvNo, newActionList.size());
+ } catch (Exception e) {
+ log.error("mainService.generateAction", e);
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+
+ if (!Cools.isEmpty(pathList)) {
+ pathList.remove(0);
+ List<int[]> codeMatrixIdxList = mapDataDispatcher.getCodeMatrixIdxList(null, pathList);
+ mapDataDispatcher.clearDynamicMatrixByCodeList(null, codeMatrixIdxList);
+ }
+
+ throw new RuntimeException("generateAction method caught an exception, rolling back transaction.", e);
+ }
+ }
+
+
+ /**
+ * 鏍规嵁鍒嗙墖鐢熸垚鍔ㄤ綔 ( 杞﹁締鍙兘宸茬粡鍋氳繃涓�浜涗换鍔′簡,姝e湪绛夊緟涓嬩竴娈典换鍔� )
+ */
+ @Transactional
+ public synchronized void generateActionV2(Long agvId, List<Segment> segmentList, List<String> pathList, Date algoStartTime) {
+ try {
+ if (Cools.isEmpty(agvId, segmentList)) {
+ return;
+ }
+ Date now = new Date();
+ long actionPrepareSts = ActionStsType.PREPARE.val();
+// JSONObject storeDirection = configService.getVal("storeDirection", JSONObject.class);
+ int angleOffsetVal = configService.getVal("mapAngleOffsetVal", Integer.class);
+ String agvNo = agvService.getAgvNo(agvId);
+// if (!agvService.judgeEnable(agvId)) {
+// throw new CoolException("AGV[" + agvNo + "]褰撳墠涓嶅彲鐢�...");
+// }
+
+ AgvModel agvModel = agvModelService.getByAgvId(agvId);
+ Double workDirection = agvModel.getWorkDirection();
+ AgvSpeedType agvSpeedType = AgvSpeedType.query(agvModel.getTravelSpeed());
+ assert agvSpeedType != null;
+
+ AgvDetail agvDetail = agvDetailService.selectMajorByAgvId(agvId);
+
+ List<Action> actionList = new ArrayList<>();
+ // start node
+ Code lastCode = codeService.getCacheById(agvDetail.getRecentCode());
+ Double lastDirection = MapService.mapToNearest(agvDetail.getAgvAngle());
+ if (!lastCode.getData().equals(pathList.get(0))) {
+ throw new CoolException("AGV[" + agvNo + "]瀹氫綅鍋忕Щ...");
+ }
+
+ //String lastCorner = null;
+ Integer index = -1;
+ boolean corner = false;
+ for (int i = pathList.size(); i < 0; i++) {
+ Code nextCode = codeService.getCacheByData(pathList.get(i));
+ if (nextCode != null && nextCode.getCornerBool()) {
+ //lastCorner = pathList.get(i);
+ index = i;
+ }
+ }
+
+ boolean first = true;
+ for (Segment segment : segmentList) {
+
+ // 鍒嗘鎵�灞炵殑Task
+ Task task = taskService.getById(segment.getTaskId());
+
+ // 鑺傜偣鏉$爜
+ Code code = codeService.getCacheById(segment.getEndNode());
+
+ // 闇�瑕佽蛋琛�
+ 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++) {
+ if (i == 0) {
+ continue;
+ }
+ String next = pathListPart.get(i);
+ Code nextCode = codeService.getCacheByData(next);
+ Double nextDirection;
+
+ boolean reverse = false;
+ if (index >= i) {
+ // DOTO 娣诲姞杞集
+ Code endCode = codeService.getCacheByData(pathList.get(pathList.size() - 1));
+ nextDirection = mapService.calculateDirection(lastCode, endCode, angleOffsetVal);
+ reverse = true;
+ } else {
+ nextDirection = mapService.calculateDirection(lastCode, nextCode, angleOffsetVal);
+
+ // 绗竴姝ワ細濡傛灉涓嬩竴涓柟鍚戞濂芥槸浣滀笟鏂瑰悜鐨勭浉鍙嶆柟鍚戯紝鍒欓噸缃笅涓�涓柟鍚戜负浣滀笟鏂瑰悜锛屾爣璁� reverse = true
+ if (!nextDirection.equals((workDirection+180) % 360)) {
+ nextDirection = workDirection;
+ reverse = true;
+ }
+
+ // 绗簩姝ワ細鍒ゆ柇褰撳墠鑺傜偣鏄惁鍙互鏃嬭浆
+ if (!lastCode.getCornerBool()) {
+ // 濡傛灉鏄綔涓氭柟鍚戯紝浣嗘槸灏忚溅鍦ㄥ贩閬撳唴鏂瑰悜閿欒锛屽垯鍋滄
+ if (reverse && !lastDirection.equals(nextDirection)) {
+// throw new CoolException(agvNo + "鍙峰皬杞︽柟鍚戦敊璇紝璇锋帹鑷宠浆寮偣鎵嬪姩璋冩暣");
+ }
+ // 濡傛灉涓嶆槸浣滀笟鏂瑰悜锛屽垽鏂槸鍚︾浉鍙嶆柟鍚戯紝濡傛灉鍙嶆柟鍚戝垯鍊掗��琛岃蛋
+ if (nextDirection.equals((lastDirection + 180) % 360)) {
+ nextDirection = lastDirection;
+ reverse = true;
+ }
+ } else {
+ if (!lastDirection.equals(nextDirection)) {
+ // 濡傛灉涓嬩釜鑺傜偣鏂瑰悜涓庡綋鍓峚gv鏂瑰悜鐩稿弽锛屽垯鍊掗��琛岃蛋锛屼絾鏄鏋滃綋鍓峚gv鏂瑰悜姝eソ涓庡伐浣滄柟鍚戠浉鍙嶏紝鍒欐棆杞嚦宸ヤ綔鏂瑰悜
+ if (nextDirection.equals((lastDirection + 180) % 360) && !workDirection.equals((lastDirection + 180) % 360)) {
+ nextDirection = lastDirection;
+ reverse = true;
+ } else {
+ // turn
+ actionList.add(new Action(
+ null, // 缂栧彿s
+ task.getBusId(), // 鎬荤嚎
+ task.getId(), // 浠诲姟
+ null, // 鍔ㄤ綔鍙�
+ null, // 浼樺厛绾�
+ ActionTypeType.TurnCorner.desc, // 鍚嶇О
+ mapService.isTurnCorner(lastCode.getData()) ? 1D : 0D, // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(nextDirection), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
+
+ lastDirection = nextDirection;
+ }
+ }
+ }
+ }
+
// 绗竴涓姩浣滀竴瀹氭槸 turn
if (actionList.isEmpty()) {
@@ -1131,7 +1783,7 @@
// 妫�楠屾柟鍚�
FuncSta chargeFuncSta = funcStaService.query(lastCode.getId(), FuncStaType.CHARGE.toString());
Double chargeDirection = Double.parseDouble(chargeFuncSta.getAngle());
- if (!lastDirection.equals(chargeDirection)) {
+ if (!lastDirection.equals(chargeDirection) && lastCode.getCornerBool()) {
actionList.add(new Action(
null, // 缂栧彿
null, // 鎬荤嚎
@@ -1274,7 +1926,7 @@
log.info("{}鍙稟gv鍔ㄤ綔缁勮瀹屾垚锛屾寚浠ゆ暟閲忥細{}", agvNo, newActionList.size());
} catch (Exception e) {
- log.error("mainService.generateAction", e);
+ log.error("mainService.generateActionV2", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
if (!Cools.isEmpty(pathList)) {
@@ -1283,7 +1935,7 @@
mapDataDispatcher.clearDynamicMatrixByCodeList(null, codeMatrixIdxList);
}
- throw new RuntimeException("generateAction method caught an exception, rolling back transaction.", e);
+ throw new RuntimeException("generateActionV2 method caught an exception, rolling back transaction.", e);
}
}
--
Gitblit v1.9.1