#
Junjie
2024-06-19 534cebb8a1a5317161dac9ac8784aea0f1c9e610
#
3个文件已修改
145 ■■■■■ 已修改文件
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java 102 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/Utils.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
@@ -56,12 +56,6 @@
    public List<Motion> generateMotion(Task task) {
        List<Motion> motionList = new ArrayList<>();
//        switch (Objects.requireNonNull(WorkZoneType.query(task.getTaskSts() == TaskStsType.NEW_INBOUND.sts ? task.getOriginSite() : task.getDestSite()))) {
//            case FIRST_ZONE:
//                motionList = this.generateFirstZoneMotion(task);
//                break;
//            default:
//        }
        motionList = this.generateFirstZoneMotion(task);
        return motionList;
    }
@@ -81,21 +75,86 @@
         * 5.穿梭车入库至目标库位
         */
        if (task.getTaskSts() == TaskStsType.NEW_INBOUND.sts) {
//            // lift
//            LiftThread liftThread = liftDispatcher.queryLiftForTransport(task.getOriginSite());
//            LiftProtocol liftProtocol = liftThread.getStatus();
//            if (liftProtocol == null) {
//                return motionList;
//            }
            // locNo
            String destLoc = task.getDestLoc();
            // shuttle
            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 (shuttleDevice == null) {
                return motionList;
            }
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleDevice.getId().intValue());
            ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
            if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
                return motionList;
            }
            if (!shuttleThread.isIdle()) {
                return motionList;
            }
            String shuttleLocNo = shuttleProtocol.getCurrentLocNo();
            //获取距离目标位置最近的空闲可换层提升机
            LiftThread liftThread = liftDispatcher.searchIdleLift(shuttleLocNo, task.getHostId(), true);
            if (liftThread == null) {
                return motionList;
            }
            Device transferLiftDevice = liftThread.getDevice();
            LiftProtocol liftProtocol = liftThread.getStatus();
            if (liftProtocol == null || liftProtocol.getLiftNo() == null) {
                return motionList;
            }
            //检测穿梭车是否有任务绑定
            boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice);
            if (shuttleResult) {
                //存在任务,禁止解析
                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())
                    .eq(ShuttleStandby::getDeviceLev, Utils.getLev(shuttleLocNo))
                    .eq(ShuttleStandby::getStatus, 1));
            //获取小车待机库位 ==> 出提升机
            ShuttleStandby shuttleStandbyFrom = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
                    .eq(ShuttleStandby::getDeviceId, transferLiftDevice.getId())
                    .eq(ShuttleStandby::getDeviceLev, Utils.getLev(destLoc))
                    .eq(ShuttleStandby::getStatus, 1));
            if (shuttleStandbyTo == null || shuttleStandbyFrom == null) {
                return motionList;
            }
            //穿梭车进提升机库位号
            String liftLocNoTo = shuttleStandbyTo.getDeviceLoc();
            //穿梭车出提升机库位号
            String liftLocNoFrom = shuttleStandbyFrom.getDeviceLoc();
            //穿梭车进提升机待机位库位号
            String standbyLocNoTo = shuttleStandbyTo.getDeviceStandbyLoc();
            //穿梭车出提升机待机位库位号
            String standbyLocNoFrom = shuttleStandbyFrom.getDeviceStandbyLoc();
            // shuttle
//            ShuttleThread shuttleThread = shuttleDispatcher.queryShuttleWhichConvenient(task, Integer.parseInt(liftThread.getStatus().getLiftNo()));
//            ShuttleThread shuttleThread = shuttleDispatcher.queryShuttleWhichConvenient(task, 1);
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, 6);
            if (Cools.isEmpty(shuttleThread)) { return motionList; }
            ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
//            String shuttleLocNo = shuttleProtocol.getCurrentLocNo();
            String shuttleLocNo = "0100201";
