优化asn ip导入,减少循环次数,减少调用综合服务接口次数
This commit is contained in:
@@ -3352,6 +3352,7 @@ public class BaseController {
|
||||
if (regionDict.getRegionType().equals(1)) {// IP
|
||||
if(regionDict.getFunctionId().intValue()==600) {//ans ip
|
||||
Map<String,List<AsnIpCfg>> asnIpCfgs=new HashMap<>();
|
||||
int total=ipPortCfgs.size();
|
||||
for (BaseIpCfg cfg : ipPortCfgs) {
|
||||
AsnIpCfg _cfg=new AsnIpCfg();
|
||||
BeanUtils.copyProperties(cfg, _cfg);
|
||||
@@ -3381,7 +3382,7 @@ public class BaseController {
|
||||
}
|
||||
}
|
||||
ipPortCfgs.clear();
|
||||
asnIpCfgService.saveAsnIpBatch(asnIpCfgs);
|
||||
asnIpCfgService.saveAsnIpBatch(asnIpCfgs,total);
|
||||
}else {
|
||||
List<Integer> compileIds=Lists.newArrayList();
|
||||
List<Integer> regionIds=Lists.newArrayList();
|
||||
|
||||
@@ -60,15 +60,6 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void save(List<AsnIpCfg> entitys){
|
||||
Date createTime=new Date();
|
||||
List<Integer> idList=ConfigServiceUtil.getId(3, entitys.size());
|
||||
int index=0;
|
||||
for(AsnIpCfg entity:entitys) {
|
||||
entity.setCreateTime(createTime);
|
||||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||||
entity.setRegionId(idList.get(index));
|
||||
index++;
|
||||
}
|
||||
this.saveBatch(entitys, AsnIpCfgDao.class);
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
@@ -88,10 +79,12 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveAsnIpBatch(Map<String,List<AsnIpCfg>> cfgs) {
|
||||
public void saveAsnIpBatch(Map<String,List<AsnIpCfg>> cfgs,int total) {
|
||||
List<AsnIpCfg> toDelAsnIpCfgs=Lists.newArrayList();
|
||||
List<AsnIpCfg> toSaveAsnIpCfgs=Lists.newArrayList();
|
||||
List<SysDataDictionaryItem> isImportAll=DictUtils.getDictList("IS_ASN_IP_IMPORT_ALL");
|
||||
List<Integer> idList=ConfigServiceUtil.getId(3, total);
|
||||
int ind=0;
|
||||
for(Entry<String,List<AsnIpCfg>> entry:cfgs.entrySet()) {
|
||||
Long asnNo=Long.parseLong(entry.getKey());
|
||||
ConfigGroupInfo configGroupInfo=this.getConfigGroupInfoByAsnNo(asnNo);
|
||||
@@ -101,15 +94,17 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
info.setDescription("Create by import excel");
|
||||
info.setGroupName("Import"+asnNo);
|
||||
info.setGroupType(4);
|
||||
this.saveAsnGroup(info);
|
||||
configGroupInfo=this.getConfigGroupInfoByAsnNo(asnNo);
|
||||
configGroupInfo=this.saveAsnGroup(info);
|
||||
}
|
||||
for(AsnIpCfg cfg:entry.getValue()) {
|
||||
cfg.setAsnIpGroup(configGroupInfo.getGroupId());
|
||||
cfg.setRegionId(idList.get(ind));
|
||||
if(configGroupInfo.getIsIssued()==0)
|
||||
cfg.setIsValid(Constants.VALID_NO);
|
||||
else
|
||||
else {
|
||||
cfg.setIsValid(Constants.VALID_YES);
|
||||
}
|
||||
ind++;
|
||||
}
|
||||
if(isImportAll.get(0).getItemCode().equals("1")) {//全量下发,删除已有的
|
||||
if(configGroupInfo.getIsIssued()==1) {//已下发
|
||||
@@ -166,8 +161,9 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
}
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveAsnGroup(PolicyGroupInfo entity) throws MaatConvertException{
|
||||
public ConfigGroupInfo saveAsnGroup(PolicyGroupInfo entity) throws MaatConvertException{
|
||||
entity.setIsValid(1);
|
||||
ConfigGroupInfo group=new ConfigGroupInfo();
|
||||
//新增
|
||||
Date createTime=new Date();
|
||||
entity.setCreatorId(UserUtils.getUser().getId());
|
||||
@@ -183,7 +179,6 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
}
|
||||
entity.setServiceGroupId(serviceGroupId);
|
||||
//新增协议分组
|
||||
ConfigGroupInfo group = new ConfigGroupInfo();
|
||||
group.setGroupId(serviceGroupId);
|
||||
group.setGroupName(entity.getGroupName());
|
||||
group.setIsIssued(0);
|
||||
@@ -192,7 +187,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
specificServiceCfgDao.insertConfigGroupInfo(group);
|
||||
policyGroupInfoDao.insert(entity);
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveAsnIpCfg(CfgIndexInfo entity) {
|
||||
@@ -201,6 +196,8 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
if(groupInfo==null) {
|
||||
throw new RuntimeException("ConfigGroupInfo is null!");
|
||||
}
|
||||
List<Integer> idList=ConfigServiceUtil.getId(3, entity.getAsnIpCfgs().size());
|
||||
int index=0;
|
||||
if(groupInfo.getIsIssued()==1) {//如果已经下发,则需要下到综合服务中
|
||||
if(entity.getAsnIpCfgs()!=null) {
|
||||
for(AsnIpCfg cfg:entity.getAsnIpCfgs()) {
|
||||
@@ -214,6 +211,8 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
cfg.setCreatorId(entity.getCurrentUser().getId());
|
||||
cfg.setAsnIpGroup(entity.getAsnIpGroup());
|
||||
cfg.setIsValid(Constants.VALID_YES);
|
||||
cfg.setRegionId(idList.get(index));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
this.save(entity.getAsnIpCfgs());
|
||||
@@ -226,6 +225,8 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
cfg.setCreatorId(entity.getCurrentUser().getId());
|
||||
cfg.setAsnIpGroup(entity.getAsnIpGroup().intValue());
|
||||
cfg.setIsValid(Constants.VALID_NO);
|
||||
cfg.setRegionId(idList.get(index));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
this.save(entity.getAsnIpCfgs());
|
||||
|
||||
@@ -543,4 +543,5 @@ cert_validate_success_info=Successful
|
||||
#ipv4 range\u65b0\u683c\u5f0f0.0.0.1-2
|
||||
ipv4_ip_range_regexp_new=^(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)-(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$
|
||||
ipv4_ip_subnet_regexp_original=^(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)/(3[0-2]|1[0-9]|2[0-9]|[0-9])$
|
||||
#域名验证正则
|
||||
domain_regexp=^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$
|
||||
Reference in New Issue
Block a user