zjj
2025-02-17 4146cd7916dc94b2336e56267824ad14904435f2
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
@@ -1,17 +1,14 @@
package com.zy.asrs.wcs.core.kernel;
import com.alibaba.fastjson.JSON;
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.enums.DeviceCtgType;
import com.zy.asrs.wcs.core.model.enums.MotionCtgType;
import com.zy.asrs.wcs.core.model.enums.TaskCtgType;
import com.zy.asrs.wcs.core.model.enums.TaskStsType;
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.ConveyorDispatcher;
import com.zy.asrs.wcs.core.utils.LiftDispatcher;
import com.zy.asrs.wcs.core.utils.ShuttleDispatcher;
import com.zy.asrs.wcs.core.utils.Utils;
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;
@@ -26,7 +23,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 1.充电任务,2.库位移转,3.小车迁移,4.手动任务
@@ -105,8 +101,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;
            }
@@ -156,24 +152,27 @@
            //穿梭车出提升机待机位库位号
            String standbyLocNoFrom = shuttleStandbyFrom.getDeviceStandbyLoc();
            //换层需要锁定的路径
            List<String> lockPath = shuttleStandbyFrom.getLockPath$();
            // 入库目标层有穿梭车
            if (Utils.getLev(shuttleLocNo) == Utils.getLev(task.getDestLoc())) {
                // 提升机载货移动
                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());
//                            dto.setSync();//异步执行
                        }))
                ));
//                // 提升机载货移动
//                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());
//                            dto.setReleaseLift(1);//执行完成后释放提升机
//                        }))
//                ));
                // 穿梭车走行至提升机库位待机位
                motionList.addAll(kernelService.shuttleMove(
@@ -183,6 +182,7 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(standbyLocNoTo);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
@@ -197,7 +197,7 @@
                        MotionCtgType.SHUTTLE_PALLET_LIFT
                ));
                // 穿梭车走行至目标库位
                // 穿梭车载货走行至目标库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
@@ -205,10 +205,12 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(destLoc);
//                            dto.setReleaseLift(2);//执行中释放提升机
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                        MotionCtgType.SHUTTLE_TRANSPORT
                ));
                // 穿梭车入库托盘下降
@@ -225,20 +227,21 @@
             */
            } 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.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());
//                            dto.setReleaseLift(1);//执行完成后释放提升机
//                        }))
//                ));
                // 穿梭车走行至提升机库位待机位
                motionList.addAll(kernelService.shuttleMove(
@@ -248,10 +251,20 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            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));
                        }))
                ));
                // 提升机空载移动到穿梭车层
@@ -279,6 +292,7 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(liftLocNoTo);
                        })),
@@ -331,6 +345,7 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(standbyLocNoFrom);
                        })),
                        MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
@@ -345,6 +360,15 @@
                        }))
                ));
                // 解锁换层路径
                motionList.addAll(kernelService.mapUnlockPath(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(JSON.toJSONString(lockPath));
                        }))
                ));
                // 穿梭车入库顶升
                motionList.addAll(kernelService.shuttleAction(
                        null,
@@ -354,7 +378,7 @@
                        MotionCtgType.SHUTTLE_PALLET_LIFT
                ));
                // 穿梭车走行至目标库位
                // 穿梭车载货走行至目标库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
@@ -362,10 +386,11 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(destLoc);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                        MotionCtgType.SHUTTLE_TRANSPORT
                ));
                // 穿梭车入库托盘下降
@@ -459,8 +484,11 @@
            //穿梭车出提升机待机位库位号
            String standbyLocNoFrom = shuttleStandbyFrom.getDeviceStandbyLoc();
            //穿梭车出提升机后小车待机位
            String shuttleFromLiftStandbyLoc = shuttleStandbyFrom.getStandbyLoc();
            //穿梭车出提升机后全部待机位
            String standbyLocs = shuttleStandbyFrom.getStandbyLoc();//获取全部待机位
            //换层需要锁定的路径
            List<String> lockPath = shuttleStandbyFrom.getLockPath$();
            //获取出库任务类型
            TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>()
