From 0dab88e8ed90367a2b8f016d019f364297ca3caa Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期一, 13 一月 2025 13:41:18 +0800
Subject: [PATCH] #
---
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/PatrolService.java | 58 ++++++++++++++++++++++++++++++----------------------------
1 files changed, 30 insertions(+), 28 deletions(-)
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/PatrolService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/PatrolService.java
index c1c97ae..07399a5 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/PatrolService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/PatrolService.java
@@ -3,17 +3,12 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.acs.common.utils.RedisSupport;
import com.zy.acs.framework.common.R;
-import com.zy.acs.manager.manager.entity.Agv;
-import com.zy.acs.manager.manager.entity.AgvDetail;
-import com.zy.acs.manager.manager.entity.Code;
-import com.zy.acs.manager.manager.entity.Task;
+import com.zy.acs.manager.manager.entity.*;
import com.zy.acs.manager.manager.enums.StatusType;
import com.zy.acs.manager.manager.enums.TaskStsType;
import com.zy.acs.manager.manager.enums.TaskTypeType;
-import com.zy.acs.manager.manager.service.AgvDetailService;
-import com.zy.acs.manager.manager.service.AgvService;
-import com.zy.acs.manager.manager.service.CodeService;
-import com.zy.acs.manager.manager.service.TaskService;
+import com.zy.acs.manager.manager.enums.TravelStateType;
+import com.zy.acs.manager.manager.service.*;
import com.zy.acs.manager.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -34,9 +29,9 @@
@Service
public class PatrolService {
- private static final int SCHEDULE_TIME_INTERVAL = 5;
+ private static final int SCHEDULE_TIME_INTERVAL = 100;
- private static final Map<String, ScheduledFuture<?>> AGV_PATROL_MAP = new ConcurrentHashMap<>();
+ public static final Map<String, ScheduledFuture<?>> AGV_PATROL_MAP = new ConcurrentHashMap<>();
private final RedisSupport redis = RedisSupport.defaultRedisSupport;
@@ -55,7 +50,7 @@
@Autowired
private MapService mapService;
@Autowired
- private LaneService laneService;
+ private TravelService travelService;
@Autowired
private AllocateService allocateService;
@Autowired
@@ -66,26 +61,28 @@
}
private void patrolOfMove(String agvNo) {
- Agv agv = agvService.selectByUuid(agvNo);
- AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
- if (taskService.count(new LambdaQueryWrapper<Task>()
- .eq(Task::getAgvId, agv.getId())
- .and(i -> {
- i.eq(Task::getTaskSts, TaskStsType.WAITING.val())
- .or().eq(Task::getTaskSts, TaskStsType.ASSIGN.val())
- .or().eq(Task::getTaskSts, TaskStsType.PROGRESS.val());
- })) > 0) {
+ Long agvId = agvService.getAgvId(agvNo);
+ if (0 < travelService.count(new LambdaQueryWrapper<Travel>()
+ .eq(Travel::getAgvId, agvId)
+ .eq(Travel::getState, TravelStateType.RUNNING.toString()))) {
return;
}
- if (!agvService.judgeEnable(agv.getId())) {
+// if (taskService.count(new LambdaQueryWrapper<Task>()
+// .eq(Task::getAgvId, agvId)
+// .in(Task::getTaskSts, TaskStsType.ASSIGN.val(), TaskStsType.PROGRESS.val())
+// ) > 0) {
+// return;
+// }
+ if (!agvService.judgeEnable(agvId)) {
return;
}
- Code destinationCode = this.getDestinationCode(agv, agvDetail);
+ AgvDetail agvDetail = agvDetailService.selectMajorByAgvId(agvId);
+ Code destinationCode = this.getDestinationCode(agvNo, agvDetail);
if (null == destinationCode) {
return;
}
- if (mainLockWrapService.buildMinorTask(agv, TaskTypeType.MOVE, destinationCode.getData(), null)) {
- log.info(agv.getUuid() + "寮�濮嬭蛋琛屾紨绀�...");
+ if (mainLockWrapService.buildMinorTask(agvId, TaskTypeType.MOVE, destinationCode.getData(), null)) {
+ log.info(agvNo + "寮�濮嬭蛋琛屾紨绀�...");
}
}
@@ -100,10 +97,10 @@
* 璇勪及HandlerController娌℃湁璋冪敤buildMajorTask锛屾墜鍔ㄥ垱寤簍ask鐨勫彲琛屾��
* agv鍦板浘鍥炬爣鍙樺寲
*/
- public Code getDestinationCode(Agv agv, AgvDetail agvDetail) {
+ public Code getDestinationCode(String agvNo, AgvDetail agvDetail) {
Integer maxAgvCountInLane = configService.getVal("maxAgvCountInLane", Integer.class);
- Code startCode = codeService.getById(agvDetail.getRecentCode());
+ Code startCode = codeService.getCacheById(agvDetail.getRecentCode());
List<String> notInCodeList = new ArrayList<>();
notInCodeList.add("00000301");
@@ -111,6 +108,7 @@
notInCodeList.add("00000303");
notInCodeList.add("00000351");
notInCodeList.add("00000353");
+ notInCodeList.add("00000401");
notInCodeList.add("00000402");
notInCodeList.add("00000311");
@@ -118,14 +116,18 @@
notInCodeList.add("00000313");
notInCodeList.add("00000361");
notInCodeList.add("00000363");
+ notInCodeList.add("00000411");
notInCodeList.add("00000412");
+
+ notInCodeList.add("00000046");
+ notInCodeList.add("00000047");
List<Code> list = codeService.list(new LambdaQueryWrapper<Code>().notIn(Code::getData, notInCodeList));
Collections.shuffle(list);
for (Code endCode : list) {
// valid lane
- if (!allocateService.validCapacityOfLane(agv, endCode)) {
+ if (!allocateService.validCapacityOfLane(agvNo, endCode)) {
continue;
}
@@ -164,7 +166,7 @@
}
};
- ScheduledFuture<?> scheduledFuture = scheduler.scheduleAtFixedRate(patrolTask, 0, SCHEDULE_TIME_INTERVAL, TimeUnit.SECONDS);
+ ScheduledFuture<?> scheduledFuture = scheduler.scheduleAtFixedRate(patrolTask, 0, SCHEDULE_TIME_INTERVAL, TimeUnit.MILLISECONDS);
AGV_PATROL_MAP.put(agvNo, scheduledFuture);
log.info("宸插惎鍔ˋGV " + agvNo + " 鐨勮窇搴撲换鍔°��");
--
Gitblit v1.9.1