zjj
2025-04-21 e29a9f245ff4e57a40bbab1c0acc3cbc31d3ac2b
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
@@ -1,8 +1,6 @@
package com.zy.asrs.wcs.core.kernel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.R;
import com.zy.asrs.wcs.core.domain.dto.MotionDto;
import com.zy.asrs.wcs.core.entity.*;
import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
@@ -479,8 +477,9 @@
            //穿梭车出提升机待机位库位号
            String standbyLocNoFrom = shuttleStandbyFrom.getDeviceStandbyLoc();
            //穿梭车出提升机后小车待机位
            String shuttleFromLiftStandbyLoc = shuttleStandbyFrom.getStandbyLoc();
            //穿梭车出提升机后全部待机位
            String standbyLocs = shuttleStandbyFrom.getStandbyLoc();//获取全部待机位
            //获取出库任务类型
            TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>()
@@ -635,7 +634,7 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(shuttleFromLiftStandbyLoc);
                            dto.setLocNo(standbyLocs);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
@@ -680,6 +679,15 @@
                            dto.setLocNo(standbyLocNoTo);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 锁定目标楼层穿梭车待机位路径
                motionList.addAll(kernelService.mapLockPath(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoFrom);
                        }))
                ));
                // 提升机空载移动到穿梭车层
@@ -895,9 +903,9 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(shuttleFromLiftStandbyLoc);
                            dto.setLocNo(standbyLocs);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                        MotionCtgType.SHUTTLE_MOVE_STANDBY
                ));
                // 输送线运输至出库口
@@ -1293,6 +1301,15 @@
                    MotionCtgType.SHUTTLE_MOVE
            ));
            // 锁定目标楼层穿梭车待机位路径
            motionList.addAll(kernelService.mapLockPath(
                    null,
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(standbyLocNoFrom);
                    }))
            ));
            // 提升机空载移动到穿梭车层
            motionList.addAll(kernelService.liftMove(
                    null
@@ -1408,6 +1425,91 @@
        }
        return motionList;
    }
    /**
     * 生成小车载货迁移动作
     */
    public List<Motion> generateShuttleLadenMoveMotion(Task task) {
        List<Motion> motionList = new ArrayList<>();
        if (task.getTaskSts() != TaskStsType.NEW_LADEN_MOVE.sts) {
            return motionList;
        }
        //originLoc 源库位
        String originLoc =  task.getOriginLoc();
        // locNo 目标库位
        String locNo = task.getDestLoc();
        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());
        if (shuttleThread == null) {
            return motionList;
        }
        ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
        if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
            return motionList;
        }
        String shuttleLocNo = shuttleProtocol.getCurrentLocNo();
        // 判断穿梭车是否在目标层
        if (Utils.getLev(shuttleLocNo) == Utils.getLev(locNo)) {
            if (!shuttleLocNo.equals(locNo)) {//小车不在目标库位
                // 穿梭车走行至源库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(shuttleLocNo);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(originLoc);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 穿梭车顶升
                motionList.add(Motion.build(motion -> {
                    motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val());
                    motion.setDevice(String.valueOf(shuttleDevice.getId()));
                    motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_LIFT.val());
                }));
                // 穿梭车走行至目标库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(originLoc);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(locNo);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
                //穿梭车托盘下降
                motionList.add(Motion.build(motion -> {
                    motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val());
                    motion.setDevice(String.valueOf(shuttleDevice.getId()));
                    motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_DOWN.val());
                }));
            }
        } else {
            //小车跨层
        }
        return motionList;
    }
    /**
     * 生成小车手动动作