//            // conveyor
//            DevpSlave devpSlave = conveyorDispatcher.queryByInBound(task.getSourceStaNo());
@@ -747,12 +806,13 @@
        String shuttleLocNo = shuttleProtocol.getCurrentLocNo();
        // lift
        Device transferLiftDevice = Utils.getRecentTransferLift(shuttleLocNo, shuttleProtocol.getShuttleNo());
        if (transferLiftDevice == null) {
        //获取距离目标位置最近的空闲可换层提升机
        LiftThread liftThread = liftDispatcher.searchIdleLift(shuttleLocNo, task.getHostId(), true);
        if (liftThread == null) {
            return motionList;
        }
        LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, transferLiftDevice.getId().intValue());
        Device transferLiftDevice = liftThread.getDevice();
        LiftProtocol liftProtocol = liftThread.getStatus();
        if (liftProtocol == null || liftProtocol.getLiftNo() == null) {
            return motionList;
@@ -853,7 +913,7 @@
                    MotionCtgType.SHUTTLE_MOVE_TO_LIFT
            ));
            // 提升机搬车 至 输送线层
            // 提升机搬车 至 充电层
            motionList.addAll(kernelService.liftMoveShuttle(
                    MotionDto.build((dto -> {
                        dto.setLiftNo(transferLiftDevice.getId().intValue());
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java
@@ -20,6 +20,7 @@
import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol;
import com.zy.asrs.wcs.rcs.service.DeviceService;
import com.zy.asrs.wcs.rcs.thread.LiftThread;
import com.zy.asrs.wcs.rcs.thread.ShuttleThread;
import com.zy.asrs.wcs.system.entity.Dict;
import com.zy.asrs.wcs.system.service.DictService;
@@ -126,10 +127,12 @@
                    continue;
                }
                Device recentTransferLift = Utils.getRecentTransferLift(locNo, Integer.parseInt(device.getDeviceNo()));
                if (recentTransferLift == null) {
                //获取距离目标位置最近的空闲可换层提升机
                LiftThread liftThread = liftDispatcher.searchIdleLift(locNo, task.getHostId(), true);
                if (liftThread == null) {
                    continue;
                }
                Device recentTransferLift = liftThread.getDevice();
                //获取小车楼层提升机待机位
                ShuttleStandby shuttleStandby = shuttleStandbyService.getOne(new LambdaQueryWrapper<ShuttleStandby>()
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/Utils.java
@@ -207,40 +207,4 @@
        return true;//有任务绑定
    }
    /**
     * 获取距离目标库位最近的提升机
     */
    public static Device getRecentTransferLift(String locNo, Integer shuttleNo) {
        BasLiftService basLiftService = SpringUtils.getBean(BasLiftService.class);
        DeviceService deviceService = SpringUtils.getBean(DeviceService.class);
        if (basLiftService == null) {
            return null;
        }
        Integer distance = Integer.MAX_VALUE;
        Long liftDeviceId = null;
        for (BasLift basLift : basLiftService.list(new LambdaQueryWrapper<BasLift>()
                .eq(BasLift::getStatus, 1)
                .eq(BasLift::getTransfer, 1))) {
            int lev = Utils.getLev(locNo);
            String liftLocNo = Utils.getLocNo(basLift.getRow(), basLift.getBay(), lev);
            List<NavigateNode> nodeList = NavigateUtils.calc(locNo, liftLocNo, NavigationMapType.NONE.id, Utils.getShuttlePoints(shuttleNo, Utils.getLev(locNo)));
            Integer originPathAllDistance = NavigateUtils.getOriginPathAllDistance(nodeList);//总距离
            if (originPathAllDistance < distance) {
                distance = originPathAllDistance;
                liftDeviceId = basLift.getDeviceId();
            }
        }
        if (liftDeviceId == null) {
            return null;
        }
        Device device = deviceService.getById(liftDeviceId);
        if (device == null) {
            return null;
        }
        return device;
    }
}