(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

@@ -18,7 +18,9 @@ import com.nis.domain.Page;
import com.nis.domain.basics.AsnGroupInfo;
import com.nis.domain.callback.InlineIp;
import com.nis.domain.configuration.AreaIpCfg;
import com.nis.domain.configuration.AsnKeywordCfg;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.NtcSubscribeIdCfg;
@@ -153,7 +155,38 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
areaIpCfgDao.saveAreaIpCfg(cfg);
}
}
//保存asn组织信息 字符串域信息
if(StringUtils.isNotBlank(entity.getUserRegion4())){
List<FunctionRegionDict> functionRegionDicts=DictUtils.getFunctionRegionDictList(entity.getFunctionId());
FunctionRegionDict regionDict=null;
for(FunctionRegionDict dict:functionRegionDicts) {
if("asn".equals(dict.getConfigServiceType())) {
regionDict=dict;
}
}
if(regionDict!=null) {
String org=entity.getUserRegion4();
List<AsnGroupInfo> asnGroupInfos=asnGroupInfoDao.getValidConfigGroupInfoByName(org);
for(AsnGroupInfo info:asnGroupInfos) {
BaseStringCfg<AsnKeywordCfg> asnKeywordCfg=new AsnKeywordCfg();
BeanUtils.copyProperties(entity, asnKeywordCfg,new String[]{"cfgId","cfgDesc","cfgRegionCode","cfgType","userRegion1","userRegion2","userRegion3"});
asnKeywordCfg.setTableName(AsnKeywordCfg.getTablename());
asnKeywordCfg.setCfgKeywords("AS"+info.getAsnId());
asnKeywordCfg.setExprType(0);
asnKeywordCfg.setMatchMethod(3);
asnKeywordCfg.setExType("0");
asnKeywordCfg.setIsHexbin(0);
asnKeywordCfg.setCfgRegionCode(regionDict.getConfigRegionCode());
asnKeywordCfg.setCfgType(regionDict.getConfigRegionValue());
asnKeywordCfg.setCreateTime(entity.getCreateTime());
asnKeywordCfg.setCreatorId(UserUtils.getUser().getId());
asnKeywordCfg.setFunctionId(regionDict.getFunctionId());
asnKeywordCfg.setCompileId(compileId);
stringCfgDao.saveStringCfgBatch(asnKeywordCfg);
}
}
}
}else{
entity.setEditTime(new Date());
entity.setEditorId(entity.getCurrentUser().getId());
@@ -189,6 +222,42 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
areaIpCfgDao.saveAreaIpCfg(cfg);
}
}
//保存asn组织信息 字符串域信息
if(StringUtils.isNotBlank(entity.getUserRegion4())){
List<FunctionRegionDict> functionRegionDicts=DictUtils.getFunctionRegionDictList(entity.getFunctionId());
FunctionRegionDict regionDict=null;
for(FunctionRegionDict dict:functionRegionDicts) {
if("asn".equals(dict.getConfigServiceType())) {
regionDict=dict;
}
}
if(regionDict!=null) {
//先删除asn keyword
String org=entity.getUserRegion4();
stringCfgDao.deleteAsnKeyword(entity);
List<AsnGroupInfo> asnGroupInfos=asnGroupInfoDao.getValidConfigGroupInfoByName(org);
for(AsnGroupInfo info:asnGroupInfos) {
BaseStringCfg<AsnKeywordCfg> asnKeywordCfg=new AsnKeywordCfg();
BeanUtils.copyProperties(entity, asnKeywordCfg,new String[]{"cfgId","cfgDesc","cfgRegionCode","cfgType","userRegion1","userRegion2","userRegion3"});
asnKeywordCfg.setTableName(AsnKeywordCfg.getTablename());
asnKeywordCfg.setCfgKeywords("AS"+info.getAsnId());
asnKeywordCfg.setExprType(0);
asnKeywordCfg.setMatchMethod(3);
asnKeywordCfg.setExType("0");
asnKeywordCfg.setIsHexbin(0);
asnKeywordCfg.setCfgRegionCode(regionDict.getConfigRegionCode());
asnKeywordCfg.setCfgType(regionDict.getConfigRegionValue());
asnKeywordCfg.setCreateTime(entity.getCreateTime());
asnKeywordCfg.setCreatorId(UserUtils.getUser().getId());
asnKeywordCfg.setFunctionId(regionDict.getFunctionId());
asnKeywordCfg.setEditorId(entity.getEditorId());
asnKeywordCfg.setEditTime(entity.getEditTime());
asnKeywordCfg.setCompileId(entity.getCompileId());
stringCfgDao.saveStringCfgBatch(asnKeywordCfg);
}
}
}
}
}
public void updateIpCfgValid(Integer isValid,String ids,Integer functionId){
@@ -217,6 +286,13 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
cfg.setTableName(NtcSubscribeIdCfg.getTablename());
ipCfgDao.updateCfgValid(cfg);
}
if(entity.getAsnKeywords()!=null && entity.getAsnKeywords().size()>0)
{
AsnKeywordCfg cfg = new AsnKeywordCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(AsnKeywordCfg.getTablename());
ipCfgDao.updateCfgValid(cfg);
}
//保存区域IP信息
if(entity.getAreaCfg()!=null && entity.getAreaCfg().size()>0){
AreaIpCfg cfg = new AreaIpCfg();
@@ -507,6 +583,26 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
strRegionList=map.get("dstList");
}
}
if(entity.getAsnKeywords()!=null && entity.getAsnKeywords().size()>0){
String regionValue=entity.getAsnKeywords().get(0).getCfgType();
if(regionValue!=null) {
for(FunctionRegionDict region:dictList) {
if(regionValue.equals(region.getConfigRegionValue())) {
maatType=region.getIsMaat();
break;
}
}
}
AsnKeywordCfg cfg = new AsnKeywordCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(AsnKeywordCfg.getTablename());
ipCfgDao.auditCfg(cfg);
if(isAudit==1&&maatType==Constants.MAAT_TYPE){
Map<String,List> map = cfgConvert(strRegionList,entity.getAsnKeywords(),2,entity,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
}
//保存区域IP信息
List<AreaIpCfg> areaIpCfgList=areaIpCfgDao.getByCompileId(entity.getCompileId());
if(!StringUtil.isEmpty(areaIpCfgList)){
@@ -638,56 +734,73 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
* @param ids cfgId
* @param functionId
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void auditAsnCfg(CfgIndexInfo entity,Integer isAudit){
entity.setTableName(CfgIndexInfo.getTablename());
entity.setIsAudit(isAudit);
ipCfgDao.auditCfg(entity);
ToMaatBean maatBean = new ToMaatBean();
List<MaatCfg> configCompileList = new ArrayList<>();
if(isAudit==Constants.AUDIT_YES) {
AsnGroupInfo asnGroupInfo=new AsnGroupInfo();
asnGroupInfo.setOrganization(entity.getUserRegion4());
asnGroupInfo.setIsValid(1);
List<AsnGroupInfo> groups=asnGroupInfoDao.findAsnGroupInfoList(asnGroupInfo);
if(groups!=null&&groups.size()>0) {
// if(configGroupInfo.getIsIssued()==1) {//复用,只下编译跟分组
// for(AsnGroupInfo group:groups) {
// MaatCfg maatCfg = new MaatCfg();
// List<GroupCfg> groupRelationList = new ArrayList<>();
// List<IpCfg> ipRegionList = new ArrayList<>();
// List<StringCfg> strRegionList = new ArrayList<>();
// List<NumBoundaryCfg> numRegionList = new ArrayList<>();
// List<DigestCfg> digestRegionList = new ArrayList<>();
// List<IpCfg> areaIpRegionList = new ArrayList<>();
// maatCfg.initDefaultValue();
// BeanUtils.copyProperties(entity, maatCfg);
// maatCfg.setAction(entity.getAction());
// maatCfg.setAuditTime(entity.getAuditTime());
// maatCfg.setIpRegionList(ipRegionList);
// maatCfg.setStrRegionList(strRegionList);
// maatCfg.setNumRegionList(numRegionList);
// maatCfg.setDigestRegionList(digestRegionList);
// maatCfg.setGroupRelationList(groupRelationList);
// maatCfg.setAreaIpRegionList(areaIpRegionList);
// maatCfg.setIsValid(entity.getIsValid());
// //group
// GroupCfg groupCfg=new GroupCfg();
// groupCfg.setCompileId(entity.getCompileId());
// groupCfg.setGroupId(Integer.parseInt(entity.getUserRegion4()));
// groupCfg.setIsValid(Constants.VALID_YES);
// groupCfg.setAuditTime(entity.getAuditTime());
// groupRelationList.add(groupCfg);
// maatCfg.setGroupNum(groupRelationList.size());
// if(group.getAsnId()!=null) {
// maatCfg.setUserRegion("ASN_ID="+group.getAsnId());
// @Transactional(readOnly=false,rollbackFor=RuntimeException.class)
// @Deprecated
// public void auditAsnCfg(CfgIndexInfo entity,Integer isAudit){
// entity.setTableName(CfgIndexInfo.getTablename());
// entity.setIsAudit(isAudit);
// ipCfgDao.auditCfg(entity);
// ToMaatBean maatBean = new ToMaatBean();
//
// List<MaatCfg> configCompileList = new ArrayList<>();
//
// if(isAudit==Constants.AUDIT_YES) {
// List<AsnKeywordCfg> asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity);
// if(asnKeywordCfgs!=null&&asnKeywordCfgs.size()>0) {
// MaatCfg maatCfg = new MaatCfg();
// List<GroupCfg> groupRelationList = new ArrayList<>();
// List<IpCfg> ipRegionList = new ArrayList<>();
// List<StringCfg> strRegionList = new ArrayList<>();
// List<NumBoundaryCfg> numRegionList = new ArrayList<>();
// List<DigestCfg> digestRegionList = new ArrayList<>();
// List<IpCfg> areaIpRegionList = new ArrayList<>();
// maatCfg.initDefaultValue();
// BeanUtils.copyProperties(entity, maatCfg);
// maatCfg.setAction(entity.getAction());
// maatCfg.setAuditTime(entity.getAuditTime());
//
// maatCfg.setNumRegionList(numRegionList);
// maatCfg.setDigestRegionList(digestRegionList);
// maatCfg.setGroupRelationList(groupRelationList);
// maatCfg.setAreaIpRegionList(areaIpRegionList);
// maatCfg.setIsValid(entity.getIsValid());
// //group
// List<Integer> groupIds=ConfigServiceUtil.getId(2, 1);
// GroupCfg groupCfg=new GroupCfg();
// groupCfg.setCompileId(entity.getCompileId());
// //groupCfg.setGroupId(Integer.parseInt(entity.getUserRegion4()));
// groupCfg.setGroupId(groupIds.get(0));
// groupCfg.setIsValid(Constants.VALID_YES);
// groupCfg.setAuditTime(entity.getAuditTime());
// groupRelationList.add(groupCfg);
// maatCfg.setGroupNum(groupRelationList.size());
// maatCfg.setIpRegionList(ipRegionList);
// List<Integer> regions=ConfigServiceUtil.getId(3, asnKeywordCfgs.size());
// int index=0;
// List<FunctionRegionDict> functionRegionDicts=DictUtils.getFunctionRegionDictList(entity.getFunctionId());
// String cfgType=null;
// for(FunctionRegionDict dict:functionRegionDicts) {
// if("asn".equals(dict.getConfigServiceType())) {
// cfgType=dict.getCfgType();
// }
// configCompileList.add(maatCfg);
// }
//
//
// for(AsnKeywordCfg keyword:asnKeywordCfgs) {
// StringCfg cfg=new StringCfg();
// BeanUtils.copyProperties(keyword, cfg);
// cfg.setRegionId(index);
// //需要根据文档
// //cfg.setCfgType(StringUtils.isBlank(cfgType)?"NTC_ASN_NUMBER":cfgType);
// cfg.setGroupId(groupIds.get(0));
// cfg.setAuditTime(entity.getAuditTime());
// cfg.setIsValid(entity.getIsValid());
// cfg.setRegionId(regions.get(index));
// //cfg.setGroupId(Integer.parseInt(entity.getUserRegion4()));
// strRegionList.add(cfg);
// index++;
// }
// maatCfg.setStrRegionList(strRegionList);
// configCompileList.add(maatCfg);
// maatBean.setConfigCompileList(configCompileList);
// maatBean.setAuditTime(entity.getAuditTime());
// maatBean.setCreatorName(entity.getCurrentUser().getName());
@@ -696,104 +809,35 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
//
// //调用服务接口下发配置数据
// String json=gsonToJson(maatBean);
// logger.info("ipaddr asn组复用配置下发配置参数:"+json);
// logger.info("ipaddr asn配置下发配置参数"+json);
// //调用服务接口下发配置
// ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
// logger.info("ipaddr asn组复用配置下发响应信息:"+result.getMsg());
// }else {//首次下发
MaatCfg maatCfg = new MaatCfg();
List<GroupCfg> groupRelationList = new ArrayList<>();
List<IpCfg> ipRegionList = new ArrayList<>();
List<StringCfg> strRegionList = new ArrayList<>();
List<NumBoundaryCfg> numRegionList = new ArrayList<>();
List<DigestCfg> digestRegionList = new ArrayList<>();
List<IpCfg> areaIpRegionList = new ArrayList<>();
maatCfg.initDefaultValue();
BeanUtils.copyProperties(entity, maatCfg);
maatCfg.setAction(entity.getAction());
maatCfg.setAuditTime(entity.getAuditTime());
maatCfg.setNumRegionList(numRegionList);
maatCfg.setDigestRegionList(digestRegionList);
maatCfg.setGroupRelationList(groupRelationList);
maatCfg.setAreaIpRegionList(areaIpRegionList);
maatCfg.setIsValid(entity.getIsValid());
//group
List<Integer> groupIds=ConfigServiceUtil.getId(2, 1);
GroupCfg groupCfg=new GroupCfg();
groupCfg.setCompileId(entity.getCompileId());
//groupCfg.setGroupId(Integer.parseInt(entity.getUserRegion4()));
groupCfg.setGroupId(groupIds.get(0));
groupCfg.setIsValid(Constants.VALID_YES);
groupCfg.setAuditTime(entity.getAuditTime());
groupRelationList.add(groupCfg);
maatCfg.setGroupNum(groupRelationList.size());
maatCfg.setIpRegionList(ipRegionList);
List<Integer> regions=ConfigServiceUtil.getId(3, groups.size());
int index=0;
List<FunctionRegionDict> functionRegionDicts=DictUtils.getFunctionRegionDictList(entity.getFunctionId());
String cfgType=null;
for(FunctionRegionDict dict:functionRegionDicts) {
if("asn".equals(dict.getConfigServiceType())) {
cfgType=dict.getCfgType();
}
}
for(AsnGroupInfo group:groups) {
StringCfg cfg=new StringCfg();
cfg.setRegionId(index);
cfg.setCfgKeywords("AS"+group.getAsnId());
cfg.setExprType(0);
cfg.setIsHexbin(0);
cfg.setMatchMethod(3);
//需要根据文档
cfg.setCfgType(StringUtils.isBlank(cfgType)?"NTC_ASN_NUMBER":cfgType);
cfg.setGroupId(groupIds.get(0));
cfg.setAuditTime(entity.getAuditTime());
cfg.setIsValid(entity.getIsValid());
cfg.setRegionId(regions.get(index));
//cfg.setGroupId(Integer.parseInt(entity.getUserRegion4()));
strRegionList.add(cfg);
index++;
}
maatCfg.setStrRegionList(strRegionList);
configCompileList.add(maatCfg);
maatBean.setConfigCompileList(configCompileList);
maatBean.setAuditTime(entity.getAuditTime());
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.INSERT_ACTION);
//调用服务接口下发配置数据
String json=gsonToJson(maatBean);
logger.info("ipaddr asn配置下发配置参数"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
logger.info("ipaddr asn配置下发响应信息"+result.getMsg());
// }
}
}else if(isAudit==Constants.AUDIT_NOT_YES) {//取消审核通过
MaatCfg maatCfg = new MaatCfg();
maatCfg.setCompileId(entity.getCompileId());
maatCfg.setServiceId(entity.getServiceId());
maatCfg.setIsValid(0);//无效
configCompileList.add(maatCfg);
maatBean.setConfigCompileList(configCompileList);
maatBean.setAuditTime(entity.getAuditTime());
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.UPDATE_ACTION);
//调用服务接口取消配置
String json=gsonToJson(maatBean);
logger.info("ipaddr asn取消下发配置参数"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.put(json,1);
logger.info("ipaddr asn取消配置响应信息"+result.getMsg());
}else {
throw new RuntimeException("unknown isAudit value "+isAudit);
}
}
// logger.info("ipaddr asn配置下发响应信息"+result.getMsg());
//// }
// }
//
// }else if(isAudit==Constants.AUDIT_NOT_YES) {//取消审核通过
// MaatCfg maatCfg = new MaatCfg();
// maatCfg.setCompileId(entity.getCompileId());
// maatCfg.setServiceId(entity.getServiceId());
// maatCfg.setIsValid(0);//无效
// configCompileList.add(maatCfg);
// maatBean.setConfigCompileList(configCompileList);
// maatBean.setAuditTime(entity.getAuditTime());
// maatBean.setCreatorName(entity.getCurrentUser().getName());
// maatBean.setVersion(Constants.MAAT_VERSION);
// maatBean.setOpAction(Constants.UPDATE_ACTION);
// //调用服务接口取消配置
// String json=gsonToJson(maatBean);
// logger.info("ipaddr asn取消下发配置参数"+json);
// //调用服务接口下发配置
// ToMaatResult result = ConfigServiceUtil.put(json,1);
// logger.info("ipaddr asn取消配置响应信息"+result.getMsg());
// }else {
// throw new RuntimeException("unknown isAudit value "+isAudit);
// }
//
// }
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void deleteIp(String ids,String compileIds,int functionId){
if(StringUtils.isNotBlank(compileIds)){
@@ -862,8 +906,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
entity.setIpPortList(ipPortList);
entity.setNtcSubscribeIdCfgList(subscribeIdList);
if(StringUtils.isNotBlank(entity.getUserRegion4())) {
List<AsnGroupInfo> infos=asnGroupInfoDao.getValidConfigGroupInfoByName((entity.getUserRegion4().trim()));
entity.setAsnGroups(infos);
List<AsnKeywordCfg> asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity);
entity.setAsnKeywords(asnKeywordCfgs);
}
return entity;
}
@@ -871,8 +915,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
List<IpPortCfg> ipPortList = ipCfgDao.getIpPortList(entity);
entity.setIpPortList(ipPortList);
if(StringUtils.isNotBlank(entity.getUserRegion4())) {
List<AsnGroupInfo> infos=asnGroupInfoDao.getValidConfigGroupInfoByName(entity.getUserRegion4().trim());
entity.setAsnGroups(infos);
List<AsnKeywordCfg> asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity);
entity.setAsnKeywords(asnKeywordCfgs);
}
return entity;
}