From 9f19c2ea1a1d4e94460eb2d881b7cf8cc10e66df Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期四, 14 十一月 2024 10:42:10 +0800 Subject: [PATCH] # --- zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java | 46 +++++++++++----------------------------------- 1 files changed, 11 insertions(+), 35 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 c5b0a72..4fcedee 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(); @@ -560,6 +528,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 +539,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()); -- Gitblit v1.9.1