diff --git a/src/main/java/com/nis/web/service/basics/SysDictInfoService.java b/src/main/java/com/nis/web/service/basics/SysDictInfoService.java index 46bd22378..74737892e 100644 --- a/src/main/java/com/nis/web/service/basics/SysDictInfoService.java +++ b/src/main/java/com/nis/web/service/basics/SysDictInfoService.java @@ -225,78 +225,101 @@ public class SysDictInfoService extends BaseService{ // 组织区域、运营商配置下发格式 public String setEffectiveRange(String areaEffectiveIds){ EffectiveRangeCfg rangeCfg = new EffectiveRangeCfg(); - List areaIspList = new ArrayList(); + List> effectiveRangeList = new ArrayList(); List locaValueList = new ArrayList(); List ispValueList = new ArrayList(); for (String areaEffectiveId : StringUtils.split(areaEffectiveIds, ",")) { - String area = ""; + List areaIspList = new ArrayList(); + + AreaIsp area = new AreaIsp(); + area.setTag(Constants.AREA_TAG); + AreaIsp isp = new AreaIsp(); + isp.setTag(Constants.ISP_TAG); + String areaStr = ""; // 区域和运营商 if(areaEffectiveId.contains(":")) { + int index = areaEffectiveId.indexOf(":"); String areaCode = areaEffectiveId.substring(0, index); String ispCode = areaEffectiveId.substring(index+1); // 查询该区域信息及其所有父节点信息 List list = sysDictInfoDao.getEffectiveArea(areaCode); for (SysDictInfo sysDictInfo : list) { - area += sysDictInfo.getItemValue(); + areaStr += sysDictInfo.getItemValue(); while(sysDictInfo.getParent().getSysDictId() != 0) { sysDictInfo = sysDictInfoDao.getDictById(sysDictInfo.getParent().getSysDictId()); - area += "/"+sysDictInfo.getItemValue(); + areaStr += "/"+sysDictInfo.getItemValue(); } } - String areaItemValue = StringUtils.revertStr(area, "/"); + String areaItemValue = StringUtils.revertStr(areaStr, "/"); if(!locaValueList.contains(areaItemValue)) { + + locaValueList = new ArrayList(); + ispValueList = new ArrayList(); + locaValueList.add(areaItemValue); + + }else { + // 区域相同就只加运营商信息 + SysDictInfo ispStr = sysDictInfoDao.getDictByItemCode(ispCode); + if(!ispValueList.contains(ispStr.getItemValue())) { + ispValueList.add(ispStr.getItemValue()); + if(ispValueList.size() < 2) { + + isp.setValue(ispValueList); + areaIspList.add(isp); + effectiveRangeList.add(areaIspList); + } + } + continue; } // 查询运营商信息 - SysDictInfo isp = sysDictInfoDao.getDictByItemCode(ispCode); - if(!ispValueList.contains(isp.getItemValue())) { - ispValueList.add(isp.getItemValue()); + SysDictInfo ispStr = sysDictInfoDao.getDictByItemCode(ispCode); + if(!ispValueList.contains(ispStr.getItemValue())) { + ispValueList.add(ispStr.getItemValue()); } + + area.setValue(locaValueList); + isp.setValue(ispValueList); + + areaIspList.add(area); + areaIspList.add(isp); + effectiveRangeList.add(areaIspList); }else { - // 区域或运营商 + // 区域 SysDictInfo dict = sysDictInfoDao.getDictByItemCode(areaEffectiveId); - if(dict.getItemType() == 1) { - // 查询所有父节点区域信息 - area += dict.getItemValue(); - while(dict.getParent().getSysDictId() != 0) { - dict = sysDictInfoDao.getDictById(dict.getParent().getSysDictId()); - area += "/"+dict.getItemValue(); - } - String areaItemValue = StringUtils.revertStr(area, "/"); - if(!locaValueList.contains(areaItemValue)) { - locaValueList.add(areaItemValue); - } - }else { - if(!ispValueList.contains(dict.getItemValue())) { - ispValueList.add(dict.getItemValue()); - } + + // 查询所有父节点区域信息 + areaStr += dict.getItemValue(); + while(dict.getParent().getSysDictId() != 0) { + dict = sysDictInfoDao.getDictById(dict.getParent().getSysDictId()); + areaStr += "/"+dict.getItemValue(); + } + String areaItemValue = StringUtils.revertStr(areaStr, "/"); + if(!locaValueList.contains(areaItemValue)) { + locaValueList = new ArrayList(); + locaValueList.add(areaItemValue); + area.setValue(locaValueList); + areaIspList.add(area); + effectiveRangeList.add(areaIspList); } } } - if(locaValueList.size() > 0) { - AreaIsp area = new AreaIsp(); - area.setTag(Constants.AREA_TAG); - area.setValue(locaValueList); - areaIspList.add(area); - } - if(ispValueList.size() > 0) { - AreaIsp isp = new AreaIsp(); - isp.setTag(Constants.ISP_TAG); - isp.setValue(ispValueList); - areaIspList.add(isp); - } - - List> effectiveRangeList = new ArrayList(); - effectiveRangeList.add(areaIspList); rangeCfg.setEffectiveRangeList(effectiveRangeList); return gsonToJson(rangeCfg); } + public static void main(String[] args) { + SysDictInfoService service = new SysDictInfoService(); + String json = service.setEffectiveRange("7182:4,7182:5"); + + System.err.println(json); + } + }