(1)asn导入加入组织国家,asn号验证,组织国家不能为空,asn号不能为两个组织所有

(2)新增asn_keyword_cfg表,用于保存并下发有效且含审核通过asn ip的 asn号
(3)asn 导入去除条数限制
(4)页面asn select选项还是会影响加载页面速度,现在改为input
(5)asn_group_info 修改org_group_id为issued_ips,用于保存审核通过的asn ip
(6)分组复用url配置文件补全v1
This commit is contained in:
wangxin
2019-01-06 11:24:49 +08:00
parent 9979bb26b2
commit f56a0fe09a
37 changed files with 968 additions and 374 deletions

View File

@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.beust.jcommander.internal.Lists;
import com.google.common.collect.Maps;
import com.nis.domain.Page;
import com.nis.domain.basics.AsnGroupInfo;
import com.nis.domain.basics.AsnIpCfg;
@@ -102,9 +103,13 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
Date editTime=new Date();
entity.setEditTime(editTime);
entity.setEditorId(entity.getCurrentUser().getId());
String org=entity.getOrganization().trim();
String country=entity.getCountry().trim();
String detail=entity.getDetail().trim();
String userRegion1=entity.getUserRegion1();
AsnGroupInfo groupInfo=new AsnGroupInfo();
groupInfo.setAsnId(Long.parseLong(userRegion1));
groupInfo=asnGroupInfoDao.getInfoByAsnNo(groupInfo);
String org=groupInfo.getOrganization().trim();
String country=groupInfo.getCountry().trim();
String detail=groupInfo.getDetail().trim();
entity.setOrganization(org);
entity.setCountry(country);
entity.setDetail(detail);
@@ -230,9 +235,23 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void delAndSend(List<AsnIpCfg> entities) {
StringBuilder sb=new StringBuilder();
Map<Long,Integer> asnDelCounts=Maps.newHashMap();
for(AsnIpCfg ip:entities) {
sb.append(ip.getCfgId());
sb.append(",");
if(asnDelCounts.containsKey(Long.parseLong(ip.getUserRegion1()))) {
int count=asnDelCounts.get(Long.parseLong(ip.getUserRegion1()))+1;
asnDelCounts.put(Long.parseLong(ip.getUserRegion1()), count);
}else {
asnDelCounts.put(Long.parseLong(ip.getUserRegion1()), 1);
}
}
//跟新asn组的审核通过IP数量
for(Entry<Long,Integer> asnDelCount: asnDelCounts.entrySet()) {
AsnGroupInfo info=new AsnGroupInfo();
info.setAsnId(asnDelCount.getKey());
info.setIssuedIPs(0l-asnDelCount.getValue());
asnGroupInfoDao.modifyIssuedIp(info);
}
sb.deleteCharAt(sb.toString().lastIndexOf(","));
asnIpCfgDao.delete(sb.toString());
@@ -242,12 +261,16 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveAsnIpCfg(CfgIndexInfo entity) {
Date createTime=new Date();
//asn号
String userRegion1=entity.getUserRegion1();
AsnGroupInfo asnGroupInfo=new AsnGroupInfo();
asnGroupInfo.setAsnId(Long.parseLong(userRegion1));
asnGroupInfo=asnGroupInfoDao.getInfoByAsnNo(asnGroupInfo);
//组织去除首尾空格
entity.setOrganization(entity.getOrganization().trim());
entity.setCountry(entity.getCountry().trim());
entity.setDetail(entity.getDetail().trim());
entity.setOrganization(asnGroupInfo.getOrganization().trim());
entity.setCountry(asnGroupInfo.getCountry().trim());
entity.setDetail(asnGroupInfo.getDetail().trim());
ConfigGroupInfo configGroupInfo=configGroupInfoDao.getAsnGroupByName(entity.getOrganization());
AsnGroupInfo asnGroupInfo=asnGroupInfoDao.getGroupIdByNameAndASNId(entity.getOrganization(), entity.getCountry(), Long.parseLong(entity.getUserRegion1()));
Integer orgGroup=0;
Integer compileId=0;
Integer asnIdGroup=0;
@@ -257,42 +280,12 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
configGroupInfo.setGroupType(4);
configGroupInfo.setInsertTime(new Date());
configGroupInfo.setIsIssued(0);
if(asnGroupInfo==null) {
List<Integer> groupIdList=ConfigServiceUtil.getId(2, 2);
orgGroup=groupIdList.get(0);
asnIdGroup=groupIdList.get(1);
}else {
List<Integer> groupIdList=ConfigServiceUtil.getId(2, 1);
orgGroup=groupIdList.get(0);
configGroupInfo.setGroupId(orgGroup);
asnIdGroup=asnGroupInfo.getGroupId();
}
List<Integer> groupIdList=ConfigServiceUtil.getId(2, 2);
orgGroup=groupIdList.get(0);
configGroupInfo.setGroupId(orgGroup);
configGroupInfoDao.insertConfigGroupInfo(configGroupInfo);
}else {
orgGroup=configGroupInfo.getGroupId();
if(asnGroupInfo==null) {
List<Integer> groupIdList=ConfigServiceUtil.getId(2, 1);
asnIdGroup=groupIdList.get(0);
}else {
asnIdGroup=asnGroupInfo.getGroupId();
}
}
if(asnGroupInfo==null) {
asnGroupInfo=new AsnGroupInfo();
asnGroupInfo.setOrganization(entity.getOrganization());
asnGroupInfo.setCountry(entity.getCountry());
asnGroupInfo.setDetail(entity.getDetail());
asnGroupInfo.setIsValid(0);
asnGroupInfo.setCreateTime(new Date());
asnGroupInfo.setCreatorId(entity.getCurrentUser().getId());
asnGroupInfo.setAsnId(Long.parseLong(entity.getUserRegion1()));
asnGroupInfo.setGroupId(asnIdGroup);
List<Integer> compileIds=ConfigServiceUtil.getId(1, 1);
asnGroupInfo.setCompileId(compileIds.get(0));
asnGroupInfoDao.insert(asnGroupInfo);
}
asnIdGroup=asnGroupInfo.getGroupId();
entity.setAsnIpGroup(asnIdGroup);
entity.setCompileId(asnGroupInfo.getCompileId());
List<Integer> idList=ConfigServiceUtil.getId(3, entity.getAsnIpCfgs().size());
@@ -384,6 +377,12 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void deleteByAsnNo(List<Long> asnNoList) {
// for(Long asnNo:asnNoList) {
// int result=0;
// do {
// result=asnIpCfgDao.deleteByAsnId(String.valueOf(asnNo));
// }while(result>0);
// }
int pointsDataLimit = 1000;//限制条数
Integer size = asnNoList.size();
if(pointsDataLimit<size){
@@ -427,9 +426,9 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
asnNoList.clear();
}
}
public void ajaxDeleteAsnIp(String ids) {
/*public void ajaxDeleteAsnIp(String ids) {
asnIpCfgDao.ajaxDeleteAsnIp(ids);
}
}*/
/**
*
* auditIpBatch(非IP类配置用审核区域IP)
@@ -448,6 +447,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
//data.entrySet().stream().forEach( enrty->{
Long asn=enrty.getKey();//ans group 的group id
List<AsnIpCfg> asnIpCfgs=enrty.getValue();
int issuedNum=asnIpCfgs.size();
for(int index = 0; index < asnIpCfgs.size();index++){
AsnIpCfg t = asnIpCfgs.get(index);
BaseIpCfg ipCfg=new BaseIpCfg();
@@ -474,6 +474,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
asnGroupInfo.setIsValid(1);
asnGroupInfo.setEditorId(UserUtils.getUser().getId());
asnGroupInfo.setEditTime(new Date());
asnGroupInfo.setIssuedIPs(issuedNum+0L);
asnGroupInfoDao.updateValid(asnGroupInfo);
maatCfg.initDefaultValue();
ToMaatBean maatBean = new ToMaatBean();
@@ -513,11 +514,15 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
logger.info("ASN IP配置下发响应信息" + result.getMsg());
}else if(asnGroupInfo.getIsValid()==1){//已经下发过,走分组复用
asnGroupInfo.setIssuedIPs(issuedNum+0l);
asnGroupInfoDao.update(asnGroupInfo);
asnIPRegionSendToMaat(asnIpCfgs,isValid);
}else {
throw new RuntimeException("asnGroupInfo isValid value is "+asnGroupInfo.getIsValid());
}
}else if(isValid==Constants.VALID_NO) {//取消审核通过
asnGroupInfo.setIssuedIPs(0L-issuedNum);
asnGroupInfoDao.update(asnGroupInfo);
//已经下发过的,调用分组复用配置删除接口
// GroupReuseAddBean maatBean = new GroupReuseAddBean();
// List<GroupReuseCfg> groupReuseList=new ArrayList<>();
@@ -546,6 +551,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
// asnGroupInfo.setEditTime(new Date());
// asnGroupInfoDao.updateValid(asnGroupInfo);
//}
}else {
throw new RuntimeException("isValid value is "+isValid);
}
@@ -557,4 +563,9 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
}
}
}
public AsnIpCfg getOne(AsnIpCfg cfg) {
// TODO Auto-generated method stub
return asnIpCfgDao.getOne(cfg);
}
}