#
zjj
2024-06-22 090b09847dc5317c2252c277fa39647e7e787988
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
@@ -2,25 +2,23 @@
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.ShuttleStandby;
import com.zy.asrs.wcs.core.entity.Task;
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.service.ShuttleStandbyService;
import com.zy.asrs.wcs.core.service.TaskService;
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.rcs.cache.SlaveConnection;
import com.zy.asrs.wcs.core.entity.Motion;
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.core.service.MotionService;
import com.zy.asrs.wcs.rcs.service.DeviceService;
import com.zy.asrs.wcs.rcs.thread.LiftThread;
import com.zy.asrs.wcs.rcs.thread.ShuttleThread;
@@ -53,6 +51,10 @@
    private DeviceService deviceService;
    @Autowired
    private ShuttleStandbyService shuttleStandbyService;
    @Autowired
    private BasConveyorPathService basConveyorPathService;
    @Autowired
    private TaskCtgService taskCtgService;
    public List<Motion> generateMotion(Task task) {
        List<Motion> motionList = new ArrayList<>();
@@ -492,6 +494,22 @@
            //穿梭车出提升机后小车待机位
            String shuttleFromLiftStandbyLoc = shuttleStandbyFrom.getStandbyLoc();
            //获取出库任务类型
            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;
            }
            /**
             * 出库
             * 一、出库起始层有穿梭车
@@ -616,6 +634,7 @@
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(5);//索牌项目5层是输送线层
                            dto.setStaNo(1);//提升机左侧
                            dto.setSync(0);//异步执行
                        }))
                ));
@@ -630,6 +649,19 @@
                            dto.setLocNo(shuttleFromLiftStandbyLoc);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 输送线运输至出库口
                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
                ));
            /**
@@ -783,17 +815,17 @@
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                            dto.setLocNo(standbyLocNoFrom);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 提升机空载移动到穿梭车层
                // 提升机空载移动到目标层
                motionList.addAll(kernelService.liftMove(
                        null
                        , MotionDto.build((dto -> {
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(shuttleLocNo));
                            dto.setLev(Utils.getLev(originLoc));
                        }))
                ));
@@ -809,12 +841,12 @@
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLocNo(standbyLocNoTo);
                            dto.setLocNo(standbyLocNoFrom);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleDevice.getId().intValue());
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLocNo(liftLocNoTo);
                            dto.setLocNo(liftLocNoFrom);
                        })),
                        MotionCtgType.SHUTTLE_MOVE_TO_LIFT
                ));
@@ -861,6 +893,7 @@
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(5);//索牌项目5层是输送线层
                            dto.setStaNo(1);//提升机左侧
                            dto.setSync(0);//异步执行
                        }))
                ));
@@ -875,6 +908,19 @@
                            dto.setLocNo(shuttleFromLiftStandbyLoc);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
                // 输送线运输至出库口
                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
                ));
            }
@@ -1109,11 +1155,12 @@
        }
        // 穿梭车开始充电
        motionList.addAll(kernelService.shuttleCharge(
        motionList.addAll(kernelService.shuttleAction(
                null,
                MotionDto.build((dto -> {
                    dto.setShuttleNo(shuttleDevice.getId().intValue());
                }))
                })),
                MotionCtgType.SHUTTLE_CHARGE_ON
        ));
        return motionList;
@@ -1151,6 +1198,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(
                    MotionDto.build((dto -> {