zhang
2026-01-05 1809dba25f489ea01c07a9ecc977d9f408545310
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/AutoRunScheduler.java
@@ -63,8 +63,18 @@
    @Scheduled(fixedDelay = 1000) // 固定频率执行,同步
//    @Scheduled(cron = "0/1 * * * * ? ")
    private void execute() {
        if (!configService.getVal("TaskAssignMode", Boolean.class)) { return; }
        this.autoRun();
        if (configService.getVal("TaskAssignMode", Boolean.class)) {
            this.autoRun();
        }
        if (configService.getVal("TaskAssignMode1", Boolean.class,false)) {
            this.autoRun0(1);
        }
        if (configService.getVal("TaskAssignMode2", Boolean.class,false)) {
            this.autoRun0(2);
        }
        if (configService.getVal("TaskAssignMode3", Boolean.class,false)) {
            this.autoRun0(3);
        }
    }
    private void autoRun() {
@@ -83,6 +93,26 @@
        // 移库
        this.runLocToLoc(memo);
    }
    private void autoRun0(Integer i) {
        int availableAgvCount = this.getAvailableAgvCount();
        if (0 == availableAgvCount) { return; }
//        List<String> staPreNos = getStaPrefixes(staGroupList);
        List<String> staPreNos = new ArrayList<>();
        String memo = "DEMO_STA_" + String.join("-", staPreNos);
        if(i ==1){
            // 入库
            this.runStaToLoc0(memo);
        }else if (i == 2){
            // 出库
            this.runLocToSta0(memo);
        }else if (i == 3){
            // 移库
            this.runLocToLoc(memo);
        }
    }
    // 入库
    private void runStaToLoc(String memo) {
@@ -133,6 +163,14 @@
    }
    private void runStaToLoc0(String memo) {
        int availableAgvCount = this.getAvailableAgvCount();
        // 最多 ? 组bus运行
        if (availableAgvCount <= busService.count(new LambdaQueryWrapper<Bus>()
                .in(Bus::getBusSts, BusStsType.RECEIVE.val(), BusStsType.PROGRESS.val())
                .in(Bus::getMemo, memo, memo)
        )) { return; }
        AgvModel agvModel = agvModelService.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, AgvModelType.CTU_BOX_TRANSPORT_AGV.toString()));
        if (null == agvModel) { return; }
@@ -245,6 +283,14 @@
    }
    private void runLocToSta0(String memo) {
        int availableAgvCount = this.getAvailableAgvCount();
        // 最多 ? 组bus运行
        if (availableAgvCount <= busService.count(new LambdaQueryWrapper<Bus>()
                .in(Bus::getBusSts, BusStsType.RECEIVE.val(), BusStsType.PROGRESS.val())
                .in(Bus::getMemo, memo, memo)
        )) { return; }
        AgvModel agvModel = agvModelService.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, AgvModelType.CTU_BOX_TRANSPORT_AGV.toString()));
        if (null == agvModel) { return; }
@@ -322,21 +368,17 @@
        // STOCK
        List<Loc> stockLocList = locService.selectRandByLocSts(LocStsType.STOCK.val(), maxCapacity);
//        LambdaQueryWrapper<Loc> stockWrapper = new LambdaQueryWrapper<Loc>().eq(Loc::getLocSts, LocStsType.STOCK.val());
//        List<Loc> stockList = locService.list(stockWrapper);
//        if (Cools.isEmpty(stockList) || stockList.size() < agvModel.getBackpack()) {
//            return;
//        }
//        Collections.shuffle(stockList);
        if (Cools.isEmpty(stockLocList)) {
            return;
        }
        Collections.shuffle(stockLocList);
        // IDLE
        List<Loc> idleLocList = locService.selectRandByLocSts(LocStsType.IDLE.val(), maxCapacity);
//        LambdaQueryWrapper<Loc> idleWrapper = new LambdaQueryWrapper<Loc>().eq(Loc::getLocSts, LocStsType.IDLE.val());
//        List<Loc> idleList = locService.list(idleWrapper);
//        if (Cools.isEmpty(idleList)) {
//            return;
//        }
//        Collections.shuffle(idleList);
        if (Cools.isEmpty(idleLocList)) {
            return;
        }
        Collections.shuffle(idleLocList);
        OpenBusSubmitParam param = new OpenBusSubmitParam();
        param.setBatch(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19));
@@ -351,6 +393,7 @@
            param.getTaskList().add(taskDto);
        }
        if (Cools.isEmpty(param.getTaskList())) { return; }
        mainService.generateBusAndTask(param, memo);
    }