#
whycq
2024-07-15 b058b8c8be2267c2a0ba4e3916871ede64f53c47
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
@@ -1,8 +1,6 @@
package com.zy.asrs.wcs.core.kernel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.R;
import com.zy.asrs.wcs.core.domain.dto.MotionDto;
import com.zy.asrs.wcs.core.entity.*;
import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
@@ -54,6 +52,10 @@
    @Autowired
    private BasConveyorPathService basConveyorPathService;
    @Autowired
    private BasConveyorStaService basConveyorStaService;
    @Autowired
    private BasConveyorService basConveyorService;
    @Autowired
    private TaskCtgService taskCtgService;
    public List<Motion> generateMotion(Task task) {
@@ -67,12 +69,6 @@
        /**
         * 入库
         * 一、入库目标层有穿梭车
         * 1.提升机升降到源层
         * 2.货物从输送线到提升机
         * 3.提升机载货移动(非必需)
         * 4.穿梭车走行至提升机
         * 5.穿梭车入库至目标库位
         */
        if (task.getTaskSts() == TaskStsType.NEW_INBOUND.sts) {
            // locNo
@@ -117,13 +113,6 @@
                return motionList;
            }
            //检测提升机是否有任务绑定
            boolean liftResult = Utils.checkLiftHasBinding(Integer.parseInt(transferLiftDevice.getDeviceNo()));
            if (liftResult) {
                //存在任务,禁止解析
                return motionList;
            }
            //获取小车待机库位 ==> 进提升机
            ShuttleStandby shuttleStandbyTo = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                    .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId())
@@ -158,13 +147,14 @@
                motionList.addAll(kernelService.liftMoveGoods(
                        MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(5);//索牌项目5层是输送线层
                            dto.setStaNo(1);//提升机左侧
                            dto.setLev(1);//光泰1层是输送线层
                            dto.setStaNo(31004);//入库站点
                        }))
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(task.getDestLoc()));
                            dto.setStaNo(0);//提升机内侧
                            dto.setStaNo(Integer.parseInt(task.getDestSite()));
                            dto.setSync(0);//异步执行
                        }))
                ));
@@ -176,32 +166,9 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 锁定提升机
                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
                ));
                // 穿梭车入库顶升
@@ -211,28 +178,6 @@
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                        })),
                        MotionCtgType.SHUTTLE_PALLET_LIFT
                ));
                // 穿梭车入库移动至提升机待机位
                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());
                        }))
                ));
                // 穿梭车走行至目标库位
@@ -260,14 +205,22 @@
            /**
             * 二、入库目标层没有穿梭车
             * 1.提升机升降到穿梭车层
             * 2.穿梭车走行至提升机待机位
             * 3.提升机搬运穿梭车至目标层
             * 4.货物从输送线到提升机
             * 5.提升机载车与货移动(非必需)
             * 6.穿梭车入库至目标库位
             */
            } 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(Integer.parseInt(task.getDestSite()));
                        }))
                ));
                // 穿梭车走行至提升机库位待机位
                motionList.addAll(kernelService.shuttleMove(
@@ -322,17 +275,15 @@
                        }))
                ));
                // 提升机载货移动
                motionList.addAll(kernelService.liftMoveGoods(
                // 提升机搬车 至 目标位置层
                motionList.addAll(kernelService.liftMoveShuttle(
                        MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(5);//索牌项目5层是输送线层
                            dto.setStaNo(1);//提升机左侧
                        }))
                        , MotionDto.build((dto -> {
                            dto.setLev(Utils.getLev(shuttleLocNo));
                        })),
                        MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(task.getDestLoc()));
                            dto.setStaNo(0);//提升机内侧
                            dto.setLev(Utils.getLev(destLoc));
                        }))
                ));
@@ -344,15 +295,6 @@
                        }))
                ));
                // 穿梭车入库顶升
                motionList.addAll(kernelService.shuttleAction(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                        })),
                        MotionCtgType.SHUTTLE_PALLET_LIFT
                ));
                // 更新小车坐标
                motionList.addAll(kernelService.shuttleUpdateLocation(
                        null
@@ -362,7 +304,7 @@
                        }))
                ));
                // 穿梭车入库移动至提升机待机位
                // 穿梭车移动至提升机待机位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
