自动化立体仓库 - WCS系统
#
Junjie
2023-11-04 f619c9d1736a3690382b58316183cee4f7dc67e6
src/main/java/com/zy/common/utils/NavigateMapData.java
@@ -146,6 +146,37 @@
        return null;
    }
    //获取JSON格式数据
    public List<List<MapNode>> getJsonData(Integer lev, Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) {
        try {
            String mapFilename = "map_" + lev + ".json";
            String fileName = this.getClass().getClassLoader().getResource(mapFilename).getPath();//获取文件路径
            File file = new File(fileName);
            StringBuffer stringBuffer = new StringBuffer();
            if (file.isFile() && file.exists()) {
                InputStreamReader isr = new InputStreamReader(new FileInputStream(file), "GBK");
                BufferedReader br = new BufferedReader(isr);
                String lineTxt = null;
                while ((lineTxt = br.readLine()) != null) {
                    stringBuffer.append(lineTxt);
                }
                br.close();
                //解析json地图数据
                ArrayList arrayList = JSON.parseObject(stringBuffer.toString(), ArrayList.class);
                List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据
                return lists;
            } else {
                System.out.println("文件不存在!");
            }
        } catch (IOException ioException) {
            ioException.printStackTrace();
        }
        return null;
    }
    /**
     * 过滤地图数据
     * mapType -1=>无过滤,1=》过滤库位状态DFX,2=》过滤库位状态X
@@ -232,6 +263,26 @@
            }
        }
        //加载白名单节点
        if (whitePoints != null) {
            List<List<MapNode>> realMap = getJsonData(lev, -1, null, null);//获取完整地图
            for (int[] points : whitePoints) {
                //获取原始节点数据
                int x = points[0];
                int y = points[1];
                List<MapNode> rows = realMap.get(x);
                MapNode col = rows.get(y);
                List<MapNode> list = lists.get(x);
                MapNode mapNode = list.get(y);
                mapNode.setValue(col.getValue());//恢复原始节点
                //更新list
                list.set(y, mapNode);
                lists.set(x, list);
            }
        }
        return lists;
    }