@@ -478,6 +506,12 @@
                return motionList;
            }
            //分析出库路径待机库位
            String lastPathStartLoc = shuttleDispatcher.analyzeOutPathWaitLoc(originLoc, standbyLocNoTo, shuttleDevice);
            if (lastPathStartLoc == null) {
                return motionList;//未分析成功
            }
            /**
             * 出库
             */
@@ -493,6 +527,7 @@
                            })),
                            MotionDto.build((dto -> {
                                dto.setShuttleNo(shuttleDevice.getId().intValue());
                                dto.setShuttleDevice(shuttleDevice);
                                dto.setLocNo(originLoc);
                            })),
                            MotionCtgType.SHUTTLE_MOVE
@@ -508,18 +543,36 @@
                        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(originLoc);
                            dto.setLocNo(lastPathStartLoc);
                        })),
                        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_MOVE
                        MotionCtgType.SHUTTLE_TRANSPORT_TO_CONVEYOR
                ));
                // 穿梭车出库托盘下降
@@ -529,6 +582,22 @@
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                        })),
                        MotionCtgType.SHUTTLE_PALLET_DOWN
                ));
                // 穿梭车提升机待机位 - 到待机位(自动选择合适待机位)
                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(standbyLocs);
                            dto.setSync(0);//异步执行
                            dto.setReleaseShuttle(1);//执行完成后释放小车
                        })),
                        MotionCtgType.SHUTTLE_MOVE_STANDBY
                ));
                // 提升机载货移动
@@ -543,22 +612,8 @@
                            dto.setLev(1);//光泰1层是输送线层
                            dto.setStaNo(31001);//出库站点
                            dto.setDevpNo(basConveyorStaOrigin.getConveyorDeviceId().intValue());
                            dto.setSync(0);//异步执行
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        }))
                ));
                // 穿梭车提升机待机位 - 到待机位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoFrom);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(shuttleFromLiftStandbyLoc);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 输送线运输至出库口
@@ -587,10 +642,20 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            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));
                        }))
                ));
                // 提升机空载移动到穿梭车层
@@ -618,6 +683,7 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(liftLocNoTo);
                        })),
@@ -670,6 +736,7 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(standbyLocNoFrom);
                        })),
                        MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
@@ -684,6 +751,15 @@
                        }))
                ));
                // 解锁换层路径
                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 -> {
@@ -693,6 +769,7 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(originLoc);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
@@ -707,18 +784,36 @@
                        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(originLoc);
                            dto.setLocNo(lastPathStartLoc);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoFrom);
                            dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//输送站
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                        MotionCtgType.SHUTTLE_TRANSPORT_TO_CONVEYOR
                ));
                // 穿梭车出库托盘下降
@@ -728,6 +823,22 @@
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                        })),
                        MotionCtgType.SHUTTLE_PALLET_DOWN
                ));
                // 穿梭车提升机待机位 - 到待机位(自动选择合适待机位)
                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(standbyLocs);
                            dto.setSync(0);//异步执行
                            dto.setReleaseShuttle(1);//执行完成后释放小车
                        })),
                        MotionCtgType.SHUTTLE_MOVE_STANDBY
                ));
                // 提升机载货移动
@@ -741,23 +852,9 @@
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(1);//光泰1层是输送线层
                            dto.setStaNo(31001);//出库站点
                            dto.setSync(0);//异步执行
                            dto.setDevpNo(basConveyorStaOrigin.getConveyorDeviceId().intValue());
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        }))
                ));
                // 穿梭车提升机待机位 - 到待机位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoFrom);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(shuttleFromLiftStandbyLoc);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 输送线运输至出库口
@@ -870,6 +967,7 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLocNo(chargeLocNo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
@@ -885,6 +983,7 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLocNo(standbyLocNoTo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
@@ -915,6 +1014,7 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
                        dto.setLocNo(liftLocNoTo);
                    })),
