#
zjj
2025-04-08 3df03c486fde77ab36b9298a94bdbb0aa065a7e2
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
@@ -4,17 +4,17 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.wcs.core.domain.dto.MotionDto;
import com.zy.asrs.wcs.core.entity.*;
import com.zy.asrs.wcs.core.model.NavigateNode;
import com.zy.asrs.wcs.core.model.enums.*;
import com.zy.asrs.wcs.core.service.*;
import com.zy.asrs.wcs.core.utils.*;
import com.zy.asrs.wcs.rcs.News;
import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
import com.zy.asrs.wcs.rcs.entity.Device;
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;
@@ -67,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;
    }
@@ -101,8 +107,8 @@
            String shuttleLocNo = shuttleProtocol.getCurrentLocNo();
            //获取距离目标位置最近的空闲可换层提升机
            LiftThread liftThread = liftDispatcher.searchIdleLift(shuttleLocNo, task.getHostId(), true);
            //获取距离目标位置最近的可换层提升机(可能不空闲)
            LiftThread liftThread = liftDispatcher.searchLift(shuttleLocNo, task.getHostId(), true);
            if (liftThread == null) {
                return motionList;
            }
@@ -113,11 +119,6 @@
                return motionList;
            }
            BasConveyorSta basConveyorStaDest = basConveyorStaService.selectBySiteNo(task.getDestSite());
            if (basConveyorStaDest == null) {
                return motionList;
            }
            //检测穿梭车是否有任务绑定
            boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo());
            if (shuttleResult) {
@@ -125,35 +126,19 @@
                return motionList;
            }
            //获取小车待机库位 ==> 进提升机
            //获取小车待机库位 ==> 提升机
            ShuttleStandby shuttleStandbyTo = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                    .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId())
                    .eq(ShuttleStandby::getDeviceLev, Utils.getLev(shuttleLocNo))
                    .eq(ShuttleStandby::getStatus, 1));
            //获取小车待机库位 ==> 出提升机
            ShuttleStandby shuttleStandbyFrom = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                    .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId())
                    .eq(ShuttleStandby::getDeviceLev, Utils.getLev(destLoc))
                    .eq(ShuttleStandby::getStatus, 1));
            if (shuttleStandbyTo == null || shuttleStandbyFrom == null) {
                return motionList;
            }
            //穿梭车进提升机库位号
            String liftLocNoTo = shuttleStandbyTo.getDeviceLoc();
            //穿梭车出提升机库位号
            String liftLocNoFrom = shuttleStandbyFrom.getDeviceLoc();
            //穿梭车进提升机待机位库位号
            //穿梭车进提升机待机位库位号  输送线位置
            String standbyLocNoTo = shuttleStandbyTo.getDeviceStandbyLoc();
            //穿梭车出提升机待机位库位号
            String standbyLocNoFrom = shuttleStandbyFrom.getDeviceStandbyLoc();
            //换层需要锁定的路径
            List<String> lockPath = shuttleStandbyFrom.getLockPath$();
            //穿梭车换层时待机位置 使用表列 memo数据
            String standbyLocNoMemo = shuttleStandbyTo.getMemo();
            // 入库目标层有穿梭车
            if (Utils.getLev(shuttleLocNo) == Utils.getLev(task.getDestLoc())) {
@@ -162,19 +147,18 @@
                motionList.addAll(kernelService.liftMoveGoods(
                        MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(1);//光泰1层是输送线层
                            dto.setStaNo(31004);//入库站点
                            dto.setStaNo(Integer.parseInt(task.getOriginSite()));//入库站点
                        }))
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(task.getDestLoc()));
                            dto.setStaNo(getStaByLev(Utils.getLev(task.getDestLoc())));
                            dto.setDevpNo(basConveyorStaDest.getConveyorDeviceId().intValue());
//                            dto.setSync();//异步执行
                        }))
                            dto.setStaNo(Integer.parseInt(task.getDestSite()));
//                            dto.setReleaseLift(1);//执行完成后释放提升机
                        })),
                        MotionCtgType.LIFT_WITH_GOODS_IN
                ));
                // 穿梭车走行至提升机库位待机位
                // 穿梭车走行至提升机库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
