#
luxiaotao1123
2024-10-30 d2bdac9da5131cfe34612d491377b0ac544d56bd
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MaintainScheduler.java
@@ -54,23 +54,24 @@
            if (agvDetail.getAgvStatus().equals(AgvStatusType.CHARGE)) {
                continue;
            }
            if (agvDetail.getVol() < agv.getChargeLine() || agvDetail.getVol() < agvModel.getLowBattery()) {
                if (taskService.count(new LambdaQueryWrapper<Task>()
            if (agvDetailService.isPowerLoss(agv, agvDetail, agvModel)) {
                if (0 < taskService.count(new LambdaQueryWrapper<Task>()
                        .eq(Task::getAgvId, agv.getId())
                        .and(i -> {
                                i.eq(Task::getTaskSts, TaskStsType.WAITING.val())
                                .or().eq(Task::getTaskSts, TaskStsType.ASSIGN.val())
                                .or().eq(Task::getTaskSts, TaskStsType.PROGRESS.val());
                        })) > 0) {
                        })
                )) {
                    continue;
                }
                if (segmentService.count(new LambdaQueryWrapper<Segment>()
                if (0 < segmentService.count(new LambdaQueryWrapper<Segment>()
                        .eq(Segment::getAgvId, agv.getId())
                        .and( i -> {
//                                i.eq(Segment::getState, SegmentStateType.WAITING.toString()).or()
                                i.eq(Segment::getState, SegmentStateType.RUNNING.toString());
                        })
                ) > 0) {
                )) {
                    continue;
                }
@@ -93,7 +94,7 @@
                continue;
            }
            // low battery status, that need to go to charge
            if (agvDetail.getVol() < agv.getChargeLine() || agvDetail.getVol() < agvModel.getLowBattery()) {
            if (agvDetailService.isPowerLoss(agv, agvDetail, agvModel)) {
                continue;
            }
            // is charging ?
@@ -110,13 +111,14 @@
                continue;
            }
            // has running tasks ?
            if (taskService.count(new LambdaQueryWrapper<Task>()
            if (0 < taskService.count(new LambdaQueryWrapper<Task>()
                    .eq(Task::getAgvId, agv.getId())
                    .and(i -> {
                            i.eq(Task::getTaskSts, TaskStsType.WAITING.val())
                            .or().eq(Task::getTaskSts, TaskStsType.ASSIGN.val())
                            .or().eq(Task::getTaskSts, TaskStsType.PROGRESS.val());
                    })) > 0) {
                    })
            )) {
                continue;
            }
            // the time between the latest task and now that be must more that 20 minutes
@@ -139,9 +141,11 @@
        for (FuncSta funcSta : funcStaList) {
            boolean beIdle = true;
            Agv agv = agvService.findByPosition(funcSta.getCode());
            AgvModel agvModel = agvModelService.getById(agv.getAgvModel());
            AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
            switch (Objects.requireNonNull(FuncStaType.query(funcSta.getType()))) {
                case CHARGE:
                    AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId());
                    if (agvDetail.getAgvStatus().equals(AgvStatusType.CHARGE)) {
                        beIdle = false;
                    } else {
@@ -150,17 +154,21 @@
                                && latestTask.getTaskType().equals(TaskTypeType.TO_CHARGE.val())
                                && latestTask.getDestCode().equals(funcSta.getCode())
                        ) {
                            beIdle = false;
                            // avoid the agv already be full battery but there was no task assign to it, so that not in charge status and battery had down
                            if (agvDetailService.isPowerLoss(agv, agvDetail, agvModel)) {
                                beIdle = false;
                            }
                        }
                    }
                    if (taskService.count(new LambdaQueryWrapper<Task>()
                    if (0 < taskService.count(new LambdaQueryWrapper<Task>()
                            .eq(Task::getTaskType, TaskTypeType.TO_CHARGE.val())
                            .eq(Task::getDestCode, funcSta.getCode())
                            .and(i -> {
                                 i.eq(Task::getTaskSts, TaskStsType.WAITING.val()).or()
                                 .eq(Task::getTaskSts, TaskStsType.ASSIGN.val()).or()
                                 .eq(Task::getTaskSts, TaskStsType.PROGRESS.val());
                            })) > 0) {
                            })
                    )) {
                        beIdle = false;
                    }
                    break;
@@ -172,14 +180,15 @@
                    ) {
                        beIdle = false;
                    }
                    if (taskService.count(new LambdaQueryWrapper<Task>()
                    if (0 < taskService.count(new LambdaQueryWrapper<Task>()
                            .eq(Task::getTaskType, TaskTypeType.TO_STANDBY.val())
                            .eq(Task::getDestCode, funcSta.getCode())
                            .and(i -> {
                                i.eq(Task::getTaskSts, TaskStsType.WAITING.val()).or()
                                .eq(Task::getTaskSts, TaskStsType.ASSIGN.val()).or()
                                .eq(Task::getTaskSts, TaskStsType.PROGRESS.val());
                            })) > 0) {
                            })
                    )) {
                        beIdle = false;
                    }
                    break;