@@ -967,6 +1067,7 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLocNo(standbyLocNoFrom);
                    })),
                    MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
@@ -988,6 +1089,7 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLocNo(chargeLocNo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
@@ -1056,6 +1158,7 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLocNo(locNo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
@@ -1110,6 +1213,7 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setShuttleDevice(shuttleDevice);
                            dto.setLocNo(locNo);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
@@ -1138,6 +1242,9 @@
            //穿梭车出提升机待机位库位号
            String standbyLocNoFrom = liftDispatcher.getLiftStandByLocNo(liftThread, Utils.getLev(task.getDestLoc()));
            //换层需要锁定的路径
            List<String> lockPath = liftDispatcher.getLockPathByLocNo(liftThread, Utils.getLev(task.getDestLoc()));
            // 穿梭车走行至提升机库位待机位
            motionList.addAll(kernelService.shuttleMove(
@@ -1147,18 +1254,19 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLiftNo(liftDevice.getId().intValue());
                        dto.setLocNo(standbyLocNoTo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
            ));
            // 锁定目标楼层穿梭车待机位路径
            // 锁定换层路径
            motionList.addAll(kernelService.mapLockPath(
                    null,
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(standbyLocNoFrom);
                        dto.setLocNo(JSON.toJSONString(lockPath));
                    }))
            ));
@@ -1187,6 +1295,7 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLiftNo(liftDevice.getId().intValue());
                        dto.setLocNo(liftLocNoTo);
                    })),
@@ -1239,6 +1348,7 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLocNo(standbyLocNoFrom);
                    })),
                    MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
@@ -1252,6 +1362,15 @@
                    }))
            ));
            // 解锁换层路径
            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 -> {
@@ -1261,6 +1380,7 @@
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setShuttleDevice(shuttleDevice);
                        dto.setLocNo(locNo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
@@ -1316,6 +1436,7 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(device.getId().intValue());
                            dto.setShuttleDevice(device);
                            dto.setLocNo(targetLoc);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
@@ -1368,6 +1489,7 @@
                            })),
                            MotionDto.build((dto -> {
                                dto.setShuttleNo(device.getId().intValue());
                                dto.setShuttleDevice(device);
                                dto.setLocNo(sourceLoc);
                            })),
                            MotionCtgType.SHUTTLE_MOVE
@@ -1381,7 +1503,7 @@
                    motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_LIFT.val());
                }));
                // 穿梭车走行至目标库位
                // 穿梭车载货走行至目标库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(device.getId().intValue());
@@ -1389,9 +1511,10 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(device.getId().intValue());
                            dto.setShuttleDevice(device);
                            dto.setLocNo(targetLoc);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                        MotionCtgType.SHUTTLE_TRANSPORT
                ));
                //托盘下降
@@ -1482,4 +1605,396 @@
        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();
        //穿梭车出提升机待机位库位号
        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.OUT))
                .eq(TaskCtg::getStatus, 1));
        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;
        }
        //分析出库路径待机库位
        String lastPathStartLoc = shuttleDispatcher.analyzeOutPathWaitLoc(originLoc, locNo, shuttleDevice);
        if (lastPathStartLoc == 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
            ));
            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.setLiftNo(transferLiftDevice.getId().intValue());
//                        dto.setLocNo(standbyLocNoTo);
//                        dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//输送站
//                    })),
//                    MotionCtgType.SHUTTLE_TRANSPORT_TO_CONVEYOR
//            ));
            // 穿梭车走行至目标库位
            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(locNo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
            ));
            // 穿梭车出库托盘下降
            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(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.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
            ));
            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(locNo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
            ));
            // 穿梭车出库托盘下降
            motionList.addAll(kernelService.shuttleAction(
                    null,
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                    })),
                    MotionCtgType.SHUTTLE_PALLET_DOWN
            ));
        }
        return motionList;
    }
}