From 18959656f9bf75e40a5802c3befd545ec33621d7 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 18 十一月 2024 12:17:24 +0800
Subject: [PATCH] #
---
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java | 73 +++++++++++++-----------------------
1 files changed, 27 insertions(+), 46 deletions(-)
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 ca8080e..7329135 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
@@ -15,7 +15,6 @@
import com.zy.acs.common.enums.AgvCompleteType;
import com.zy.acs.common.enums.AgvDirectionType;
import com.zy.acs.common.enums.AgvSpeedType;
-import com.zy.acs.common.utils.RedisSupport;
import com.zy.acs.common.utils.Utils;
import com.zy.acs.framework.common.Cools;
import com.zy.acs.framework.common.SnowflakeIdWorker;
@@ -25,6 +24,7 @@
import com.zy.acs.manager.common.exception.BusinessException;
import com.zy.acs.manager.common.utils.CommonUtil;
import com.zy.acs.manager.core.domain.AgvBackpackDto;
+import com.zy.acs.manager.core.domain.Lane;
import com.zy.acs.manager.core.domain.TaskPosDto;
import com.zy.acs.manager.core.service.astart.MapDataDispatcher;
import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam;
@@ -41,7 +41,6 @@
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.*;
-import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
/**
@@ -50,10 +49,6 @@
@Slf4j
@Component("mainService")
public class MainService {
-
- private final RedisSupport redis = RedisSupport.defaultRedisSupport;
- private static final int LOCK_TIMEOUT = 5;
- private final ReentrantLock lock = new ReentrantLock(Boolean.TRUE);
@Autowired
private BusService busService;
@@ -97,6 +92,8 @@
private TrafficService trafficService;
@Autowired
private AgvModelService agvModelService;
+ @Autowired
+ private LaneService laneService;
@SuppressWarnings("all")
@@ -235,35 +232,6 @@
throw new BusinessException("seqNum: " + task.getSeqNum() + " failed to update");
}
}
-
-
- // ------------------------------------------
-
-
-//
-// Map<String, List<Long>> taskAllot = new HashMap<>();
-// for (Task task : taskList) {
-// Agv agv = missionAssignService.execute(task, taskAllot, taskIds);
-// if (null == agv) {
-// log.warn("Task[{}] has an issue锛� because it failed to checkout agv which is idle...", task.getSeqNum());
-// continue;
-// }
-//
-//
-// task.setAgvId(agv.getId());
-// task.setTaskSts(TaskStsType.WAITING.val());
-// task.setIoTime(now);
-// task.setUpdateTime(now);
-// if (!taskService.updateById(task)) {
-// throw new BusinessException("seqNum: " + task.getSeqNum() + " failed to update");
-// }
-//
-// if (taskAllot.containsKey(agv.getUuid())) {
-// taskAllot.get(agv.getUuid()).add(task.getId());
-// } else {
-// taskAllot.put(agv.getUuid(), Utils.singletonList(task.getId()));
-// }
-// }
} catch (Exception e) {
log.error("mainService.infuseAgvForTask", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -285,6 +253,10 @@
}
if (!Cools.isEmpty(taskService.selectInSts(agvId, TaskStsType.ASSIGN, TaskStsType.PROGRESS))) {
throw new CoolException("AGV[" + agv.getUuid() + "]鍒嗛厤浠诲姟澶辫触锛屽凡瀛樺湪鎵ц浠诲姟...");
+ }
+ if (!Cools.isEmpty(segmentService.getByAgvAndState(agv.getId(), SegmentStateType.WAITING.toString()))
+ || !Cools.isEmpty(segmentService.getByAgvAndState(agv.getId(), SegmentStateType.RUNNING.toString()))) {
+ throw new CoolException("AGV[" + agv.getUuid() + "] failed to assign锛宐ecause already has the segment in running...");
}
// execute ----------------------------------------------------
@@ -523,17 +495,19 @@
* 鍏呯數 鍥炲緟鏈轰綅浠诲姟
*/
@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(Agv agv, AgvDetail agvDetail, TaskTypeType taskType, String destination) {
+ public boolean buildMinorTask(Agv agv, TaskTypeType taskType, String destination, Jam jam) {
if (Cools.isEmpty(agv, taskType)) { return false; }
try {
- if (null == agvDetail) {
- agvDetail = agvDetailService.selectByAgvId(agv.getId());
- }
+ AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
if (!agvService.judgeEnable(agv.getId())) {
return false;
}
if (!Cools.isEmpty(taskService.selectInSts(agv.getId(), TaskStsType.ASSIGN, TaskStsType.PROGRESS))) {
throw new CoolException("AGV[" + agv.getUuid() + "] failed to assign锛宐ecause already has the task in running...");
+ }
+ if (!Cools.isEmpty(segmentService.getByAgvAndState(agv.getId(), SegmentStateType.WAITING.toString()))
+ || !Cools.isEmpty(segmentService.getByAgvAndState(agv.getId(), SegmentStateType.RUNNING.toString()))) {
+ throw new CoolException("AGV[" + agv.getUuid() + "] failed to assign锛宐ecause already has the segment in running...");
}
Date now = new Date();
@@ -560,6 +534,9 @@
if (null == endCode) {
return false;
}
+ if (!allocateService.validCapacityOfLane(agv, endCode)) {
+ throw new BusinessException("the lane with code:" + endCode.getData() + " is full of AGV[" + agv.getUuid() + "]!!!");
+ }
Task task = new Task();
task.setAgvId(agv.getId());
@@ -568,6 +545,11 @@
task.setSeqNum(Utils.generateSeqNum(Cools.isEmpty(lastTasks)?null:lastTasks.get(0).getSeqNum()));
task.setOriCode(agvDetail.getCode());
task.setDestCode(endCode.getId());
+ // lane
+ Lane destLane = laneService.search(endCode.getData());
+ if (null != destLane) {
+ task.setDestLaneHash(destLane.getHashCode());
+ }
task.setPriority(taskType.equals(TaskTypeType.TO_CHARGE)?2:1);
task.setTaskSts(TaskStsType.ASSIGN.val());
task.setTaskType(taskType.val());
@@ -626,6 +608,10 @@
}
if (!segmentService.save(next)) {
throw new BusinessException("segment failed to save");
+ } else {
+ if (null != jam && i == 0) {
+ jam.setAvoSeg(next.getId());
+ }
}
}
@@ -645,10 +631,6 @@
default:
break;
}
-
-// if (taskType.equals(TaskTypeType.TO_STANDBY)) {
-// redis.setObject(RedisConstant.AGV_TO_STANDBY_FLAG, agv.getUuid(), false);
-// }
return true;
} catch (Exception e) {
@@ -684,13 +666,12 @@
List<Action> actionList = new ArrayList<>();
// start node
Code lastCode = codeService.getById(agvDetail.getRecentCode());
+ Double lastDirection = agvDetail.getAgvAngle();
if (!lastCode.getData().equals(pathList.get(0))) {
throw new CoolException("AGV[" + agv.getUuid() + "]瀹氫綅鍋忕Щ...");
}
- Double lastDirection = agvDetail.getAgvAngle();
boolean first = true;
-
for (Segment segment : segmentList) {
// 鍒嗘鎵�灞炵殑Task
@@ -922,7 +903,7 @@
break;
case TO_CHARGE:
// 妫�楠屾柟鍚�
- FuncSta chargeFuncSta = funcStaService.query(agvId, lastCode.getId(), FuncStaType.CHARGE.toString());
+ FuncSta chargeFuncSta = funcStaService.query(lastCode.getId(), FuncStaType.CHARGE.toString());
Double chargeDirection = Double.parseDouble(chargeFuncSta.getAngle());
if (!lastDirection.equals(chargeDirection)) {
actionList.add(new Action(
--
Gitblit v1.9.1