#
luxiaotao1123
2024-11-04 7f70cb15d035f0c233b9e62b9e43aa985317c908
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;
                }
@@ -80,8 +81,8 @@
    }
//    @Scheduled(cron = "0/30 * * * * ? ")
    @Scheduled(cron = "0 */2 * * * ? ")
    @Scheduled(cron = "0/1 * * * * ? ")
//    @Scheduled(cron = "0 */2 * * * ? ")
    private synchronized void autoStandby(){
        if (!configService.getVal("automaticStandbyPosition", Boolean.class)) { return; }
@@ -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,22 +111,23 @@
                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
            // the time between the latest task and now that be must more that 10 seconds
            Integer intervalOfAutoStandby = configService.getVal("intervalOfAutoStandby", Integer.class);
            if (null != intervalOfAutoStandby && intervalOfAutoStandby > 0) {
                Task latestTask = taskService.findLatestTask(agv.getId(), TaskStsType.COMPLETE);
                if (null != latestTask && !latestTask.getTaskType().equals(TaskTypeType.TO_CHARGE.val())) {
                    long minutes = DateUtils.diffToMinute(latestTask.getUpdateTime(), new Date());
                    if (minutes < intervalOfAutoStandby) { continue; }
                Task latestTask = taskService.findLatestTask(agv.getId(), null);
                if (null != latestTask) {
                    long seconds = DateUtils.diffToSeconds(latestTask.getUpdateTime(), new Date());
                    if (seconds < intervalOfAutoStandby) { continue; }
                }
            }
@@ -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;