#
Junjie
2024-04-23 2d07710d47f88a1d76e12cda1144cb2f288bf5ae
#
3个文件已修改
216 ■■■■■ 已修改文件
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/ShuttleStandby.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/LiftDispatcher.java 102 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/entity/ShuttleStandby.java
@@ -132,9 +132,9 @@
    private String deviceStandbyLoc;
    /**
     * 待机位库位号
     * 小车待机位库位号
     */
    @ApiModelProperty(value= "待机位库位号")
    @ApiModelProperty(value= "小车待机位库位号")
    private String standbyLoc;
    public ShuttleStandby() {}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
@@ -972,16 +972,16 @@
        // locNo
        String locNo = task.getDestLoc();
        Device device = deviceService.getOne(new LambdaQueryWrapper<Device>()
        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 (device == null) {
        if (shuttleDevice == null) {
            return motionList;
        }
        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleDevice.getId().intValue());
        if (shuttleThread == null) {
            return motionList;
        }
@@ -999,11 +999,111 @@
            // 穿梭车走行至目标库位
            motionList.addAll(kernelService.shuttleMove(
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(device.getId().intValue());
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(shuttleLocNo);
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(device.getId().intValue());
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(locNo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
            ));
        } else {
            //小车跨层
            //获取距离目标位置最近的空闲提升机
            LiftThread liftThread = liftDispatcher.searchIdleLift(locNo, task.getHostId());
            if (liftThread == null) {
                return motionList;
            }
            Device liftDevice = liftThread.getDevice();
            //穿梭车到提升机库位号
            String liftLocNoTo = liftDispatcher.getLiftLocNo(liftThread, Utils.getLev(shuttleLocNo));
            //穿梭车出提升机库位号
            String liftLocNoFrom = liftDispatcher.getLiftLocNo(liftThread, Utils.getLev(task.getDestLoc()));
            //穿梭车到提升机待机位库位号
            String standbyLocNoTo = liftDispatcher.getLiftStandByLocNo(liftThread, Utils.getLev(shuttleLocNo));
            //穿梭车出提升机待机位库位号
            String standbyLocNoFrom = liftDispatcher.getLiftStandByLocNo(liftThread, Utils.getLev(task.getDestLoc()));
            // 穿梭车走行至提升机库位待机位
            motionList.addAll(kernelService.shuttleMove(
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(shuttleLocNo);
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLiftNo(liftDevice.getId().intValue());
                        dto.setLocNo(standbyLocNoTo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
            ));
            // 提升机空载移动到穿梭车层
            motionList.addAll(kernelService.liftMove(
                    null
                    , MotionDto.build((dto -> {
                        dto.setLiftNo(liftDevice.getId().intValue());
                        dto.setLev(Utils.getLev(shuttleLocNo));
                    }))
            ));
            // 穿梭车待机位至提升机库位
            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(liftDevice.getId().intValue());
                        dto.setLocNo(liftLocNoTo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE_TO_LIFT
            ));
            // 提升机搬车 至 目标位置层
            motionList.addAll(kernelService.liftMoveShuttle(
                    MotionDto.build((dto -> {
                        dto.setLiftNo(liftDevice.getId().intValue());
                        dto.setLev(Utils.getLev(shuttleLocNo));
                    })),
                    MotionDto.build((dto -> {
                        dto.setLiftNo(liftDevice.getId().intValue());
                        dto.setLev(Utils.getLev(locNo));
                    }))
            ));
            // 穿梭车走行至提升机待机位
            motionList.addAll(kernelService.shuttleMove(
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLiftNo(liftDevice.getId().intValue());
                        dto.setLocNo(liftLocNoFrom);
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(standbyLocNoFrom);
                    })),
                    MotionCtgType.SHUTTLE_MOVE_FROM_LIFT
            ));
            // 穿梭车提升机待机位至目标位置
            motionList.addAll(kernelService.shuttleMove(
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLiftNo(liftDevice.getId().intValue());
                        dto.setLocNo(standbyLocNoFrom);
                    })),
                    MotionDto.build((dto -> {
                        dto.setShuttleNo(shuttleDevice.getId().intValue());
                        dto.setLocNo(locNo);
                    })),
                    MotionCtgType.SHUTTLE_MOVE
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/LiftDispatcher.java
@@ -1,10 +1,24 @@
package com.zy.asrs.wcs.core.utils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zy.asrs.wcs.core.entity.BasLift;
import com.zy.asrs.wcs.core.entity.ShuttleStandby;
import com.zy.asrs.wcs.core.model.NavigateNode;
import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
import com.zy.asrs.wcs.core.model.enums.NavigationMapType;
import com.zy.asrs.wcs.core.model.enums.WorkZoneType;
import com.zy.asrs.wcs.core.service.BasLiftService;
import com.zy.asrs.wcs.core.service.ShuttleStandbyService;
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;
import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol;
import com.zy.asrs.wcs.rcs.service.DeviceService;
import com.zy.asrs.wcs.rcs.thread.LiftThread;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created by vincent on 2023/10/16
@@ -12,10 +26,90 @@
@Service
public class LiftDispatcher {
    public LiftThread queryLiftForTransport(String staNo) {
        WorkZoneType zoneType = WorkZoneType.query(staNo);
        LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, zoneType.liftNo);
        return liftThread;
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private BasLiftService basLiftService;
    @Autowired
    private ShuttleStandbyService shuttleStandbyService;
    /**
     * 根据目标位置搜索空闲提升机
     */
    public LiftThread searchIdleLift(String locNo, Long hostId) {
        LiftThread recentLiftThread = null;
        Integer finalDistance = Integer.MAX_VALUE;
        List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>()
                .eq(Device::getDeviceType, DeviceCtgType.LIFT.val())
                .eq(Device::getHostId, hostId)
                .eq(Device::getStatus, 1));
        for (Device device : list) {
            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue());
            if (liftThread == null) {
                continue;
            }
            LiftProtocol liftProtocol = liftThread.getStatus();
            if (liftProtocol == null) {
                continue;
            }
            if (!liftThread.isIdle()) {
                continue;
            }
            ShuttleStandby standby = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                    .eq(ShuttleStandby::getDeviceId, device.getId())
                    .eq(ShuttleStandby::getDeviceLev, Utils.getLev(locNo))
                    .eq(ShuttleStandby::getStatus, 1));
            if (standby == null) {
                continue;
            }
            String liftLocNo = Utils.getLocNo(Utils.getRow(standby.getDeviceStandbyLoc()), Utils.getBay(standby.getDeviceStandbyLoc()), Utils.getLev(locNo));
            List<NavigateNode> nodeList = NavigateUtils.calc(locNo, liftLocNo, NavigationMapType.NONE.id, null);
            Integer originPathAllDistance = NavigateUtils.getOriginPathAllDistance(nodeList);//总距离
            if (originPathAllDistance < finalDistance) {
                finalDistance = originPathAllDistance;
                recentLiftThread = liftThread;
            }
        }
        return recentLiftThread;
    }
    /**
     * 获取提升机位置
     */
    public String getLiftLocNo(LiftThread liftThread, Integer lev) {
        Device device = liftThread.getDevice();
        ShuttleStandby standby = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                .eq(ShuttleStandby::getDeviceId, device.getId())
                .eq(ShuttleStandby::getDeviceLev, lev)
                .eq(ShuttleStandby::getStatus, 1));
        if (standby == null) {
            return null;
        }
        String liftLocNo = Utils.getLocNo(Utils.getRow(standby.getDeviceLoc()), Utils.getBay(standby.getDeviceLoc()), lev);
        return liftLocNo;
    }
    /**
     * 获取提升机待机位位置
     */
    public String getLiftStandByLocNo(LiftThread liftThread, Integer lev) {
        Device device = liftThread.getDevice();
        ShuttleStandby standby = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                .eq(ShuttleStandby::getDeviceId, device.getId())
                .eq(ShuttleStandby::getDeviceLev, lev)
                .eq(ShuttleStandby::getStatus, 1));
        if (standby == null) {
            return null;
        }
        String liftLocNo = Utils.getLocNo(Utils.getRow(standby.getDeviceStandbyLoc()), Utils.getBay(standby.getDeviceStandbyLoc()), lev);
        return liftLocNo;
    }
}