@@ -182,184 +166,10 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                        })),
                        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(standbyLocNoFrom);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(destLoc);
                        })),
                        MotionCtgType.SHUTTLE_TRANSPORT
                ));
                // 穿梭车入库托盘下降
                motionList.addAll(kernelService.shuttleAction(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                        })),
                        MotionCtgType.SHUTTLE_PALLET_DOWN
                ));
            /**
             * 二、入库目标层没有穿梭车
             */
            } else {
                // 提升机载货移动
                motionList.addAll(kernelService.liftMoveGoods(
                        MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(1);//光泰1层是输送线层
                            dto.setStaNo(31004);//入库站点
                        }))
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(task.getDestLoc()));
                            dto.setStaNo(getStaByLev(Utils.getLev(task.getDestLoc())));
                            dto.setDevpNo(basConveyorStaDest.getConveyorDeviceId().intValue());
                        }))
                ));
                // 穿梭车走行至提升机库位待机位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(shuttleLocNo);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 锁定换层路径
                motionList.addAll(kernelService.mapLockPath(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(JSON.toJSONString(lockPath));
                        }))
                ));
                // 提升机空载移动到穿梭车层
                motionList.addAll(kernelService.liftMove(
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(shuttleLocNo));
                        }))
                ));
                // 锁定提升机
                motionList.addAll(kernelService.liftLock(
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                        }))
                ));
                // 穿梭车待机位至提升机
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(liftLocNoTo);
                        })),
                        MotionCtgType.SHUTTLE_MOVE_TO_LIFT
                ));
                // 解锁提升机
                motionList.addAll(kernelService.liftUnlock(
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                        }))
                ));
                // 提升机搬车 至 目标位置层
                motionList.addAll(kernelService.liftMoveShuttle(
                        MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(shuttleLocNo));
                        })),
                        MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(destLoc));
                        }))
                ));
                // 锁定提升机
                motionList.addAll(kernelService.liftLock(
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                        }))
                ));
                // 更新小车坐标
                motionList.addAll(kernelService.shuttleUpdateLocation(
                        null
                        , MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(liftLocNoFrom);
                        }))
                ));
                // 穿梭车移动至提升机待机位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(liftLocNoFrom);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoFrom);
                        })),
                        MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
                ));
                // 解锁提升机
                motionList.addAll(kernelService.liftUnlock(
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        }))
                ));
                // 解锁换层路径
                motionList.addAll(kernelService.mapUnlockPath(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(JSON.toJSONString(lockPath));
                        }))
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 穿梭车入库顶升
@@ -371,16 +181,34 @@
                        MotionCtgType.SHUTTLE_PALLET_LIFT
                ));
                // 穿梭车载货走行至待机库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(liftLocNoTo);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        })),
                        MotionCtgType.SHUTTLE_TRANSPORT
                ));
                // 穿梭车载货走行至目标库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoFrom);
                            dto.setLocNo(standbyLocNoTo);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(destLoc);
                            dto.setReleaseLift(2);//执行中释放提升机
                        })),
                        MotionCtgType.SHUTTLE_TRANSPORT
                ));
@@ -393,7 +221,6 @@
                        })),
                        MotionCtgType.SHUTTLE_PALLET_DOWN
                ));
            }
        }
