策略组group id region id 不固定版本
This commit is contained in:
@@ -575,6 +575,25 @@ public class ConfigConvertUtil {
|
|||||||
dstIp.setDstPortMask("65535");
|
dstIp.setDstPortMask("65535");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static <T> Map<Integer,Integer> getGroupIdList(List<T> srcList){
|
||||||
|
Set<Integer> groupIdSet=new HashSet<>();
|
||||||
|
Map<Integer,Integer> groupIdMap=new HashMap<>();
|
||||||
|
for(T src:srcList){
|
||||||
|
BaseCfg cfg=(BaseCfg)src;
|
||||||
|
if(!groupIdSet.contains(cfg.getGroupId())){
|
||||||
|
groupIdSet.add(cfg.getGroupId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if(groupIdSet.size()>0){
|
||||||
|
List<Integer> groupIds= ConfigServiceUtil.getId(2,groupIdSet.size());
|
||||||
|
for(Integer id:groupIdSet){
|
||||||
|
groupIdMap.put(id,groupIds.get(0));
|
||||||
|
}
|
||||||
|
groupIds.remove(0);
|
||||||
|
}
|
||||||
|
return groupIdMap;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*Obj 组maat配置转换
|
*Obj 组maat配置转换
|
||||||
* @param <T>
|
* @param <T>
|
||||||
@@ -591,6 +610,7 @@ public class ConfigConvertUtil {
|
|||||||
List groupRelationList, Map<String,Object> maatTableMap, Set<Integer> groupIdSet) {
|
List groupRelationList, Map<String,Object> maatTableMap, Set<Integer> groupIdSet) {
|
||||||
long start=System.currentTimeMillis(),end=0l;
|
long start=System.currentTimeMillis(),end=0l;
|
||||||
Map<String, List> map = new HashMap();
|
Map<String, List> map = new HashMap();
|
||||||
|
Map<Integer,Integer> groupIdMap=getGroupIdList(srcList);
|
||||||
if (cfgType == 1) {
|
if (cfgType == 1) {
|
||||||
List numRegionList = new ArrayList();
|
List numRegionList = new ArrayList();
|
||||||
int pos=0;
|
int pos=0;
|
||||||
@@ -607,15 +627,17 @@ public class ConfigConvertUtil {
|
|||||||
|
|
||||||
if (!groupIdSet.contains(baseIpCfg.getGroupId())) {
|
if (!groupIdSet.contains(baseIpCfg.getGroupId())) {
|
||||||
GroupCfg group = new GroupCfg();
|
GroupCfg group = new GroupCfg();
|
||||||
//groupId = ConfigServiceUtil.getId(2, 1).get(0);
|
// group.setGroupId(baseIpCfg.getGroupId());
|
||||||
group.setGroupId(baseIpCfg.getGroupId());
|
Integer groupId =groupIdMap.get(baseIpCfg.getGroupId());
|
||||||
|
group.setGroupId(groupId);
|
||||||
group.setCompileId(baseCfg.getCompileId());
|
group.setCompileId(baseCfg.getCompileId());
|
||||||
group.setAuditTime(baseCfg.getAuditTime());
|
group.setAuditTime(baseCfg.getAuditTime());
|
||||||
group.setIsValid(baseCfg.getIsValid());
|
group.setIsValid(baseCfg.getIsValid());
|
||||||
groupRelationList.add(group);
|
groupRelationList.add(group);
|
||||||
groupIdSet.add(baseIpCfg.getGroupId());
|
groupIdSet.add(baseIpCfg.getGroupId());
|
||||||
}
|
}
|
||||||
cfg.setGroupId(baseIpCfg.getGroupId());
|
// cfg.setGroupId(baseIpCfg.getGroupId());
|
||||||
|
cfg.setGroupId(groupIdMap.get(baseIpCfg.getGroupId()));
|
||||||
cfg.setAuditTime(baseCfg.getAuditTime());
|
cfg.setAuditTime(baseCfg.getAuditTime());
|
||||||
cfg.setIsValid(baseCfg.getIsValid());
|
cfg.setIsValid(baseCfg.getIsValid());
|
||||||
if(maatTableMap.containsKey("ipMaatTable")){
|
if(maatTableMap.containsKey("ipMaatTable")){
|
||||||
@@ -623,11 +645,11 @@ public class ConfigConvertUtil {
|
|||||||
cfg.setCfgType(ipMaatTable.get(baseIpCfg.getGroupId().toString()));
|
cfg.setCfgType(ipMaatTable.get(baseIpCfg.getGroupId().toString()));
|
||||||
}
|
}
|
||||||
List<IpCfg> cfgs = ipConvert(cfg, baseIpCfg);
|
List<IpCfg> cfgs = ipConvert(cfg, baseIpCfg);
|
||||||
if (cfgs.size() > 1) {
|
if (cfgs.size() > 0) {
|
||||||
List<Integer> ids =regionIdList.subList(pos,pos+cfgs.size());
|
List<Integer> ids =regionIdList.subList(pos,pos+cfgs.size());
|
||||||
//支持range????
|
//支持range????
|
||||||
for (int j = 1; j < cfgs.size(); j++) {
|
for (int j = 0; j < cfgs.size(); j++) {
|
||||||
cfgs.get(j).setRegionId(ids.get(j-1));
|
cfgs.get(j).setRegionId(ids.get(j));
|
||||||
}
|
}
|
||||||
pos+=cfgs.size();
|
pos+=cfgs.size();
|
||||||
}
|
}
|
||||||
@@ -664,14 +686,16 @@ public class ConfigConvertUtil {
|
|||||||
}
|
}
|
||||||
regionIdList.clear();
|
regionIdList.clear();
|
||||||
} else if (cfgType == 2 || cfgType == 3) {
|
} else if (cfgType == 2 || cfgType == 3) {
|
||||||
//List<Integer> groupIdList = ConfigServiceUtil.getId(2, srcList.size());
|
// List<Integer> groupIdList = ConfigServiceUtil.getId(2, srcList.size());
|
||||||
//List<Integer> regionIdList = ConfigServiceUtil.getId(3, srcList.size());
|
List<Integer> regionIdList = ConfigServiceUtil.getId(3, srcList.size());
|
||||||
for (int i = 0; i < srcList.size(); i++) {
|
for (int i = 0; i < srcList.size(); i++) {
|
||||||
BaseStringCfg baserStringCfg=new BaseStringCfg();
|
BaseStringCfg baserStringCfg=new BaseStringCfg();
|
||||||
BeanUtils.copyProperties(srcList.get(i),baserStringCfg);
|
BeanUtils.copyProperties(srcList.get(i),baserStringCfg);
|
||||||
if(!groupIdSet.contains(baserStringCfg.getGroupId())){
|
if(!groupIdSet.contains(baserStringCfg.getGroupId())){
|
||||||
GroupCfg group = new GroupCfg();
|
GroupCfg group = new GroupCfg();
|
||||||
group.setGroupId(baserStringCfg.getGroupId());
|
// group.setGroupId(baserStringCfg.getGroupId());
|
||||||
|
Integer groupId =groupIdMap.get(baserStringCfg.getGroupId());
|
||||||
|
group.setGroupId(groupId);
|
||||||
group.setCompileId(baseCfg.getCompileId());
|
group.setCompileId(baseCfg.getCompileId());
|
||||||
group.setAuditTime(baseCfg.getAuditTime());
|
group.setAuditTime(baseCfg.getAuditTime());
|
||||||
group.setIsValid(baseCfg.getIsValid());
|
group.setIsValid(baseCfg.getIsValid());
|
||||||
@@ -680,8 +704,10 @@ public class ConfigConvertUtil {
|
|||||||
}
|
}
|
||||||
StringCfg cfg = new StringCfg();
|
StringCfg cfg = new StringCfg();
|
||||||
BeanUtils.copyProperties(srcList.get(i), cfg);
|
BeanUtils.copyProperties(srcList.get(i), cfg);
|
||||||
cfg.setGroupId(baserStringCfg.getGroupId());
|
// cfg.setGroupId(baserStringCfg.getGroupId());
|
||||||
cfg.setRegionId(baserStringCfg.getRegionId());
|
// cfg.setRegionId(baserStringCfg.getRegionId());
|
||||||
|
cfg.setGroupId(groupIdMap.get(baserStringCfg.getGroupId()));
|
||||||
|
cfg.setRegionId(regionIdList.get(i));
|
||||||
cfg.setAuditTime(baseCfg.getAuditTime());
|
cfg.setAuditTime(baseCfg.getAuditTime());
|
||||||
cfg.setIsValid(baseCfg.getIsValid());
|
cfg.setIsValid(baseCfg.getIsValid());
|
||||||
// 处理配置关键字转译
|
// 处理配置关键字转译
|
||||||
@@ -696,44 +722,52 @@ public class ConfigConvertUtil {
|
|||||||
}
|
}
|
||||||
} else if (cfgType == 4) {
|
} else if (cfgType == 4) {
|
||||||
// List<Integer> groupIdList = ConfigServiceUtil.getId(2, srcList.size());
|
// List<Integer> groupIdList = ConfigServiceUtil.getId(2, srcList.size());
|
||||||
// List<Integer> regionIdList = ConfigServiceUtil.getId(3, srcList.size());
|
List<Integer> regionIdList = ConfigServiceUtil.getId(3, srcList.size());
|
||||||
for (int i = 0; i < srcList.size(); i++) {
|
for (int i = 0; i < srcList.size(); i++) {
|
||||||
// 一条业务配置创建一个分组
|
// 一条业务配置创建一个分组
|
||||||
NumBoundaryCfg cfg = new NumBoundaryCfg();
|
NumBoundaryCfg cfg = new NumBoundaryCfg();
|
||||||
BeanUtils.copyProperties(srcList.get(i), cfg);
|
BeanUtils.copyProperties(srcList.get(i), cfg);
|
||||||
if(!groupIdSet.contains(cfg.getGroupId())){
|
if(!groupIdSet.contains(cfg.getGroupId())){
|
||||||
GroupCfg group = new GroupCfg();
|
GroupCfg group = new GroupCfg();
|
||||||
group.setGroupId(cfg.getGroupId());
|
// group.setGroupId(cfg.getGroupId());
|
||||||
|
Integer groupId =groupIdMap.get(cfg.getGroupId());
|
||||||
|
group.setGroupId(groupId);
|
||||||
group.setCompileId(baseCfg.getCompileId());
|
group.setCompileId(baseCfg.getCompileId());
|
||||||
group.setAuditTime(baseCfg.getAuditTime());
|
group.setAuditTime(baseCfg.getAuditTime());
|
||||||
group.setIsValid(baseCfg.getIsValid());
|
group.setIsValid(baseCfg.getIsValid());
|
||||||
groupRelationList.add(group);
|
groupRelationList.add(group);
|
||||||
groupIdSet.add(cfg.getGroupId());
|
groupIdSet.add(cfg.getGroupId());
|
||||||
}
|
}
|
||||||
cfg.setGroupId(cfg.getGroupId());
|
// cfg.setGroupId(cfg.getGroupId());
|
||||||
cfg.setRegionId(cfg.getRegionId());
|
// cfg.setRegionId(cfg.getRegionId());
|
||||||
|
cfg.setGroupId(groupIdMap.get(cfg.getGroupId()));
|
||||||
|
cfg.setRegionId(regionIdList.get(i));
|
||||||
cfg.setAuditTime(baseCfg.getAuditTime());
|
cfg.setAuditTime(baseCfg.getAuditTime());
|
||||||
cfg.setIsValid(baseCfg.getIsValid());
|
cfg.setIsValid(baseCfg.getIsValid());
|
||||||
dstList.add(cfg);
|
dstList.add(cfg);
|
||||||
}
|
}
|
||||||
} else if (cfgType == 5) {
|
} else if (cfgType == 5) {
|
||||||
//List<Integer> groupIdList = ConfigServiceUtil.getId(2, srcList.size());
|
//List<Integer> groupIdList = ConfigServiceUtil.getId(2, srcList.size());
|
||||||
//List<Integer> regionIdList = ConfigServiceUtil.getId(3, srcList.size());
|
List<Integer> regionIdList = ConfigServiceUtil.getId(3, srcList.size());
|
||||||
for (int i = 0; i < srcList.size(); i++) {
|
for (int i = 0; i < srcList.size(); i++) {
|
||||||
// 一条业务配置创建一个分组
|
// 一条业务配置创建一个分组
|
||||||
com.nis.domain.maat.MaatCfg.DigestCfg cfg = new com.nis.domain.maat.MaatCfg.DigestCfg();
|
com.nis.domain.maat.MaatCfg.DigestCfg cfg = new com.nis.domain.maat.MaatCfg.DigestCfg();
|
||||||
BeanUtils.copyProperties(srcList.get(i), cfg);
|
BeanUtils.copyProperties(srcList.get(i), cfg);
|
||||||
if(!groupIdSet.contains(cfg.getGroupId())){
|
if(!groupIdSet.contains(cfg.getGroupId())){
|
||||||
GroupCfg group = new GroupCfg();
|
GroupCfg group = new GroupCfg();
|
||||||
group.setGroupId(cfg.getGroupId());
|
// group.setGroupId(cfg.getGroupId());
|
||||||
|
Integer groupId =groupIdMap.get(cfg.getGroupId());
|
||||||
|
group.setGroupId(groupId);
|
||||||
group.setCompileId(baseCfg.getCompileId());
|
group.setCompileId(baseCfg.getCompileId());
|
||||||
group.setAuditTime(baseCfg.getAuditTime());
|
group.setAuditTime(baseCfg.getAuditTime());
|
||||||
group.setIsValid(baseCfg.getIsValid());
|
group.setIsValid(baseCfg.getIsValid());
|
||||||
groupRelationList.add(group);
|
groupRelationList.add(group);
|
||||||
groupIdSet.add(cfg.getGroupId());
|
groupIdSet.add(cfg.getGroupId());
|
||||||
}
|
}
|
||||||
cfg.setGroupId(cfg.getGroupId());
|
// cfg.setGroupId(cfg.getGroupId());
|
||||||
cfg.setRegionId(cfg.getRegionId());
|
// cfg.setRegionId(cfg.getRegionId());
|
||||||
|
cfg.setGroupId(groupIdMap.get(cfg.getGroupId()));
|
||||||
|
cfg.setRegionId(regionIdList.get(i));
|
||||||
cfg.setAuditTime(baseCfg.getAuditTime());
|
cfg.setAuditTime(baseCfg.getAuditTime());
|
||||||
cfg.setIsValid(baseCfg.getIsValid());
|
cfg.setIsValid(baseCfg.getIsValid());
|
||||||
dstList.add(cfg);
|
dstList.add(cfg);
|
||||||
@@ -986,7 +1020,7 @@ public class ConfigConvertUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//拆分IP数量大于1获取ID
|
//拆分IP数量大于1获取ID
|
||||||
if(total>1){
|
if(total>0){
|
||||||
regionIdsList=ConfigServiceUtil.getId(3,total);
|
regionIdsList=ConfigServiceUtil.getId(3,total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user