#
Junjie
2024-10-17 d62c5c0eb2e28b7bf27d23de84a609b5a2e415e4
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.手动任务
@@ -156,6 +152,9 @@
            //穿梭车出提升机待机位库位号
            String standbyLocNoFrom = shuttleStandbyFrom.getDeviceStandbyLoc();
            //换层需要锁定的路径
            List<String> lockPath = shuttleStandbyFrom.getLockPath$();
            // 入库目标层有穿梭车
            if (Utils.getLev(shuttleLocNo) == Utils.getLev(task.getDestLoc())) {
@@ -197,7 +196,7 @@
                        MotionCtgType.SHUTTLE_PALLET_LIFT
                ));
                // 穿梭车走行至目标库位
                // 穿梭车载货走行至目标库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
@@ -207,8 +206,9 @@
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(destLoc);
                            dto.setReleaseLift(2);//执行中释放提升机
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                        MotionCtgType.SHUTTLE_TRANSPORT
                ));
                // 穿梭车入库托盘下降
@@ -254,12 +254,12 @@
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 锁定目标楼层穿梭车待机位路径
                // 锁定换层路径
                motionList.addAll(kernelService.mapLockPath(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoFrom);
                            dto.setLocNo(JSON.toJSONString(lockPath));
                        }))
                ));
@@ -354,6 +354,15 @@
                        }))
                ));
                // 解锁换层路径
                motionList.addAll(kernelService.mapUnlockPath(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(JSON.toJSONString(lockPath));
                        }))
                ));
                // 穿梭车入库顶升
                motionList.addAll(kernelService.shuttleAction(
                        null,
@@ -363,7 +372,7 @@
                        MotionCtgType.SHUTTLE_PALLET_LIFT
                ));
                // 穿梭车走行至目标库位
                // 穿梭车载货走行至目标库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
@@ -373,8 +382,9 @@
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(destLoc);
                            dto.setReleaseLift(2);//执行中释放提升机
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                        MotionCtgType.SHUTTLE_TRANSPORT
                ));
                // 穿梭车入库托盘下降
@@ -468,8 +478,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>()
@@ -485,6 +498,12 @@
                    .eq(BasConveyorPath::getTypeNo, taskCtg.getId()));
            if (basConveyorPath == null) {
                return motionList;
            }
            //分析出库路径待机库位
            String lastPathStartLoc = shuttleDispatcher.analyzeOutPathWaitLoc(originLoc, standbyLocNoTo, shuttleDevice);
            if (lastPathStartLoc == null) {
                return motionList;//未分析成功
            }
            /**
@@ -517,7 +536,7 @@
                        MotionCtgType.SHUTTLE_PALLET_LIFT
                ));
                // 穿梭车出库至提升机待机位
                // 穿梭车载货出库至最后一段路径等待
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
@@ -525,10 +544,24 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            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.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                            dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//输送站
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                        MotionCtgType.SHUTTLE_TRANSPORT_TO_CONVEYOR
                ));
                // 穿梭车出库托盘下降
@@ -538,6 +571,21 @@
                            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.setLocNo(standbyLocs);
                            dto.setSync(0);//异步执行
                            dto.setReleaseShuttle(1);//执行完成后释放小车
                        })),
                        MotionCtgType.SHUTTLE_MOVE_STANDBY
                ));
                // 提升机载货移动
@@ -552,22 +600,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
                ));
                // 输送线运输至出库口
@@ -602,12 +636,12 @@
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 锁定目标楼层穿梭车待机位路径
                // 锁定换层路径
                motionList.addAll(kernelService.mapLockPath(
                        null,
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoFrom);
                            dto.setLocNo(JSON.toJSONString(lockPath));
                        }))
                ));
@@ -702,6 +736,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 -> {
@@ -725,7 +768,7 @@
                        MotionCtgType.SHUTTLE_PALLET_LIFT
                ));
                // 穿梭车出库至提升机待机位
                // 穿梭车载货出库至最后一段路径等待
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
@@ -733,10 +776,24 @@
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            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.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoFrom);
                            dto.setStaNo(getStaByLev(Utils.getLev(task.getOriginLoc())));//输送站
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                        MotionCtgType.SHUTTLE_TRANSPORT_TO_CONVEYOR
                ));
                // 穿梭车出库托盘下降
@@ -746,6 +803,21 @@
                            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.setLocNo(standbyLocs);
                            dto.setSync(0);//异步执行
                            dto.setReleaseShuttle(1);//执行完成后释放小车
                        })),
                        MotionCtgType.SHUTTLE_MOVE_STANDBY
                ));
                // 提升机载货移动
@@ -759,23 +831,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
                ));
                // 输送线运输至出库口
@@ -1156,6 +1214,9 @@
            //穿梭车出提升机待机位库位号
            String standbyLocNoFrom = liftDispatcher.getLiftStandByLocNo(liftThread, Utils.getLev(task.getDestLoc()));
            //换层需要锁定的路径
            List<String> lockPath = liftDispatcher.getLockPathByLocNo(liftThread, Utils.getLev(task.getDestLoc()));
            // 穿梭车走行至提升机库位待机位
            motionList.addAll(kernelService.shuttleMove(
@@ -1171,12 +1232,12 @@
                    MotionCtgType.SHUTTLE_MOVE
            ));
            // 锁定目标楼层穿梭车待机位路径
            // 锁定换层路径
            motionList.addAll(kernelService.mapLockPath(
                    null,
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(standbyLocNoFrom);
                        dto.setLocNo(JSON.toJSONString(lockPath));
                    }))
            ));
@@ -1267,6 +1328,15 @@
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(liftDevice.getId().intValue());
                    }))
            ));
            // 解锁换层路径
            motionList.addAll(kernelService.mapUnlockPath(
                    null,
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(JSON.toJSONString(lockPath));
                    }))
            ));
@@ -1399,7 +1469,7 @@
                    motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_LIFT.val());
                }));
                // 穿梭车走行至目标库位
                // 穿梭车载货走行至目标库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(device.getId().intValue());
@@ -1409,7 +1479,7 @@
                            dto.setShuttleNo(device.getId().intValue());
                            dto.setLocNo(targetLoc);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                        MotionCtgType.SHUTTLE_TRANSPORT
                ));
                //托盘下降