Junjie
2024-12-11 81188cbe3d51e951ce4c853edb886272a4eb51a3
#path similarity
2个文件已修改
167 ■■■■■ 已修改文件
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java 108 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/LiftDispatcher.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java
@@ -109,14 +109,6 @@
            return false;
        }
        Double similarityRef = 0.9D;
        Dict similarityRefDict = dictService.getOne(new LambdaQueryWrapper<Dict>()
                .eq(Dict::getFlag, "similarityRef")
                .eq(Dict::getStatus, 1));
        if (similarityRefDict != null) {
            similarityRef = Double.parseDouble(similarityRefDict.getValue());
        }
        ShuttleAssignCommand assignCommand = new ShuttleAssignCommand();
        assignCommand.setShuttleNo(deviceNo);
        assignCommand.setTaskNo(motion.getTaskNo());
@@ -130,10 +122,6 @@
        LiftThread liftThread = null;
        LiftProtocol liftProtocol = null;
        String movePath = null;
        List<NavigateNode> originPath = null;
        List<NavigateNode> finalPath = null;
        Double similarity = null;
        switch (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl()))){
            case SHUTTLE_MOVE:
@@ -146,15 +134,8 @@
                shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
                shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE;
                movePath = motion.getMovePath();
                if (!Cools.isEmpty(movePath)) {
                    originPath = JSON.parseArray(movePath, NavigateNode.class);
                    finalPath = assignCommand.getNodes();
                    similarity = navigateUtils.similarityPath(originPath, finalPath);
                    if(similarity <= similarityRef) {
                        News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
                        return false;
                    }
                if (!checkSimilarityPath(motion, assignCommand)) {
                    return false;
                }
                break;
@@ -168,15 +149,8 @@
                shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
                shuttleTaskModeType = ShuttleTaskModeType.TRANSPORT;
                movePath = motion.getMovePath();
                if (!Cools.isEmpty(movePath)) {
                    originPath = JSON.parseArray(movePath, NavigateNode.class);
                    finalPath = assignCommand.getNodes();
                    similarity = navigateUtils.similarityPath(originPath, finalPath);
                    if(similarity <= similarityRef) {
                        News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
                        return false;
                    }
                if (!checkSimilarityPath(motion, assignCommand)) {
                    return false;
                }
                if (motion.getReleaseLift() == 2) {//执行中释放提升机
@@ -220,15 +194,8 @@
                shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
                shuttleTaskModeType = ShuttleTaskModeType.TRANSPORT_TO_CONVEYOR;
                movePath = motion.getMovePath();
                if (!Cools.isEmpty(movePath)) {
                    originPath = JSON.parseArray(movePath, NavigateNode.class);
                    finalPath = assignCommand.getNodes();
                    similarity = navigateUtils.similarityPath(originPath, finalPath);
                    if(similarity <= similarityRef) {
                        News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
                        return false;
                    }
                if (!checkSimilarityPath(motion, assignCommand)) {
                    return false;
                }
                break;
@@ -236,15 +203,8 @@
                shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
                shuttleTaskModeType = ShuttleTaskModeType.MOVE_PALLET_LIFT;
                movePath = motion.getMovePath();
                if (!Cools.isEmpty(movePath)) {
                    originPath = JSON.parseArray(movePath, NavigateNode.class);
                    finalPath = assignCommand.getNodes();
                    similarity = navigateUtils.similarityPath(originPath, finalPath);
                    if(similarity <= similarityRef) {
                        News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
                        return false;
                    }
                if (!checkSimilarityPath(motion, assignCommand)) {
                    return false;
                }
                shuttleCommands.add(0, shuttleThread.getLiftCommand(motion.getTaskNo(), true));
@@ -253,15 +213,8 @@
                shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread);
                shuttleTaskModeType = ShuttleTaskModeType.MOVE_PALLET_DOWN;
                movePath = motion.getMovePath();
                if (!Cools.isEmpty(movePath)) {
                    originPath = JSON.parseArray(movePath, NavigateNode.class);
                    finalPath = assignCommand.getNodes();
                    similarity = navigateUtils.similarityPath(originPath, finalPath);
                    if(similarity <= similarityRef) {
                        News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
                        return false;
                    }
                if (!checkSimilarityPath(motion, assignCommand)) {
                    return false;
                }
                shuttleCommands.add(shuttleCommands.size(), shuttleThread.getLiftCommand(motion.getTaskNo(), false));
@@ -373,15 +326,8 @@
                String shuttleFromLiftStandbyLoc = shuttleDispatcher.searchAvailableLocNo(Integer.valueOf(shuttleDevice.getDeviceNo()), shuttleDevice.getHostId(), shuttleThread.getStatus().getCurrentLocNo(), standbyLocs);
                shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), shuttleFromLiftStandbyLoc, NavigationMapType.NORMAL.id, assignCommand, shuttleThread);
                movePath = motion.getMovePath();
                if (!Cools.isEmpty(movePath)) {
                    originPath = JSON.parseArray(movePath, NavigateNode.class);
                    finalPath = assignCommand.getNodes();
                    similarity = navigateUtils.similarityPath(originPath, finalPath);
                    if(similarity <= similarityRef) {
                        News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
                        return false;
                    }
                if (!checkSimilarityPath(motion, assignCommand)) {
                    return false;
                }
                //更新动作可用待机位
@@ -701,5 +647,35 @@
        return commands;
    }
    private boolean checkSimilarityPath(Motion motion, ShuttleAssignCommand assignCommand) {
        String movePath = motion.getMovePath();
        if (Cools.isEmpty(movePath)) {
            return false;
        }
        Double similarityRef = 0.9D;
        Dict similarityRefDict = dictService.getOne(new LambdaQueryWrapper<Dict>()
                .eq(Dict::getFlag, "similarityRef")
                .eq(Dict::getStatus, 1));
        if (similarityRefDict != null) {
            similarityRef = Double.parseDouble(similarityRefDict.getValue());
        }
        List<NavigateNode> originPath = JSON.parseArray(movePath, NavigateNode.class);
        List<NavigateNode> finalPath = assignCommand.getNodes();
        if (finalPath == null) {
            return false;
        }
        Double similarity = navigateUtils.similarityPath(originPath, finalPath);
        if (similarity <= similarityRef) {
            News.error("{} dash {} path similarity mismatch!", motion.getOrigin(), motion.getTarget());
            return false;
        }
        return true;
    }
}
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/LiftDispatcher.java
@@ -41,6 +41,65 @@
     * 根据目标位置搜索空闲提升机
     * transfer: 是否可换层
     */
    public LiftThread searchLift(String locNo, Long hostId, Boolean transfer) {
        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;
            }
            if (transfer) {
                BasLift basLift = basLiftService.getOne(new LambdaQueryWrapper<BasLift>().eq(BasLift::getLiftNo, device.getDeviceNo()).eq(BasLift::getHostId, hostId));
                if (basLift == null) {
                    continue;
                }
                if (basLift.getTransfer() != 1) {
                    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);
            if (nodeList == null) {
                continue;
            }
            Integer originPathAllDistance = navigateUtils.getOriginPathAllDistance(nodeList);//总距离
            if (originPathAllDistance < finalDistance) {
                finalDistance = originPathAllDistance;
                recentLiftThread = liftThread;
            }
        }
        return recentLiftThread;
    }
    /**
     * 根据目标位置搜索空闲提升机
     * transfer: 是否可换层
     */
    public LiftThread searchIdleLift(String locNo, Long hostId, Boolean transfer) {
        LiftThread recentLiftThread = null;
        Integer finalDistance = Integer.MAX_VALUE;