@@ -437,11 +264,6 @@
                return motionList;
            }
            BasConveyorSta basConveyorStaOrigin = basConveyorStaService.selectBySiteNo(task.getOriginSite());
            if (basConveyorStaOrigin == null) {
                return motionList;
            }
            //检测穿梭车是否有任务绑定
            boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo());
            if (shuttleResult) {
@@ -455,32 +277,14 @@
                    .eq(ShuttleStandby::getDeviceLev, Utils.getLev(shuttleLocNo))
                    .eq(ShuttleStandby::getStatus, 1));
            //获取小车待机库位 ==> 出提升机
            ShuttleStandby shuttleStandbyFrom = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                    .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId())
                    .eq(ShuttleStandby::getDeviceLev, Utils.getLev(originLoc))
                    .eq(ShuttleStandby::getStatus, 1));
            if (shuttleStandbyTo == null || shuttleStandbyFrom == null) {
                return motionList;
            }
            //穿梭车进提升机库位号
            String liftLocNoTo = shuttleStandbyTo.getDeviceLoc();
            //穿梭车出提升机库位号
            String liftLocNoFrom = shuttleStandbyFrom.getDeviceLoc();
            //穿梭车进提升机待机位库位号
            //穿梭车进提升机待机位库位号 输送线位置
            String standbyLocNoTo = shuttleStandbyTo.getDeviceStandbyLoc();
            //穿梭车出提升机待机位库位号
            String standbyLocNoFrom = shuttleStandbyFrom.getDeviceStandbyLoc();
            //穿梭车出提升机后小车待机位
            String shuttleFromLiftStandbyLoc = shuttleStandbyFrom.getStandbyLoc();
            //换层需要锁定的路径
            List<String> lockPath = shuttleStandbyFrom.getLockPath$();
            //穿梭车待机位置 使用表列
            String standbyLocNoList = shuttleStandbyTo.getStandbyLoc();
            //获取出库任务类型
            TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>()
@@ -489,27 +293,12 @@
            if (taskCtg == null) {
                return motionList;
            }
            //获取输送线路径
            BasConveyorPath basConveyorPath = basConveyorPathService.getOne(new LambdaQueryWrapper<BasConveyorPath>()
                    .eq(BasConveyorPath::getDeviceStn, task.getOriginSite())
                    .eq(BasConveyorPath::getDeviceNo, liftProtocol.getLiftNo())
                    .eq(BasConveyorPath::getTypeNo, taskCtg.getId()));
            if (basConveyorPath == null) {
                return motionList;
            }
            //计算路径并分解成两段动作
            List<NavigateNode> nodeList = NavigateUtils.calc(originLoc, standbyLocNoTo, NavigationMapType.DFX.id, Utils.getShuttlePoints(Integer.parseInt(shuttleDevice.getDeviceNo()), Utils.getLev(originLoc)));
            if (nodeList == null) {
                News.error("{} dash {} can't find navigate path!", originLoc, standbyLocNoTo);
                return null;
            //分析出库路径待机库位
            String lastPathStartLoc = shuttleDispatcher.analyzeOutPathWaitLoc(originLoc, standbyLocNoTo, shuttleDevice);
            if (lastPathStartLoc == null) {
                return motionList;//未分析成功
            }
            //获取分段路径
            ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(nodeList);
            //取出最后一段路径
            ArrayList<NavigateNode> navigateNodes = data.get(data.size() - 1);
            NavigateNode startNode = navigateNodes.get(0);
            String lastPathStartLoc = Utils.getLocNo(startNode.getX(), startNode.getY(), startNode.getZ());
            /**
             * 出库
@@ -526,6 +315,7 @@
                            })),
                            MotionDto.build((dto -> {
                                dto.setShuttleNo(shuttleDevice.getId().intValue());
                                dto.setShuttleDevice(shuttleDevice);
                                dto.setLocNo(originLoc);
                            })),
                            MotionCtgType.SHUTTLE_MOVE
@@ -541,18 +331,21 @@
                        MotionCtgType.SHUTTLE_PALLET_LIFT
                ));
                // 穿梭车载货出库至最后一段路径等待
                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(lastPathStartLoc);
                        })),
                        MotionCtgType.SHUTTLE_TRANSPORT
                ));
                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(
@@ -562,11 +355,36 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                            dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//输送站
                        })),
                        MotionCtgType.SHUTTLE_TRANSPORT_TO_CONVEYOR
                        MotionCtgType.SHUTTLE_TRANSPORT
                ));
                Integer liftLevLogic = liftDispatcher.getLiftLevOffset(transferLiftDevice.getId().intValue(), Utils.getLev(originLoc));
                // 提升机空载移动到出库层
                motionList.addAll(kernelService.liftMove(
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(liftLevLogic);
                        }))
                ));
                // 穿梭车走行至提升机库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(liftLocNoTo);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 穿梭车出库托盘下降
@@ -578,19 +396,20 @@
                        MotionCtgType.SHUTTLE_PALLET_DOWN
                ));
                // 穿梭车提升机待机位 - 到待机位
                // 穿梭车提升机待机位 - 到待机位(自动选择合适待机位)
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoFrom);
                            dto.setLocNo(liftLocNoTo);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(shuttleFromLiftStandbyLoc);
                            dto.setSync(0);//异步执行
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(standbyLocNoList);
//                            dto.setSync(0);//异步执行
                            dto.setReleaseShuttle(1);//执行完成后释放小车
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                        MotionCtgType.SHUTTLE_MOVE_STANDBY
                ));
                // 提升机载货移动
@@ -598,36 +417,88 @@
                        MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(task.getOriginLoc()));
                            dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//起始站点
                            dto.setStaNo(Integer.parseInt(task.getOriginSite()));//起始站点
                        }))
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(1);//光泰1层是输送线层
                            dto.setStaNo(31001);//出库站点
                            dto.setDevpNo(basConveyorStaOrigin.getConveyorDeviceId().intValue());
                            dto.setStaNo(Integer.parseInt(task.getDestSite()));//出库站点
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        }))
                        })),
                        MotionCtgType.LIFT_WITH_GOODS_OUT
                ));
                // 输送线运输至出库口
//                motionList.addAll(kernelService.conveyorOutbound(
//                        MotionDto.build((dto -> {
//                            dto.setDevpNo(basConveyorPath.getDeviceId().intValue());
//                            dto.setStaNo(basConveyorPath.getDeviceStn());
//                        })),
//                        MotionDto.build((dto -> {
//                            dto.setDevpNo(basConveyorPath.getDeviceId().intValue());
//                            dto.setStaNo(basConveyorPath.getStnNo());
//                        })),
//                        MotionCtgType.CONVEYOR_OUTBOUND
//                ));
            }
            /**
             * 二、出库起始层没有穿梭车
             */
        }
        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();
            //检测穿梭车是否有任务绑定
            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());
