From 7c4d3d957c431aad12f90511770e2fe429bcd380 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 24 十二月 2024 16:38:25 +0800
Subject: [PATCH] #
---
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/PatrolService.java | 66 +++++++++++++++++++++++++++-----
1 files changed, 55 insertions(+), 11 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 f7fe7d8..d9cca2f 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
@@ -14,6 +14,7 @@
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.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -33,9 +34,9 @@
@Service
public class PatrolService {
- private static final int SCHEDULE_TIME_INTERVAL = 5;
+ private static final int SCHEDULE_TIME_INTERVAL = 300;
- 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;
@@ -47,14 +48,18 @@
private AgvDetailService agvDetailService;
@Autowired
private TaskService taskService;
-// @Autowired
-// private MainService mainService;
@Autowired
private MainLockWrapService mainLockWrapService;
@Autowired
private CodeService codeService;
@Autowired
private MapService mapService;
+ @Autowired
+ private LaneService laneService;
+ @Autowired
+ private AllocateService allocateService;
+ @Autowired
+ private ConfigService configService;
private void executePatrolLogic(String agvNo) {
this.patrolOfMove(agvNo);
@@ -75,30 +80,69 @@
if (!agvService.judgeEnable(agv.getId())) {
return;
}
- Code randomCode = this.getRandomCode(agvDetail);
- if (null == randomCode) {
+ Code destinationCode = this.getDestinationCode(agv, agvDetail);
+ if (null == destinationCode) {
return;
}
- if (mainLockWrapService.buildMinorTask(agv, agvDetail, TaskTypeType.MOVE, randomCode.getData())) {
+ if (mainLockWrapService.buildMinorTask(agv, TaskTypeType.MOVE, destinationCode.getData(), null)) {
log.info(agv.getUuid() + "寮�濮嬭蛋琛屾紨绀�...");
}
}
- public Code getRandomCode(AgvDetail agvDetail) {
+ /**
+ * 4涓湴鏂硅皟鐢ㄤ簡buildMinorTask锛屽湪浠�涔堟椂鍊欍�佸摢閲岃缃畉ask鐨刲ane
+ * (
+ * HandlerController, 鎵嬪姩 锛堟墜鍔ㄦ槸鍚﹂渶瑕佸垽鏂璴ane锛�
+ * MaintainScheduler, 鑷姩 锛堜竴鑸笉闇�瑕佽�冭檻 lane锛�
+ * PatrolService, 鑷姩 锛堥渶瑕侀澶勭悊 lane锛� 鉁�
+ * TrafficService, 鑷姩 锛堝鍧�鏃跺凡缁忓鐞嗚繃 lane锛� 鉁�
+ * )
+ * 璇勪及HandlerController娌℃湁璋冪敤buildMajorTask锛屾墜鍔ㄥ垱寤簍ask鐨勫彲琛屾��
+ * agv鍦板浘鍥炬爣鍙樺寲
+ */
+ public Code getDestinationCode(Agv agv, AgvDetail agvDetail) {
+ Integer maxAgvCountInLane = configService.getVal("maxAgvCountInLane", Integer.class);
+
Code startCode = codeService.getById(agvDetail.getRecentCode());
+
List<String> notInCodeList = new ArrayList<>();
- notInCodeList.add("00000061");
+ notInCodeList.add("00000301");
+ notInCodeList.add("00000302");
+ notInCodeList.add("00000303");
+ notInCodeList.add("00000351");
+ notInCodeList.add("00000353");
+ notInCodeList.add("00000401");
+ notInCodeList.add("00000402");
+
+ notInCodeList.add("00000311");
+ notInCodeList.add("00000312");
+ 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)) {
+ continue;
+ }
+
+ // valid path length
List<String> pathList = mapService.validFeasibility(startCode, endCode);
if (pathList.size() >= 5) {
return endCode;
}
}
+
return list.stream().findFirst().orElse(null);
}
-
// ---------------------------------------------------------------------------
@@ -125,7 +169,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