一段方法内部递归代码的写法

  /**
     * 获取某个拓扑节点所配置的所有的监控unitId和KPi,包括所关联的子拓扑所配置的数据
     * 方法内递归调用
     *
     * @param mapValue(ID、GRAPH_ID,节点ID和拓扑图的ID)
     *
     * @return unitId、kpiId集合
     */
    @SuppressWarnings({"rawtypes", "unchecked"})
    public  LinkedHashMap<String, Object> getCurrentTopoNodeConfig(Map<String, String> mapValue) {
        boolean isCountinue = true;
        LinkedList<String> paramListKbp = new LinkedList<String>();
        LinkedList<String> paramListKpi = new LinkedList<String>();
        while (isCountinue) {
            List<Map> listNodeCount = new ArrayList();
            if (mapValue.get("ITETOR_TYPE") != null) {
                String subNodeList = mapValue.get("ITETOR_TYPE");
                listNodeCount = (ArrayList) JSONUtil.fromJSON(subNodeList);
            } else {
                listNodeCount.add(mapValue);
            }
            if (listNodeCount != null && listNodeCount.size() > 0) {
                for (int j = 0; j < listNodeCount.size(); j++) {
                    mapValue = listNodeCount.get(j);
                    List resultValue = e2eDao.showMonitorTopuResNodeuResNode(mapValue);//获取父页面唯一数据
                    if (resultValue != null && resultValue.size() > 0) {
                        Map<String, String> graphMap = (Map<String, String>) resultValue.get(0);
                        String customPropers = graphMap.get("CUSTOM_PROPS");
                        if (!"".equals(customPropers)) {
                            Map unitMapSub = getMonitorResUnitIdAndKpiItem(customPropers);
                            List unitListItemSub = null;
                            List kpiListItemSub = null;
                            if (unitMapSub.get("UNIT_ID_ITEM") != null) {
                                unitListItemSub = (ArrayList) unitMapSub.get("UNIT_ID_ITEM");
                            }
                            if (unitMapSub.get("KPI_ID_ITEM") != null) {
                                kpiListItemSub = (ArrayList) unitMapSub.get("KPI_ID_ITEM");
                            }
                            if (unitListItemSub != null) {// unit集合点
                                for (int l = 0; l < unitListItemSub.size(); l++) {
                                    paramListKbp.add(unitListItemSub.get(l) + "");
                                }
                            }
                            if (kpiListItemSub != null) {// KPI集合点
                                for (int l = 0; l < kpiListItemSub.size(); l++) {
                                    paramListKpi.add(kpiListItemSub.get(l) + "");
                                }
                            }
                            Map<String, String> customMap = (Map) JSONUtil.fromJSON(customPropers);
                            String subGraphId = customMap.get("subGraphId");
                            // 如果包括子实体页面
                            if (!"".equals(subGraphId) && !"null".equals(subGraphId) && subGraphId != null) {
                                Map subMapValue = new HashMap();
                                subMapValue.put("GRAPH_ID", subGraphId);
                                List resultValueSub = e2eDao.showMonitorTopuResNodeuResNode(subMapValue);//获取子页面内所有的节点数据
                                if (resultValueSub != null && resultValueSub.size() > 0) {
                                    List subNodeList = new ArrayList();
                                    for (int k = 0; k < resultValueSub.size(); k++) {
                                        Map<String, String> graphMapSub = (Map<String, String>) resultValueSub.get(k);
                                         mapValue = new HashMap();
                                        mapValue.put("ID", graphMapSub.get("ID"));
                                        mapValue.put("GRAPH_ID", graphMapSub.get("GRAPH_ID"));
                                        subNodeList.add(mapValue);
                                    }
                                    mapValue.put("ITETOR_TYPE", JSONUtil.toJSON(subNodeList));
                                } else {
                                    isCountinue = false;
                                }
                            } else {
                                isCountinue = false;
                            }
                        } else {
                            isCountinue = false;
                        }
                    } else {
                        isCountinue = false;
                    }
                }
            } else {
                isCountinue = false;
            }
        }
        LinkedHashMap returnMap = new LinkedHashMap();
        returnMap.put("EXT_UNIT_ID", paramListKbp);
        returnMap.put("KPI_ID", paramListKpi);
        return returnMap;
    }


转载于:https://my.oschina.net/runningwork/blog/220648

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值