#
vincentlu
2025-01-10 bf69ac8c77ba9598b86b72f7b674d96de8af780b
#
8个文件已修改
72 ■■■■ 已修改文件
zy-acs-manager/src/main/java/com/zy/acs/manager/core/HandlerController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/KernelScheduler.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MaintainScheduler.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AllocateService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainLockWrapService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/PatrolService.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/HandlerController.java
@@ -112,13 +112,13 @@
                if (null == endCode) {
                    return R.error();
                }
                if (!mainLockWrapService.buildMinorTask(agv, param.getTaskMode(), endCode.getData(), null)) {
                if (!mainLockWrapService.buildMinorTask(agv.getId(), param.getTaskMode(), endCode.getData(), null)) {
                    return R.error();
                }
                break;
            case TO_CHARGE:
            case TO_STANDBY:
                if (!mainLockWrapService.buildMinorTask(agv, param.getTaskMode(), null, null)) {
                if (!mainLockWrapService.buildMinorTask(agv.getId(), param.getTaskMode(), null, null)) {
                    return R.error();
                }
                break;
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/KernelScheduler.java
@@ -35,7 +35,7 @@
@Component
public class KernelScheduler {
    public static int CORE_SCAN_FREQUENCY_MILLISECOND = 30;
    public static int CORE_SCAN_FREQUENCY_MILLISECOND = 15;
    private static final int LOCK_TIMEOUT = 5;
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MaintainScheduler.java
@@ -81,7 +81,7 @@
                    continue;
                }
                mainLockWrapService.buildMinorTask(agv, TaskTypeType.TO_CHARGE, null, null);
                mainLockWrapService.buildMinorTask(agv.getId(), TaskTypeType.TO_CHARGE, null, null);
            }
        }
    }
@@ -144,7 +144,7 @@
                }
