#
vincentlu
2026-01-05 efabc6ba991acfd01d38bb0bf4e8cfd772416617
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/AutoRunScheduler.java
@@ -24,6 +24,8 @@
@Component
public class AutoRunScheduler {
    private static final AgvModelType DEFAULT_AGV_MODEL = AgvModelType.CTU_BOX_TRANSPORT_AGV;
    private final RedisSupport redis = RedisSupport.defaultRedisSupport;
    @Autowired
@@ -52,10 +54,13 @@
//    @Scheduled(cron = "0/1 * * * * ? ")
    private void execute() {
        if (!configService.getVal("TaskAssignMode", Boolean.class)) { return; }
        this.autoRun();
        AgvModel agvModel = agvModelService.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, DEFAULT_AGV_MODEL.toString()));
        if (null == agvModel) { return; }
        this.autoRun(agvModel);
    }
    private void autoRun() {
    private void autoRun(AgvModel agvModel) {
        int availableAgvCount = this.getAvailableAgvCount();
        if (0 == availableAgvCount) { return; }
@@ -64,23 +69,19 @@
        String memo = "DEMO_STA_" + String.join("-", staPreNos);
        // 入库
        this.runStaToLoc(memo);
        this.runStaToLoc(agvModel, memo);
        // 出库
        this.runLocToSta(memo);
        this.runLocToSta(agvModel, memo);
        // 移库
        this.runLocToLoc(memo);
        this.runLocToLoc(agvModel, memo);
    }
    // 入库
    private void runStaToLoc(String memo) {
        AgvModel agvModel = agvModelService.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, AgvModelType.CTU_BOX_TRANSPORT_AGV.toString()));
        if (null == agvModel) { return; }
    private void runStaToLoc(AgvModel agvModel, String memo) {
        // STOCK STA
        List<Sta> stockList = staService.list(new LambdaQueryWrapper<Sta>()
                .eq(Sta::getStaSts, StaStsType.STOCK.val())
                .eq(Sta::getStatus, StatusType.ENABLE.val));
        List<Sta> stockList = staService.queryAvailableOutSta(1);
        if (Cools.isEmpty(stockList)) { return; }
        Collections.shuffle(stockList);
@@ -88,7 +89,7 @@
        param.setBatch(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19));
        for (int i = 0; i < Math.min(agvModel.getBackpack(), stockList.size()) ; i++) {
            Sta stockSta = stockList.get(i);
            String staCode = stockSta.getCode$();
            String staCode = codeService.getCacheById(stockSta.getCode()).getData();
            Loc idleLoc = null;
@@ -133,14 +134,10 @@
    }
    // 出库
    private void runLocToSta(String memo) {
        AgvModel agvModel = agvModelService.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, AgvModelType.CTU_BOX_TRANSPORT_AGV.toString()));
        if (null == agvModel) { return; }
    private void runLocToSta(AgvModel agvModel, String memo) {
        // IDLE STA
        List<Sta> idleList = staService.list(new LambdaQueryWrapper<Sta>()
                .eq(Sta::getStaSts, StaStsType.IDLE.val())
                .eq(Sta::getStatus, StatusType.ENABLE.val));
        List<Sta> idleList = staService.queryAvailableInSta(1);
        if (Cools.isEmpty(idleList)) { return; }
        Collections.shuffle(idleList);
@@ -148,7 +145,7 @@
        param.setBatch(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19));
        for (int i = 0; i < Math.min(agvModel.getBackpack(), idleList.size()) ; i++) {
            Sta idleSta = idleList.get(i);
            String staCode = idleSta.getCode$();
            String staCode = codeService.getCacheById(idleSta.getCode()).getData();
            Loc stockLoc = null;
@@ -193,7 +190,7 @@
    }
    // 移库
    private void runLocToLoc(String staTaskMemo) {
    private void runLocToLoc(AgvModel agvModel, String staTaskMemo) {
        String memo = "DEMO_LOC";
        int availableAgvCount = this.getAvailableAgvCount();
@@ -203,9 +200,6 @@
                .in(Bus::getBusSts, BusStsType.RECEIVE.val(), BusStsType.PROGRESS.val())
                .in(Bus::getMemo, memo, staTaskMemo)
        )) { return; }
        AgvModel agvModel = agvModelService.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, AgvModelType.CTU_BOX_TRANSPORT_AGV.toString()));
        if (null == agvModel) { return; }
        int maxCapacity = agvModel.getBackpack();