@@ -381,7 +323,17 @@
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        }))
                ));
                // 穿梭车入库顶升
                motionList.addAll(kernelService.shuttleAction(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                        })),
                        MotionCtgType.SHUTTLE_PALLET_LIFT
                ));
                // 穿梭车走行至目标库位
@@ -457,13 +409,6 @@
                return motionList;
            }
            //检测提升机是否有任务绑定
            boolean liftResult = Utils.checkLiftHasBinding(Integer.parseInt(transferLiftDevice.getDeviceNo()));
            if (liftResult) {
                //存在任务,禁止解析
                return motionList;
            }
            //获取小车待机库位 ==> 进提升机
            ShuttleStandby shuttleStandbyTo = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                    .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId())
@@ -512,13 +457,6 @@
            /**
             * 出库
             * 一、出库起始层有穿梭车
             * 1.穿梭车走行至出库库位
             * 2.提升机到出库起始层
             * 3.穿梭车出库至提升机
             * 4.穿梭车离开提升机
             * 5.提升机载货移动(非必需)
             * 6.输送线运输至出库口
             */
            if (Utils.getLev(shuttleLocNo) == Utils.getLev(originLoc)) {
@@ -561,37 +499,6 @@
                        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.shuttleAction(
                        null,
@@ -601,39 +508,19 @@
                        MotionCtgType.SHUTTLE_PALLET_DOWN
                ));
                // 穿梭车离开提升机 - 到提升机待机位
                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.liftMoveGoods(
                        MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(task.getOriginLoc()));
                            dto.setStaNo(0);//提升机内侧
                            dto.setStaNo(Integer.parseInt(task.getOriginSite()));//起始站点
                        }))
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(5);//索牌项目5层是输送线层
                            dto.setStaNo(1);//提升机左侧
                            dto.setLev(1);//光泰1层是输送线层
                            dto.setStaNo(31004);//出库站点
                            dto.setSync(0);//异步执行
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        }))
                ));
@@ -665,16 +552,6 @@
            /**
             * 二、出库起始层没有穿梭车
             *
             * 1.提升机到穿梭车层
             * 2.穿梭车走行至提升机
             * 3.提升机载车至出库起始层
             * 4.穿梭车走行至出库库位
             * 5.穿梭车出库至提升机
             * 6.穿梭车离开提升机
             * 7.提升机载货移动(非必需)
             * 8.输送线运输至出库口
             *
             */
            } else {
@@ -779,6 +656,7 @@
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        }))
                ));
@@ -814,40 +692,9 @@
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                            dto.setLocNo(standbyLocNoFrom);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 提升机空载移动到穿梭车层
                motionList.addAll(kernelService.liftMove(
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(shuttleLocNo));
                        }))
                ));
                // 锁定提升机
                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
                ));
                // 穿梭车出库托盘下降
@@ -859,39 +706,19 @@
                        MotionCtgType.SHUTTLE_PALLET_DOWN
                ));
                // 穿梭车离开提升机 - 到提升机待机位
                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.liftMoveGoods(
                        MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(task.getOriginLoc()));
                            dto.setStaNo(0);//提升机内侧
                            dto.setStaNo(Integer.parseInt(task.getOriginSite()));//起始站点
                        }))
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(5);//索牌项目5层是输送线层
                            dto.setStaNo(1);//提升机左侧
                            dto.setLev(1);//光泰1层是输送线层
                            dto.setStaNo(31004);//出库站点
                            dto.setSync(0);//异步执行
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        }))
                ));
@@ -976,13 +803,6 @@
        //检测穿梭车是否有任务绑定
        boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo());
        if (shuttleResult) {
            //存在任务,禁止解析
            return motionList;
        }
        //检测提升机是否有任务绑定
        boolean liftResult = Utils.checkLiftHasBinding(Integer.parseInt(transferLiftDevice.getDeviceNo()));
        if (liftResult) {
            //存在任务,禁止解析
            return motionList;
        }
