From 3c65b4169a1bf08c94a58eef551d4c8466d21aab Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期四, 05 二月 2026 10:56:43 +0800
Subject: [PATCH] #
---
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java | 392 +++++++++++++++++++++++++++++++++++--------------------
1 files changed, 251 insertions(+), 141 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 daa7470..230d0e6 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
@@ -4,13 +4,11 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.zy.acs.common.constant.RedisConstant;
-import com.zy.acs.common.domain.AgvAction;
-import com.zy.acs.common.domain.AgvActionItem;
-import com.zy.acs.common.domain.AgvProtocol;
-import com.zy.acs.common.domain.BaseResult;
+import com.zy.acs.common.domain.*;
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;
@@ -21,10 +19,11 @@
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;
-import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam;
+import com.zy.acs.manager.core.integrate.dto.OpenBusSubmitParam;
import com.zy.acs.manager.manager.entity.*;
import com.zy.acs.manager.manager.enums.*;
import com.zy.acs.manager.manager.service.*;
@@ -89,11 +88,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
@@ -105,11 +104,12 @@
@Transactional
public Bus generateBusAndTask(OpenBusSubmitParam busSubmitParam, String memo) {
String errorMsg = busService.checkoutValid(busSubmitParam);
+ Boolean maintainLocSts = configService.getVal("maintainLocSts", Boolean.class);
if (!Cools.isEmpty(errorMsg)) {
throw new BusinessException(errorMsg);
}
- String batch = busSubmitParam.getBatch();
- List<TaskDto> taskDtoList = busSubmitParam.getTaskList();
+ String batchNo = busSubmitParam.getBatchNo();
+ List<TaskDto> taskDtoList = busSubmitParam.getTasks();
if (Cools.isEmpty(taskDtoList)) {
throw new BusinessException("taskList can't be empty!");
}
@@ -124,7 +124,7 @@
Date now = new Date();
Bus bus = new Bus();
bus.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
- bus.setBusNo(batch);
+ bus.setBusNo(batchNo);
bus.setStartTime(now);
bus.setBusSts(BusStsType.RECEIVE.val());
bus.setMemo(memo);
@@ -148,35 +148,39 @@
Sta destSta = null;
switch (TaskTypeType.get(task.getTaskTypeEl())) {
case LOC_TO_LOC:
- oriLoc = locService.getById(task.getOriLoc());
- if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
- throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " is not in STOCK status");
- }
- oriLoc.setLocSts(LocStsType.PAKOUT.val());
- oriLoc.setUpdateTime(now);
- if (!locService.updateById(oriLoc)) {
- throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " failed to update");
- }
+ if (maintainLocSts) {
+ oriLoc = locService.getById(task.getOriLoc());
+ if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
+ throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " is not in STOCK status");
+ }
+ oriLoc.setLocSts(LocStsType.PAKOUT.val());
+ oriLoc.setUpdateTime(now);
+ if (!locService.updateById(oriLoc)) {
+ throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " failed to update");
+ }
- destLoc = locService.getById(task.getDestLoc());
- if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
- throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " is not in IDLE status");
- }
- destLoc.setLocSts(LocStsType.PAKIN.val());
- destLoc.setUpdateTime(now);
- if (!locService.updateById(destLoc)) {
- throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " failed to update");
+ destLoc = locService.getById(task.getDestLoc());
+ if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
+ throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " is not in IDLE status");
+ }
+ destLoc.setLocSts(LocStsType.PAKIN.val());
+ destLoc.setUpdateTime(now);
+ if (!locService.updateById(destLoc)) {
+ throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " failed to update");
+ }
}
break;
case LOC_TO_STA:
- oriLoc = locService.getById(task.getOriLoc());
- if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
- throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " is not in STOCK status");
- }
- oriLoc.setLocSts(LocStsType.PAKOUT.val());
- oriLoc.setUpdateTime(now);
- if (!locService.updateById(oriLoc)) {
- throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " failed to update");
+ if (maintainLocSts) {
+ oriLoc = locService.getById(task.getOriLoc());
+ if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
+ throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " is not in STOCK status");
+ }
+ oriLoc.setLocSts(LocStsType.PAKOUT.val());
+ oriLoc.setUpdateTime(now);
+ if (!locService.updateById(oriLoc)) {
+ throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " failed to update");
+ }
}
destSta = staService.getById(task.getDestSta());
@@ -190,14 +194,16 @@
throw new BusinessException("oriSta锛�" + task.getOriSta$() + " failed to reserve");
}
- destLoc = locService.getById(task.getDestLoc());
- if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
- throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " is not in IDLE status");
- }
- destLoc.setLocSts(LocStsType.PAKIN.val());
- destLoc.setUpdateTime(now);
- if (!locService.updateById(destLoc)) {
- throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " failed to update");
+ if (maintainLocSts) {
+ destLoc = locService.getById(task.getDestLoc());
+ if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
+ throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " is not in IDLE status");
+ }
+ destLoc.setLocSts(LocStsType.PAKIN.val());
+ destLoc.setUpdateTime(now);
+ if (!locService.updateById(destLoc)) {
+ throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " failed to update");
+ }
}
break;
case STA_TO_STA:
@@ -250,33 +256,28 @@
, (task, agvNo, sta) -> {
Long agvId = agvService.getAgvId(agvNo);
-// List<Travel> travelList = travelService.list(new LambdaQueryWrapper<Travel>()
-// .eq(Travel::getAgvId, agvId)
-// .eq(Travel::getState, TravelStateType.RUNNING.toString())
-// .orderByDesc(Travel::getCreateTime));
-// if (Cools.isEmpty(travelList)) {
-// throw new BusinessException("[Agv: " + agvNo + "]allocate inbound failed to find travel");
+ Travel travel = travelService.findRunningTravel(agvId);
+ if (null == travel) {
+ throw new CoolException("[Agv:" + agvNo + "] allocate inbound failed: no roller waiting travel");
+ }
+
+ // curr segment
+ Segment currSeg = segmentService.getCurrWaitingSeg(travel.getId(), agvId);
+// if (null == currSeg) {
+// currSeg = segmentService.getCurrRunningSeg(travel.getId(), agvId, null);
// }
-// Travel travel = travelList.get(0);
-//
-// List<Segment> currSegments = segmentService.list(new LambdaQueryWrapper<Segment>()
-// .eq(Segment::getAgvId, agvId)
-// .eq(Segment::getTravelId, travel.getId())
-// );
- // load segment
- Segment currSeg = segmentService.getRollerWaiting(agvId, sta.getCode(), TaskPosDto.PosType.ORI_STA);
if (null == currSeg) {
- throw new BusinessException("[Agv:" + agvNo + "] allocate inbound failed: no roller waiting segment");
+ throw new CoolException("[Agv:" + agvNo + "] allocate inbound failed: no waiting segment");
}
// get backpack lev
int backpackLev = 0;
- int backpack = agvService.getBackpack(agvId);
+ int backpackCap = agvService.getBackpack(agvId);
List<Integer> usedBackpacks = segmentService.selectUsedBackpacks(currSeg.getTravelId(), agvId);
- if (usedBackpacks.size() >= backpack) {
+ if (usedBackpacks.size() >= backpackCap) {
throw new CoolException("[Agv:" + agvNo + "] allocate inbound segment failed: no idle backpack to use");
}
- for (int lev = 1; lev <= backpack; lev++) {
+ for (int lev = 1; lev <= backpackCap; lev++) {
if (!usedBackpacks.contains(lev)) {
backpackLev = lev;
break;
@@ -362,7 +363,6 @@
// DEST-only sort
destPosList.sort((a, b) -> {
-
// 涓昏酱
double aFirst = a.getFirstWeight(sameGroupXy);
double bFirst = b.getFirstWeight(sameGroupXy);
@@ -380,11 +380,10 @@
// get placeSeg serial
int placeSegSerial;
- // query placeSeg idx
int idx = -1;
for (int i = 0; i < destPosList.size(); i++) {
- if (Objects.equals(destPosList.get(i).getCodeId(), newDto.getCodeId())
- && Objects.equals(destPosList.get(i).getTaskId(), newDto.getTaskId())) {
+ if (Objects.equals(destPosList.get(i).getTaskId(), newDto.getTaskId())
+ && Objects.equals(destPosList.get(i).getCodeId(), newDto.getCodeId())) {
idx = i;
break;
}
@@ -446,10 +445,13 @@
if (!taskService.updateById(task)) {
throw new BusinessException("seqNum: " + task.getSeqNum() + " failed to update");
}
+ // update reserve
+ staReserveService.allocateCallBack(task, agvId);
}
// normal
, (task, agvNo, sta) -> {
Long agvId = agvService.getAgvId(agvNo);
+ // update task
task.setAgvId(agvId);
task.setTaskSts(TaskStsType.WAITING.val());
task.setIoTime(now);
@@ -457,6 +459,8 @@
if (!taskService.updateById(task)) {
throw new BusinessException("seqNum: " + task.getSeqNum() + " failed to update");
}
+ // update reserve
+ staReserveService.allocateCallBack(task, agvId);
});
// if (Cools.isEmpty(agvNo)) {
//// log.warn("Task[{}] has an issue锛� because it failed to check out agv which is idle...", task.getSeqNum());
@@ -486,7 +490,7 @@
try {
// valid -----------------------------------------------
Agv agv = agvService.getById(agvId);
- if (!agvService.judgeEnable(agv.getId(), false)) {
+ if (!agvService.judgeEnable(agv.getId())) {
return;
}
if (!Cools.isEmpty(taskService.selectInSts(agvId, TaskStsType.ASSIGN, TaskStsType.PROGRESS))) {
@@ -506,9 +510,9 @@
return o2.getPriority() - o1.getPriority();
}
});
- Integer backpack = agvService.getBackpack(agvId);
- if (taskList.size() > backpack) {
- taskList = taskList.subList(0, backpack);
+ Integer backpackCap = agvService.getBackpack(agvId);
+ if (taskList.size() > backpackCap) {
+ taskList = taskList.subList(0, backpackCap);
}
AgvDetail agvDetail = agvDetailService.selectByAgvId(agvId);
@@ -578,7 +582,7 @@
}
- if (backpackLev > backpack) {
+ if (backpackLev > backpackCap) {
throw new BusinessException("瑙f瀽Task澶辫触,AGV鑳岀瘬宸叉弧......");
}
@@ -664,6 +668,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));
@@ -781,17 +786,19 @@
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
- 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());
task.setTaskType(taskType.val());
+ task.setUplinkSts(TaskUplinkStateType.SKIPPED.toString());
task.setIoTime(now);
task.setStartTime(now);
if (!taskService.save(task)) {
@@ -799,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));
@@ -892,6 +900,8 @@
long actionPrepareSts = ActionStsType.PREPARE.val();
// JSONObject storeDirection = configService.getVal("storeDirection", JSONObject.class);
int angleOffsetVal = configService.getVal("mapAngleOffsetVal", Integer.class);
+// Double defaultShelfDepth = configService.getVal("defaultShelfDepth", Double.class);
+// defaultShelfDepth = Optional.ofNullable(defaultShelfDepth).orElse((double) 0);
String agvNo = agvService.getAgvNo(agvId);
// if (!agvService.judgeEnable(agvId)) {
// throw new CoolException("AGV[" + agvNo + "]褰撳墠涓嶅彲鐢�...");
@@ -899,6 +909,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());
@@ -927,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++) {
@@ -936,51 +946,118 @@
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) {
+ final double oppNextLaneDir = (nextLaneDir + 180) % 360;
+
+ 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((lastDirection + 180) % 360)) {
- nextDirection = lastDirection;
+
+ 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 {
- 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.calcSpinDirection(lastCode, lastDirection, nextDirection).val, // 灞炴�у��
+ lastCode.getData(), // 鍦伴潰鐮�
+ String.valueOf(nextDirection), // 鍔ㄤ綔鍙傛暟
+ ActionTypeType.TurnCorner.val(), // 鍔ㄤ綔绫诲瀷
+ actionPrepareSts, // 鍔ㄤ綔杩涘害
+ agvId, // AGV
+ now // 宸ヤ綔鏃堕棿
+ ));
- lastDirection = nextDirection;
+ lastDirection = nextDirection;
+ }
}
}
}
@@ -995,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(), // 鍔ㄤ綔绫诲瀷
@@ -1008,10 +1085,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, // 缂栧彿
@@ -1038,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, // 缂栧彿
@@ -1046,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;
@@ -1085,7 +1178,7 @@
ActionTypeType.ReadyTakeFromShelvesLoc.desc, // 鍚嶇О
(double) agvDirectionType.val, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
- String.valueOf(oriLoc.getOffset()), // 鍔ㄤ綔鍙傛暟
+ JSON.toJSONString(new HeightDepthDto(oriLoc.getOffset())), // 鍔ㄤ綔鍙傛暟
ActionTypeType.ReadyTakeFromShelvesLoc.val(), // 鍔ㄤ綔绫诲瀷
actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
@@ -1148,7 +1241,7 @@
ActionTypeType.ReadyReleaseToShelvesLoc.desc, // 鍚嶇О
(double) agvDirectionType.val, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
- String.valueOf(destLoc.getOffset()), // 鍔ㄤ綔鍙傛暟
+ JSON.toJSONString(new HeightDepthDto(destLoc.getOffset())), // 鍔ㄤ綔鍙傛暟
ActionTypeType.ReadyReleaseToShelvesLoc.val(), // 鍔ㄤ綔绫诲瀷
actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
@@ -1172,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(), // 鍔ㄤ綔绫诲瀷
@@ -1193,7 +1286,7 @@
ActionTypeType.ReadyTakeFromConveyorSta.desc, // 鍚嶇О
staWorkDirection, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
- String.valueOf(oriSta.getOffset()), // 鍔ㄤ綔鍙傛暟
+ JSON.toJSONString(new HeightDepthDto(oriSta.getHeight(), Optional.ofNullable(oriSta.getDepth()).orElse((double) 0))), // 鍔ㄤ綔鍙傛暟
ActionTypeType.ReadyTakeFromConveyorSta.val(), // 鍔ㄤ綔绫诲瀷
actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
@@ -1236,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(), // 鍔ㄤ綔绫诲瀷
@@ -1276,7 +1369,7 @@
ActionTypeType.ReadyReleaseToConveyorSta.desc, // 鍚嶇О
staWorkDirection, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
- String.valueOf(destSta.getOffset()), // 鍔ㄤ綔鍙傛暟
+ JSON.toJSONString(new HeightDepthDto(destSta.getHeight(), Optional.ofNullable(destSta.getDepth()).orElse((double) 0))), // 鍔ㄤ綔鍙傛暟
ActionTypeType.ReadyReleaseToConveyorSta.val(), // 鍔ㄤ綔绫诲瀷
actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
@@ -1295,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(), // 鍔ㄤ綔绫诲瀷
@@ -1549,14 +1642,22 @@
agvAction.add(new AgvActionItem<>(ReadyTakeFromShelvesLoc.class)
.setVal(action.getVal().intValue())
.setQrCode(action.getCode())
- .bodySync(body -> body.setHeight((short) Double.parseDouble(action.getParams())))
+ .bodySync((body) -> {
+ HeightDepthDto heightDepthDto = JSON.parseObject(action.getParams(), HeightDepthDto.class);
+ body.setHeight(heightDepthDto.getHeight());
+ body.setDepth(heightDepthDto.getDepth());
+ })
);
break;
case ReadyTakeFromConveyorSta:
agvAction.add(new AgvActionItem<>(ReadyTakeFromConveyorSta.class)
.setVal(action.getVal().intValue())
.setQrCode(action.getCode())
- .bodySync(body -> body.setHeight((short) Double.parseDouble(action.getParams())))
+ .bodySync((body) -> {
+ HeightDepthDto heightDepthDto = JSON.parseObject(action.getParams(), HeightDepthDto.class);
+ body.setHeight(heightDepthDto.getHeight());
+ body.setDepth(heightDepthDto.getDepth());
+ })
);
break;
case ReadyTakeFromAgvSite:
@@ -1570,21 +1671,22 @@
agvAction.add(new AgvActionItem<>(ReadyReleaseToShelvesLoc.class)
.setVal(action.getVal().intValue())
.setQrCode(action.getCode())
- .bodySync(body -> body.setHeight((short) Double.parseDouble(action.getParams())))
- );
- break;
- case LoadPlatformLift:
- agvAction.add(new AgvActionItem<>(LoadPlatformLift.class)
- .setVal(action.getVal().intValue())
- .setQrCode(action.getCode())
- .bodySync(body -> body.setHeight((short) Double.parseDouble(action.getParams())))
+ .bodySync((body) -> {
+ HeightDepthDto heightDepthDto = JSON.parseObject(action.getParams(), HeightDepthDto.class);
+ body.setHeight(heightDepthDto.getHeight());
+ body.setDepth(heightDepthDto.getDepth());
+ })
);
break;
case ReadyReleaseToConveyorSta:
agvAction.add(new AgvActionItem<>(ReadyReleaseToConveyorSta.class)
.setVal(action.getVal().intValue())
.setQrCode(action.getCode())
- .bodySync(body -> body.setHeight((short) Double.parseDouble(action.getParams())))
+ .bodySync((body) -> {
+ HeightDepthDto heightDepthDto = JSON.parseObject(action.getParams(), HeightDepthDto.class);
+ body.setHeight(heightDepthDto.getHeight());
+ body.setDepth(heightDepthDto.getDepth());
+ })
);
break;
case ReadyReleaseToAgvSite:
@@ -1592,6 +1694,13 @@
.setVal(action.getVal().intValue())
.setQrCode(action.getCode())
.bodySync(body -> body.setDepth((short) Double.parseDouble(action.getParams())))
+ );
+ break;
+ case LoadPlatformLift:
+ agvAction.add(new AgvActionItem<>(LoadPlatformLift.class)
+ .setVal(action.getVal().intValue())
+ .setQrCode(action.getCode())
+ .bodySync(body -> body.setHeight((short) Double.parseDouble(action.getParams())))
);
break;
case FinishPath:
@@ -1744,7 +1853,7 @@
Code code = codeService.getCacheByData(agv_06_up.getQrCode());
// query current segment
- Segment currSeg = segmentService.getCurrRunningSeg(agv.getId(), code.getId());
+ Segment currSeg = segmentService.getCurrRunningSeg(null, agv.getId(), code.getId());
if (null == currSeg) {
log.error("failed to find curr segment [{}]", agv.getUuid());
} else {
@@ -1768,7 +1877,7 @@
// load from sta
sta = staService.getById(currTask.getOriSta());
// reserve to be waiting
- if (!staReserveService.waitingStaReserve(sta, currTask, 1, StaReserveType.OUT)) {
+ if (!staReserveService.waitingStaReserve(sta, currTask, currSeg, 1, StaReserveType.OUT)) {
break;
}
// convey plc valid
@@ -1777,13 +1886,14 @@
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:
// place to sta
sta = staService.getById(currTask.getDestSta());
// reserve to be waiting
- if (!staReserveService.waitingStaReserve(sta, currTask, 1, StaReserveType.IN)) {
+ if (!staReserveService.waitingStaReserve(sta, currTask, currSeg, 1, StaReserveType.IN)) {
break;
}
// convey plc valid
@@ -1792,10 +1902,11 @@
staReserveService.rollbackWaitingToReserved(sta, currTask, StaReserveType.IN);
break;
}
+ log.info("AGV [{}] unload permitted at conveyor station [{}]", protocol.getAgvNo(), sta.getStaNo());
success = true;
break;
default:
- log.error("agv[{}] has wrong posType [{}], segment [{}]", protocol.getAgvNo(), posType.toString(), currSeg.getId());
+ log.error("AGV [{}] has wrong posType [{}], segment [{}]", protocol.getAgvNo(), posType.toString(), currSeg.getId());
break;
}
}
@@ -1809,7 +1920,6 @@
agv_06_down.setSerialNo(agv_06_up.getSerialNo());
agv_06_down.setActionCode(agv_06_up.getActionCode());
agv_06_down.setResult(success ? 1 : 0);
-
redis.push(RedisConstant.AGV_PATH_DOWN_FLAG, AgvProtocol.build(protocol.getAgvNo()).setMessageBody(agv_06_down));
}
--
Gitblit v1.9.1