| | |
| | | @Autowired |
| | | private ValidService validService; |
| | | @Autowired |
| | | private AllocateService allocateService; |
| | | @Autowired |
| | | private CodeService codeService; |
| | | @Autowired |
| | | private MapService mapService; |
| | |
| | | private TrafficService trafficService; |
| | | @Autowired |
| | | private AgvModelService agvModelService; |
| | | @Autowired |
| | | private MissionAssignService missionAssignService; |
| | | |
| | | |
| | | @SuppressWarnings("all") |
| | | @Transactional |
| | |
| | | * 任务分配给车辆 ( 车辆此时是空闲且静止的 ) |
| | | */ |
| | | @Transactional |
| | | public synchronized void infuseAgvForTask(Bus bus) { |
| | | public synchronized void allocateTask(Bus bus) { |
| | | try { |
| | | Date now = new Date(); |
| | | List<Task> taskList = taskService.list(new LambdaQueryWrapper<Task>() |
| | |
| | | } |
| | | return; |
| | | } |
| | | List<Long> taskIds = taskList.stream().map(Task::getId).distinct().collect(Collectors.toList()); |
| | | |
| | | Map<String, List<Long>> taskAllot = new HashMap<>(); |
| | | List<Long> taskIds = taskList.stream().map(Task::getId).distinct().collect(Collectors.toList()); |
| | | for (Task task : taskList) { |
| | | Agv agv = missionAssignService.execute(task, taskAllot, taskIds); |
| | | Agv agv = allocateService.execute(task); |
| | | 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); |
| | |
| | | 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())); |
| | | } |
| | | } |
| | | |
| | | // bus.setUpdateTime(now); |
| | | // if (!busService.updateById(bus)) { |
| | | // throw new BusinessException(bus.getSeqNum() + "总线更新失败"); |
| | | |
| | | // ------------------------------------------ |
| | | |
| | | |
| | | // |
| | | // 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); |
| | |
| | | |
| | | // valid ----------------------------------------------- |
| | | Agv agv = agvService.getById(agvId); |
| | | if (!agvService.judgeEnable(agv.getId(), agvDetail -> agvDetail.getVol() > agv.getChargeLine())) { |
| | | if (!agvService.judgeEnable(agv.getId(), true)) { |
| | | throw new CoolException("AGV[" + agv.getUuid() + "]当前不可用..."); |
| | | } |
| | | if (!Cools.isEmpty(taskService.selectInSts(agvId, TaskStsType.ASSIGN, TaskStsType.PROGRESS))) { |
| | |
| | | taskList.sort(new Comparator<Task>() { |
| | | @Override |
| | | public int compare(Task o1, Task o2) { |
| | | return 0; |
| | | return o1.getPriority() - o2.getPriority(); |
| | | } |
| | | }); |
| | | Integer backpack = agvService.getBackpack(agv); |