From b1dd4c6e284244bd7224e2c050a9670fbd9a38ea Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期一, 19 一月 2026 16:21:49 +0800
Subject: [PATCH] #
---
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/PatrolService.java | 98 +++++++++++++++----------------------------------
1 files changed, 30 insertions(+), 68 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 13d4a97..1c9c942 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
@@ -41,7 +41,7 @@
private ScheduledExecutorService scheduler = null;
- private List<String> CODE_DATA_CACHE = new ArrayList<>();
+ private List<String> ALL_CODE_DATA_CACHE = new ArrayList<>();
private List<String> LOC_CODE_DATA_CACHE = new ArrayList<>();
@@ -73,6 +73,24 @@
private ConfigService configService;
@Autowired
private AgvModelService agvModelService;
+ @Autowired
+ private AgvAreaDispatcher agvAreaDispatcher;
+
+ @PostConstruct
+ public void init() {
+ int count = agvService.count(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val));
+ if (count > 0) {
+ this.scheduler = Executors.newScheduledThreadPool(count);
+ }
+ // init all code data
+ List<Code> codeList = codeService.list(new LambdaQueryWrapper<Code>().eq(Code::getStatus, StatusType.ENABLE.val));
+ this.ALL_CODE_DATA_CACHE = codeList.stream().map(Code::getData).distinct().collect(Collectors.toList());
+
+ // int all loc code data
+ List<Code> locCodeList = codeService.getAllLocCode();
+ this.LOC_CODE_DATA_CACHE = locCodeList.stream().map(Code::getData).distinct().collect(Collectors.toList());
+
+ }
// pick & drop logic --------------------------------------------------
@@ -196,59 +214,19 @@
* agv鍦板浘鍥炬爣鍙樺寲
*/
public String getDestinationCode(String agvNo, AgvDetail agvDetail) {
-
Code startCode = codeService.getCacheById(agvDetail.getRecentCode());
-
Set<String> notInCodeSet = new HashSet<>();
- notInCodeSet.add("00000301");
- notInCodeSet.add("00000302");
- notInCodeSet.add("00000303");
- notInCodeSet.add("00000351");
- notInCodeSet.add("00000353");
- notInCodeSet.add("00000401");
- notInCodeSet.add("00000402");
+ Long agvId = agvDetail.getAgvId();
- notInCodeSet.add("00000311");
- notInCodeSet.add("00000312");
- notInCodeSet.add("00000313");
- notInCodeSet.add("00000361");
- notInCodeSet.add("00000363");
- notInCodeSet.add("00000411");
- notInCodeSet.add("00000412");
+ List<String> codeList = null;
+ if (agvAreaDispatcher.isAgvExistsInAnyArea(agvId)) {
+ codeList = agvAreaDispatcher.getCodesByAgvId(agvId);
+ } else {
+ codeList = ALL_CODE_DATA_CACHE;
+ }
+ Collections.shuffle(codeList);
- notInCodeSet.add("00000046");
- notInCodeSet.add("00000047");
-
- notInCodeSet.add("00000270");
- notInCodeSet.add("00000265");
- notInCodeSet.add("00000229");
- notInCodeSet.add("00000188");
- notInCodeSet.add("00000133");
- notInCodeSet.add("00000134");
- notInCodeSet.add("00000279");
- notInCodeSet.add("00000278");
- notInCodeSet.add("00000266");
- notInCodeSet.add("00000267");
- notInCodeSet.add("00000268");
- notInCodeSet.add("00000269");
- notInCodeSet.add("00000271");
- notInCodeSet.add("00000272");
- notInCodeSet.add("00000273");
- notInCodeSet.add("00000274");
- notInCodeSet.add("00000275");
- notInCodeSet.add("00000276");
- notInCodeSet.add("00000277");
- notInCodeSet.add("00000285");
- notInCodeSet.add("00000286");
- notInCodeSet.add("00000280");
- notInCodeSet.add("00000281");
- notInCodeSet.add("00000282");
- notInCodeSet.add("00000283");
- notInCodeSet.add("00000284");
-
- Collections.shuffle(CODE_DATA_CACHE);
-
- for (String endCodeData : CODE_DATA_CACHE) {
+ for (String endCodeData : codeList) {
if (notInCodeSet.contains(endCodeData)) { continue; }
Code endCode = codeService.getCacheByData(endCodeData);
@@ -264,7 +242,7 @@
}
}
- return CODE_DATA_CACHE.stream().findFirst().orElse(null);
+ return codeList.stream().findFirst().orElse(null);
}
// ---------------------------------------------------------------------------
@@ -287,7 +265,7 @@
executePatrolLogic(agvNo);
// executeUShapeConveyor(agvNo);
} catch (Exception e) {
- log.error("鎵цAGV{}璺戝簱浠诲姟鏃跺彂鐢熷紓甯�: {}", agvNo, e.getMessage());
+ log.error("鎵цAGV{}璺戝簱浠诲姟鏃跺彂鐢熷紓甯�", agvNo, e);
}
};
@@ -318,22 +296,6 @@
log.error("鏈兘鎴愬姛鍋滄AGV " + agvNo + " 鐨勮窇搴撲换鍔°��");
return R.error("鏈兘鎴愬姛鍋滄AGV " + agvNo + " 鐨勮窇搴撲换鍔°��");
}
- }
-
- @PostConstruct
- public void init() {
- int count = agvService.count(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val));
- if (count > 0) {
- this.scheduler = Executors.newScheduledThreadPool(count);
- }
- // init all code data
- List<Code> codeList = codeService.list(new LambdaQueryWrapper<Code>().eq(Code::getStatus, StatusType.ENABLE.val));
- this.CODE_DATA_CACHE = codeList.stream().map(Code::getData).distinct().collect(Collectors.toList());
-
- // int all loc code data
- List<Code> locCodeList = codeService.getAllLocCode();
- this.LOC_CODE_DATA_CACHE = locCodeList.stream().map(Code::getData).distinct().collect(Collectors.toList());
-
}
@PreDestroy
--
Gitblit v1.9.1