From 513f54c61991af2078c9098845df3e840ea5b863 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期二, 17 六月 2025 14:29:48 +0800
Subject: [PATCH] 1
---
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java | 56 ++++++++-----
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainZkdService.java | 56 ++++++-------
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/OpenAlgorithmController.java | 15 ++-
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/IMainService.java | 51 ++++++++++++
zy-acs-manager/src/main/java/com/zy/acs/manager/core/third/zkd/dto/Navigation.java | 2
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficZkdService.java | 4
6 files changed, 125 insertions(+), 59 deletions(-)
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/IMainService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/IMainService.java
new file mode 100644
index 0000000..66db355
--- /dev/null
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/IMainService.java
@@ -0,0 +1,51 @@
+package com.zy.acs.manager.core.service;
+
+import com.zy.acs.common.domain.AgvProtocol;
+import com.zy.acs.manager.common.domain.param.HandlerPublishParam;
+import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam;
+import com.zy.acs.manager.manager.entity.Bus;
+import com.zy.acs.manager.manager.entity.Jam;
+import com.zy.acs.manager.manager.entity.Segment;
+import com.zy.acs.manager.manager.entity.Task;
+import com.zy.acs.manager.manager.enums.TaskTypeType;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by vincent on 2023/6/14
+ */
+public interface IMainService {
+
+
+ //Bus generateBusAndTask(OpenBusSubmitParam busSubmitParam, String memo);
+
+ /**
+ * 浠诲姟鍒嗛厤缁欒溅杈� ( 杞﹁締姝ゆ椂鏄┖闂蹭笖闈欐鐨� )
+ */
+ void allocateTask(Bus bus);
+
+ /**
+ * 瑙f瀽鍙栨斁璐ч泦鍚堜换鍔�,杩涜鏈�浼樼殑鎺掑垪缁勫悎椤哄簭 ( 杞﹁締姝ゆ椂鏄┖闂蹭笖闈欐鐨� )
+ * todo: {@link com.zy.acs.manager.core.HandlerController#controlAgv(String, HandlerPublishParam)}
+ */
+ void buildMajorTask(Long agvId, List<Task> taskList);
+
+
+ /**
+ * 鍏呯數 鍥炲緟鏈轰綅浠诲姟
+ */
+ //boolean buildMinorTask(Long agvId, TaskTypeType taskType, String destination, Jam jam);
+
+ /**
+ * 鏍规嵁鍒嗙墖鐢熸垚鍔ㄤ綔 ( 杞﹁締鍙兘宸茬粡鍋氳繃涓�浜涗换鍔′簡,姝e湪绛夊緟涓嬩竴娈典换鍔� )
+ */
+ void generateAction(Long agvId, List<Segment> segmentList, List<String> pathList, Date algoStartTime);
+
+ void publishAction(String actionGroupId);
+
+ void upDataSubscribe(AgvProtocol protocol);
+
+ void settleSegmentList(List<Segment> segmentList, String serialNo);
+
+}
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 dbf5fd2..c18e9f1 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
@@ -48,7 +48,7 @@
*/
@Slf4j
@Service("mainService")
-public class MainService {
+public class MainService implements IMainService {
@Autowired
private BusService busService;
@@ -284,7 +284,9 @@
*/
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void buildMajorTask(Long agvId, List<Task> taskList) {
- if (Cools.isEmpty(agvId, taskList)) { return; }
+ if (Cools.isEmpty(agvId, taskList)) {
+ return;
+ }
try {
// valid -----------------------------------------------
Agv agv = agvService.getById(agvId);
@@ -324,16 +326,18 @@
* val: new TaskPosDto(taskId, new Double[]{code.getX(), code.getY()}, posType)
*/
Map<String, List<TaskPosDto>> groups = new HashMap<>();
- final String sameGroupXy = configService.getVal( "sameGroupXy", String.class);
+ final String sameGroupXy = configService.getVal("sameGroupXy", String.class);
int backpackLev = 0;
for (Task task : taskList) {
- backpackLev ++;
+ backpackLev++;
Code startCode = null;
Code endCode = null;
- Loc oriLoc = null; Loc destLoc = null;
- Sta oriSta = null; Sta destSta = null;
+ Loc oriLoc = null;
+ Loc destLoc = null;
+ Sta oriSta = null;
+ Sta destSta = null;
switch (Objects.requireNonNull(TaskTypeType.get(task.getTaskTypeEl()))) {
case LOC_TO_LOC:
oriLoc = locService.getById(task.getOriLoc());
@@ -436,7 +440,7 @@
// re-order by agv current position
Code currCode = codeService.getCacheById(agvDetail.getRecentCode());
- Double[] currPosition = new Double[] {currCode.getX(), currCode.getY()};
+ Double[] currPosition = new Double[]{currCode.getX(), currCode.getY()};
List<List<TaskPosDto>> pickGroups = new ArrayList<>();
List<List<TaskPosDto>> dropGroups = new ArrayList<>();
@@ -482,7 +486,7 @@
List<Segment> segmentList = new ArrayList<>();
for (List<TaskPosDto> dtoList : list) {
for (TaskPosDto taskPosDto : dtoList) {
- segSerial ++;
+ segSerial++;
AgvBackpackType backpackType = AgvBackpackDto.find(backpackDtoList, taskPosDto.getTaskId());
assert null != backpackType;
@@ -530,9 +534,12 @@
/**
* 鍏呯數 鍥炲緟鏈轰綅浠诲姟
*/
- @Transactional(propagation = Propagation.REQUIRES_NEW) // although there is a Transactional here that the lock is isolated, but we can't join the caller's Transactional
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
+ // although there is a Transactional here that the lock is isolated, but we can't join the caller's Transactional
public boolean buildMinorTask(Long agvId, TaskTypeType taskType, String destination, Jam jam) {
- if (Cools.isEmpty(agvId, taskType)) { return false; }
+ if (Cools.isEmpty(agvId, taskType)) {
+ return false;
+ }
try {
String agvNo = agvService.getAgvNo(agvId);
if (!agvService.judgeEnable(agvId)) {
@@ -579,7 +586,7 @@
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.setOriCode(agvDetail.getCode());
task.setDestCode(endCode.getId());
// lane
@@ -587,7 +594,7 @@
if (null != destLane) {
task.setDestLaneHash(destLane.getHashCode());
}
- task.setPriority(taskType.equals(TaskTypeType.TO_CHARGE)?2:1);
+ task.setPriority(taskType.equals(TaskTypeType.TO_CHARGE) ? 2 : 1);
task.setTaskSts(TaskStsType.ASSIGN.val());
task.setTaskType(taskType.val());
task.setIoTime(now);
@@ -609,11 +616,12 @@
}
// generate segment
- int segSerial = 0; segSerial ++;
+ int segSerial = 0;
+ segSerial++;
List<Segment> segmentList = new ArrayList<>();
String posType = "";
- switch (taskType){
+ switch (taskType) {
case TO_CHARGE:
posType = TaskPosDto.PosType.TO_CHARGE.toString();
break;
@@ -685,7 +693,9 @@
@Transactional
public synchronized void generateAction(Long agvId, List<Segment> segmentList, List<String> pathList, Date algoStartTime) {
try {
- if (Cools.isEmpty(agvId, segmentList)) { return; }
+ if (Cools.isEmpty(agvId, segmentList)) {
+ return;
+ }
Date now = new Date();
long actionPrepareSts = ActionStsType.PREPARE.val();
// JSONObject storeDirection = configService.getVal("storeDirection", JSONObject.class);
@@ -727,7 +737,9 @@
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; }
+ if (i == 0) {
+ continue;
+ }
String next = pathListPart.get(i);
@@ -936,7 +948,7 @@
task.getBusId(), // 鎬荤嚎
task.getId(), // 浠诲姟
null, // 鍔ㄤ綔鍙�
- null, // 浼樺厛绾�
+ null, // 浼樺厛绾�
ActionTypeType.ReadyReleaseToShelvesLoc.desc, // 鍚嶇О
(double) agvDirectionType.val, // 灞炴�у��
lastCode.getData(), // 鍦伴潰鐮�
@@ -1437,9 +1449,9 @@
// segment list
List<Segment> segmentList = segmentService.list(new LambdaQueryWrapper<Segment>()
- .eq(Segment::getGroupId, serialNo)
+ .eq(Segment::getGroupId, serialNo)
// .eq(Segment::getState, SegmentStateType.RUNNING.toString())
- .orderByAsc(Segment::getSerial)
+ .orderByAsc(Segment::getSerial)
);
// settlement
@@ -1469,8 +1481,10 @@
for (Segment segment : segmentList) {
boolean taskComplete = false;
- Task task = taskService.getById(segment.getTaskId()); assert null != task;
- TaskTypeType typeType = TaskTypeType.get(task.getTaskTypeEl()); assert null != typeType;
+ Task task = taskService.getById(segment.getTaskId());
+ assert null != task;
+ TaskTypeType typeType = TaskTypeType.get(task.getTaskTypeEl());
+ assert null != typeType;
TaskPosDto.PosType posType = TaskPosDto.queryPosType(segment.getPosType());
switch (Objects.requireNonNull(posType)) {
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainZkdService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainZkdService.java
index 03ad08c..284c70c 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainZkdService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainZkdService.java
@@ -19,7 +19,6 @@
import com.zy.acs.framework.exception.CoolException;
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.TaskPosDto;
import com.zy.acs.manager.core.service.astart.MapDataDispatcher;
import com.zy.acs.manager.core.third.zkd.HttpUtils;
@@ -46,8 +45,8 @@
* Created by vincent on 2023/6/14
*/
@Slf4j
-@Service("mainService")
-public class MainZkdService {
+@Service("zkdMainService")
+public class MainZkdService implements IMainService {
@Autowired
private BusService busService;
@@ -101,7 +100,7 @@
* 浠诲姟鍒嗛厤缁欒溅杈� ( 杞﹁締姝ゆ椂鏄┖闂蹭笖闈欐鐨� )
*/
@Transactional
- public synchronized void allocateTaskByZkd(Bus bus) {
+ public synchronized void allocateTask(Bus bus) {
try {
Date now = new Date();
List<Task> taskList = taskService.list(new LambdaQueryWrapper<Task>()
@@ -182,6 +181,8 @@
}
}
+
+
/**
* 瑙f瀽鍙栨斁璐ч泦鍚堜换鍔�,杩涜鏈�浼樼殑鎺掑垪缁勫悎椤哄簭 ( 杞﹁締姝ゆ椂鏄┖闂蹭笖闈欐鐨� )
* todo: {@link com.zy.acs.manager.core.HandlerController#controlAgv(String, HandlerPublishParam)}
@@ -200,27 +201,30 @@
if (!travelService.save(travel)) {
throw new BusinessException("浠诲姟缁勪繚瀛樺け璐�");
}
-
// generate segment
int segSerial = 0;
List<Segment> segmentList = new ArrayList<>();
- for (List<TaskPosDto> dtoList : list) {
- for (TaskPosDto taskPosDto : dtoList) {
- segSerial++;
- AgvBackpackType backpackType = AgvBackpackDto.find(backpackDtoList, taskPosDto.getTaskId());
- assert null != backpackType;
+ for (Navigation.CodeDTO codeDTO : navigation.getCodeList()) {
+ segSerial++;
+ Task task = taskService.getById(Long.parseLong(codeDTO.getTaskId()));
+ Segment segment = new Segment();
+ segment.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
+ segment.setTravelId(travel.getId());
+ segment.setAgvId(agvId);
+ segment.setTaskId(task.getId());
+ segment.setSerial(segSerial);
+ Code cacheByData = codeService.getCacheByData(codeDTO.getCode());
+ segment.setEndNode(cacheByData.getId());
+ segment.setPosType(codeDTO.getPosType());
+ segment.setBackpack(codeDTO.getLev());
+ segment.setState(SegmentStateType.INIT.toString());
+ segmentList.add(segment);
- Segment segment = new Segment();
- segment.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
- segment.setTravelId(travel.getId());
- segment.setAgvId(agvId);
- segment.setTaskId(taskPosDto.getTaskId());
- segment.setSerial(segSerial);
- segment.setEndNode(taskPosDto.getCodeId());
- segment.setPosType(taskPosDto.getPosType().toString());
- segment.setBackpack(backpackType.lev);
- segment.setState(SegmentStateType.INIT.toString());
- segmentList.add(segment);
+ task.setTaskSts(TaskStsType.ASSIGN.val());
+ task.setStartTime(new Date());
+ task.setUpdateTime(new Date());
+ if (!taskService.updateById(task)) {
+ throw new BusinessException(task.getUuid() + "浠诲姟鏇存柊澶辫触");
}
}
for (int i = 0; i < segmentList.size(); i++) {
@@ -230,16 +234,6 @@
}
if (!segmentService.save(segment)) {
throw new BusinessException("浠诲姟缁勪繚瀛樺け璐�");
- }
- }
-
- // task
- for (Task task : taskList) {
- task.setTaskSts(TaskStsType.ASSIGN.val());
- task.setStartTime(now);
- task.setUpdateTime(now);
- if (!taskService.updateById(task)) {
- throw new BusinessException(task.getUuid() + "浠诲姟鏇存柊澶辫触");
}
}
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficZkdService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficZkdService.java
index 257e066..861f248 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficZkdService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficZkdService.java
@@ -39,7 +39,7 @@
@Autowired
private SegmentService segmentService;
@Autowired
- private MainService mainService;
+ private MainZkdService mainZkdService;
@Autowired
private MainLockWrapService mainLockWrapService;
@Autowired
@@ -99,7 +99,7 @@
segmentList.add(segment);
- mainService.generateAction(segment.getAgvId(), segmentList, pathList, now);
+ mainZkdService.generateAction(segment.getAgvId(), segmentList, null, now);
} catch (Exception e) {
log.error("TrafficService.trigger", e);
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/third/zkd/dto/Navigation.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/third/zkd/dto/Navigation.java
index d9b1128..e2b6b21 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/third/zkd/dto/Navigation.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/third/zkd/dto/Navigation.java
@@ -12,6 +12,8 @@
private List<CodeDTO> CodeList;
+ private String segId;
+
@Data
public class CodeDTO implements Serializable {
/**
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/OpenAlgorithmController.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/OpenAlgorithmController.java
index 24dd8a0..f6fb37d 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/OpenAlgorithmController.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/OpenAlgorithmController.java
@@ -3,8 +3,10 @@
import com.zy.acs.framework.common.Cools;
import com.zy.acs.framework.common.R;
import com.zy.acs.manager.common.annotation.OperationLog;
+import com.zy.acs.manager.core.service.MainZkdService;
import com.zy.acs.manager.core.third.zkd.dto.Navigation;
import com.zy.acs.manager.manager.controller.param.OpenAgvParam;
+import com.zy.acs.manager.manager.service.AgvService;
import com.zy.acs.manager.manager.service.CodeService;
import com.zy.acs.manager.manager.service.OpenAlgorithmService;
import com.zy.acs.manager.system.controller.BaseController;
@@ -27,6 +29,12 @@
private OpenAlgorithmService openAlgorithmService;
@Autowired
+ private MainZkdService mainZkdService;
+
+ @Autowired
+ private AgvService agvService;
+
+ @Autowired
private CodeService codeService;
@PostMapping("/getAgv")
@@ -42,13 +50,10 @@
}
-
@RequestMapping("/zkd/navigation/v1")
public Object navigation(@RequestBody Navigation navigation) {
- String agvId = navigation.getAgvId();
- navigation.getCodeList().forEach(codeDTO -> {
-
- });
+ Long agvId = agvService.getAgvId(navigation.getAgvId());
+ mainZkdService.buildMajorTask(agvId, navigation);
return null;
}
--
Gitblit v1.9.1