#
Junjie
2025-04-02 15356da6eeca013fafc9bb6ed2d2a4a12422ce04
#
5个文件已修改
325 ■■■■ 已修改文件
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java 277 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ConveyorDispatcher.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/StaProtocol.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/FyxcDevpThread.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
@@ -12,7 +12,9 @@
import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
import com.zy.asrs.wcs.rcs.model.protocol.StaProtocol;
import com.zy.asrs.wcs.rcs.service.DeviceService;
import com.zy.asrs.wcs.rcs.thread.DevpThread;
import com.zy.asrs.wcs.rcs.thread.LiftThread;
import com.zy.asrs.wcs.rcs.thread.ShuttleThread;
import org.springframework.beans.factory.annotation.Autowired;
@@ -65,7 +67,13 @@
    public List<Motion> generateMotion(Task task) {
        List<Motion> motionList = new ArrayList<>();
        motionList = this.generateFirstZoneMotion(task);
        int originSite = Integer.parseInt(task.getOriginSite());
        int destSite = Integer.parseInt(task.getDestSite());
        if (originSite == 1015 || originSite == 1026 || destSite == 1015 || destSite == 1026) {
            motionList = generateSecondZoneMotion(task);
        }else {
            motionList = generateFirstZoneMotion(task);
        }
        return motionList;
    }
@@ -260,10 +268,7 @@
                return motionList;
            }
            BasConveyorSta basConveyorStaOrigin = basConveyorStaService.selectBySiteNo(task.getOriginSite());
            if (basConveyorStaOrigin == null) {
                return motionList;
            }
            //检测穿梭车是否有任务绑定
            boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo());
