From 6a19c21930c9fef7fe1dd3aaa35133f68375300a Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期四, 05 二月 2026 15:44:15 +0800
Subject: [PATCH] #
---
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java | 202 +++++++++++++++++++++++++++----------------------
1 files changed, 111 insertions(+), 91 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 6dbea83..495193d 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,10 +4,7 @@
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.*;
@@ -26,7 +23,7 @@
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.*;
@@ -107,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!");
}
@@ -126,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);
@@ -150,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());
@@ -192,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:
@@ -252,23 +256,18 @@
, (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
@@ -364,7 +363,6 @@
// DEST-only sort
destPosList.sort((a, b) -> {
-
// 涓昏酱
double aFirst = a.getFirstWeight(sameGroupXy);
double bFirst = b.getFirstWeight(sameGroupXy);
@@ -382,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;
}
@@ -493,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))) {
@@ -801,6 +798,7 @@
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)) {
@@ -902,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 + "]褰撳墠涓嶅彲鐢�...");
@@ -1155,7 +1155,7 @@
}
// 浣滀笟鐐瑰姩浣�
- AgvDirectionType agvDirectionType;
+ ActuatorDirectionType actuatorDirectionType;
Double staWorkDirection;
AgvBackpackType backpackType = AgvBackpackType.query(segment.getBackpack());
switch (Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType()))) {
@@ -1168,7 +1168,8 @@
// 璐ф灦鍙栬揣
Loc oriLoc = locService.getById(task.getOriLoc());
// 璁$畻宸﹀彸鏂瑰悜
- agvDirectionType = mapService.calculateAgvWorkDirectionByShelf(oriLoc, lastCode);
+ actuatorDirectionType = ActuatorDirectionType.fromVal(oriLoc.getCompDirect());
+// actuatorDirectionType = mapService.calculateAgvWorkDirectionByShelf(oriLoc, lastCode);
actionList.add(new Action(
null, // 缂栧彿
task.getBusId(), // 鎬荤嚎
@@ -1176,9 +1177,9 @@
null, // 鍔ㄤ綔鍙�
null, // 浼樺厛绾�
ActionTypeType.ReadyTakeFromShelvesLoc.desc, // 鍚嶇О
- (double) agvDirectionType.val, // 灞炴�у��
+ (double) actuatorDirectionType.val, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
- String.valueOf(oriLoc.getOffset()), // 鍔ㄤ綔鍙傛暟
+ JSON.toJSONString(new HeightDepthDto(oriLoc.getOffset())), // 鍔ㄤ綔鍙傛暟
ActionTypeType.ReadyTakeFromShelvesLoc.val(), // 鍔ㄤ綔绫诲瀷
actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
@@ -1231,7 +1232,8 @@
// 璐ф灦鏀捐揣
Loc destLoc = locService.getById(task.getDestLoc());
// 璁$畻宸﹀彸鏂瑰悜
- agvDirectionType = mapService.calculateAgvWorkDirectionByShelf(destLoc, lastCode);
+ actuatorDirectionType = ActuatorDirectionType.fromVal(destLoc.getCompDirect());
+// actuatorDirectionType = mapService.calculateAgvWorkDirectionByShelf(destLoc, lastCode);
actionList.add(new Action(
null, // 缂栧彿
task.getBusId(), // 鎬荤嚎
@@ -1239,9 +1241,9 @@
null, // 鍔ㄤ綔鍙�
null, // 浼樺厛绾�
ActionTypeType.ReadyReleaseToShelvesLoc.desc, // 鍚嶇О
- (double) agvDirectionType.val, // 灞炴�у��
+ (double) actuatorDirectionType.val, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
- String.valueOf(destLoc.getOffset()), // 鍔ㄤ綔鍙傛暟
+ JSON.toJSONString(new HeightDepthDto(destLoc.getOffset())), // 鍔ㄤ綔鍙傛暟
ActionTypeType.ReadyReleaseToShelvesLoc.val(), // 鍔ㄤ綔绫诲瀷
actionPrepareSts, // 鍔ㄤ綔杩涘害
agvId, // AGV
@@ -1276,7 +1278,8 @@
lastDirection = oriStaWorkDirection;
}
// 璁$畻璐у弶宸ヤ綔鏂瑰悜
- staWorkDirection = mapService.calculateAgvWorkDirectionByStation(oriStaWorkDirection, lastDirection);
+ actuatorDirectionType = ActuatorDirectionType.fromVal(oriSta.getActDir());
+// staWorkDirection = mapService.calculateAgvWorkDirectionByStation(oriStaWorkDirection, lastDirection);
actionList.add(new Action(
null, // 缂栧彿
task.getBusId(), // 鎬荤嚎
@@ -1284,9 +1287,9 @@
null, // 鍔ㄤ綔鍙�
null, // 浼樺厛绾�
ActionTypeType.ReadyTakeFromConveyorSta.desc, // 鍚嶇О
- staWorkDirection, // 灞炴�у��
+ (double) actuatorDirectionType.val, // 灞炴�у��
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
@@ -1359,7 +1362,8 @@
));
}
// 璁$畻璐у弶宸ヤ綔鏂瑰悜
- staWorkDirection = mapService.calculateAgvWorkDirectionByStation(destStaWorkDirection, lastDirection);
+// staWorkDirection = mapService.calculateAgvWorkDirectionByStation(destStaWorkDirection, lastDirection);
+ actuatorDirectionType = ActuatorDirectionType.fromVal(destSta.getActDir());
actionList.add(new Action(
null, // 缂栧彿
task.getBusId(), // 鎬荤嚎
@@ -1367,9 +1371,9 @@
null, // 鍔ㄤ綔鍙�
null, // 浼樺厛绾�
ActionTypeType.ReadyReleaseToConveyorSta.desc, // 鍚嶇О
- staWorkDirection, // 灞炴�у��
+ (double) actuatorDirectionType.val, // 灞炴�у��
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
@@ -1642,14 +1646,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:
@@ -1663,21 +1675,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:
@@ -1685,6 +1698,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:
@@ -1837,7 +1857,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 {
@@ -1861,7 +1881,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
@@ -1870,14 +1890,14 @@
staReserveService.rollbackWaitingToReserved(sta, currTask, StaReserveType.OUT);
break;
}
- log.info("AGV[{}] load permitted at conveyor station [{}]", protocol.getAgvNo(), sta.getStaNo());
+ 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
@@ -1886,11 +1906,11 @@
staReserveService.rollbackWaitingToReserved(sta, currTask, StaReserveType.IN);
break;
}
- log.info("AGV[{}] unload permitted at conveyor station [{}]", protocol.getAgvNo(), sta.getStaNo());
+ 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;
}
}
--
Gitblit v1.9.1