#
Junjie
22 小时以前 6e02d92c3b9c240fa78a343b67ddf0db12d840e6
src/main/java/com/zy/common/utils/ShuttleOperaUtils.java
@@ -51,10 +51,16 @@
    private DeviceConfigService deviceConfigService;
    public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) {
        return getStartToTargetCommands(startLocNo, endLocNo, mapTypes, null, assignCommand, shuttleThread);
        return getStartToTargetCommands(startLocNo, endLocNo, mapTypes, null, assignCommand, shuttleThread, "move");
    }
    public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, List<int[]> whites, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) {
    public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread, String moveType) {
        return getStartToTargetCommands(startLocNo, endLocNo, mapTypes, null, assignCommand, shuttleThread, moveType);
    }
    public synchronized List<ShuttleCommand> getStartToTargetCommands(String startLocNo, String endLocNo, List<NavigationMapType> mapTypes, List<int[]> whites, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread, String moveType) {
        long getStartTime = System.currentTimeMillis();
        ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
        if (shuttleProtocol == null) {
            return null;
@@ -77,7 +83,7 @@
            if (whites != null) {
                boolean flag = false;
                for (int[] white : whites) {
                    if(white[0] == node.getX() && white[1] == node.getY()) {
                    if (white[0] == node.getX() && white[1] == node.getY()) {
                        flag = true;
                        break;
                    }
@@ -95,9 +101,11 @@
        //获取分段路径
        List<List<NavigateNode>> data = navigateUtils.getSectionPath(nodeList);
        long endTime = System.currentTimeMillis();
        News.info("getSection path time:{}", (endTime - startTime));
        News.info("[RCS Debug] getSection path time:{}", (endTime - startTime));
        //将每一段路径分成command指令
        for (List<NavigateNode> nodes : data) {
        for (int i = 0; i < data.size(); i++) {
            List<NavigateNode> nodes = data.get(i);
            //开始路径
            NavigateNode startPath = nodes.get(0);
@@ -110,6 +118,15 @@
            String distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ());
            //获取移动命令
            ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes);
            if (i + 1 == data.size()) {
                if (moveType.equals("inLift")) {
                    command = shuttleThread.getMoveLiftCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, true);
                }else if (moveType.equals("outLift")) {
                    command = shuttleThread.getMoveLiftCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes, false);
                }
            }
            command.setNodes(nodes);//将行走节点添加到每一步命令中
            commands.add(command);
        }
@@ -126,6 +143,8 @@
            }
        }
        assignCommand.setShuttleMoveCommandsContinuously(shuttleMoveCommandsContinuously);
        News.info("{}任务,{}小车,{} - {} 路径命令包计算成功,耗时:{}ms", assignCommand.getTaskNo(), shuttleProtocol.getShuttleNo(), startLocNo, endLocNo, System.currentTimeMillis() - startTime);
        return commands;
    }
@@ -153,17 +172,20 @@
        return commands;
    }
    //检测障碍物车
    public synchronized boolean checkObstacle(String locNo, List<Integer> whiteShuttles) {
    /**
     * 检测障碍物车
     * @return 0:无障碍 1:有障碍调度成功 2:有障碍调度失败
     */
    public synchronized int checkObstacle(String locNo, List<Integer> whiteShuttles, List<NavigateNode> whiteNodes) {
        int innerCircle = 0;
        int outerCircle = 3;
        Config avoidInnerCircleConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "avoidInnerCircle"));
        if(avoidInnerCircleConfig != null) {
        if (avoidInnerCircleConfig != null) {
            innerCircle = Integer.parseInt(avoidInnerCircleConfig.getValue());
        }
        Config avoidOuterCircleConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "avoidOuterCircle"));
        if(avoidOuterCircleConfig != null) {
        if (avoidOuterCircleConfig != null) {
            outerCircle = Integer.parseInt(avoidOuterCircleConfig.getValue());
        }
@@ -187,11 +209,11 @@
        List<NavigateNode> innerNodes = getInnerNodes(locNo, innerCircle, whiteShuttlePointList);
        List<Integer> nodesCar = findNodesCar(innerNodes);
        if (nodesCar.isEmpty()) {
            return false;//内圈中无车
            return 0;//内圈中无车
        }
        //获取外圈节点
        List<NavigateNode> outerNodes = getOuterNodes(locNo, outerCircle, whiteShuttlePointList, innerNodes);
        List<NavigateNode> outerNodes = getOuterNodes(locNo, outerCircle, whiteShuttlePointList, innerNodes, whiteNodes);
        //将内圈节点中障碍小车调离
        for (Integer shuttleNo : nodesCar) {
@@ -214,20 +236,21 @@
                List<NavigateNode> avoidInnerNodes = getInnerNodes(dispatchLocNo, innerCircle, new ArrayList<>());
                //计算内圈是否有小车
                List<Integer> avoidNodesCar = findNodesCar(avoidInnerNodes);
                if(!avoidNodesCar.isEmpty()) {
                   continue;
                if (!avoidNodesCar.isEmpty()) {
                    continue;
                }
                targetLocNo = dispatchLocNo;
                break;
            }
            if(targetLocNo == null) {
            if (targetLocNo == null) {
                continue;
            }
            shuttleDispatchUtils.dispatchShuttle(null, targetLocNo, shuttleNo);
            boolean dispatched = shuttleDispatchUtils.dispatchShuttle(null, targetLocNo, shuttleNo);
            return dispatched ? 1 : 2;
        }
        return true;//内圈中有车
        return 2;//内圈中有车
    }
    private HashMap<String, Integer> findCarMap() {
@@ -268,7 +291,7 @@
        return list;
    }
    private List<NavigateNode> getOuterNodes(String locNo, int outerCircle, List<int[]> whiteShuttlePointList, List<NavigateNode> innerNodes) {
    private List<NavigateNode> getOuterNodes(String locNo, int outerCircle, List<int[]> whiteShuttlePointList, List<NavigateNode> innerNodes, List<NavigateNode> whiteNodes) {
        List<NavigateNode> outerNodes = new ArrayList<>();
        List<NavigateNode> outerNodesTmp = new ArrayList<>();
        int lev = Utils.getLev(locNo);
@@ -293,13 +316,24 @@
        for (NavigateNode node : outerNodesTmp) {
            boolean flag = false;
            for (NavigateNode innerNode : innerNodes) {
                if(node.getX() == innerNode.getX() && node.getY() == innerNode.getY()) {
                if (node.getX() == innerNode.getX() && node.getY() == innerNode.getY()) {
                    flag = true;
                    break;
                }
            }
            if(flag) {
            if (flag) {
                continue;
            }
            for (NavigateNode whiteNode : whiteNodes) {
                if (node.getX() == whiteNode.getX() && node.getY() == whiteNode.getY()) {
                    flag = true;
                    break;
                }
            }
            if (flag) {
                continue;
            }
@@ -500,7 +534,7 @@
    private boolean is_valid(int[][] map, int x, int y) {
        if (x < 0 || x >= map.length
                || y < 0 || y >= map[0].length) {
                || y < 0 || y >= map[1].length) {
            return false;
        }
        // 如果结点的位置小于0,则不合法