@@ -442,6 +447,268 @@
        return motionList;
    }
    public List<Motion> generateSecondZoneMotion(Task task) {
        List<Motion> motionList = new ArrayList<>();
        int originSite = Integer.parseInt(task.getOriginSite());
        String conveyLocNo;
        if (originSite == 1015 || originSite == 1026) {
            BasConveyorSta basConveyorStaOrigin = basConveyorStaService.selectBySiteNo(task.getOriginSite());
            if (basConveyorStaOrigin == null) {
                return motionList;
            }
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, basConveyorStaOrigin.getConveyorId().intValue());
            StaProtocol staProtocol = devpThread.getStation().get(originSite);
            if (staProtocol == null) {
                return motionList;
            } else {
                staProtocol = staProtocol.clone();
            }
            conveyLocNo = staProtocol.getLocNo();
        }else {
            conveyLocNo = null;
        }
        if(conveyLocNo == null) {
            return motionList;
        }
        /**
         * 入库
         */
        if (task.getTaskSts() == TaskStsType.NEW_INBOUND.sts) {
            // locNo
            String destLoc = task.getDestLoc();
            // shuttle
            Device shuttleDevice = deviceService.getOne(new LambdaQueryWrapper<Device>()
                    .eq(Device::getDeviceNo, task.getShuttleNo())
                    .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val())
                    .eq(Device::getHostId, task.getHostId())
                    .eq(Device::getStatus, 1));
            if (shuttleDevice == null) {
                return motionList;
            }
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleDevice.getId().intValue());
            ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
            if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
                return motionList;
            }
            if (!shuttleThread.isIdle()) {
                return motionList;
            }
            String shuttleLocNo = shuttleProtocol.getCurrentLocNo();
            BasConveyorSta basConveyorStaDest = basConveyorStaService.selectBySiteNo(task.getDestSite());
            if (basConveyorStaDest == null) {
                return motionList;
            }
            //检测穿梭车是否有任务绑定
            boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo());
            if (shuttleResult) {
                //存在任务,禁止解析
                return motionList;
            }
            // 入库目标层有穿梭车
            if (Utils.getLev(shuttleLocNo) == Utils.getLev(task.getDestLoc())) {
                // 穿梭车走行至取货库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(shuttleLocNo);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(conveyLocNo);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 穿梭车入库顶升
                motionList.addAll(kernelService.shuttleAction(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                        })),
                        MotionCtgType.SHUTTLE_PALLET_LIFT
                ));
                // 穿梭车载货走行至目标库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(conveyLocNo);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(destLoc);
                        })),
                        MotionCtgType.SHUTTLE_TRANSPORT
                ));
                // 穿梭车入库托盘下降
                motionList.addAll(kernelService.shuttleAction(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                        })),
                        MotionCtgType.SHUTTLE_PALLET_DOWN
                ));
            }
        }
        /**
         * 出库
         */
        if (task.getTaskSts() == TaskStsType.NEW_OUTBOUND.sts) {
            // locNo
            String originLoc = task.getOriginLoc();
            // shuttle
            Device shuttleDevice = deviceService.getOne(new LambdaQueryWrapper<Device>()
                    .eq(Device::getDeviceNo, task.getShuttleNo())
                    .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val())
                    .eq(Device::getHostId, task.getHostId())
                    .eq(Device::getStatus, 1));
            if (shuttleDevice == null) {
                return motionList;
            }
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleDevice.getId().intValue());
            ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
            if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
                return motionList;
            }
            if (!shuttleThread.isIdle()) {
                return motionList;
            }
            String shuttleLocNo = shuttleProtocol.getCurrentLocNo();
            //检测穿梭车是否有任务绑定
            boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo());
            if (shuttleResult) {
                //存在任务,禁止解析
                return motionList;
            }
            //分析出库路径放货库位
            String lastPathStartLoc = shuttleDispatcher.analyzeOutPathWaitLoc(originLoc, conveyLocNo, shuttleDevice);
            if (lastPathStartLoc == null) {
                return motionList;//未分析成功
            }
            String standbyLocNo;
            if (originSite == 1015) {
                standbyLocNo = "1200101";
            } else if (originSite == 1026) {
                standbyLocNo = "1200105";
            } else {
                standbyLocNo = null;
            }
            /**
             * 出库
             */
            if (Utils.getLev(shuttleLocNo) == Utils.getLev(originLoc)) {
                //穿梭车不在出库库位
                if (!shuttleLocNo.equals(task.getOriginLoc())) {
                    // 穿梭车走行至出库库位
                    motionList.addAll(kernelService.shuttleMove(
                            MotionDto.build((dto -> {
                                dto.setShuttleNo(shuttleDevice.getId().intValue());
                                dto.setLocNo(shuttleLocNo);
                            })),
                            MotionDto.build((dto -> {
                                dto.setShuttleNo(shuttleDevice.getId().intValue());
                                dto.setShuttleDevice(shuttleDevice);
                                dto.setLocNo(originLoc);
                            })),
                            MotionCtgType.SHUTTLE_MOVE
                    ));
                }
                // 穿梭车出库顶升
                motionList.addAll(kernelService.shuttleAction(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                        })),
                        MotionCtgType.SHUTTLE_PALLET_LIFT
                ));
                if (!originLoc.equals(lastPathStartLoc)) {
                    // 穿梭车载货出库至最后一段路径等待
                    motionList.addAll(kernelService.shuttleMove(
                            MotionDto.build((dto -> {
                                dto.setShuttleNo(shuttleDevice.getId().intValue());
                                dto.setLocNo(originLoc);
                            })),
                            MotionDto.build((dto -> {
                                dto.setShuttleNo(shuttleDevice.getId().intValue());
                                dto.setShuttleDevice(shuttleDevice);
                                dto.setLocNo(lastPathStartLoc);
                            })),
                            MotionCtgType.SHUTTLE_TRANSPORT
                    ));
                }
                // 穿梭车载货至输送线位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(lastPathStartLoc);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(conveyLocNo);
                            dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//输送站
                        })),
                        MotionCtgType.SHUTTLE_TRANSPORT_TO_CONVEYOR
                ));
                // 穿梭车出库托盘下降
                motionList.addAll(kernelService.shuttleAction(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                        })),
                        MotionCtgType.SHUTTLE_PALLET_DOWN
                ));
                // 穿梭车提升机待机位 - 到待机位(自动选择合适待机位)
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(conveyLocNo);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(standbyLocNo);
                            dto.setSync(0);//异步执行
                            dto.setReleaseShuttle(1);//执行完成后释放小车
                        })),
                        MotionCtgType.SHUTTLE_MOVE_STANDBY
                ));
            }
        }
        return motionList;
    }
    /**
     * 生成充电动作
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
@@ -192,7 +192,7 @@
                        if (task1 != null) {
                            News.error("工作档已存在,工作号={}", task1.getTaskNo());
                            if (staProtocol.getWorkNo().intValue() != Integer.parseInt(task1.getTaskNo())) {
                                devpThread.writeWorkSta(staProtocol.getSiteId(), Short.parseShort(task1.getTaskNo()), Short.parseShort(task1.getDestSite()));
                                devpThread.writeWorkSta(staProtocol.getSiteId(), Short.parseShort(task1.getTaskNo()), Short.parseShort(task1.getOriginSite()));
                                devpThread.setPakMk(staProtocol.getSiteId(), false);
                                News.info("输送线入库命令下发,任务数据={}", JSON.toJSON(task1));
                            }
@@ -519,6 +519,11 @@
                            //穿梭车进提升机待机位库位号  输送线位置
                            String standbyLocNoTo = shuttleStandbyTo.getDeviceStandbyLoc();
                            //不走提升机
                            if (staProtocol.getSiteId() == 1015 || staProtocol.getSiteId() == 1026) {
                                standbyLocNoTo = staProtocol.getLocNo();
                            }
                            if (Cools.isEmpty(task.getShuttleNo())) {
                                //分配小车
                                //调度空闲车去取货待机位
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ConveyorDispatcher.java
@@ -1,41 +1,10 @@
package com.zy.asrs.wcs.core.utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * Created by vincent on 2023/10/20
 */
@Slf4j
@Service
public class ConveyorDispatcher {
//    @Autowired
//    private SlaveProperties slaveProperties;
//
//    public DevpSlave queryByInBound(Integer staNo) {
//        for (DevpSlave devpSlave : slaveProperties.getDevp()) {
//            for (DevpSlave.Sta sta : devpSlave.getInSta()) {
//                if (sta.getStaNo().equals(staNo)) {
//                    return devpSlave;
//                }
//            }
//
//        }
//        return null;
//    }
//
//    public DevpSlave queryByOutBound(Integer staNo) {
//        for (DevpSlave devpSlave : slaveProperties.getDevp()) {
//            for (DevpSlave.Sta sta : devpSlave.getOutSta()) {
//                if (sta.getStaNo().equals(staNo)) {
//                    return devpSlave;
//                }
//            }
//
//        }
//        return null;
//    }
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/model/protocol/StaProtocol.java
@@ -85,6 +85,9 @@
    // 工作模式
    private Integer workMode;
    // 库位号
    private String locNo;
    @Override
    public StaProtocol clone() {
        try {
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/FyxcDevpThread.java
@@ -125,6 +125,13 @@
                if (null == staProtocol) {
                    staProtocol = new StaProtocol();
                    staProtocol.setSiteId(siteId);
                    if (siteId == 1015) {
                        staProtocol.setLocNo("1200301");
                    }else if (siteId == 1026) {
                        staProtocol.setLocNo("1200305");
                    }
                    station.put(siteId, staProtocol);
                }
                Thread.sleep(300);