@@ -635,134 +506,125 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(conveyLocNo);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 锁定换层路径
                motionList.addAll(kernelService.mapLockPath(
                // 穿梭车入库顶升
                motionList.addAll(kernelService.shuttleAction(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(JSON.toJSONString(lockPath));
                        }))
                        })),
                        MotionCtgType.SHUTTLE_PALLET_LIFT
                ));
                // 提升机空载移动到穿梭车层
                motionList.addAll(kernelService.liftMove(
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(shuttleLocNo));
                        }))
                ));
                // 锁定提升机
                motionList.addAll(kernelService.liftLock(
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                        }))
                ));
                // 穿梭车待机位至提升机
                // 穿梭车载货走行至目标库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                            dto.setLocNo(conveyLocNo);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(liftLocNoTo);
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(destLoc);
                        })),
                        MotionCtgType.SHUTTLE_MOVE_TO_LIFT
                        MotionCtgType.SHUTTLE_TRANSPORT
                ));
                // 解锁提升机
                motionList.addAll(kernelService.liftUnlock(
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                        }))
                ));
                // 提升机搬车 至 目标位置层
                motionList.addAll(kernelService.liftMoveShuttle(
                        MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(shuttleLocNo));
                        })),
                        MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(liftLocNoFrom));
                        }))
                ));
                // 锁定提升机
                motionList.addAll(kernelService.liftLock(
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                        }))
                ));
                // 更新小车坐标
                motionList.addAll(kernelService.shuttleUpdateLocation(
                        null
                        , MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(liftLocNoFrom);
                        }))
                ));
                // 穿梭车走行至提升机待机位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(liftLocNoFrom);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoFrom);
                        })),
                        MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
                ));
                // 解锁提升机
                motionList.addAll(kernelService.liftUnlock(
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        }))
                ));
                // 解锁换层路径
                motionList.addAll(kernelService.mapUnlockPath(
                // 穿梭车入库托盘下降
                motionList.addAll(kernelService.shuttleAction(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(JSON.toJSONString(lockPath));
                        }))
                        })),
                        MotionCtgType.SHUTTLE_PALLET_DOWN
                ));
            }
                // 穿梭车提升机待机位至出库库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoFrom);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(originLoc);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
        }
        /**
         * 出库
         */
        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;//未分析成功
            }
            //获取小车待机库位 ==> 进提升机
            ShuttleStandby shuttleStandbyTo = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                    .eq(ShuttleStandby::getDeviceLev, Utils.getLev(shuttleLocNo))
                    .eq(ShuttleStandby::getStatus, 1));
            //穿梭车待机位置 使用表列
            String standbyLocNoList = shuttleStandbyTo.getStandbyLoc();
            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(
@@ -773,20 +635,23 @@
                        MotionCtgType.SHUTTLE_PALLET_LIFT
                ));
                // 穿梭车载货出库至最后一段路径等待
                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(lastPathStartLoc);
                        })),
                        MotionCtgType.SHUTTLE_TRANSPORT
                ));
                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());
