From 500f6ce071c0bc14d6720354ce148599ac3f35ee Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期五, 25 十月 2024 15:38:42 +0800 Subject: [PATCH] # --- zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java | 49 ++++++++++++++++++++++++++++++++----------------- 1 files changed, 32 insertions(+), 17 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 763aee2..8da6ca8 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 @@ -194,7 +194,7 @@ * 浠诲姟鍒嗛厤缁欒溅杈� ( 杞﹁締姝ゆ椂鏄┖闂蹭笖闈欐鐨� ) */ @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>() @@ -211,17 +211,14 @@ } 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 = missionAssignService.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); @@ -229,17 +226,35 @@ 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); @@ -261,7 +276,7 @@ // 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))) { @@ -274,7 +289,7 @@ 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); -- Gitblit v1.9.1