#
luxiaotao1123
2026-01-27 2a30823fa12361a2873d914edca1c5ffe684d3ec
#
1个文件已添加
5个文件已修改
218 ■■■■■ 已修改文件
zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyReleaseToConveyorSta.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyReleaseToShelvesLoc.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyTakeFromConveyorSta.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyTakeFromShelvesLoc.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/ConveyorAutoRunScheduler.java 178 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TransferStationHandler.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyReleaseToConveyorSta.java
@@ -2,6 +2,7 @@
import com.zy.acs.common.domain.protocol.IActionBody;
import com.zy.acs.common.utils.Utils;
import com.zy.acs.framework.common.RadixTools;
import lombok.Data;
import java.io.Serializable;
@@ -18,13 +19,15 @@
    @Override
    public byte[] writeToBytes() {
        return Utils.reverse(RadixTools.shortToByte(this.height));
//        byte[] heightBytes = Utils.reverse(RadixTools.shortToByte(this.height));
//        byte[] depthBytes = Utils.reverse(RadixTools.shortToByte(this.depth));
//        return Utils.merge(heightBytes, depthBytes);
        byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
        byte depthByte  = (byte) ((this.depth  == null ? 0 : this.depth)  & 0xFF);
        return Utils.merge(heightByte, depthByte);
//        byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
//        byte depthByte  = (byte) ((this.depth  == null ? 0 : this.depth)  & 0xFF);
//        return Utils.merge(heightByte, depthByte);
//        return new byte[]{ heightByte, depthByte };
    }
zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyReleaseToShelvesLoc.java
@@ -2,6 +2,7 @@
import com.zy.acs.common.domain.protocol.IActionBody;
import com.zy.acs.common.utils.Utils;
import com.zy.acs.framework.common.RadixTools;
import lombok.Data;
import java.io.Serializable;
@@ -18,13 +19,15 @@
    @Override
    public byte[] writeToBytes() {
        return Utils.reverse(RadixTools.shortToByte(this.height));
//        byte[] heightBytes = Utils.reverse(RadixTools.shortToByte(this.height));
//        byte[] depthBytes = Utils.reverse(RadixTools.shortToByte(this.depth));
//        return Utils.merge(heightBytes, depthBytes);
        byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
        byte depthByte  = (byte) ((this.depth  == null ? 0 : this.depth)  & 0xFF);
        return Utils.merge(heightByte, depthByte);
//        byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
//        byte depthByte  = (byte) ((this.depth  == null ? 0 : this.depth)  & 0xFF);
//        return Utils.merge(heightByte, depthByte);
//        return new byte[]{ heightByte, depthByte };
    }
zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyTakeFromConveyorSta.java
@@ -2,6 +2,7 @@
import com.zy.acs.common.domain.protocol.IActionBody;
import com.zy.acs.common.utils.Utils;
import com.zy.acs.framework.common.RadixTools;
import lombok.Data;
import java.io.Serializable;
@@ -18,13 +19,15 @@
    @Override
    public byte[] writeToBytes() {
        return Utils.reverse(RadixTools.shortToByte(this.height));
//        byte[] heightBytes = Utils.reverse(RadixTools.shortToByte(this.height));
//        byte[] depthBytes = Utils.reverse(RadixTools.shortToByte(this.depth));
//        return Utils.merge(heightBytes, depthBytes);
        byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
        byte depthByte  = (byte) ((this.depth  == null ? 0 : this.depth)  & 0xFF);
        return Utils.merge(heightByte, depthByte);
//        byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
//        byte depthByte  = (byte) ((this.depth  == null ? 0 : this.depth)  & 0xFF);
//        return Utils.merge(heightByte, depthByte);
//        return new byte[]{ heightByte, depthByte };
    }
zy-acs-common/src/main/java/com/zy/acs/common/domain/protocol/action/ReadyTakeFromShelvesLoc.java
@@ -2,6 +2,7 @@
import com.zy.acs.common.domain.protocol.IActionBody;
import com.zy.acs.common.utils.Utils;
import com.zy.acs.framework.common.RadixTools;
import lombok.Data;
import java.io.Serializable;
@@ -18,13 +19,15 @@
    @Override
    public byte[] writeToBytes() {
        return Utils.reverse(RadixTools.shortToByte(this.height));
//        byte[] heightBytes = Utils.reverse(RadixTools.shortToByte(this.height));
//        byte[] depthBytes = Utils.reverse(RadixTools.shortToByte(this.depth));
//        return Utils.merge(heightBytes, depthBytes);
        byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
        byte depthByte  = (byte) ((this.depth  == null ? 0 : this.depth)  & 0xFF);
        return Utils.merge(heightByte, depthByte);
//        byte heightByte = (byte) ((this.height == null ? 0 : this.height) & 0xFF);
//        byte depthByte  = (byte) ((this.depth  == null ? 0 : this.depth)  & 0xFF);
//        return Utils.merge(heightByte, depthByte);
//        return new byte[]{ heightByte, depthByte };
    }
zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/ConveyorAutoRunScheduler.java
New file
@@ -0,0 +1,178 @@
package com.zy.acs.manager.core.scheduler;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.acs.common.constant.RedisConstant;
import com.zy.acs.common.utils.RedisSupport;
import com.zy.acs.framework.common.Cools;
import com.zy.acs.framework.common.SnowflakeIdWorker;
import com.zy.acs.manager.common.domain.TaskDto;
import com.zy.acs.manager.core.service.AreaGovernService;
import com.zy.acs.manager.core.service.MainService;
import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam;
import com.zy.acs.manager.manager.entity.*;
import com.zy.acs.manager.manager.enums.AgvModelType;
import com.zy.acs.manager.manager.enums.BusStsType;
import com.zy.acs.manager.manager.enums.LocStsType;
import com.zy.acs.manager.manager.enums.StatusType;
import com.zy.acs.manager.manager.service.*;
import com.zy.acs.manager.manager.service.impl.CodeServiceImpl;
import com.zy.acs.manager.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.*;
@Slf4j
@Component
public class ConveyorAutoRunScheduler {
    private static final AgvModelType DEFAULT_AGV_MODEL = AgvModelType.CTU_BOX_TRANSPORT_AGV;
    private final RedisSupport redis = RedisSupport.defaultRedisSupport;
    @Autowired
    private AgvService agvService;
    @Autowired
    private BusService busService;
    @Autowired
    private MainService mainService;
    @Autowired
    private ConfigService configService;
    @Autowired
    private LocService locService;
    @Autowired
    private StaService staService;
    @Autowired
    private AgvModelService agvModelService;
    @Autowired
    private SnowflakeIdWorker snowflakeIdWorker;
    @Autowired
    private AreaGovernService areaGovernService;
    @Autowired
    private CodeServiceImpl codeService;
    //    @Scheduled(fixedRate = 500) // 固定频率执行,不同步
    @Scheduled(fixedDelay = 1000) // 固定频率执行,同步
//    @Scheduled(cron = "0/1 * * * * ? ")
    private void execute() {
        //if (!configService.getVal("ConveyorTaskAssignMode", Boolean.class)) { return; }
        AgvModel agvModel = agvModelService.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, DEFAULT_AGV_MODEL.toString()));
        if (null == agvModel) { return; }
        //this.autoRun(agvModel);
    }
    private void autoRun(AgvModel agvModel) {
        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);
        // 最多 ? 组bus运行
        if (1 <= busService.count(new LambdaQueryWrapper<Bus>()
                .in(Bus::getBusSts, BusStsType.RECEIVE.val(), BusStsType.PROGRESS.val())
                .in(Bus::getMemo, memo)
        )) { return; }
        // 出库
        this.runLocToSta(agvModel, memo);
    }
    // 出库
    private void runLocToSta(AgvModel agvModel, String memo) {
        // IDLE STA
        List<Sta> idleList = new ArrayList<>();
        idleList.add(staService.selectByStaNo("1001"));
        idleList.add(staService.selectByStaNo("1007"));
        if (Cools.isEmpty(idleList)) { return; }
        Collections.shuffle(idleList);
        OpenBusSubmitParam param = new OpenBusSubmitParam();
        param.setBatch(String.valueOf(snowflakeIdWorker.nextId()).substring(13, 19));
        for (int i = 0; i < agvModel.getBackpack() ; i++) {
            Sta idleSta = idleList.get(i);
            String staCode = codeService.getCacheById(idleSta.getCode()).getData();
            Loc stockLoc = null;
            // 所在区域的条码,如果没有area绑定,就全地图
            List<String> codeList = areaGovernService.queryCodesByOneCode(staCode);
            if (Cools.isEmpty(codeList)) {
                stockLoc = locService.selectRandOneByLocSts(LocStsType.STOCK.val(), 1);
            } else {
                Collections.shuffle(codeList);
                for (String codeData : codeList) {
                    Code code = codeService.getCacheByData(codeData);
                    if (null == code) { break; }
                    List<Loc> locList = locService.list(new LambdaQueryWrapper<Loc>()
                            .eq(Loc::getCode, code.getId()).eq(Loc::getLocSts, LocStsType.STOCK.val()));
                    if (Cools.isEmpty(locList)) {
                        break;
                    } else if (locList.size() == 1) {
                        stockLoc = locList.get(0);
                    } else {
                        Collections.shuffle(locList);
                        stockLoc = locList.get(0);
                    }
                    if (null != stockLoc) {
                        break;
                    }
                }
            }
            if (null == stockLoc) { break; }
            TaskDto taskDto = new TaskDto();
            taskDto.setOriLoc(stockLoc.getLocNo());
            taskDto.setDestSta(idleSta.getStaNo());
            taskDto.setPriority(100);
            taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19));
            param.getTaskList().add(taskDto);
        }
        if (Cools.isEmpty(param.getTaskList())) { return; }
        mainService.generateBusAndTask(param, memo);
    }
    public static List<String> getStaPrefixes(List<String> staGroupList) {
        Set<String> rowSet = new HashSet<>();
        for (String s : staGroupList) {
            rowSet.add(s.split("-")[0]);
        }
        List<String> result = new ArrayList<>(rowSet);
        result.sort(Comparator.comparingInt(Integer::parseInt));
        return result;
    }
    private int getAvailableAgvCount() {
        int res = 0;
        List<Agv> agvList = agvService.list(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val));
        if (Cools.isEmpty(agvList)) {
            return res;
        }
        for (Agv agv : agvList) {
            if (null == redis.getObject(RedisConstant.AGV_ONLINE_FLAG, agv.getUuid())) {
                continue;
            }
            if (!agv.getStatusBool()) {
                continue;
            }
            res++;
        }
        return res;
    }
}
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TransferStationHandler.java
@@ -18,8 +18,8 @@
@Service
public class TransferStationHandler {
    private static final int DEFAULT_LOAD_DELAY_MS  = 1000; // load ( inbound ) delay timeout
    private static final int DEFAULT_PLACE_DELAY_MS  = 15000; // place ( outbound ) delay timeout
    private static final int DEFAULT_LOAD_DELAY_MS  = 15000; // load ( inbound ) delay timeout
    private static final int DEFAULT_PLACE_DELAY_MS  = 1000; // place ( outbound ) delay timeout
    @Autowired
    private SegmentService segmentService;