#
luxiaotao1123
2024-10-25 fff2e8aa532540036088744c76efe5bffc7733a3
#
2个文件已修改
70 ■■■■■ 已修改文件
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MissionAssignService.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
@@ -211,6 +211,25 @@
                }
                return;
            }
            for (Task task : taskList) {
                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);
                task.setUpdateTime(now);
                if (!taskService.updateById(task)) {
                    throw new BusinessException("seqNum: " + task.getSeqNum() + " failed to update");
                }
            }
            // ------------------------------------------
            List<Long> taskIds = taskList.stream().map(Task::getId).distinct().collect(Collectors.toList());
            Map<String, List<Long>> taskAllot = new HashMap<>();
@@ -236,11 +255,6 @@
                    taskAllot.put(agv.getUuid(), Utils.singletonList(task.getId()));
                }
            }
//            bus.setUpdateTime(now);
//            if (!busService.updateById(bus)) {
//                throw new BusinessException(bus.getSeqNum() + "总线更新失败");
//            }
        } catch (Exception e) {
            log.error("mainService.infuseAgvForTask", e);
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -274,7 +288,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);
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MissionAssignService.java
@@ -15,6 +15,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -34,6 +35,49 @@
    private ConfigService configService;
    @Autowired
    private TaskService taskService;
    @Autowired
    private LaneService laneService;
    /**
     * get available agv list which is idle
     */
    private List<Agv> getAvailableAgv() {
        List<Agv> result = new ArrayList<>();
        List<Agv> agvList = agvService.list(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, 1));
        Collections.shuffle(agvList);
        for (Agv agv : agvList) {
            // 1. without running tasks
            if (0 < taskService.count(new LambdaQueryWrapper<Task>()
                    .eq(Task::getAgvId, agv.getId())
                    .and(i ->
                            i.eq(Task::getTaskSts, TaskStsType.ASSIGN.val())
                            .or().eq(Task::getTaskSts, TaskStsType.PROGRESS.val())
                    )
            )) {
                continue;
            }
            // 2. in idle status
            final Agv finalAgv = agv;
            if (!agvService.judgeEnable(finalAgv.getId(), agvDetail -> agvDetail.getVol() > finalAgv.getChargeLine())) {
                continue;
            }
            result.add(agv);
        }
        return result;
    }
    public synchronized Agv execute(Task task) {
        List<Agv> availableAgvList = getAvailableAgv();
        if (Cools.isEmpty(availableAgvList)) {
            return null;
        }
        return null;
    }
    public synchronized Agv execute(Task task, Map<String, List<Long>> taskAllot, List<Long> taskIds) {
        String oriLocNo = task.getOriLoc$();