From bfe51f9c2ce2181fee372ed5f9017c7af59cc896 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期一, 01 九月 2025 12:49:55 +0800
Subject: [PATCH] 1
---
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java | 64 +++++++++++++++++++++++++++----
1 files changed, 55 insertions(+), 9 deletions(-)
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java
index 1542f2f..b98f6bb 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java
@@ -5,11 +5,9 @@
import com.zy.acs.common.enums.AgvStatusType;
import com.zy.acs.framework.common.Cools;
import com.zy.acs.manager.common.utils.CommonUtil;
+import com.zy.acs.manager.core.constant.AgvAreaDispatcher;
import com.zy.acs.manager.manager.entity.*;
-import com.zy.acs.manager.manager.enums.FuncStaType;
-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.enums.*;
import com.zy.acs.manager.manager.mapper.FuncStaMapper;
import com.zy.acs.manager.manager.service.*;
import org.springframework.beans.factory.annotation.Autowired;
@@ -31,6 +29,8 @@
private AgvModelService agvModelService;
@Autowired
private TaskService taskService;
+ @Autowired
+ private AgvAreaDispatcher agvAreaDispatcher;
@Override
public FuncSta getByCodeAndType(Long codeId, String type) {
@@ -53,14 +53,29 @@
@Override
public List<FuncSta> findInIdleStatus(FuncStaType type, Long agvId) {
LambdaQueryWrapper<FuncSta> wrapper = new LambdaQueryWrapper<FuncSta>()
- .eq(FuncSta::getType, type).eq(FuncSta::getStatus, StatusType.ENABLE.val);
+ .eq(FuncSta::getType, type).eq(FuncSta::getStatus, StatusType.ENABLE.val).eq(FuncSta::getState, FuncStaStateType.IDLE.toString());
List<FuncSta> funcStaList = this.list(wrapper);
if (Cools.isEmpty(funcStaList)) {
return new ArrayList<>();
}
- Collections.shuffle(funcStaList);
+ // area limit
+ List<String> areaCodeList = agvAreaDispatcher.getAreaCodeListByAgvNo(agvService.getAgvNo(agvId));
+ if (Cools.isEmpty(areaCodeList)) {
+ funcStaList.clear();
+ } else {
+ funcStaList.removeIf(funcSta -> {
+ Code code = codeService.getCacheById(funcSta.getCode());
+ if (Cools.isEmpty(code, code.getData())) { return true; }
+ return !areaCodeList.contains(code.getData());
+ });
+ }
+
+ if (!Cools.isEmpty(funcStaList)) {
+ Collections.shuffle(funcStaList);
+ }
+
// filter idle
funcStaList = funcStaList.stream().filter(funcSta -> {
@@ -146,7 +161,7 @@
}
if (null != codeId) {
- Code currCode = codeService.getById(codeId);
+ Code currCode = codeService.getCacheById(codeId);
Double[] startPos = new Double[]{currCode.getX(), currCode.getY()};
// checkout one funSta which is the closest
@@ -155,10 +170,10 @@
funcStaList.sort(new Comparator<FuncSta>() {
@Override
public int compare(FuncSta o1, FuncSta o2) {
- Code o1Code = codeService.getById(o1.getCode());
+ Code o1Code = codeService.getCacheById(o1.getCode());
int o1Distance = CommonUtil.calcDistance(startPos, new Double[]{o1Code.getX(), o1Code.getY()});
- Code o2Code = codeService.getById(o2.getCode());
+ Code o2Code = codeService.getCacheById(o2.getCode());
int o2Distance = CommonUtil.calcDistance(startPos, new Double[]{o2Code.getX(), o2Code.getY()});
return o1Distance - o2Distance;
@@ -171,6 +186,37 @@
}
@Override
+ public FuncSta checkoutFurthestFunSta(Long codeId, List<FuncSta> funcStaList) {
+ if (Cools.isEmpty(funcStaList)) {
+ return null;
+ }
+
+ if (null != codeId) {
+ Code currCode = codeService.getCacheById(codeId);
+ Double[] startPos = new Double[]{currCode.getX(), currCode.getY()};
+
+ // checkout one funSta which is the closest
+
+ // compare => compare杩斿洖璐熸暟锛屽垯鎺掑湪闆嗗悎鍓嶉潰 锛坅sc锛�
+ funcStaList.sort(new Comparator<FuncSta>() {
+ @Override
+ public int compare(FuncSta o1, FuncSta o2) {
+ Code o1Code = codeService.getCacheById(o1.getCode());
+ int o1Distance = CommonUtil.calcDistance(startPos, new Double[]{o1Code.getX(), o1Code.getY()});
+
+ Code o2Code = codeService.getCacheById(o2.getCode());
+ int o2Distance = CommonUtil.calcDistance(startPos, new Double[]{o2Code.getX(), o2Code.getY()});
+
+ return o2Distance - o1Distance;
+ }
+ });
+
+ }
+
+ return funcStaList.stream().findFirst().orElse(null);
+ }
+
+ @Override
public Boolean isCanBeIdle(FuncSta funcSta) {
Agv agv;
switch (Objects.requireNonNull(FuncStaType.query(funcSta.getType()))) {
--
Gitblit v1.9.1