ASN 版本恢复1月4号之版本
This commit is contained in:
@@ -7,7 +7,6 @@ import java.math.BigDecimal;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -58,7 +57,6 @@ import com.nis.domain.configuration.AppPolicyCfg;
|
||||
import com.nis.domain.configuration.AppTopicDomainCfg;
|
||||
import com.nis.domain.configuration.AreaBean;
|
||||
import com.nis.domain.configuration.AreaIpCfg;
|
||||
import com.nis.domain.configuration.AsnKeywordCfg;
|
||||
import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
@@ -546,48 +544,6 @@ public abstract class BaseService {
|
||||
cfg.setIsValid(baseCfg.getIsValid());
|
||||
dstList.add(cfg);
|
||||
}
|
||||
} else if (cfgType == 7) { //ASN关键字配置
|
||||
/*//TODO 下发之前是否需要增加asn号的有效性校验,创建配置和下发配置不是在同一时间
|
||||
//TODO 考虑增加配置id、表名和ASN组织,以及ASN NO的关系。
|
||||
//TODO 如果ASNO 和组织关系没有了,数据需要清理,asn组织和配置id关系没有了,也需要清理
|
||||
int regionNum=0;
|
||||
//多个ASNNO存在一个ASN关键字配置中,
|
||||
for (int i = 0; i < srcList.size(); i++) {
|
||||
AsnKeywordCfg asnKeywordCfg=(AsnKeywordCfg)srcList.get(i);
|
||||
regionNum+=asnKeywordCfg.getCfgKeywords().split(",").length;
|
||||
|
||||
}
|
||||
|
||||
//List<Integer> groupIdList = ConfigServiceUtil.getId(2, srcList.size());
|
||||
List<Integer> regionIdList = ConfigServiceUtil.getId(3, regionNum);
|
||||
Integer regionIndex=0;*/
|
||||
List<Integer> listGroupId=new ArrayList<>();
|
||||
for (int i = 0; i < srcList.size(); i++) {
|
||||
AsnKeywordCfg asnKeywordCfg = (AsnKeywordCfg)srcList.get(i);
|
||||
GroupCfg group = new GroupCfg();
|
||||
group.setGroupId(Integer.parseInt(asnKeywordCfg.getUserRegion1()));
|
||||
group.setCompileId(baseCfg.getCompileId());
|
||||
group.setAuditTime(baseCfg.getAuditTime());
|
||||
group.setIsValid(baseCfg.getIsValid());
|
||||
group.setIsCommonGroup(1);//标识为公共组 //TODO 已下发过的组是否还需标记为公共组
|
||||
if(!listGroupId.contains(group.getGroupId())){
|
||||
groupRelationList.add(group);
|
||||
listGroupId.add(group.getGroupId());
|
||||
}
|
||||
|
||||
//****************是否下发域信息*******
|
||||
if("1".equals(asnKeywordCfg.getUserRegion3())){
|
||||
StringCfg cfg = new StringCfg();
|
||||
BeanUtils.copyProperties(asnKeywordCfg, cfg);
|
||||
cfg.setGroupId(group.getGroupId());
|
||||
cfg.setRegionId(Integer.parseInt(asnKeywordCfg.getUserRegion2()));
|
||||
cfg.setAuditTime(baseCfg.getAuditTime());
|
||||
cfg.setIsValid(baseCfg.getIsValid());
|
||||
// 处理配置关键字转译
|
||||
cfg.setCfgKeywords(Constants.ASN_KEY+keywordsEscape(asnKeywordCfg.getCfgKeywords()));
|
||||
dstList.add(cfg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dstList.addAll(srcList);
|
||||
}
|
||||
@@ -1905,7 +1861,7 @@ public abstract class BaseService {
|
||||
group.setIssuedIPs(asnGroupAddRegion.getValue()+0l);
|
||||
((AsnGroupInfoDao) batchSqlSession.getMapper(AsnGroupInfoDao.class)).modifyIssuedIp(group);;
|
||||
}
|
||||
asnIPRegionSendToMaat(toAddRegionAsnIpCfgs,Constants.VALID_YES,Constants.OPACTION_POST);
|
||||
asnIPRegionSendToMaat(toAddRegionAsnIpCfgs,Constants.VALID_YES);
|
||||
}
|
||||
if(toSendFirstAsnIpCfgs.size()>0) {
|
||||
List<MaatCfg> configCompileList = new ArrayList();
|
||||
@@ -2239,7 +2195,7 @@ public abstract class BaseService {
|
||||
List<GroupReuseCfg> groupReuseList=new ArrayList<>();
|
||||
GroupReuseCfg groupReuseCfg=new GroupReuseCfg();
|
||||
/*groupReuseCfg.setUserRegion(userRegion);*/
|
||||
/*groupReuseCfg.setServiceId(tempList.get(0).getServiceId());*/
|
||||
groupReuseCfg.setServiceId(tempList.get(0).getServiceId());
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(tempList,Constants.VALID_YES,configGroupInfo.getGroupId()));
|
||||
groupReuseCfg.setIpRegionList(ipRegionList);
|
||||
groupReuseCfg.setStrRegionList(strRegionList);
|
||||
@@ -2254,7 +2210,7 @@ public abstract class BaseService {
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("app协议IP域新增配置下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,1);
|
||||
ToMaatResult result = ConfigServiceUtil.postGroupReuseSources(json);
|
||||
logger.info("app协议IP域新增配置响应信息:"+result.getMsg());
|
||||
}else {
|
||||
throw new RuntimeException("Unknown configGroupInfo isIssued value");
|
||||
@@ -2324,7 +2280,7 @@ public abstract class BaseService {
|
||||
List<GroupReuseCfg> groupReuseList=new ArrayList<>();
|
||||
GroupReuseCfg groupReuseCfg=new GroupReuseCfg();
|
||||
/*groupReuseCfg.setUserRegion(userRegion);*/
|
||||
/*groupReuseCfg.setServiceId(tempList.get(0).getServiceId());*/
|
||||
groupReuseCfg.setServiceId(tempList.get(0).getServiceId());
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(tempList,Constants.VALID_YES,configGroupInfo.getGroupId()));
|
||||
groupReuseCfg.setIpRegionList(ipRegionList);
|
||||
groupReuseCfg.setStrRegionList(strRegionList);
|
||||
@@ -2339,7 +2295,7 @@ public abstract class BaseService {
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("app协议IP域新增配置下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,1);
|
||||
ToMaatResult result = ConfigServiceUtil.postGroupReuseSources(json);
|
||||
logger.info("app协议IP域新增配置响应信息:"+result.getMsg());
|
||||
}else {
|
||||
throw new RuntimeException("Unknown configGroupInfo isIssued value");
|
||||
@@ -2914,11 +2870,10 @@ public abstract class BaseService {
|
||||
|
||||
}
|
||||
/**
|
||||
* asn ip分组复用新增[POST],修改[PUT],删除[PUT]
|
||||
* 首次下发直接走maat,公共组第二次下发直接走addCommonRegion,updateCommonRegion,delCommonRegion
|
||||
* asn ip分组复用新增
|
||||
* @param asnIpCfgs
|
||||
*/
|
||||
public void asnIPRegionSendToMaat(List<AsnIpCfg> asnIpCfgs,Integer valid,Integer action) {
|
||||
public void asnIPRegionSendToMaat(List<AsnIpCfg> asnIpCfgs,Integer valid) {
|
||||
logger.warn("asnIPRegionSendToMaat start");
|
||||
long start=System.currentTimeMillis();
|
||||
GroupReuseAddBean maatBean = new GroupReuseAddBean();
|
||||
@@ -2936,19 +2891,19 @@ public abstract class BaseService {
|
||||
maatBean.setCreatorName(UserUtils.getUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
if(valid==Constants.VALID_YES) {
|
||||
maatBean.setOpAction(action);
|
||||
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(maatBean);
|
||||
if(asnIpCfgs.size()<=100) {
|
||||
logger.info("asn ip复用域 "+action+"下发配置参数:"+json);
|
||||
logger.info("asn ip复用域新增配置下发配置参数:"+json);
|
||||
}else {
|
||||
logger.info("asn ip复用域 "+action+" 配置下发region条数:"+asnIpCfgs.size());
|
||||
logger.info("asn ip复用域新增配置下发region条数:"+asnIpCfgs.size());
|
||||
}
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result =ConfigServiceUtil.auditCommonGroupRegionSources(json,action);
|
||||
logger.info("asn ip复用域 "+action+" 配置响应信息:"+result.getMsg());
|
||||
ToMaatResult result =ConfigServiceUtil.postGroupReuseSources(json);
|
||||
logger.info("asn ip复用域新增配置响应信息:"+result.getMsg());
|
||||
}else {
|
||||
maatBean.setOpAction(action);
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(maatBean);
|
||||
if(asnIpCfgs.size()<=100) {
|
||||
@@ -2958,301 +2913,13 @@ public abstract class BaseService {
|
||||
|
||||
}
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3);
|
||||
ToMaatResult result = ConfigServiceUtil.put(json,3);
|
||||
logger.info("asn ip复用域删除配置响应信息:"+result.getMsg());
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("asnIPRegionSendToMaat finish,cost:"+(end-start));
|
||||
}
|
||||
|
||||
/**
|
||||
* ASN关键字配置处理
|
||||
* @param asnList
|
||||
* @param entity
|
||||
*/
|
||||
public void handleAsn(List<AsnKeywordCfg> asnList,BaseCfg entity) {
|
||||
//无效子配置后,再新增子配置
|
||||
StringCfgDao stringCfgDao=SpringContextHolder.getBean(StringCfgDao.class);
|
||||
stringCfgDao.deleteAsnKeyword(entity);
|
||||
String commonGroupIds="";//公共表存储组织GroupIds
|
||||
if(asnList != null && asnList.size()>0){
|
||||
for (AsnKeywordCfg asnKeywordCfg : asnList) {
|
||||
BeanUtils.copyProperties(entity, asnKeywordCfg,new String[]{"cfgId","cfgRegionCode","cfgType","userRegion1","userRegion2","userRegion3","userRegion4","userRegion5"});
|
||||
asnKeywordCfg.setTableName(AsnKeywordCfg.getTablename());
|
||||
asnKeywordCfg.setIsAudit(entity.getIsAudit());
|
||||
asnKeywordCfg.setIsValid(entity.getIsValid());
|
||||
asnKeywordCfg.setEditTime(entity.getEditTime());
|
||||
asnKeywordCfg.setEditorId(entity.getEditorId());
|
||||
asnKeywordCfg.setExprType(0);
|
||||
asnKeywordCfg.setMatchMethod(3);
|
||||
asnKeywordCfg.setExType("0");
|
||||
asnKeywordCfg.setIsHexbin(0);
|
||||
asnKeywordCfg.setCreateTime(new Date());
|
||||
asnKeywordCfg.setCreatorId(UserUtils.getUser().getId());
|
||||
stringCfgDao.saveStringCfgBatch(asnKeywordCfg);
|
||||
|
||||
commonGroupIds+=asnKeywordCfg.getUserRegion1()+",";//组织GroupId
|
||||
}
|
||||
}
|
||||
if(!StringUtil.isEmpty(commonGroupIds)){
|
||||
commonGroupIds=commonGroupIds.substring(0, commonGroupIds.length()-1);
|
||||
}
|
||||
entity.setCommonGroupIds(commonGroupIds);
|
||||
//return entity;
|
||||
}
|
||||
/**
|
||||
* ASN关键字配置处理
|
||||
* @param asnList
|
||||
* @param entity
|
||||
*/
|
||||
public void auditAsnCfg(List<GroupCfg> groupRelationList,List<StringCfg> strRegionList,BaseCfg entity,List<AsnKeywordCfg> asnList){
|
||||
//注意:一条配置是一个分组,keywords=asnNos|userRegion1=groupId|userRegion2=isAuditAll 0 1
|
||||
if(!StringUtil.isEmpty(asnList)){
|
||||
AsnGroupInfoDao asnGroupInfoDao=SpringContextHolder.getBean(AsnGroupInfoDao.class);
|
||||
ConfigGroupInfoDao configGroupInfoDao=SpringContextHolder.getBean(ConfigGroupInfoDao.class);
|
||||
|
||||
//1、修改域配置为下发状态
|
||||
AsnKeywordCfg asnCfg=new AsnKeywordCfg();
|
||||
BeanUtils.copyProperties(entity, asnCfg);
|
||||
asnCfg.setTableName(AsnKeywordCfg.getTablename());
|
||||
IpCfgDao ipCfgDao=SpringContextHolder.getBean(IpCfgDao.class);
|
||||
ipCfgDao.auditCfg(asnCfg);
|
||||
|
||||
//需要标记为下发全部域的groupId集合
|
||||
List signAuditAllGroupList=new ArrayList<>();
|
||||
//需要标记下发的groupId
|
||||
List isUsedGroupIdList=new ArrayList<>();
|
||||
//所有已被策略引用过的域
|
||||
List<AsnGroupInfo> auditRegionList=new ArrayList<>();
|
||||
//所有未被策略过的域
|
||||
List<AsnGroupInfo> notAuditRegionList=new ArrayList<>();
|
||||
//域和分组的关系
|
||||
Map<String,String> groupWithRegion=new HashMap<>();
|
||||
//所有策略所选asn No
|
||||
List<String> asnNoList=new ArrayList<>();
|
||||
//所有未下发过的asnNo
|
||||
List<String> notAuditAsnNoList=new ArrayList<>();
|
||||
//最新的asn域集合
|
||||
List<AsnKeywordCfg> newAsnList=new ArrayList<>();
|
||||
|
||||
//2、记录标记为下发all的groupId|存储组和asnno的关系|记录需要标记为已下发的group
|
||||
for (AsnKeywordCfg asnKeywordCfg : asnList) {
|
||||
asnKeywordCfg.setUserRegion2(StringUtil.isEmpty(asnKeywordCfg.getUserRegion2()) ? "1":"0");
|
||||
if("1".equals(asnKeywordCfg.getUserRegion2())){ //是否标记为下发ALL
|
||||
signAuditAllGroupList.add(Integer.parseInt(asnKeywordCfg.getUserRegion1()));
|
||||
}
|
||||
for (String asnstr: asnKeywordCfg.getCfgKeywords().split(",")) {
|
||||
groupWithRegion.put(asnstr, asnKeywordCfg.getUserRegion1());
|
||||
}
|
||||
if(!isUsedGroupIdList.contains(Integer.parseInt(asnKeywordCfg.getUserRegion1()))){
|
||||
isUsedGroupIdList.add(Integer.parseInt(asnKeywordCfg.getUserRegion1()));
|
||||
}
|
||||
List<String> list=Arrays.asList(asnKeywordCfg.getCfgKeywords().split(","));
|
||||
asnNoList.addAll(list);
|
||||
}
|
||||
|
||||
//3、//根据asnNoList查询所有下发过的ASN NO
|
||||
if(!StringUtil.isEmpty(asnNoList)){
|
||||
auditRegionList=asnGroupInfoDao.findAsnGroupInfoByAsnNos(asnNoList, 1);
|
||||
}
|
||||
//已下发过的ASN NO只需要下发组
|
||||
if(!StringUtil.isEmpty(auditRegionList)){
|
||||
for (AsnGroupInfo asnGroupInfo : auditRegionList) {
|
||||
AsnKeywordCfg cfg = new AsnKeywordCfg();
|
||||
cfg.initDefaultValue();
|
||||
cfg.setTableName(AsnKeywordCfg.getTablename());
|
||||
cfg.setCfgType(asnList.get(0).getCfgType());
|
||||
cfg.setCompileId(entity.getCompileId());
|
||||
cfg.setCfgKeywords(asnGroupInfo.getGroupId().toString());//关键字
|
||||
cfg.setUserRegion1(groupWithRegion.get(asnGroupInfo.getAsnId().toString())); //组号
|
||||
cfg.setUserRegion2(asnGroupInfo.getRegionId().toString());//regionid
|
||||
cfg.setUserRegion3("0"); //是否下发域
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setFunctionId(entity.getFunctionId());
|
||||
newAsnList.add(cfg);
|
||||
}
|
||||
}
|
||||
|
||||
//4、查询所有未下发过的 ASN NO
|
||||
if(!StringUtil.isEmpty(asnNoList)){
|
||||
notAuditRegionList=asnGroupInfoDao.findAsnGroupInfoByAsnNos(asnNoList, 0);
|
||||
}
|
||||
|
||||
if(!StringUtil.isEmpty(notAuditRegionList)){
|
||||
for (AsnGroupInfo asnGroupInfo : notAuditRegionList) {
|
||||
AsnKeywordCfg cfg = new AsnKeywordCfg();
|
||||
cfg.initDefaultValue();
|
||||
cfg.setTableName(AsnKeywordCfg.getTablename());
|
||||
cfg.setCompileId(entity.getCompileId());
|
||||
cfg.setCfgType(asnList.get(0).getCfgType());
|
||||
cfg.setCfgKeywords(asnGroupInfo.getAsnId().toString());//关键字
|
||||
cfg.setUserRegion1(groupWithRegion.get(asnGroupInfo.getAsnId().toString())); //groupId
|
||||
cfg.setUserRegion2(asnGroupInfo.getRegionId().toString());//regionid
|
||||
cfg.setUserRegion3("1"); //是否下发域
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setFunctionId(entity.getFunctionId());
|
||||
newAsnList.add(cfg);
|
||||
notAuditAsnNoList.add(asnGroupInfo.getAsnId().toString());
|
||||
}
|
||||
}
|
||||
//5、修改所有下发的asn no为已下发
|
||||
if(!StringUtil.isEmpty(notAuditAsnNoList)){
|
||||
asnGroupInfoDao.updateIsUsedAndIsValid(notAuditAsnNoList,1,null);
|
||||
}
|
||||
//6、标记组已被策略标记为全部下发
|
||||
configGroupInfoDao.updateIsAuditAll(4, 1,signAuditAllGroupList );
|
||||
//7、标记组已被策略引用
|
||||
configGroupInfoDao.updateIsUsed(4, 1, isUsedGroupIdList);
|
||||
//8、maat配置转换
|
||||
if(!StringUtil.isEmpty(newAsnList)){
|
||||
Map<String,List> map = cfgConvert(strRegionList,newAsnList,7,entity,groupRelationList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*if(asnList!=null && asnList.size()>0){
|
||||
|
||||
for (AsnKeywordCfg asnKeywordCfg : asnList) {
|
||||
asnNoStr+=asnKeywordCfg.getCfgKeywords()+",";
|
||||
}
|
||||
|
||||
AsnKeywordCfg cfg = new AsnKeywordCfg();
|
||||
cfg.setTableName(AsnKeywordCfg.getTablename());
|
||||
cfg.setCompileId(entity.getCompileId());
|
||||
cfg.setIsAudit(entity.getIsAudit());
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditorId(entity.getAuditorId());
|
||||
cfg.setAuditTime(entity.getAuditTime());
|
||||
cfg.setFunctionId(entity.getFunctionId());
|
||||
ipCfgDao.auditCfg(cfg);
|
||||
Map<String,List> map = cfgConvert(strRegionList,asnList,7,entity,groupRelationList);
|
||||
groupRelationList=map.get("groupList");
|
||||
strRegionList=map.get("dstList");
|
||||
}
|
||||
//修改配置选中的ASN NO 和 asn orga是否被策略引用过
|
||||
if(!StringUtil.isEmpty(asnNoStr)){
|
||||
asnNoStr=asnNoStr.substring(0, asnNoStr.length()-1);
|
||||
if(!StringUtil.isEmpty(asnNoStr)){
|
||||
//如果asnGroup由is_use=0,修改为is_use=1;查询asn no下所有未下发的asn ip,并进行下发,走POST接口【暂时不考虑】
|
||||
AsnIpCfgDao asnIpCfgDao=SpringContextHolder.getBean(AsnIpCfgDao.class);
|
||||
AsnIpCfg asnIp=new AsnIpCfg();
|
||||
asnIp.setIsAudit(0);
|
||||
asnIp.setIsValid(0);
|
||||
List<AsnIpCfg> asnIpList=asnIpCfgDao.findAllListByAsnGroup(asnIp, null, asnNoStr);
|
||||
|
||||
//下发asn IP和修改asn ip的状态必须在一个事物中
|
||||
//重新修改下发时间,下发人员信息
|
||||
AsnIpCfg auditAsnIpCfg=new AsnIpCfg();
|
||||
auditAsnIpCfg.setIsAudit(1);
|
||||
auditAsnIpCfg.setAuditTime(new Date());
|
||||
auditAsnIpCfg.setAuditorId(UserUtils.getUser().getId());
|
||||
auditAsnIpCfg.setIsValid(1);
|
||||
auditAllAsnRegionCfg(auditAsnIpCfg, null, asnNoStr);
|
||||
|
||||
AsnGroupInfoDao asnGroupInfoDao=SpringContextHolder.getBean(AsnGroupInfoDao.class);
|
||||
asnGroupInfoDao.updateIsUsed(asnNoStr, 1);
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置取消时,需要将公共组id发送至服务端
|
||||
* @param maatCfg
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public MaatCfg addKeepGroupList(MaatCfg maatCfg,BaseCfg entity){
|
||||
if(!StringUtil.isEmpty(entity.getCommonGroupIds())){
|
||||
List<GroupCfg> keepGroupList = new ArrayList();
|
||||
String[] orgGroupIds=entity.getCommonGroupIds().split(",");
|
||||
for (int i = 0; i < orgGroupIds.length; i++) {
|
||||
if(!StringUtil.isEmpty(orgGroupIds[i])){
|
||||
GroupCfg groupCfg=new GroupCfg();
|
||||
groupCfg.setGroupId(Integer.parseInt(orgGroupIds[i]));
|
||||
keepGroupList.add(groupCfg);
|
||||
}
|
||||
}
|
||||
if(!StringUtil.isEmpty(keepGroupList)){
|
||||
maatCfg.setKeepGroupList(keepGroupList);
|
||||
}
|
||||
}
|
||||
return maatCfg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共组新增域
|
||||
* @param srcMap
|
||||
* @param isValid
|
||||
* @param cfgType
|
||||
* @param commonType 公共组类型 4 ASN
|
||||
* @return
|
||||
*/
|
||||
public static <T> List<GroupReuseCfg> convertCommonRegion(Map<Integer,List<T>> srcMap,List<GroupReuseCfg> commonGroupList,Integer isValid,Integer cfgType,Integer commonType) {
|
||||
for (Integer groupId : srcMap.keySet()) {
|
||||
GroupReuseCfg groupCfg=new GroupReuseCfg();
|
||||
List<StringCfg> strRegionList=new ArrayList<>();
|
||||
List<IpCfg> ipRegionList=new ArrayList<>();
|
||||
List<NumBoundaryCfg> numRegionList=new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < srcMap.get(groupId).size(); i++) {
|
||||
if (cfgType == 1) {
|
||||
IpCfg cfg = new IpCfg();
|
||||
BaseIpCfg baseIpCfg = (BaseIpCfg)srcMap.get(groupId).get(i);
|
||||
// 区域IP配置,多条IP配置属于同一个分组,其他业务配置IP,一条配置一个分组
|
||||
cfg.setGroupId(groupId);
|
||||
List<IpCfg> cfgs = ipConvert(cfg, baseIpCfg);
|
||||
ipRegionList.addAll(cfgs);
|
||||
|
||||
}
|
||||
if(cfgType==4){
|
||||
// 一条业务配置创建一个分组
|
||||
NumBoundaryCfg cfg = new NumBoundaryCfg();
|
||||
BeanUtils.copyProperties(srcMap.get(groupId).get(i), cfg);
|
||||
cfg.setGroupId(groupId);
|
||||
numRegionList.add(cfg);
|
||||
}
|
||||
if(cfgType==2 || cfgType==3){
|
||||
// 一条业务配置创建一个分组
|
||||
StringCfg cfg = new StringCfg();
|
||||
BaseStringCfg strCfg=(BaseStringCfg)srcMap.get(groupId).get(i);
|
||||
BeanUtils.copyProperties(srcMap.get(groupId).get(i), cfg);
|
||||
cfg.setGroupId(groupId);
|
||||
cfg.setCfgType(strCfg.getCfgType());
|
||||
cfg.setRegionId(cfg.getRegionId());
|
||||
cfg.setAuditTime(strCfg.getAuditTime());
|
||||
cfg.setMatchMethod(strCfg.getMatchMethod());
|
||||
cfg.setIsValid(isValid);
|
||||
cfg.setIsHexbin(strCfg.getIsHexbin());
|
||||
cfg.setExprType(strCfg.getExprType());
|
||||
// 处理配置关键字转译
|
||||
if(commonType == 4){
|
||||
cfg.setCfgKeywords(Constants.ASN_KEY+keywordsEscape(cfg.getCfgKeywords()));
|
||||
}else{
|
||||
cfg.setCfgKeywords(keywordsEscape(cfg.getCfgKeywords()));
|
||||
}
|
||||
|
||||
// 增强字符串转换
|
||||
cfg.setDistrict(keywordsEscape(cfg.getDistrict()));
|
||||
strRegionList.add(cfg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
groupCfg.setStrRegionList(strRegionList);
|
||||
groupCfg.setIpRegionList(ipRegionList);
|
||||
groupCfg.setNumRegionList(numRegionList);
|
||||
commonGroupList.add(groupCfg);
|
||||
}
|
||||
return commonGroupList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理IpSpoofing配置导入
|
||||
* @param list
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.nis.web.service.basics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -14,9 +13,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.basics.AsnGroupInfo;
|
||||
import com.nis.domain.configuration.AsnKeywordCfg;
|
||||
import com.nis.domain.maat.GroupReuseAddBean;
|
||||
import com.nis.domain.maat.GroupReuseCfg;
|
||||
import com.nis.domain.maat.MaatCfg;
|
||||
import com.nis.domain.maat.ToMaatBean;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
@@ -89,8 +85,6 @@ public class AsnGroupInfoService extends BaseService{
|
||||
configGroupInfo.setGroupName(org.toUpperCase());
|
||||
configGroupInfo.setIsIssued(0);
|
||||
configGroupInfo.setGroupType(4);
|
||||
configGroupInfo.setIsAuditAll(0);
|
||||
configGroupInfo.setIsUsed(0);
|
||||
configGroupInfo.setGroupId(groupIds.get(1));
|
||||
configGroupInfo.setInsertTime(new Date());
|
||||
configGroupInfoDao.insertConfigGroupInfo(configGroupInfo);
|
||||
@@ -110,33 +104,13 @@ public class AsnGroupInfoService extends BaseService{
|
||||
entity.setCreateTime(createTime);
|
||||
entity.setGroupId(groupId);
|
||||
entity.setIsValid(0);
|
||||
//分组已被策略设定为下发全部域,则需要自动下发新增的asno
|
||||
if(configGroupInfo.getIsAuditAll() != null && configGroupInfo.getIsAuditAll().equals(1)){
|
||||
entity.setIsUsed(1);
|
||||
}else{
|
||||
entity.setIsUsed(0);
|
||||
}
|
||||
|
||||
List<Integer> compileIds= ConfigServiceUtil.getId(1,1);
|
||||
if(compileIds.size()>0) {
|
||||
entity.setCompileId(compileIds.get(0));
|
||||
}else {
|
||||
throw new MaatConvertException("Get asn reigon id failed");
|
||||
}
|
||||
List<Integer> regionIds= ConfigServiceUtil.getId(3,1);
|
||||
if(regionIds.size()>0) {
|
||||
entity.setRegionId(regionIds.get(0));
|
||||
}else {
|
||||
throw new MaatConvertException("Get asn reigon id failed");
|
||||
throw new MaatConvertException("Get asn group id failed");
|
||||
}
|
||||
asnGroupInfoDao.insert(entity);
|
||||
//新增,需要判断组是否被标记为全量下发,如果标记则下发新增的,没有不下发
|
||||
if(configGroupInfo.getIsAuditAll() != null
|
||||
&& configGroupInfo.getIsAuditAll().equals(1)
|
||||
&& configGroupInfo.getIsUsed()!= null
|
||||
&& configGroupInfo.getIsUsed().equals(1)){
|
||||
auditAsn(entity,configGroupInfo,Constants.OPACTION_POST);
|
||||
}
|
||||
//修改
|
||||
}else{
|
||||
long id=entity.getId();
|
||||
@@ -157,8 +131,6 @@ public class AsnGroupInfoService extends BaseService{
|
||||
configGroupInfo1.setGroupName(entity.getOrganization().toUpperCase());
|
||||
configGroupInfo1.setIsIssued(0);
|
||||
configGroupInfo1.setGroupType(4);
|
||||
configGroupInfo1.setIsUsed(0);
|
||||
configGroupInfo1.setIsAuditAll(0);
|
||||
configGroupInfo1.setGroupId(groupIds.get(1));
|
||||
configGroupInfo1.setInsertTime(new Date());
|
||||
configGroupInfoDao.insertConfigGroupInfo(configGroupInfo1);
|
||||
@@ -169,151 +141,53 @@ public class AsnGroupInfoService extends BaseService{
|
||||
entity.setGroupId(groupId);
|
||||
asnGroupInfoDao.update(entity);
|
||||
asnIpCfgDao.updateAsn(String.valueOf(entity.getAsnId()),entity.getOrganization(),entity.getCountry(),entity.getDetail());
|
||||
if(configGroupInfo1.getIsUsed()!= null
|
||||
&& configGroupInfo1.getIsUsed().equals(1)){
|
||||
group.setGroupId(groupId);
|
||||
group.setAsnId(entity.getAsnId());
|
||||
auditAsn(group,configGroupInfo1,Constants.OPACTION_PUT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
public void auditAsn(AsnGroupInfo entity,ConfigGroupInfo group,Integer action){
|
||||
Map<Integer, List<AsnKeywordCfg>> srcMap=new HashMap<>();
|
||||
List srcList=new ArrayList<>();
|
||||
AsnKeywordCfg cfg=new AsnKeywordCfg();
|
||||
cfg.initDefaultValue();
|
||||
cfg.setGroupId(group.getGroupId());
|
||||
cfg.setCfgKeywords(entity.getAsnId().toString());
|
||||
cfg.setRegionId(entity.getRegionId());
|
||||
cfg.setCfgType(Constants.NTC_ASN_NUMBER);
|
||||
cfg.setAuditTime(new Date());
|
||||
srcList.add(cfg);
|
||||
srcMap.put(group.getGroupId(), srcList);
|
||||
GroupReuseAddBean commonGroupBean=new GroupReuseAddBean();
|
||||
List<GroupReuseCfg> commonGroupList=new ArrayList<>();
|
||||
commonGroupList=convertCommonRegion(srcMap,commonGroupList,1,2,4);
|
||||
commonGroupBean.setGroupReuseCfgList(commonGroupList);
|
||||
//如果已经被引用,则修改
|
||||
commonGroupBean.setAuditTime(new Date());
|
||||
commonGroupBean.setCreatorName(UserUtils.getUser().getName());
|
||||
commonGroupBean.setVersion(Constants.MAAT_VERSION);
|
||||
if(entity.getIsUsed() != null && entity.getIsUsed().equals(1)){ //已经被引用过的asn可调用修改region
|
||||
commonGroupBean.setOpAction(action);
|
||||
String json = gsonToJson(commonGroupBean);
|
||||
logger.info("ASN配置下发配置参数:" + json);
|
||||
// 调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json, action);
|
||||
}else{//已经被引用过的asn可调用新增region
|
||||
commonGroupBean.setOpAction(action);
|
||||
String json = gsonToJson(commonGroupBean);
|
||||
logger.info("ASN配置下发配置参数:" + json);
|
||||
// 调用服务接口下发配
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json, action);
|
||||
}
|
||||
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void delete(String ids,String asnIds){
|
||||
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
List<GroupReuseCfg> commonGroupList=new ArrayList<>();
|
||||
//查询已经被策略引用的asn
|
||||
List<AsnGroupInfo> asnList=asnGroupInfoDao.findAsnGroupInfoByAsnNos(Arrays.asList(asnIds.split(",")), 1);
|
||||
//修改asn为无效,且解除引用
|
||||
asnGroupInfoDao.updateIsUsedAndIsValid(Arrays.asList(asnIds.split(",")), 0, -1);
|
||||
//删除asn下的所有asn IP
|
||||
asnIpCfgDao.deleteByAsnId(asnIds);
|
||||
|
||||
//查询已经被策略引用的asn,需要走取消接口
|
||||
if(!StringUtil.isEmpty(asnList)){
|
||||
Map<Integer, List<AsnKeywordCfg>> srcMap=new HashMap<>();
|
||||
Map<String, Integer> groupIdMap=new HashMap<>();
|
||||
for (AsnGroupInfo asnGroupInfo : asnList) {
|
||||
//查询groupId
|
||||
if(StringUtil.isEmpty(groupIdMap.get(asnGroupInfo.getOrganization()))){
|
||||
ConfigGroupInfo group=configGroupInfoDao.getAsnGroupByName(asnGroupInfo.getOrganization());
|
||||
groupIdMap.put(asnGroupInfo.getOrganization(), group.getGroupId());
|
||||
List<AsnKeywordCfg> list1=new ArrayList<>();
|
||||
AsnKeywordCfg asnCfg=new AsnKeywordCfg();
|
||||
asnCfg.initDefaultValue();
|
||||
asnCfg.setCfgType(Constants.NTC_ASN_NUMBER);
|
||||
asnCfg.setRegionId(asnGroupInfo.getRegionId());
|
||||
asnCfg.setGroupId(group.getGroupId());
|
||||
asnCfg.setIsValid(0);
|
||||
list1.add(asnCfg);
|
||||
srcMap.put(group.getGroupId(), list1);
|
||||
}else{
|
||||
Integer groupId=groupIdMap.get(asnGroupInfo.getOrganization());
|
||||
List list2=srcMap.get(groupId);
|
||||
AsnKeywordCfg asnCfg=new AsnKeywordCfg();
|
||||
asnCfg.initDefaultValue();
|
||||
asnCfg.setCfgType(Constants.NTC_ASN_NUMBER);
|
||||
asnCfg.setRegionId(asnGroupInfo.getRegionId());
|
||||
asnCfg.setGroupId(groupId);
|
||||
asnCfg.setIsValid(0);
|
||||
list2.add(asnCfg);
|
||||
srcMap.put(groupId, list2);
|
||||
List<FunctionServiceDict> dicts=DictUtils.getFunctionServiceDictList(600);
|
||||
int result=0;
|
||||
do {
|
||||
result=asnIpCfgDao.deleteByAsnId(asnIds);
|
||||
}while(result>0);
|
||||
for (String id : ids.split(",")) {
|
||||
if(!StringUtil.isEmpty(id)){
|
||||
AsnGroupInfo entity=asnGroupInfoDao.getById(Integer.parseInt(id));
|
||||
int valid=entity.getIsValid();
|
||||
entity.setIsValid(-1);
|
||||
entity.setId(Long.parseLong(id));
|
||||
asnGroupInfoDao.updateValid(entity);
|
||||
if(asnGroupInfoDao.getCountGroupInfoByName(entity.getOrganization())==0) {
|
||||
configGroupInfoDao.delAsnGroup(entity.getOrganization());
|
||||
}
|
||||
//取消下发过的编译
|
||||
if(valid==1) {
|
||||
ToMaatBean maatBean = new ToMaatBean();
|
||||
MaatCfg maatCfg = new MaatCfg();
|
||||
List<MaatCfg> configCompileList = new ArrayList();
|
||||
maatCfg.setCompileId(entity.getCompileId());
|
||||
maatCfg.setServiceId(dicts.get(0).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("asn ip配置取消配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult _result = ConfigServiceUtil.put(json,1);
|
||||
logger.info("asn ip配置取消配置响应信息:"+_result.getMsg());
|
||||
}
|
||||
}
|
||||
commonGroupList=convertCommonRegion(srcMap, commonGroupList, 0, 2,4);
|
||||
GroupReuseAddBean commonGroupBean=new GroupReuseAddBean();
|
||||
commonGroupBean.setGroupReuseCfgList(commonGroupList);
|
||||
commonGroupBean.setAuditTime(new Date());
|
||||
commonGroupBean.setCreatorName(UserUtils.getUser().getName());
|
||||
commonGroupBean.setVersion(Constants.MAAT_VERSION);
|
||||
commonGroupBean.setOpAction(2);
|
||||
String json = gsonToJson(commonGroupBean);
|
||||
logger.info("ASN配置下发配置参数:" + json);
|
||||
// 调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*List<FunctionServiceDict> dicts=DictUtils.getFunctionServiceDictList(600);
|
||||
int result=0;
|
||||
do {
|
||||
result=asnIpCfgDao.deleteByAsnId(asnIds);
|
||||
}while(result>0);
|
||||
for (String id : ids.split(",")) {
|
||||
if(!StringUtil.isEmpty(id)){
|
||||
AsnGroupInfo entity=asnGroupInfoDao.getById(Integer.parseInt(id));
|
||||
int valid=entity.getIsValid();
|
||||
entity.setIsValid(-1);
|
||||
entity.setId(Long.parseLong(id));
|
||||
asnGroupInfoDao.updateValid(entity);
|
||||
if(asnGroupInfoDao.getCountGroupInfoByName(entity.getOrganization())==0) {
|
||||
configGroupInfoDao.delAsnGroup(entity.getOrganization());
|
||||
}
|
||||
//取消下发过的编译
|
||||
if(valid==1) {
|
||||
ToMaatBean maatBean = new ToMaatBean();
|
||||
MaatCfg maatCfg = new MaatCfg();
|
||||
List<MaatCfg> configCompileList = new ArrayList();
|
||||
maatCfg.setCompileId(entity.getCompileId());
|
||||
maatCfg.setServiceId(dicts.get(0).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("asn ip配置取消配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult _result = ConfigServiceUtil.put(json,1);
|
||||
logger.info("asn ip配置取消配置响应信息:"+_result.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
public boolean checkIps(String groupIds) {
|
||||
for(String groupId:groupIds.split(",")) {
|
||||
@@ -360,13 +234,4 @@ public class AsnGroupInfoService extends BaseService{
|
||||
}
|
||||
return map;
|
||||
}
|
||||
public List<AsnGroupInfo> findAsnGroupList(AsnGroupInfo asnGroupInfo){
|
||||
List<AsnGroupInfo> list=asnGroupInfoDao.findAsnGroupInfoByAsnGroup(asnGroupInfo);
|
||||
return list;
|
||||
}
|
||||
public List<AsnGroupInfo> findAsnGroupList(List<String> asnNos,Integer isUsed){
|
||||
List<AsnGroupInfo> list=asnGroupInfoDao.findAsnGroupInfoByAsnNos(asnNos,null );
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ import com.nis.domain.basics.AsnGroupInfo;
|
||||
import com.nis.domain.basics.AsnIpCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.maat.GroupReuseAddBean;
|
||||
import com.nis.domain.maat.GroupReuseCfg;
|
||||
import com.nis.domain.maat.MaatCfg;
|
||||
import com.nis.domain.maat.MaatCfg.DigestCfg;
|
||||
import com.nis.domain.maat.MaatCfg.GroupCfg;
|
||||
@@ -36,7 +34,6 @@ import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.domain.specific.ConfigGroupInfo;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.CrudDao;
|
||||
import com.nis.web.dao.basics.AsnGroupInfoDao;
|
||||
import com.nis.web.dao.basics.AsnIpCfgDao;
|
||||
@@ -103,8 +100,6 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void update(AsnIpCfg entity){
|
||||
List<AsnIpCfg> auditAsnIpList=new ArrayList<>();
|
||||
List<AsnGroupInfo> auditAsnGroupList=new ArrayList<>();
|
||||
Date editTime=new Date();
|
||||
entity.setEditTime(editTime);
|
||||
entity.setEditorId(entity.getCurrentUser().getId());
|
||||
@@ -119,53 +114,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
entity.setCountry(country);
|
||||
entity.setDetail(detail);
|
||||
entity.setCompileId(groupInfo.getCompileId());
|
||||
/**
|
||||
* isvalid=0 and asnNo=false 直接修改
|
||||
* isvalid=0 and asnNo=true 需要下发
|
||||
* isvalid=1 需要下发asnNo下所有的域配置
|
||||
*/
|
||||
/*if(groupInfo.getIsUsed().equals(1) && entity.getIsValid().equals(Constants.VALID_NO)){
|
||||
entity.setAuditTime(editTime);
|
||||
entity.setAuditorId(entity.getCurrentUser().getId());
|
||||
entity.setIsValid(Constants.VALID_YES);
|
||||
entity.setIsAudit(Constants.AUDIT_YES);
|
||||
auditAsnIpList.add(entity);
|
||||
}
|
||||
if(groupInfo.getIsUsed().equals(1) && entity.getIsValid().equals(Constants.VALID_YES)){
|
||||
entity.setAuditTime(editTime);
|
||||
entity.setAuditorId(entity.getCurrentUser().getId());
|
||||
entity.setIsValid(Constants.VALID_YES);
|
||||
entity.setIsAudit(Constants.AUDIT_YES);
|
||||
auditAsnGroupList.add(groupInfo);
|
||||
}*/
|
||||
if(entity.getIsValid() ==1){
|
||||
entity.setAuditTime(editTime);
|
||||
entity.setAuditorId(entity.getCurrentUser().getId());
|
||||
entity.setEditTime(editTime);
|
||||
entity.setEditorId(entity.getCurrentUser().getId());
|
||||
entity.setIsValid(Constants.VALID_YES);
|
||||
entity.setIsAudit(Constants.AUDIT_YES);
|
||||
}else{
|
||||
entity.setEditTime(editTime);
|
||||
entity.setEditorId(entity.getCurrentUser().getId());
|
||||
entity.setIsValid(Constants.VALID_NO);
|
||||
entity.setIsAudit(Constants.VALID_NO);
|
||||
}
|
||||
asnIpCfgDao.update(entity);
|
||||
//ASN下发状态时可以更改,更改之后直接下发
|
||||
if(entity.getIsValid() ==1){
|
||||
auditAsnIpList.add(entity);
|
||||
asnIPRegionSendToMaat(auditAsnIpList,Constants.VALID_YES,Constants.OPACTION_PUT);
|
||||
}
|
||||
//common group 新增下发 ASN IP配置
|
||||
/*if(!StringUtil.isEmpty(auditAsnIpList)){
|
||||
asnIPRegionSendToMaat(auditAsnIpList,Constants.VALID_YES,Constants.OPACTION_POST);
|
||||
}*/
|
||||
|
||||
//common group 修改已下发过的配置,全量下发 ASN NO下的所有有效配置
|
||||
/*if(entity.getIsAudit().equals(Constants.VALID_YES)){
|
||||
auditAllAsnRegionCfg(entity,auditAsnGroupList,null);
|
||||
}*/
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void processGroup(Map<Long,AsnGroupInfo> asnNoMap){
|
||||
@@ -307,12 +256,11 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
}
|
||||
sb.deleteCharAt(sb.toString().lastIndexOf(","));
|
||||
asnIpCfgDao.delete(sb.toString());
|
||||
asnIPRegionSendToMaat(entities,Constants.VALID_NO,Constants.OPACTION_PUT);
|
||||
asnIPRegionSendToMaat(entities,Constants.VALID_NO);
|
||||
}
|
||||
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveAsnIpCfg(CfgIndexInfo entity) {
|
||||
List<AsnIpCfg> auditAsnIpList=new ArrayList<>();
|
||||
Date createTime=new Date();
|
||||
//asn号
|
||||
String userRegion1=entity.getUserRegion1();
|
||||
@@ -353,27 +301,13 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
cfg.setCreateTime(createTime);
|
||||
cfg.setCreatorId(entity.getCurrentUser().getId());
|
||||
cfg.setAsnIpGroup(entity.getAsnIpGroup().intValue());
|
||||
cfg.setIsValid(Constants.VALID_NO);
|
||||
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
||||
cfg.setRegionId(idList.get(index));
|
||||
//TODO 注意:被策略引用并下发过的ASN NO,配置新增后直接下发【此功能暂时不做自动,asnip拥有审核功能】
|
||||
/*if(asnGroupInfo.getIsUsed().equals(1)){
|
||||
cfg.setIsValid(Constants.VALID_YES);
|
||||
cfg.setIsAudit(Constants.AUDIT_YES);
|
||||
cfg.setAuditorId(UserUtils.getUser().getId());
|
||||
cfg.setAuditTime(createTime);
|
||||
auditAsnIpList.add(cfg);
|
||||
}else{*/
|
||||
cfg.setIsValid(Constants.VALID_NO);
|
||||
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
||||
/*}*/
|
||||
index++;
|
||||
}
|
||||
|
||||
}
|
||||
this.save(entity.getAsnIpCfgs());
|
||||
//TODO 注意:被策略引用并下发过的ASN NO,配置新增后直接下发【此功能暂时不做自动,asnip拥有审核功能】
|
||||
/*if(!StringUtil.isEmpty(auditAsnIpList)){
|
||||
asnIPRegionSendToMaat(auditAsnIpList,Constants.VALID_YES,Constants.OPACTION_POST);
|
||||
}*/
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void delete(String ids) {
|
||||
@@ -398,7 +332,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
//已经下发过的,调用分组复用配置删除接口
|
||||
// splitAndSend(issuedList,Constants.VALID_NO);
|
||||
if(issuedList.size() > 0){
|
||||
asnIPRegionSendToMaat(issuedList,Constants.VALID_NO,Constants.OPACTION_PUT);
|
||||
asnIPRegionSendToMaat(issuedList,Constants.VALID_NO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -506,11 +440,14 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void auditIpBatch(List<AsnIpCfg> asnIpCfgs,Long asn,Integer isValid) {
|
||||
List<AsnGroupInfo> auditAsnGroupList=new ArrayList<>();
|
||||
public void auditIpBatch(Map<Long,List<AsnIpCfg>> data,Integer isValid) {
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
final SqlSession batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
try{
|
||||
for(Entry<Long,List<AsnIpCfg>> enrty:data.entrySet()) {
|
||||
//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);
|
||||
@@ -524,7 +461,6 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
asnGroupInfo.setAsnId(asn);
|
||||
asnGroupInfo=asnGroupInfoDao.getInfoByAsnNo(asnGroupInfo);
|
||||
Integer groupId=asnGroupInfo.getGroupId();
|
||||
|
||||
MaatCfg maatCfg = new MaatCfg();
|
||||
List<MaatCfg> configCompileList = new ArrayList();
|
||||
List<GroupCfg> groupRelationList = new ArrayList();
|
||||
@@ -548,8 +484,6 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
groupCfg.setCompileId(asnGroupInfo.getCompileId());
|
||||
groupCfg.setGroupId(groupId);
|
||||
groupCfg.setIsValid(Constants.VALID_YES);
|
||||
//asnGroupId标记为公共组
|
||||
groupCfg.setIsCommonGroup(1);
|
||||
groupCfg.setAuditTime(asnIpCfgs.get(0).getAuditTime());
|
||||
groupRelationList.add(groupCfg);
|
||||
BeanUtils.copyProperties(asnIpCfgs.get(0), maatCfg);
|
||||
@@ -583,7 +517,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
}else if(asnGroupInfo.getIsValid()==1){//已经下发过,走分组复用
|
||||
asnGroupInfo.setIssuedIPs(issuedNum+0l);
|
||||
asnGroupInfoDao.update(asnGroupInfo);
|
||||
asnIPRegionSendToMaat(asnIpCfgs,isValid,Constants.OPACTION_POST);
|
||||
asnIPRegionSendToMaat(asnIpCfgs,isValid);
|
||||
}else {
|
||||
throw new RuntimeException("asnGroupInfo isValid value is "+asnGroupInfo.getIsValid());
|
||||
}
|
||||
@@ -591,34 +525,39 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
asnGroupInfo.setIssuedIPs(0L-issuedNum);
|
||||
asnGroupInfoDao.update(asnGroupInfo);
|
||||
//已经下发过的,调用分组复用配置删除接口
|
||||
GroupReuseAddBean maatBean = new GroupReuseAddBean();
|
||||
List<GroupReuseCfg> groupReuseList=new ArrayList<>();
|
||||
GroupReuseCfg groupReuseCfg=new GroupReuseCfg();
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(asnIpCfgs,Constants.VALID_NO,groupId));
|
||||
groupReuseCfg.setIpRegionList(ipRegionList);
|
||||
groupReuseCfg.setStrRegionList(strRegionList);
|
||||
groupReuseCfg.setNumRegionList(numRegionList);
|
||||
groupReuseList.add(groupReuseCfg);
|
||||
maatBean.setGroupReuseCfgList(groupReuseList);
|
||||
maatBean.setAuditTime(asnIpCfgs.get(0).getAuditTime());
|
||||
maatBean.setCreatorName(asnIpCfgs.get(0).getCurrentUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("ASN IP域删除配置下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3);
|
||||
logger.info("ASN IP域删除配置响应信息:"+result.getMsg());
|
||||
// GroupReuseAddBean maatBean = new GroupReuseAddBean();
|
||||
// List<GroupReuseCfg> groupReuseList=new ArrayList<>();
|
||||
// GroupReuseCfg groupReuseCfg=new GroupReuseCfg();
|
||||
// ipRegionList.addAll(groupReuseCfgAddRemoveConvert(asnIpCfgs,Constants.VALID_NO,groupId));
|
||||
// groupReuseCfg.setIpRegionList(ipRegionList);
|
||||
// groupReuseCfg.setStrRegionList(strRegionList);
|
||||
// groupReuseCfg.setNumRegionList(numRegionList);
|
||||
// groupReuseList.add(groupReuseCfg);
|
||||
// maatBean.setGroupReuseCfgList(groupReuseList);
|
||||
// maatBean.setAuditTime(asnIpCfgs.get(0).getAuditTime());
|
||||
// maatBean.setCreatorName(asnIpCfgs.get(0).getCurrentUser().getName());
|
||||
// maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
// maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
// //调用服务接口下发配置数据
|
||||
// String json=gsonToJson(maatBean);
|
||||
// logger.info("ASN IP域删除配置下发配置参数:"+json);
|
||||
// //调用服务接口下发配置
|
||||
// ToMaatResult result = ConfigServiceUtil.put(json,3);
|
||||
// logger.info("ASN IP域删除配置响应信息:"+result.getMsg());
|
||||
asnIPRegionSendToMaat(asnIpCfgs,isValid);
|
||||
//如果一个asn组下没有IP了,修改有效状态
|
||||
if(hasValidAsnIp(asn)) {
|
||||
asnGroupInfo.setIsValid(0);
|
||||
asnGroupInfo.setEditorId(UserUtils.getUser().getId());
|
||||
asnGroupInfo.setEditTime(new Date());
|
||||
asnGroupInfoDao.updateValid(asnGroupInfo);
|
||||
}
|
||||
//if(hasValidAsnIp(asn)) {
|
||||
// asnGroupInfo.setIsValid(0);
|
||||
// asnGroupInfo.setEditorId(UserUtils.getUser().getId());
|
||||
// asnGroupInfo.setEditTime(new Date());
|
||||
// asnGroupInfoDao.updateValid(asnGroupInfo);
|
||||
//}
|
||||
|
||||
}else {
|
||||
throw new RuntimeException("isValid value is "+isValid);
|
||||
}
|
||||
//});
|
||||
}
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
|
||||
@@ -1212,7 +1212,6 @@ public class AppCfgService extends BaseService {
|
||||
GroupCfg groupCfg=new GroupCfg();
|
||||
groupCfg.setCompileId(entitys.get(0).getCompileId());
|
||||
groupCfg.setGroupId(groupId);
|
||||
groupCfg.setIsCommonGroup(1);
|
||||
groupCfg.setIsValid(Constants.VALID_YES);
|
||||
groupCfg.setAuditTime(entitys.get(0).getAuditTime());
|
||||
groupRelationList.add(groupCfg);
|
||||
@@ -1251,7 +1250,7 @@ public class AppCfgService extends BaseService {
|
||||
List<GroupReuseCfg> groupReuseList=new ArrayList<>();
|
||||
GroupReuseCfg groupReuseCfg=new GroupReuseCfg();
|
||||
/*groupReuseCfg.setUserRegion(userRegion);*/
|
||||
/*groupReuseCfg.setServiceId(entitys.get(0).getServiceId());*/
|
||||
groupReuseCfg.setServiceId(entitys.get(0).getServiceId());
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(entitys,Constants.VALID_YES,groupId));
|
||||
groupReuseCfg.setIpRegionList(ipRegionList);
|
||||
groupReuseCfg.setStrRegionList(strRegionList);
|
||||
@@ -1266,7 +1265,7 @@ public class AppCfgService extends BaseService {
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("app协议IP域新增配置下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,1);
|
||||
ToMaatResult result = ConfigServiceUtil.postGroupReuseSources(json);
|
||||
logger.info("app协议IP域新增配置响应信息:"+result.getMsg());
|
||||
}else {
|
||||
throw new RuntimeException("Unknown configGroupInfo isIssued value");
|
||||
@@ -1290,7 +1289,7 @@ public class AppCfgService extends BaseService {
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("app协议IP域删除配置下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3);
|
||||
ToMaatResult result = ConfigServiceUtil.put(json,3);
|
||||
logger.info("app协议IP域删除配置响应信息:"+result.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1513,7 +1513,7 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
List<GroupReuseCfg> groupReuseList=new ArrayList<>();
|
||||
GroupReuseCfg groupReuseCfg=new GroupReuseCfg();
|
||||
/*groupReuseCfg.setUserRegion(userRegion);*/
|
||||
/*groupReuseCfg.setServiceId(entitys.get(0).getServiceId());*/
|
||||
groupReuseCfg.setServiceId(entitys.get(0).getServiceId());
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(entitys,entity.getIsValid(),entitys.get(0).getGroupId()));
|
||||
groupReuseCfg.setIpRegionList(ipRegionList);
|
||||
groupReuseCfg.setStrRegionList(strRegionList);
|
||||
@@ -1592,7 +1592,7 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
}else {
|
||||
logger.info("app ip批量生效:"+json);
|
||||
//调用服务接口同步回调类配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,1);
|
||||
ToMaatResult result = ConfigServiceUtil.postGroupReuseSources(json);
|
||||
if(result!=null){
|
||||
logger.info("app ip批量生效响应信息:"+result.getMsg());
|
||||
}
|
||||
|
||||
@@ -132,8 +132,6 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
entity.setCompileId(compileId);
|
||||
entity.setCreateTime(new Date());
|
||||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||||
//保存asn组织信息 字符串域信息
|
||||
handleAsn(entity.getAsnKeywords(), entity);
|
||||
ipCfgDao.saveCfgIndex(entity);
|
||||
if(entity.getIpPortList()!=null){
|
||||
for(IpPortCfg cfg:entity.getIpPortList()){
|
||||
@@ -157,15 +155,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) {
|
||||
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());
|
||||
//保存asn组织信息 字符串域信息
|
||||
handleAsn(entity.getAsnKeywords(), entity);
|
||||
ipCfgDao.updateCfgIndex(entity);
|
||||
entity.setCreateTime(new Date());
|
||||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||||
//无效子配置后,再新增子配置
|
||||
ipCfgDao.deleteIpCfg(entity);
|
||||
stringCfgDao.deleteSubscribeIdCfgByCfgIndexInfo(entity);
|
||||
@@ -173,6 +198,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
area.setCompileId(entity.getCompileId());
|
||||
area.setFunctionId(entity.getFunctionId());
|
||||
areaIpCfgDao.deleteAreaIpCfg(area);
|
||||
entity.setCreateTime(new Date());
|
||||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||||
if(entity.getIpPortList()!=null){
|
||||
for(IpPortCfg cfg:entity.getIpPortList()){
|
||||
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
|
||||
@@ -195,9 +222,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||||
}
|
||||
}
|
||||
handleAsn(entity.getAsnKeywords(), entity);
|
||||
//保存asn组织信息 字符串域信息
|
||||
/*if(StringUtils.isNotBlank(entity.getUserRegion4())){
|
||||
if(StringUtils.isNotBlank(entity.getUserRegion4())){
|
||||
List<FunctionRegionDict> functionRegionDicts=DictUtils.getFunctionRegionDictList(entity.getFunctionId());
|
||||
FunctionRegionDict regionDict=null;
|
||||
for(FunctionRegionDict dict:functionRegionDicts) {
|
||||
@@ -231,7 +257,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
}
|
||||
}
|
||||
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
public void updateIpCfgValid(Integer isValid,String ids,Integer functionId){
|
||||
@@ -545,8 +571,6 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
numRegionList.addAll(map.get("numRegionList"));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
maatType=1;
|
||||
}
|
||||
if(entity.getNtcSubscribeIdCfgList()!=null && entity.getNtcSubscribeIdCfgList().size()>0){
|
||||
NtcSubscribeIdCfg cfg = new NtcSubscribeIdCfg();
|
||||
@@ -559,8 +583,26 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
strRegionList=map.get("dstList");
|
||||
}
|
||||
}
|
||||
//asn配置下发
|
||||
auditAsnCfg(groupRelationList,strRegionList,entity,entity.getAsnKeywords());
|
||||
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)){
|
||||
@@ -668,7 +710,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
maatCfg.setCompileId(entity.getCompileId());
|
||||
maatCfg.setServiceId(entity.getServiceId());
|
||||
maatCfg.setIsValid(0);//无效
|
||||
configCompileList.add(addKeepGroupList(maatCfg,entity));
|
||||
configCompileList.add(maatCfg);
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(entity.getAuditTime());
|
||||
maatBean.setCreatorName(entity.getCurrentUser().getName());
|
||||
@@ -863,7 +905,7 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
List<NtcSubscribeIdCfg> subscribeIdList = stringCfgDao.findSubscribeIdCfgListByCfgIndexInfo(entity);
|
||||
entity.setIpPortList(ipPortList);
|
||||
entity.setNtcSubscribeIdCfgList(subscribeIdList);
|
||||
if(StringUtils.isNotBlank(entity.getCommonGroupIds())) {
|
||||
if(StringUtils.isNotBlank(entity.getUserRegion4())) {
|
||||
List<AsnKeywordCfg> asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity);
|
||||
entity.setAsnKeywords(asnKeywordCfgs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user