@@ -794,8 +659,8 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoFrom);
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(conveyLocNo);
                            dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//输送站
                        })),
                        MotionCtgType.SHUTTLE_TRANSPORT_TO_CONVEYOR
@@ -810,49 +675,21 @@
                        MotionCtgType.SHUTTLE_PALLET_DOWN
                ));
                // 穿梭车提升机待机位 - 到待机位
                // 穿梭车提升机待机位 - 到待机位(自动选择合适待机位)
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoFrom);
                            dto.setLocNo(conveyLocNo);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(shuttleFromLiftStandbyLoc);
                            dto.setSync(0);//异步执行
                            dto.setReleaseShuttle(1);//执行完成后释放穿梭车
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(standbyLocNoList);
//                            dto.setSync(0);//异步执行
                            dto.setReleaseShuttle(1);//执行完成后释放小车
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                        MotionCtgType.SHUTTLE_MOVE_STANDBY
                ));
                // 提升机载货移动
                motionList.addAll(kernelService.liftMoveGoods(
                        MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(task.getOriginLoc()));
                            dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//起始站点
                        }))
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(1);//光泰1层是输送线层
                            dto.setStaNo(31001);//出库站点
                            dto.setDevpNo(basConveyorStaOrigin.getConveyorDeviceId().intValue());
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        }))
                ));
                // 输送线运输至出库口
//                motionList.addAll(kernelService.conveyorOutbound(
//                        MotionDto.build((dto -> {
//                            dto.setDevpNo(basConveyorPath.getDeviceId().intValue());
//                            dto.setStaNo(basConveyorPath.getDeviceStn());
//                        })),
//                        MotionDto.build((dto -> {
//                            dto.setDevpNo(basConveyorPath.getDeviceId().intValue());
//                            dto.setStaNo(basConveyorPath.getStnNo());
//                        })),
//                        MotionCtgType.CONVEYOR_OUTBOUND
//                ));
            }
