| | |
| | | |
| | | //解析json地图数据 |
| | | ArrayList arrayList = JSON.parseObject(stringBuffer.toString(), ArrayList.class); |
| | | List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据 |
| | | //重建数据格式 |
| | | List<List<MapNode>> lists = rebuildData(arrayList); |
| | | |
| | | if (!file.delete()) { |
| | | System.out.println("临时文件删除失败"); |
| | |
| | | * @param shuttlePoints 穿梭车节点,需要加载进地图 |
| | | */ |
| | | public List<List<MapNode>> filterMap(Integer mapType, List arrayList, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | //重建数据格式 |
| | | List<List<MapNode>> lists = rebuildData(arrayList); |
| | | |
| | | //载入库位信息 |
| | | lists = loadLocMast(mapType, lists, lev, whitePoints); |
| | | |
| | | //加载车辆 |
| | | lists = loadShuttle(lists, shuttlePoints); |
| | | |
| | | //加载货叉提升机点位 |
| | | lists = loadForkLift(lists, mapType, lev); |
| | | |
| | | //加载白名单节点 |
| | | lists = loadWhite(lists, lev, whitePoints); |
| | | |
| | | return lists; |
| | | } |
| | | |
| | | //重建数据格式 |
| | | public List<List<MapNode>> rebuildData(List arrayList) { |
| | | List<List<MapNode>> lists = new ArrayList<>(); |
| | | |
| | | //重建数据格式 |
| | |
| | | lists.add(list); |
| | | } |
| | | |
| | | return lists; |
| | | } |
| | | |
| | | //载入库位信息 |
| | | public List<List<MapNode>> loadLocMast(Integer mapType, List<List<MapNode>> lists, Integer lev, List<int[]> whitePoints) { |
| | | //过滤数据 |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | //获取当前楼层库位数据 |
| | | List<LocMast> locMasts = locMastService.selectLocByLev(lev); |
| | | for (LocMast locMast : locMasts) { |
| | | Integer row = locMast.getRow1(); |
| | | Integer bay = locMast.getBay1(); |
| | | try { |
| | | //获取当前楼层库位数据 |
| | | List<LocMast> locMasts = locMastService.selectLocByLev(lev); |
| | | for (LocMast locMast : locMasts) { |
| | | Integer row = locMast.getRow1(); |
| | | Integer bay = locMast.getBay1(); |
| | | |
| | | boolean whiteFlag = false;//默认不存在白名单 |
| | | if (whitePoints != null) { |
| | | for (int[] whitePoint : whitePoints) { |
| | | if (whitePoint[0] == row && whitePoint[1] == bay) { |
| | | //存在白名单 |
| | | whiteFlag = true; |
| | | break; |
| | | boolean whiteFlag = false;//默认不存在白名单 |
| | | if (whitePoints != null) { |
| | | for (int[] whitePoint : whitePoints) { |
| | | if (whitePoint[0] == row && whitePoint[1] == bay) { |
| | | //存在白名单 |
| | | whiteFlag = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (whiteFlag) { |
| | | continue;//存在白名单,不执行下列过滤方案 |
| | | } |
| | | |
| | | |
| | | List<MapNode> list = lists.get(row); |
| | | MapNode mapNode = list.get(bay); |
| | | |
| | | if (mapType == NavigationMapType.NONE.id) { |
| | | //不过滤任何数据 |
| | | } else if (mapType == NavigationMapType.DFX.id) { |
| | | //车辆有货 |
| | | //读取对应库位数据,将DFX库位状态的节点置为-1(障碍物) |
| | | if (locMast.getLocSts().equals("F") |
| | | || locMast.getLocSts().equals("D") |
| | | || locMast.getLocSts().equals("X") |
| | | || locMast.getLocSts().equals("R") |
| | | || locMast.getLocSts().equals("P") |
| | | ) { |
| | | mapNode.setValue(MapNodeType.DISABLE.id);//禁用节点 |
| | | if (whiteFlag) { |
| | | continue;//存在白名单,不执行下列过滤方案 |
| | | } |
| | | } else if (mapType == NavigationMapType.NORMAL.id) { |
| | | //过滤库位状态X |
| | | if (locMast.getLocSts().equals("X")) { |
| | | mapNode.setValue(MapNodeType.DISABLE.id);//禁用节点 |
| | | } |
| | | } |
| | | |
| | | //更新list |
| | | list.set(bay, mapNode); |
| | | lists.set(row, list); |
| | | |
| | | List<MapNode> list = lists.get(row); |
| | | MapNode mapNode = list.get(bay); |
| | | |
| | | if (mapType == NavigationMapType.NONE.id) { |
| | | //不过滤任何数据 |
| | | } else if (mapType == NavigationMapType.DFX.id) { |
| | | //车辆有货 |
| | | //读取对应库位数据,将DFX库位状态的节点置为-1(障碍物) |
| | | if (locMast.getLocSts().equals("F") |
| | | || locMast.getLocSts().equals("D") |
| | | || locMast.getLocSts().equals("X") |
| | | || locMast.getLocSts().equals("R") |
| | | || locMast.getLocSts().equals("P") |
| | | ) { |
| | | mapNode.setValue(MapNodeType.DISABLE.id);//禁用节点 |
| | | } |
| | | } else if (mapType == NavigationMapType.NORMAL.id) { |
| | | //过滤库位状态X |
| | | if (locMast.getLocSts().equals("X")) { |
| | | mapNode.setValue(MapNodeType.DISABLE.id);//禁用节点 |
| | | } |
| | | } |
| | | |
| | | //更新list |
| | | list.set(bay, mapNode); |
| | | lists.set(row, list); |
| | | } |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return lists; |
| | | } |
| | | |
| | | //加载车辆 |
| | | public List<List<MapNode>> loadShuttle(List<List<MapNode>> lists, List<int[]> shuttlePoints) { |
| | | //加载车辆坐标到地图中 |
| | | if (shuttlePoints != null) { |
| | | for (int[] points : shuttlePoints) { |
| | |
| | | } |
| | | } |
| | | |
| | | return lists; |
| | | } |
| | | |
| | | //加载白名单节点 |
| | | public List<List<MapNode>> loadWhite(List<List<MapNode>> lists, Integer lev, List<int[]> whitePoints) { |
| | | //加载白名单节点 |
| | | if (whitePoints != null) { |
| | | List<List<MapNode>> realMap = getJsonData(lev, -1, null, null);//获取完整地图 |
| | |
| | | lists.set(x, list); |
| | | } |
| | | } |
| | | return lists; |
| | | } |
| | | |
| | | //加载货叉提升机放货点位数据 |
| | | for (ForkLiftSlave forkLiftSlave : slaveProperties.getForkLift()) { |
| | | ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, forkLiftSlave.getId()); |
| | | if (forkLiftThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | for (ForkLiftStaProtocol staProtocol : forkLiftThread.getForkLiftStaProtocols()) { |
| | | int row = Utils.getRow(staProtocol.getLocNo()); |
| | | int bay = Utils.getBay(staProtocol.getLocNo()); |
| | | |
| | | List<MapNode> list = lists.get(row); |
| | | MapNode mapNode = list.get(bay); |
| | | |
| | | if (mapType == NavigationMapType.DFX.id) { |
| | | //车辆有货 |
| | | if (staProtocol.getHasTray()) { |
| | | mapNode.setValue(MapNodeType.DISABLE.id); |
| | | } |
| | | }else { |
| | | if (staProtocol.getHasCar()) { |
| | | mapNode.setValue(MapNodeType.CAR.id); |
| | | } |
| | | //加载货叉提升机点位 |
| | | public List<List<MapNode>> loadForkLift(List<List<MapNode>> lists, Integer mapType, Integer lev) { |
| | | try { |
| | | //加载货叉提升机放货点位数据 |
| | | for (ForkLiftSlave forkLiftSlave : slaveProperties.getForkLift()) { |
| | | ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, forkLiftSlave.getId()); |
| | | if (forkLiftThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | //更新list |
| | | list.set(bay, mapNode); |
| | | lists.set(row, list); |
| | | for (ForkLiftStaProtocol staProtocol : forkLiftThread.getForkLiftStaProtocols()) { |
| | | if (staProtocol.getLev() != lev) { |
| | | continue; |
| | | } |
| | | int row = Utils.getRow(staProtocol.getLocNo()); |
| | | int bay = Utils.getBay(staProtocol.getLocNo()); |
| | | |
| | | List<MapNode> list = lists.get(row); |
| | | MapNode mapNode = list.get(bay); |
| | | |
| | | if (mapType == NavigationMapType.DFX.id) { |
| | | //车辆有货 |
| | | if (staProtocol.getHasTray() != null && staProtocol.getHasTray()) { |
| | | mapNode.setValue(MapNodeType.DISABLE.id); |
| | | } |
| | | } else { |
| | | if (staProtocol.getHasCar() != null && staProtocol.getHasCar()) { |
| | | mapNode.setValue(MapNodeType.CAR.id); |
| | | } |
| | | } |
| | | |
| | | //更新list |
| | | list.set(bay, mapNode); |
| | | lists.set(row, list); |
| | | } |
| | | |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return lists; |
| | | } |
| | | |