区域、运营商配置下发格式修改.
This commit is contained in:
@@ -2,7 +2,9 @@ package com.nis.web.service.basics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -222,104 +224,80 @@ public class SysDictInfoService extends BaseService{
|
||||
return sysDictInfoDao.getDistrictDict(tableName);
|
||||
}
|
||||
|
||||
// 组织区域、运营商配置下发格式
|
||||
|
||||
/**
|
||||
* 组织区域、运营商配置下发格式
|
||||
* @param areaEffectiveIds
|
||||
* @return
|
||||
*/
|
||||
public String setEffectiveRange(String areaEffectiveIds){
|
||||
EffectiveRangeCfg rangeCfg = new EffectiveRangeCfg();
|
||||
List<List<AreaIsp>> effectiveRangeList = new ArrayList();
|
||||
|
||||
List<String> locaValueList = new ArrayList();
|
||||
List<String> ispValueList = new ArrayList();
|
||||
|
||||
HashMap<String, List<String>> map = new HashMap<String,List<String>>();
|
||||
List<String> ispList = new ArrayList();
|
||||
for (String areaEffectiveId : StringUtils.split(areaEffectiveIds, ",")) {
|
||||
List<AreaIsp> 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<SysDictInfo> list = sysDictInfoDao.getEffectiveArea(areaCode);
|
||||
for (SysDictInfo sysDictInfo : list) {
|
||||
areaStr += sysDictInfo.getItemValue();
|
||||
while(sysDictInfo.getParent().getSysDictId() != 0) {
|
||||
sysDictInfo = sysDictInfoDao.getDictById(sysDictInfo.getParent().getSysDictId());
|
||||
areaStr += "/"+sysDictInfo.getItemValue();
|
||||
|
||||
if(!map.containsKey(areaCode)){
|
||||
ispList = new ArrayList();
|
||||
ispList.add(ispCode);
|
||||
map.put(areaCode, ispList);
|
||||
}else{
|
||||
if(!ispList.contains(ispCode)){
|
||||
ispList.add(ispCode);
|
||||
}
|
||||
map.replace(areaCode, ispList);
|
||||
}
|
||||
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 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);
|
||||
|
||||
// 查询所有父节点区域信息
|
||||
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(!map.containsKey(areaEffectiveId)){
|
||||
map.put(areaEffectiveId, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
EffectiveRangeCfg rangeCfg = new EffectiveRangeCfg();
|
||||
List<List<AreaIsp>> effectiveRangeList = new ArrayList();
|
||||
Set<String> keySet = map.keySet();
|
||||
for (String key : keySet) {
|
||||
AreaIsp area = new AreaIsp();
|
||||
area.setTag(Constants.AREA_TAG);
|
||||
AreaIsp isp = new AreaIsp();
|
||||
isp.setTag(Constants.ISP_TAG);
|
||||
List<String> locaValueList = new ArrayList();
|
||||
List<String> ispValueList = new ArrayList();
|
||||
List<AreaIsp> areaIspList = new ArrayList();
|
||||
// 获取区域信息
|
||||
String areaStr = "";
|
||||
SysDictInfo areaDict = sysDictInfoDao.getDictByItemCode(key);
|
||||
areaStr += areaDict.getItemValue();
|
||||
while(areaDict.getParent().getSysDictId() != 0) {
|
||||
areaDict = sysDictInfoDao.getDictById(areaDict.getParent().getSysDictId());
|
||||
areaStr += "/"+areaDict.getItemValue();
|
||||
}
|
||||
locaValueList.add(StringUtils.revertStr(areaStr, "/"));
|
||||
area.setValue(locaValueList);
|
||||
areaIspList.add(area);
|
||||
|
||||
// 获取运营商信息
|
||||
if(map.get(key) != null){
|
||||
for (String ispCode : map.get(key)) {
|
||||
SysDictInfo ispDict = sysDictInfoDao.getDictByItemCode(ispCode);
|
||||
ispValueList.add(ispDict.getItemValue());
|
||||
}
|
||||
isp.setValue(ispValueList);
|
||||
areaIspList.add(isp);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user