@@ -1148,16 +968,15 @@
                    MotionCtgType.SHUTTLE_MOVE
            ));
            task.setLiftNo(Integer.parseInt(transferLiftDevice.getDeviceNo()));
            taskService.updateById(task);
        }
        // 穿梭车开始充电
        motionList.addAll(kernelService.shuttleCharge(
        motionList.addAll(kernelService.shuttleAction(
                null,
                MotionDto.build((dto -> {
                    dto.setShuttleNo(shuttleDevice.getId().intValue());
                }))
                })),
                MotionCtgType.SHUTTLE_CHARGE_ON
        ));
        return motionList;
@@ -1194,6 +1013,15 @@
        // 判断穿梭车是否在目标层
        if (Utils.getLev(shuttleLocNo) == Utils.getLev(locNo)) {
            // 穿梭车关闭充电
            motionList.addAll(kernelService.shuttleAction(
                    null,
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                    })),
                    MotionCtgType.SHUTTLE_CHARGE_OFF
            ));
            // 穿梭车走行至目标库位
            motionList.addAll(kernelService.shuttleMove(
@@ -1331,14 +1159,6 @@
                    MotionCtgType.SHUTTLE_MOVE_TO_LIFT
            ));
            // 向提升机发送小车已到位信号
            motionList.addAll(kernelService.liftShuttleArrival(
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(liftDevice.getId().intValue());
                    }))
            ));
            // 解锁提升机
            motionList.addAll(kernelService.liftUnlock(
                    null
@@ -1427,7 +1247,7 @@
        String sourceLoc = task.getOriginLoc();//源库位
        String targetLoc = task.getDestLoc();//任务目标(借用字段)
        String targetSite = task.getDestSite();//任务类型(借用字段)
        String targetSite = task.getMemo();//任务类型(借用字段)
        Device device = deviceService.getOne(new LambdaQueryWrapper<Device>()
                .eq(Device::getDeviceNo, task.getShuttleNo())
@@ -1571,7 +1391,8 @@
            return motionList;
        }
        if (task.getDestSite().equals("move")) {
        String destSite = task.getMemo();//任务目标(借用字段)
        if (destSite.equals("move")) {
            //提升机升降楼层
            // 提升机空载移动到穿梭车层
@@ -1583,23 +1404,45 @@
                    }))
            ));
        } else if (task.getDestSite().equals("movePallet")) {
        } else if (destSite.equals("movePallet")) {
            //移动托盘
            BasConveyorSta basConveyorStaOrigin = basConveyorStaService.selectBySiteNo(task.getOriginSite());
            BasConveyorSta basConveyorStaDest = basConveyorStaService.selectBySiteNo(task.getDestSite());
            if(basConveyorStaOrigin == null || basConveyorStaDest == null) {
                return motionList;
            }
            // 提升机移动托盘
            motionList.addAll(kernelService.liftMoveGoods(
                    MotionDto.build((dto -> {
                        dto.setLiftNo(device.getId().intValue());
                        dto.setLev(Integer.parseInt(task.getOriginLoc()));
                        dto.setLev(Utils.getLev(basConveyorStaOrigin.getLocNo()));
                        dto.setStaNo(Integer.parseInt(task.getOriginSite()));
                    }))
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(device.getId().intValue());
                        dto.setLev(Integer.parseInt(task.getDestLoc()));
                        dto.setLev(Utils.getLev(basConveyorStaDest.getLocNo()));
                        dto.setDevpNo(basConveyorStaDest.getConveyorDeviceId().intValue());
                        dto.setStaNo(Integer.parseInt(task.getDestSite()));
                    }))
            ));
        } else if (destSite.equals("lock")) {
            // 锁定提升机
            motionList.addAll(kernelService.liftLock(
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(device.getId().intValue());
                    }))
            ));
        } else if (destSite.equals("unlock")) {
            // 解锁提升机
            motionList.addAll(kernelService.liftUnlock(
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(device.getId().intValue());
                    }))
            ));
        }
        return motionList;