@@ -860,7 +697,6 @@
        return motionList;
    }
    /**
     * 生成充电动作
@@ -894,51 +730,12 @@
        String shuttleLocNo = shuttleProtocol.getCurrentLocNo();
        //获取距离目标位置最近的空闲可换层提升机
        LiftThread liftThread = liftDispatcher.searchIdleLift(shuttleLocNo, task.getHostId(), true);
        if (liftThread == null) {
            return motionList;
        }
        Device transferLiftDevice = liftThread.getDevice();
        LiftProtocol liftProtocol = liftThread.getStatus();
        if (liftProtocol == null || liftProtocol.getLiftNo() == null) {
            return motionList;
        }
        //检测穿梭车是否有任务绑定
        boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo());
        if (shuttleResult) {
            //存在任务,禁止解析
            return motionList;
        }
        //获取小车待机库位 ==> 进提升机
        ShuttleStandby shuttleStandbyTo = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId())
                .eq(ShuttleStandby::getDeviceLev, Utils.getLev(shuttleLocNo))
                .eq(ShuttleStandby::getStatus, 1));
        //获取小车待机库位 ==> 出提升机
        ShuttleStandby shuttleStandbyFrom = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId())
                .eq(ShuttleStandby::getDeviceLev, Utils.getLev(chargeLocNo))
                .eq(ShuttleStandby::getStatus, 1));
        if (shuttleStandbyTo == null || shuttleStandbyFrom == null) {
            return motionList;
        }
        //穿梭车进提升机库位号
        String liftLocNoTo = shuttleStandbyTo.getDeviceLoc();
        //穿梭车出提升机库位号
        String liftLocNoFrom = shuttleStandbyFrom.getDeviceLoc();
        //穿梭车进提升机待机位库位号
        String standbyLocNoTo = shuttleStandbyTo.getDeviceStandbyLoc();
        //穿梭车出提升机待机位库位号
        String standbyLocNoFrom = shuttleStandbyFrom.getDeviceStandbyLoc();
        // 判断穿梭车是否在充电层
        if (Utils.getLev(shuttleLocNo) == Utils.getLev(chargeLocNo)) {
@@ -951,124 +748,7 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(chargeLocNo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
            ));
        } else {
            // 穿梭车走行至提升机待机位
            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(standbyLocNoTo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
            ));
            // 提升机空载移动到穿梭车层
            motionList.addAll(kernelService.liftMove(
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                        dto.setLev(Utils.getLev(shuttleLocNo));
                    }))
            ));
            // 锁定提升机
            motionList.addAll(kernelService.liftLock(
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                    }))
            ));
            // 穿梭车提升机待机位至提升机
            motionList.addAll(kernelService.shuttleMove(
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(standbyLocNoTo);
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                        dto.setLocNo(liftLocNoTo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE_TO_LIFT
            ));
            // 解锁提升机
            motionList.addAll(kernelService.liftUnlock(
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                    }))
            ));
            // 提升机搬车 至 充电层
            motionList.addAll(kernelService.liftMoveShuttle(
                    MotionDto.build((dto -> {
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                        dto.setLev(Utils.getLev(shuttleLocNo));
                    })),
                    MotionDto.build((dto -> {
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                        dto.setLev(Utils.getLev(chargeLocNo));
                    }))
            ));
            // 锁定提升机
            motionList.addAll(kernelService.liftLock(
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                    }))
            ));
            // 更新小车坐标
            motionList.addAll(kernelService.shuttleUpdateLocation(
                    null
                    , MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(liftLocNoFrom);
                    }))
            ));
            // 穿梭车提升机至提升机待机位
            motionList.addAll(kernelService.shuttleMove(
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                        dto.setLocNo(liftLocNoFrom);
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(standbyLocNoFrom);
                    })),
                    MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
            ));
            // 解锁提升机
            motionList.addAll(kernelService.liftUnlock(
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                    }))
            ));
            // 穿梭车提升机待机位至充电位
            motionList.addAll(kernelService.shuttleMove(
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(standbyLocNoFrom);
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLocNo(chargeLocNo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
@@ -1137,6 +817,7 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLocNo(locNo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
@@ -1177,7 +858,7 @@
            return motionList;
        }
        String shuttleLocNo = shuttleProtocol.getCurrentLocNo();
        String shuttleLocNo = task.getOriginLoc();
        // 判断穿梭车是否在目标层
        if (Utils.getLev(shuttleLocNo) == Utils.getLev(locNo)) {
@@ -1191,6 +872,7 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(locNo);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
@@ -1231,6 +913,7 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLiftNo(liftDevice.getId().intValue());
                        dto.setLocNo(standbyLocNoTo);
                    })),
@@ -1271,6 +954,7 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLiftNo(liftDevice.getId().intValue());
                        dto.setLocNo(liftLocNoTo);
                    })),
@@ -1323,6 +1007,7 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLocNo(standbyLocNoFrom);
                    })),
                    MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
@@ -1354,6 +1039,7 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLocNo(locNo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
@@ -1409,6 +1095,7 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(device.getId().intValue());
                            dto.setShuttleDevice(device);
                            dto.setLocNo(targetLoc);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
@@ -1461,6 +1148,7 @@
                            })),
                            MotionDto.build((dto -> {
                                dto.setShuttleNo(device.getId().intValue());
                                dto.setShuttleDevice(device);
                                dto.setLocNo(sourceLoc);
                            })),
                            MotionCtgType.SHUTTLE_MOVE
@@ -1482,6 +1170,7 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(device.getId().intValue());
                            dto.setShuttleDevice(device);
                            dto.setLocNo(targetLoc);
                        })),
                        MotionCtgType.SHUTTLE_TRANSPORT
@@ -1522,12 +1211,13 @@
        if (destSite.equals("move")) {
            //提升机升降楼层
            Integer liftLevLogic = liftDispatcher.getLiftLevOffset(device.getId().intValue(), Integer.parseInt(task.getDestLoc()));
            // 提升机空载移动到穿梭车层
            motionList.addAll(kernelService.liftMove(
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(device.getId().intValue());
                        dto.setLev(Integer.parseInt(task.getDestLoc()));
                        dto.setLev(liftLevLogic);
                    }))
            ));
@@ -1539,19 +1229,23 @@
                return motionList;
            }
            Integer originLev = liftDispatcher.getLiftLevOffset(device.getId().intValue(), Utils.getLev(basConveyorStaOrigin.getLocNo()));
            Integer targetLev = liftDispatcher.getLiftLevOffset(device.getId().intValue(), Utils.getLev(basConveyorStaDest.getLocNo()));
            // 提升机移动托盘
            motionList.addAll(kernelService.liftMoveGoods(
                    MotionDto.build((dto -> {
                        dto.setLiftNo(device.getId().intValue());
                        dto.setLev(Utils.getLev(basConveyorStaOrigin.getLocNo()));
                        dto.setLev(originLev);
                        dto.setStaNo(Integer.parseInt(task.getOriginSite()));
                    }))
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(device.getId().intValue());
                        dto.setLev(Utils.getLev(basConveyorStaDest.getLocNo()));
                        dto.setLev(targetLev);
                        dto.setDevpNo(basConveyorStaDest.getConveyorDeviceId().intValue());
                        dto.setStaNo(Integer.parseInt(task.getDestSite()));
                    }))
                    })),
                    MotionCtgType.LIFT_WITH_GOODS
            ));
        } else if (destSite.equals("lock")) {
@@ -1575,4 +1269,340 @@
        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();
        // 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();
        //获取距离目标位置最近的空闲可换层提升机
        LiftThread liftThread = liftDispatcher.searchIdleLift(shuttleLocNo, task.getHostId(), true);
        if (liftThread == null) {
            return motionList;
        }
        Device transferLiftDevice = liftThread.getDevice();
        LiftProtocol liftProtocol = liftThread.getStatus();
        if (liftProtocol == null || liftProtocol.getLiftNo() == null) {
            return motionList;
        }
        //检测穿梭车是否有任务绑定
        boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo());
        if (shuttleResult) {
            //存在任务,禁止解析
            return motionList;
        }
        //获取小车待机库位 ==> 进提升机
        ShuttleStandby shuttleStandbyTo = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId())
                .eq(ShuttleStandby::getDeviceLev, Utils.getLev(shuttleLocNo))
                .eq(ShuttleStandby::getStatus, 1));
        //获取小车待机库位 ==> 出提升机
        ShuttleStandby shuttleStandbyFrom = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId())
                .eq(ShuttleStandby::getDeviceLev, Utils.getLev(originLoc))
                .eq(ShuttleStandby::getStatus, 1));
        if (shuttleStandbyTo == null || shuttleStandbyFrom == null) {
            return motionList;
        }
        //穿梭车进提升机库位号
        String liftLocNoTo = shuttleStandbyTo.getDeviceLoc();
        //穿梭车出提升机库位号
        String liftLocNoFrom = shuttleStandbyFrom.getDeviceLoc();
        //穿梭车进提升机待机位库位号 输送线位置
        String standbyLocNoTo = shuttleStandbyTo.getDeviceStandbyLoc();
        //穿梭车换层时待机位置 使用表列 memo数据
        String standbyLocNoMemo = shuttleStandbyTo.getMemo();
        //穿梭车出提升机待机位库位号
        String standbyLocNoFrom = shuttleStandbyFrom.getDeviceStandbyLoc();
        //穿梭车出提升机后全部待机位
        String standbyLocs = shuttleStandbyFrom.getStandbyLoc();//获取全部待机位
        //换层需要锁定的路径
        List<String> lockPath = shuttleStandbyFrom.getLockPath$();
        //获取出库任务类型
        TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>()
                .eq(TaskCtg::getFlag, String.valueOf(TaskCtgType.MOVE))
                .eq(TaskCtg::getStatus, 1));
        if (taskCtg == null) {
            return motionList;
        }
        /**
         * 出库
         */
        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
            ));
            // 穿梭车走行至目标库位
            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(locNo);
                    })),
                    MotionCtgType.SHUTTLE_TRANSPORT
            ));
            // 穿梭车出库托盘下降
            motionList.addAll(kernelService.shuttleAction(
                    null,
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                    })),
                    MotionCtgType.SHUTTLE_PALLET_DOWN
            ));
            /**
             * 二、出库起始层没有穿梭车
             */
        } else {
            // 穿梭车走行至提升机库位待机位
            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.setLiftNo(transferLiftDevice.getId().intValue());
                        dto.setLocNo(standbyLocNoMemo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
            ));
            // 锁定换层路径
            motionList.addAll(kernelService.mapLockPath(
                    null,
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(JSON.toJSONString(lockPath));
                    }))
            ));
            // 提升机空载移动到穿梭车层
            motionList.addAll(kernelService.liftMove(
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                        dto.setLev(Utils.getLev(shuttleLocNo));
                    }))
            ));
            // 锁定提升机
            motionList.addAll(kernelService.liftLock(
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                    }))
            ));
            // 穿梭车待机位至提升机
            motionList.addAll(kernelService.shuttleMove(
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(standbyLocNoMemo);
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                        dto.setLocNo(liftLocNoTo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE_TO_LIFT
            ));
            // 解锁提升机
            motionList.addAll(kernelService.liftUnlock(
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                    }))
            ));
            // 提升机搬车 至 目标位置层
            motionList.addAll(kernelService.liftMoveShuttle(
                    MotionDto.build((dto -> {
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                        dto.setLev(Utils.getLev(shuttleLocNo));
                    })),
                    MotionDto.build((dto -> {
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                        dto.setLev(Utils.getLev(liftLocNoFrom));
                    }))
            ));
            // 锁定提升机
            motionList.addAll(kernelService.liftLock(
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                    }))
            ));
            // 更新小车坐标
            motionList.addAll(kernelService.shuttleUpdateLocation(
                    null
                    , MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(liftLocNoFrom);
                    }))
            ));
            // 穿梭车走行至提升机待机位
            motionList.addAll(kernelService.shuttleMove(
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                        dto.setLocNo(liftLocNoFrom);
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLocNo(standbyLocNoFrom);
                    })),
                    MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
            ));
            // 解锁提升机
            motionList.addAll(kernelService.liftUnlock(
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                        dto.setReleaseLift(1);//执行完成后释放提升机
                    }))
            ));
            // 解锁换层路径
            motionList.addAll(kernelService.mapUnlockPath(
                    null,
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(JSON.toJSONString(lockPath));
                    }))
            ));
            // 穿梭车提升机待机位至出库库位
            motionList.addAll(kernelService.shuttleMove(
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                        dto.setLocNo(standbyLocNoFrom);
                    })),
                    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
            ));
            // 穿梭车走行至目标库位
            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(locNo);
                    })),
                    MotionCtgType.SHUTTLE_TRANSPORT
            ));
            // 穿梭车出库托盘下降
            motionList.addAll(kernelService.shuttleAction(
                    null,
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                    })),
                    MotionCtgType.SHUTTLE_PALLET_DOWN
            ));
        }
        return motionList;
    }
}