//            }
            mainLockWrapService.buildMinorTask(agv, TaskTypeType.TO_STANDBY, null, null);
            mainLockWrapService.buildMinorTask(agv.getId(), TaskTypeType.TO_STANDBY, null, null);
        }
    }
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AllocateService.java
@@ -232,13 +232,13 @@
        return -weight;
    }
    public Boolean validCapacityOfLane(Agv agv, Code code) {
    public Boolean validCapacityOfLane(String agvNo, Code code) {
        Lane lane = laneService.search(code.getData());
        if (null != lane) {
            Integer maxAgvCountInLane = configService.getVal("maxAgvCountInLane", Integer.class);
            List<String> agvNosByLane = this.findAgvNosByLane(lane);
            agvNosByLane.remove(agv.getUuid());
            agvNosByLane.remove(agvNo);
            if (agvNosByLane.size() >= maxAgvCountInLane) {
                return false;
            }
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainLockWrapService.java
@@ -46,7 +46,7 @@
        }
    }
    public boolean buildMinorTask(Agv agv, TaskTypeType taskType, String destination, Jam jam) {
    public boolean buildMinorTask(Long agvId, TaskTypeType taskType, String destination, Jam jam) {
        boolean lockAcquired = false;
        try {
            if (!(lockAcquired = this.lock.tryLock(LOCK_TIMEOUT, TimeUnit.SECONDS))) {
@@ -54,7 +54,7 @@
            }
//            log.info("buildMinorTask AGV[{}] lock time: {}", agv.getUuid(), System.currentTimeMillis());
            return mainService.buildMinorTask(agv, taskType, destination, jam);
            return mainService.buildMinorTask(agvId, taskType, destination, jam);
        } catch (Exception e) {
            log.error("MainLockWrapService.buildMinorTask[task]", e);
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
@@ -493,19 +493,20 @@
     * 充电 回待机位任务
     */
    @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, TaskTypeType taskType, String destination, Jam jam) {
        if (Cools.isEmpty(agv, taskType)) { return false; }
    public boolean buildMinorTask(Long agvId, TaskTypeType taskType, String destination, Jam jam) {
        if (Cools.isEmpty(agvId, taskType)) { return false; }
        try {
            AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
            if (!agvService.judgeEnable(agv.getId())) {
            String agvNo = agvService.getAgvNo(agvId);
            AgvDetail agvDetail = agvDetailService.selectByAgvId(agvId);
            if (!agvService.judgeEnable(agvId)) {
                return false;
            }
            if (!Cools.isEmpty(taskService.selectInSts(agv.getId(), TaskStsType.ASSIGN, TaskStsType.PROGRESS))) {
                throw new CoolException("AGV[" + agv.getUuid() + "] failed to assign,because already has the task in running...");
            if (!Cools.isEmpty(taskService.selectInSts(agvId, TaskStsType.ASSIGN, TaskStsType.PROGRESS))) {
                throw new CoolException("AGV[" + agvNo + "] failed to assign,because 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,because already has the segment in running...");
            if (!Cools.isEmpty(segmentService.getByAgvAndState(agvId, SegmentStateType.WAITING.toString()))
                    || !Cools.isEmpty(segmentService.getByAgvAndState(agvId, SegmentStateType.RUNNING.toString()))) {
                throw new CoolException("AGV[" + agvNo + "] failed to assign,because already has the segment in running...");
            }
            Date now = new Date();
@@ -513,13 +514,13 @@
            switch (taskType) {
                case TO_CHARGE:
                case TO_STANDBY:
                    List<FuncSta> idleFunStaList = funcStaService.findInIdleStatus(FuncStaType.query(taskType), agv.getId());
                    List<FuncSta> idleFunStaList = funcStaService.findInIdleStatus(FuncStaType.query(taskType), agvId);
                    if (!Cools.isEmpty(idleFunStaList)) {
                        FuncSta funcSta = funcStaService.checkoutClosestFunSta(agvDetail.getRecentCode(), idleFunStaList);
                        endCode = codeService.getById(funcSta.getCode());
                    }
                    if (null == endCode) {
                        log.warn("AGV[{}] failed to search destination,there hadn't any idle funSta,TaskTypeType:{}", agv.getUuid(), taskType.toString());
                        log.warn("AGV[{}] failed to search destination,there hadn't any idle funSta,TaskTypeType:{}", agvNo, taskType.toString());
                    }
                    break;
                case MOVE:
@@ -532,12 +533,12 @@
            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() + "]!!!");
            if (!allocateService.validCapacityOfLane(agvNo, endCode)) {
                throw new BusinessException("the lane with code:" + endCode.getData() + " is full of AGV[" + agvNo + "]!!!");
            }
            Task task = new Task();
            task.setAgvId(agv.getId());
            task.setAgvId(agvId);
            task.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
            List<Task> lastTasks = taskService.list(new LambdaQueryWrapper<Task>().orderByDesc(Task::getId));
            task.setSeqNum(Utils.generateSeqNum(Cools.isEmpty(lastTasks)?null:lastTasks.get(0).getSeqNum()));
@@ -561,7 +562,7 @@
            Travel travel = new Travel();
            travel.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
            travel.setTravelId(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
            travel.setAgvId(agv.getId());
            travel.setAgvId(agvId);
//            travel.setTaskContent(JSON.toJSONString(list));
            travel.setTaskIds(GsonUtils.toJson(Utils.singletonList(task.getId())));
            travel.setState(TravelStateType.RUNNING.toString());
@@ -591,7 +592,7 @@
            Segment segment = new Segment();
            segment.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
            segment.setTravelId(travel.getId());
            segment.setAgvId(agv.getId());
            segment.setAgvId(agvId);
            segment.setTaskId(task.getId());
            segment.setSerial(segSerial);
            segment.setEndNode(endCode.getId());
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/PatrolService.java
@@ -77,13 +77,12 @@
        if (!agvService.judgeEnable(agvId)) {
            return;
        }
        Agv agv = agvService.getById(agvId);
        Code destinationCode = this.getDestinationCode(agv, agvDetail);
        Code destinationCode = this.getDestinationCode(agvNo, agvDetail);
        if (null == destinationCode) {
            return;
        }
        if (mainLockWrapService.buildMinorTask(agv, TaskTypeType.MOVE, destinationCode.getData(), null)) {
            log.info(agv.getUuid() + "开始走行演示...");
        if (mainLockWrapService.buildMinorTask(agvId, TaskTypeType.MOVE, destinationCode.getData(), null)) {
            log.info(agvNo + "开始走行演示...");
        }
    }
@@ -98,7 +97,7 @@
     * 评估HandlerController没有调用buildMajorTask,手动创建task的可行性
     * agv地图图标变化
     */
    public Code getDestinationCode(Agv agv, AgvDetail agvDetail) {
    public Code getDestinationCode(String agvNo, AgvDetail agvDetail) {
        Integer maxAgvCountInLane = configService.getVal("maxAgvCountInLane", Integer.class);
        Code startCode = codeService.getById(agvDetail.getRecentCode());
@@ -128,7 +127,7 @@
        for (Code endCode : list) {
            // valid lane
            if (!allocateService.validCapacityOfLane(agv, endCode)) {
            if (!allocateService.validCapacityOfLane(agvNo, endCode)) {
                continue;
            }
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java
@@ -477,8 +477,8 @@
     * avoidPathList include wave node and dynamic node
     */
    private boolean notifyVehicleAvoid(String agvNo, String agvPosCode, List<String> avoidPathList, String sponsor, Jam jam) {
        Agv agv = agvService.selectByUuid(agvNo);
        if (!Cools.isEmpty(segmentService.getByAgvAndState(agv.getId(), SegmentStateType.RUNNING.toString()))) {
        Long agvId = agvService.getAgvId(agvNo);
        if (!Cools.isEmpty(segmentService.getByAgvAndState(agvId, SegmentStateType.RUNNING.toString()))) {
            log.warn("{}号车辆避让失败,存在进行中任务!!!", agvNo);
            return false;
        }
@@ -496,7 +496,7 @@
        String endCodeData = finalNode.getCodeData();
        Code endCode = codeService.getCacheByData(endCodeData);
        List<Segment> waitingSegList = segmentService.getByAgvAndState(agv.getId(), SegmentStateType.WAITING.toString());
        List<Segment> waitingSegList = segmentService.getByAgvAndState(agvId, SegmentStateType.WAITING.toString());
        if (!Cools.isEmpty(waitingSegList)) {
            if (waitingSegList.size() > 1) {
@@ -517,7 +517,7 @@
            Segment insertSeg = new Segment();
            insertSeg.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
            insertSeg.setTravelId(segment.getTravelId());
            insertSeg.setAgvId(agv.getId());
            insertSeg.setAgvId(agvId);
            insertSeg.setTaskId(segment.getTaskId());
            insertSeg.setSerial(segment.getSerial() - 1);
            insertSeg.setEndNode(endCode.getId());
@@ -533,7 +533,7 @@
        } else {
            return mainLockWrapService.buildMinorTask(agv, TaskTypeType.MOVE, endCodeData, jam);
            return mainLockWrapService.buildMinorTask(agvId, TaskTypeType.MOVE, endCodeData, jam);
        }
        return true;