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;
@@ -117,13 +115,6 @@
                return motionList;
            }
            //检测提升机是否有任务绑定
            boolean liftResult = Utils.checkLiftHasBinding(Integer.parseInt(transferLiftDevice.getDeviceNo()));
            if (liftResult) {
                //存在任务,禁止解析
                return motionList;
            }
            //获取小车待机库位 ==> 进提升机
            ShuttleStandby shuttleStandbyTo = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                    .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId())
@@ -165,6 +156,7 @@
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(task.getDestLoc()));
                            dto.setStaNo(0);//提升机内侧
                            dto.setSync(0);//异步执行
                        }))
                ));
@@ -176,7 +168,6 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
@@ -232,6 +223,7 @@
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        }))
                ));
@@ -381,6 +373,7 @@
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        }))
                ));
@@ -457,13 +450,6 @@
                return motionList;
            }
            //检测提升机是否有任务绑定
            boolean liftResult = Utils.checkLiftHasBinding(Integer.parseInt(transferLiftDevice.getDeviceNo()));
            if (liftResult) {
                //存在任务,禁止解析
                return motionList;
            }
            //获取小车待机库位 ==> 进提升机
            ShuttleStandby shuttleStandbyTo = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                    .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId())
@@ -491,8 +477,9 @@
            //穿梭车出提升机待机位库位号
            String standbyLocNoFrom = shuttleStandbyFrom.getDeviceStandbyLoc();
            //穿梭车出提升机后小车待机位
            String shuttleFromLiftStandbyLoc = shuttleStandbyFrom.getStandbyLoc();
            //穿梭车出提升机后全部待机位
            String standbyLocs = shuttleStandbyFrom.getStandbyLoc();//获取全部待机位
            //获取出库任务类型
            TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>()
@@ -634,6 +621,8 @@
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(5);//索牌项目5层是输送线层
                            dto.setStaNo(1);//提升机左侧
                            dto.setSync(0);//异步执行
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        }))
                ));
@@ -645,7 +634,7 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(shuttleFromLiftStandbyLoc);
                            dto.setLocNo(standbyLocs);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
@@ -690,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);
                        }))
                ));
                // 提升机空载移动到穿梭车层
@@ -779,6 +777,7 @@
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        }))
                ));
@@ -814,17 +813,17 @@
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                            dto.setLocNo(standbyLocNoFrom);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 提升机空载移动到穿梭车层
                // 提升机空载移动到目标层
                motionList.addAll(kernelService.liftMove(
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(shuttleLocNo));
                            dto.setLev(Utils.getLev(originLoc));
                        }))
                ));
@@ -840,12 +839,12 @@
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                            dto.setLocNo(standbyLocNoFrom);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(liftLocNoTo);
                            dto.setLocNo(liftLocNoFrom);
                        })),
                        MotionCtgType.SHUTTLE_MOVE_TO_LIFT
                ));
@@ -892,6 +891,7 @@
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(5);//索牌项目5层是输送线层
                            dto.setStaNo(1);//提升机左侧
                            dto.setSync(0);//异步执行
                        }))
                ));
@@ -903,9 +903,9 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(shuttleFromLiftStandbyLoc);
                            dto.setLocNo(standbyLocs);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                        MotionCtgType.SHUTTLE_MOVE_STANDBY
                ));
                // 输送线运输至出库口
@@ -976,13 +976,6 @@
        //检测穿梭车是否有任务绑定
        boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo());
        if (shuttleResult) {
            //存在任务,禁止解析
            return motionList;
        }
        //检测提升机是否有任务绑定
        boolean liftResult = Utils.checkLiftHasBinding(Integer.parseInt(transferLiftDevice.getDeviceNo()));
        if (liftResult) {
            //存在任务,禁止解析
            return motionList;
        }
@@ -1148,16 +1141,15 @@
                    MotionCtgType.SHUTTLE_MOVE
            ));
            task.setLiftNo(Integer.parseInt(transferLiftDevice.getDeviceNo()));
            taskService.updateById(task);
        }
        // 穿梭车开始充电
        motionList.addAll(kernelService.shuttleCharge(
        motionList.addAll(kernelService.shuttleAction(
                null,
                MotionDto.build((dto -> {
                    dto.setShuttleNo(shuttleDevice.getId().intValue());
                }))
                })),
                MotionCtgType.SHUTTLE_CHARGE_ON
        ));
        return motionList;
@@ -1194,6 +1186,15 @@
        // 判断穿梭车是否在目标层
        if (Utils.getLev(shuttleLocNo) == Utils.getLev(locNo)) {
            // 穿梭车关闭充电
            motionList.addAll(kernelService.shuttleAction(
                    null,
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                    })),
                    MotionCtgType.SHUTTLE_CHARGE_OFF
            ));
            // 穿梭车走行至目标库位
            motionList.addAll(kernelService.shuttleMove(
@@ -1298,6 +1299,15 @@
                        dto.setLocNo(standbyLocNoTo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
            ));
            // 锁定目标楼层穿梭车待机位路径
            motionList.addAll(kernelService.mapLockPath(
                    null,
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(standbyLocNoFrom);
                    }))
            ));
            // 提升机空载移动到穿梭车层
@@ -1415,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;
    }
    /**
     * 生成小车手动动作