#
Junjie
2024-04-09 f84448a10d99a0fa82e71088051e3517637edaa7
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
@@ -4,6 +4,7 @@
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.wcs.core.domain.dto.MotionDto;
import com.zy.asrs.wcs.core.entity.Task;
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.TaskStsType;
import com.zy.asrs.wcs.core.model.enums.WorkZoneType;
@@ -982,6 +983,98 @@
        return motionList;
    }
    /**
     * 生成小车手动动作
     */
    public List<Motion> generateShuttleManualMotion(Task task) {
        List<Motion> motionList = new ArrayList<>();
        if (task.getTaskSts() != TaskStsType.NEW_MANUAL.sts) {
            return motionList;
        }
        String targetLoc = task.getDestLoc();//任务目标(借用字段)
        String targetSite = task.getDestSite();//任务类型(借用字段)
        //获取穿梭车类型
        DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>()
                .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle))
                .eq(DeviceType::getStatus, 1));
        if (deviceType == null) {
            return motionList;
        }
        Device device = deviceService.getOne(new LambdaQueryWrapper<Device>()
                .eq(Device::getDeviceNo, task.getShuttleNo())
                .eq(Device::getDeviceType, deviceType.getId())
                .eq(Device::getHostId, task.getHostId())
                .eq(Device::getStatus, 1));
        if (device == null) {
            return motionList;
        }
        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
        if (shuttleThread == null) {
            return motionList;
        }
        ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
        if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
            return motionList;
        }
        if (targetSite.equals("moveLoc")) {//移动
            String shuttleLocNo = shuttleProtocol.getCurrentLocNo();
            // 判断穿梭车是否在目标层
            if (Utils.getLev(shuttleLocNo) == Utils.getLev(targetLoc)) {
                // 穿梭车走行至目标库位
                motionList.addAll(kernelService.shuttleMove(
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
                            dto.setLocNo(shuttleLocNo);
                        })),
                        MotionDto.build((dto -> {
                            dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue());
                            dto.setLocNo(targetLoc);
                        })),
                        MotionCtgType.SHUTTLE_MOVE
                ));
            }
        } else if (targetSite.equals("palletLift")) {
            //托盘顶升
            motionList.add(Motion.build(motion -> {
                motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val());
                motion.setDevice(String.valueOf(task.getShuttleNo()));
                motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_LIFT.val());
            }));
        } else if (targetSite.equals("palletDown")) {
            //托盘下降
            motionList.add(Motion.build(motion -> {
                motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val());
                motion.setDevice(String.valueOf(task.getShuttleNo()));
                motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_DOWN.val());
            }));
        } else if (targetSite.equals("chargeOpen")) {
            //充电开
            motionList.add(Motion.build(motion -> {
                motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val());
                motion.setDevice(String.valueOf(task.getShuttleNo()));
                motion.setMotionCtg(MotionCtgType.SHUTTLE_CHARGE_ON.val());
            }));
        } else if (targetSite.equals("chargeClose")) {
            //充电关
            motionList.add(Motion.build(motion -> {
                motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val());
                motion.setDevice(String.valueOf(task.getShuttleNo()));
                motion.setMotionCtg(MotionCtgType.SHUTTLE_CHARGE_OFF.val());
            }));
        } else if (targetSite.equals("reset")) {
            //复位
        }
        return motionList;
    }
}