#
luxiaotao1123
2024-11-04 6f5c384b7f838f35e3da4db129a57c76cd54d508
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/MaintainScheduler.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.acs.common.enums.AgvStatusType;
import com.zy.acs.common.utils.RedisSupport;
import com.zy.acs.framework.common.DateUtils;
import com.zy.acs.manager.core.service.MainService;
import com.zy.acs.manager.manager.entity.*;
@@ -24,6 +25,8 @@
@Slf4j
@Component
public class MaintainScheduler {
    private final RedisSupport redis = RedisSupport.defaultRedisSupport;
    @Autowired
    private AgvService agvService;
@@ -81,8 +84,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; }
@@ -121,15 +124,17 @@
            )) {
                continue;
            }
            // the time between the latest task and now that be must more that 20 minutes
            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; }
            // the time between the latest task and now that be must more that 10 seconds
//            if (!Optional.ofNullable((Boolean) redis.getObject(RedisConstant.AGV_TO_STANDBY_FLAG, agv.getUuid())).orElse(false)) {
                Integer intervalOfAutoStandby = configService.getVal("intervalOfAutoStandby", Integer.class);
                if (null != intervalOfAutoStandby && intervalOfAutoStandby > 0) {
                    Task latestTask = taskService.findLatestTask(agv.getId(), null);
                    if (null != latestTask) {
                        long seconds = DateUtils.diffToSeconds(latestTask.getUpdateTime(), new Date());
                        if (seconds < intervalOfAutoStandby) { continue; }
                    }
                }
            }
//            }
            mainService.buildMinorTask(agv, agvDetail, TaskTypeType.TO_STANDBY, null);
        }