ASN IP 导入并下发功能
This commit is contained in:
@@ -1537,7 +1537,8 @@ public class BaseController {
|
|||||||
}else if(regionDict.getFunctionId().equals(214)) { // IpSpoofing
|
}else if(regionDict.getFunctionId().equals(214)) { // IpSpoofing
|
||||||
BlockingQueue<IpSpoofingTemplate> list = ei.getDataList(IpSpoofingTemplate.class );
|
BlockingQueue<IpSpoofingTemplate> list = ei.getDataList(IpSpoofingTemplate.class );
|
||||||
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,null, list);
|
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,null, list);
|
||||||
}else if(regionDict.getFunctionId().equals(405)) { // APP IP
|
}else if(regionDict.getFunctionId().equals(405) || regionDict.getFunctionId().equals(563) || regionDict.getFunctionId().equals(565)
|
||||||
|
|| regionDict.getFunctionId().equals(566)) { // APP Feature IP
|
||||||
BlockingQueue<IpAllNotDoLogTemplate> list = ei.getDataList(IpAllNotDoLogTemplate.class );
|
BlockingQueue<IpAllNotDoLogTemplate> list = ei.getDataList(IpAllNotDoLogTemplate.class );
|
||||||
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,null, list);
|
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,null, list);
|
||||||
}else {
|
}else {
|
||||||
@@ -1605,6 +1606,9 @@ public class BaseController {
|
|||||||
} else if(regionDict.getFunctionId().equals(563)){// APP Payload
|
} else if(regionDict.getFunctionId().equals(563)){// APP Payload
|
||||||
BlockingQueue<AppPayloadTemplate> list = ei.getDataList(AppPayloadTemplate.class);
|
BlockingQueue<AppPayloadTemplate> list = ei.getDataList(AppPayloadTemplate.class);
|
||||||
appComplexFeatureCfgs = this.checkAppComplexFeatureStringCfgMulity(errTip,serviceDict, regionDict, list);
|
appComplexFeatureCfgs = this.checkAppComplexFeatureStringCfgMulity(errTip,serviceDict, regionDict, list);
|
||||||
|
} else if(regionDict.getFunctionId().equals(565) || regionDict.getFunctionId().equals(564) || regionDict.getFunctionId().equals(566)){// APP Feature StrPlus
|
||||||
|
BlockingQueue<ComplexStringAllNotDoLogTemplate> list = ei.getDataList(ComplexStringAllNotDoLogTemplate.class);
|
||||||
|
complexkeywordCfgs = this.checkComplexStringCfgMulity(errTip,serviceDict, regionDict, list);
|
||||||
} else {
|
} else {
|
||||||
BlockingQueue<ComplexStringAllTemplate> list = ei.getDataList(ComplexStringAllTemplate.class
|
BlockingQueue<ComplexStringAllTemplate> list = ei.getDataList(ComplexStringAllTemplate.class
|
||||||
);
|
);
|
||||||
@@ -1654,13 +1658,22 @@ public class BaseController {
|
|||||||
//处理config_group_info和asn_group_info
|
//处理config_group_info和asn_group_info
|
||||||
asnIpCfgService.processGroup(serviceDict,asnNoMaps,asnOrgList,isSend,isImportAll.get(0).getItemCode());
|
asnIpCfgService.processGroup(serviceDict,asnNoMaps,asnOrgList,isSend,isImportAll.get(0).getItemCode());
|
||||||
//每次批量之后需要更新已下发的组
|
//每次批量之后需要更新已下发的组
|
||||||
asnNoMaps.get(3).clear();
|
if(isImportAll.get(0).getItemCode().equals("1")){
|
||||||
|
asnNoMaps.get(3).clear();
|
||||||
|
}
|
||||||
//处理asn ip
|
//处理asn ip
|
||||||
List<BaseIpCfg> _ipPortCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
List<BaseIpCfg> _ipPortCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||||
|
List<AsnIpCfg> asnIpCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||||
|
int index=0;
|
||||||
|
//未下发过的组织下asn ip信息
|
||||||
|
Map<Long,List<AsnIpCfg>> newAsnIpMap=Maps.newConcurrentMap();
|
||||||
|
int newAsnIpIndex=0;
|
||||||
|
//下发过的组织下asn ip信息
|
||||||
|
Map<Long,List<AsnIpCfg>> oldAsnIpMap=Maps.newConcurrentMap();
|
||||||
|
int oldAsnIpIndex=0;
|
||||||
while(!ipPortCfgs.isEmpty()) {
|
while(!ipPortCfgs.isEmpty()) {
|
||||||
ipPortCfgs.drainTo(_ipPortCfgs, Constants.MAAT_JSON_SEND_SIZE);
|
ipPortCfgs.drainTo(_ipPortCfgs, Constants.MAAT_JSON_SEND_SIZE);
|
||||||
asnIpCfgService.processAsnIp(serviceDict,regionDict,_ipPortCfgs,asnNoMaps,isSend,isImportAll.get(0).getItemCode(),requestId, attribute, classify);
|
List<Integer> regionIds=Lists.newArrayList();
|
||||||
/*List<Integer> regionIds=Lists.newArrayList();
|
|
||||||
try {
|
try {
|
||||||
regionIds = ConfigServiceUtil.getId(3,_ipPortCfgs.size());
|
regionIds = ConfigServiceUtil.getId(3,_ipPortCfgs.size());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1668,60 +1681,109 @@ public class BaseController {
|
|||||||
logger.info("获取域ID出错");
|
logger.info("获取域ID出错");
|
||||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||||
}
|
}
|
||||||
int ind=0;
|
index=0;
|
||||||
for (BaseIpCfg cfg : _ipPortCfgs) {
|
for (BaseIpCfg cfg : _ipPortCfgs) {
|
||||||
AsnIpCfg _cfg=new AsnIpCfg();
|
AsnIpCfg asnIpCfg=new AsnIpCfg();
|
||||||
BeanUtils.copyProperties(cfg, _cfg,new String[] {"cfgId"});
|
BeanUtils.copyProperties(cfg, asnIpCfg,new String[] {"cfgId"});
|
||||||
_cfg.setTableName(AsnIpCfg.getTablename());
|
asnIpCfg.setTableName(AsnIpCfg.getTablename());
|
||||||
_cfg.setAction(serviceDict==null?0:serviceDict.getAction());
|
asnIpCfg.setAction(serviceDict==null?0:serviceDict.getAction());
|
||||||
_cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
asnIpCfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
||||||
_cfg.setCfgType(regionDict.getConfigRegionValue());
|
asnIpCfg.setCfgType(regionDict.getConfigRegionValue());
|
||||||
_cfg.setCreateTime(date);
|
asnIpCfg.setCreateTime(date);
|
||||||
_cfg.setCreatorId(UserUtils.getUser().getId());
|
asnIpCfg.setCreatorId(UserUtils.getUser().getId());
|
||||||
_cfg.setDoLog(2);
|
asnIpCfg.setDoLog(2);
|
||||||
_cfg.setFunctionId(regionDict.getFunctionId());
|
asnIpCfg.setFunctionId(regionDict.getFunctionId());
|
||||||
if(isSend.equals("1")) {
|
if(isSend.equals("1")) {
|
||||||
_cfg.setIsAudit(Constants.AUDIT_YES);
|
asnIpCfg.setIsAudit(Constants.AUDIT_YES);
|
||||||
_cfg.setIsValid(Constants.VALID_YES);
|
asnIpCfg.setIsValid(Constants.VALID_YES);
|
||||||
_cfg.setAuditorId(UserUtils.getUser().getId());
|
asnIpCfg.setAuditorId(UserUtils.getUser().getId());
|
||||||
_cfg.setAuditTime(date);
|
asnIpCfg.setAuditTime(date);
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
_cfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
asnIpCfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
||||||
_cfg.setIsValid(Constants.VALID_NO);
|
asnIpCfg.setIsValid(Constants.VALID_NO);
|
||||||
}
|
|
||||||
_cfg.setIsAreaEffective(0);
|
|
||||||
_cfg.setLable("0");
|
|
||||||
_cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
|
|
||||||
_cfg.setAttribute(attribute);
|
|
||||||
_cfg.setClassify(classify);
|
|
||||||
// _cfg.setServiceId(0);
|
|
||||||
_cfg.setServiceId(serviceDict==null?0:serviceDict.getServiceId());
|
|
||||||
//设置region id
|
|
||||||
if(regionIds!=null&®ionIds.size()==_ipPortCfgs.size()) {
|
|
||||||
_cfg.setRegionId(regionIds.get(ind));
|
|
||||||
}
|
}
|
||||||
|
asnIpCfg.setIsAreaEffective(0);
|
||||||
|
asnIpCfg.setLable("0");
|
||||||
|
asnIpCfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
|
||||||
|
asnIpCfg.setAttribute(attribute);
|
||||||
|
asnIpCfg.setClassify(classify);
|
||||||
|
asnIpCfg.setServiceId(serviceDict==null?0:serviceDict.getServiceId());
|
||||||
|
asnIpCfg.setRegionId(regionIds.get(index));
|
||||||
//设置group id,compileId
|
//设置group id,compileId
|
||||||
if(asnNoMaps.get(0).containsKey(Long.parseLong(_cfg.getUserRegion1()))) {
|
asnIpCfg.setAsnIpGroup(asnNoMaps.get(2).get(Long.parseLong(asnIpCfg.getUserRegion1())).getGroupId());
|
||||||
_cfg.setAsnIpGroup(asnNoMaps.get(0).get(Long.parseLong(_cfg.getUserRegion1())).getGroupId());
|
asnIpCfg.setCompileId(asnNoMaps.get(2).get(Long.parseLong(asnIpCfg.getUserRegion1())).getCompileId());
|
||||||
_cfg.setCompileId(asnNoMaps.get(0).get(Long.parseLong(_cfg.getUserRegion1())).getCompileId());
|
if(isSend.equals("1")) {
|
||||||
}else if(asnNoMaps.get(1).containsKey(Long.parseLong(_cfg.getUserRegion1()))) {
|
//已下发
|
||||||
_cfg.setAsnIpGroup(asnNoMaps.get(1).get(Long.parseLong(_cfg.getUserRegion1())).getGroupId());
|
if(asnNoMaps.get(3).keySet().contains(Long.valueOf(asnIpCfg.getUserRegion1()))){
|
||||||
_cfg.setCompileId(asnNoMaps.get(1).get(Long.parseLong(_cfg.getUserRegion1())).getCompileId());
|
//groupId已经在了
|
||||||
}else {
|
if(oldAsnIpMap.keySet().contains(Long.valueOf(asnIpCfg.getAsnIpGroup()))){
|
||||||
//AsnGroupInfo info=AsnCacheUtils.get(Long.parseLong(_cfg.getUserRegion1()));
|
oldAsnIpMap.get(Long.valueOf(asnIpCfg.getAsnIpGroup())).add(asnIpCfg);
|
||||||
AsnGroupInfo info=asnGroupInfos.get(Long.parseLong(_cfg.getUserRegion1()));
|
oldAsnIpIndex++;
|
||||||
if(info!=null) {
|
}else{
|
||||||
_cfg.setAsnIpGroup(info.getGroupId());
|
List list=new ArrayList<>();
|
||||||
_cfg.setCompileId(info.getCompileId());
|
list.add(asnIpCfg);
|
||||||
|
oldAsnIpMap.put(Long.valueOf(asnIpCfg.getAsnIpGroup()), list);
|
||||||
|
oldAsnIpIndex++;
|
||||||
|
}
|
||||||
|
}else{//未下发
|
||||||
|
//groupId已经在了
|
||||||
|
if(newAsnIpMap.keySet().contains(Long.valueOf(asnIpCfg.getAsnIpGroup()))){
|
||||||
|
newAsnIpMap.get(Long.valueOf(asnIpCfg.getAsnIpGroup())).add(asnIpCfg);
|
||||||
|
newAsnIpIndex++;
|
||||||
|
}else{
|
||||||
|
List list=new ArrayList<>();
|
||||||
|
list.add(asnIpCfg);
|
||||||
|
newAsnIpMap.put(Long.valueOf(asnIpCfg.getAsnIpGroup()), list);
|
||||||
|
newAsnIpIndex++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
/**********************新的asn ip达到最大量后发送一次***********************/
|
||||||
|
//未下发过的asnGroup
|
||||||
|
if(newAsnIpIndex==Constants.MAAT_JSON_SEND_SIZE){
|
||||||
|
asnIpCfgService.auditAsnIp(newAsnIpMap,asnNoMaps,"maat",newAsnIpIndex);
|
||||||
|
newAsnIpMap.clear();
|
||||||
|
newAsnIpIndex=0;
|
||||||
|
}
|
||||||
|
/**********************新的asn ip达到最大量后发送一次***********************/
|
||||||
|
//已下发过的asnGroup
|
||||||
|
if(oldAsnIpIndex==Constants.MAAT_JSON_SEND_SIZE){
|
||||||
|
asnIpCfgService.auditAsnIp(oldAsnIpMap,asnNoMaps,"common",oldAsnIpIndex);
|
||||||
|
oldAsnIpMap.clear();
|
||||||
|
oldAsnIpIndex=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
asnIpCfgs.add(asnIpCfg);
|
||||||
}
|
}
|
||||||
asnIpCfgs.add(_cfg);
|
//仅仅需要保存的数
|
||||||
ind++;
|
if(asnIpCfgs.size()==Constants.MAAT_JSON_SEND_SIZE){
|
||||||
|
asnIpCfgService.saveAsnIp(asnIpCfgs);
|
||||||
|
asnIpCfgs.clear();
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
|
||||||
|
}
|
||||||
|
if(isSend.equals("1")) {
|
||||||
|
//未下发过的asnGroup
|
||||||
|
if(!newAsnIpMap.isEmpty()){
|
||||||
|
asnIpCfgService.auditAsnIp(newAsnIpMap,asnNoMaps,"maat",newAsnIpIndex);
|
||||||
|
newAsnIpMap.clear();
|
||||||
|
newAsnIpIndex=0;
|
||||||
|
}
|
||||||
|
//已下发过的asnGroup
|
||||||
|
if(!oldAsnIpMap.isEmpty()){
|
||||||
|
asnIpCfgService.auditAsnIp(oldAsnIpMap,asnNoMaps,"common",oldAsnIpIndex);
|
||||||
|
oldAsnIpMap.clear();
|
||||||
|
oldAsnIpIndex=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//仅仅需要保存的数
|
||||||
|
if(!StringUtil.isEmpty(asnIpCfgs)){
|
||||||
|
asnIpCfgService.saveAsnIp(asnIpCfgs);
|
||||||
|
asnIpCfgs.clear();
|
||||||
}
|
}
|
||||||
ipCfgService.saveAndSend(regionDict, serviceDict, specificServiceCfg, asnIpCfgs, cfgIndexInfos, appPolicyCfgs,appFeatureIndexs,asnNoMaps,isSend.equals("1"));*/
|
|
||||||
_ipPortCfgs.clear();
|
_ipPortCfgs.clear();
|
||||||
/*asnIpCfgs.clear();*/
|
|
||||||
}
|
}
|
||||||
}else if(regionDict.getFunctionId().intValue()==214) { // IpSpoofing
|
}else if(regionDict.getFunctionId().intValue()==214) { // IpSpoofing
|
||||||
List<BaseIpCfg> _ipPortCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
List<BaseIpCfg> _ipPortCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||||
@@ -2470,7 +2532,8 @@ public class BaseController {
|
|||||||
ei.loadInitParams(IpWhitelistTemplate.class, msgProp, regionDict, serviceDict);
|
ei.loadInitParams(IpWhitelistTemplate.class, msgProp, regionDict, serviceDict);
|
||||||
} else if(regionDict.getFunctionId().equals(214)) { // IpSpoofing
|
} else if(regionDict.getFunctionId().equals(214)) { // IpSpoofing
|
||||||
ei.loadInitParams(IpSpoofingTemplate.class, msgProp, regionDict, serviceDict);
|
ei.loadInitParams(IpSpoofingTemplate.class, msgProp, regionDict, serviceDict);
|
||||||
} else if(regionDict.getFunctionId().equals(405)) { // APP IP
|
} else if(regionDict.getFunctionId().equals(405) || regionDict.getFunctionId().equals(563) || regionDict.getFunctionId().equals(565)
|
||||||
|
|| regionDict.getFunctionId().equals(566)) { // APP Feature IP
|
||||||
ei.loadInitParams(IpAllNotDoLogTemplate.class, msgProp, regionDict, serviceDict);
|
ei.loadInitParams(IpAllNotDoLogTemplate.class, msgProp, regionDict, serviceDict);
|
||||||
} else {
|
} else {
|
||||||
ei.loadInitParams(IpAllTemplate.class, msgProp, regionDict, serviceDict);
|
ei.loadInitParams(IpAllTemplate.class, msgProp, regionDict, serviceDict);
|
||||||
@@ -2516,6 +2579,8 @@ public class BaseController {
|
|||||||
ei.loadInitParams(ComplexStringAllNotDoLogTemplate.class, this.getMsgProp(), regionDict, serviceDict);
|
ei.loadInitParams(ComplexStringAllNotDoLogTemplate.class, this.getMsgProp(), regionDict, serviceDict);
|
||||||
}else if(regionDict.getFunctionId().equals(563)) {// APP Payload
|
}else if(regionDict.getFunctionId().equals(563)) {// APP Payload
|
||||||
ei.loadInitParams(AppPayloadTemplate.class, this.getMsgProp(), regionDict, serviceDict);
|
ei.loadInitParams(AppPayloadTemplate.class, this.getMsgProp(), regionDict, serviceDict);
|
||||||
|
}else if(regionDict.getFunctionId().equals(565) || regionDict.getFunctionId().equals(564) || regionDict.getFunctionId().equals(566)){// APP Feature StrPlus
|
||||||
|
ei.loadInitParams(ComplexStringAllNotDoLogTemplate.class, this.getMsgProp(), regionDict, serviceDict);
|
||||||
} else {
|
} else {
|
||||||
ei.loadInitParams(ComplexStringAllTemplate.class, msgProp, regionDict, serviceDict);
|
ei.loadInitParams(ComplexStringAllTemplate.class, msgProp, regionDict, serviceDict);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2138,6 +2138,7 @@ public abstract class BaseService {
|
|||||||
long start=System.currentTimeMillis();
|
long start=System.currentTimeMillis();
|
||||||
ConfigGroupInfo configGroupInfo=configGroupInfoDao.getConfigGroupInfoByGroupId(specificServiceCfg.getGroupId());
|
ConfigGroupInfo configGroupInfo=configGroupInfoDao.getConfigGroupInfoByGroupId(specificServiceCfg.getGroupId());
|
||||||
if(configGroupInfo==null) {//一般特定服务的组号是新增之后就有的,不会进入这一步。
|
if(configGroupInfo==null) {//一般特定服务的组号是新增之后就有的,不会进入这一步。
|
||||||
|
Date date = new Date();
|
||||||
Integer groupId = ConfigServiceUtil.getId(2, 1).get(0);
|
Integer groupId = ConfigServiceUtil.getId(2, 1).get(0);
|
||||||
Integer compileId=ConfigServiceUtil.getId(1, 1).get(0);
|
Integer compileId=ConfigServiceUtil.getId(1, 1).get(0);
|
||||||
specificServiceCfg.setGroupId(groupId);
|
specificServiceCfg.setGroupId(groupId);
|
||||||
@@ -2147,9 +2148,10 @@ public abstract class BaseService {
|
|||||||
configGroupInfo.setIsIssued(0);
|
configGroupInfo.setIsIssued(0);
|
||||||
configGroupInfo.setGroupType(1);
|
configGroupInfo.setGroupType(1);
|
||||||
configGroupInfo.setCompileId(compileId);
|
configGroupInfo.setCompileId(compileId);
|
||||||
|
configGroupInfo.setInsertTime(date);
|
||||||
configGroupInfoDao.insertConfigGroupInfo(configGroupInfo);
|
configGroupInfoDao.insertConfigGroupInfo(configGroupInfo);
|
||||||
//更新group_id
|
//更新group_id
|
||||||
specificServiceCfg.setOpTime(new Date());
|
specificServiceCfg.setOpTime(date);
|
||||||
specificServiceCfgDao.update(specificServiceCfg);
|
specificServiceCfgDao.update(specificServiceCfg);
|
||||||
}
|
}
|
||||||
Integer compileId = configGroupInfo.getCompileId();
|
Integer compileId = configGroupInfo.getCompileId();
|
||||||
@@ -2931,7 +2933,8 @@ public abstract class BaseService {
|
|||||||
}
|
}
|
||||||
//调用服务接口下发配置
|
//调用服务接口下发配置
|
||||||
ToMaatResult result =ConfigServiceUtil.auditCommonGroupRegionSources(json,action);
|
ToMaatResult result =ConfigServiceUtil.auditCommonGroupRegionSources(json,action);
|
||||||
logger.info("asn ip复用域 "+action+" 配置响应信息:"+result.getMsg());
|
//logger.info("asn ip复用域 "+action+" 配置响应信息:"+result.getMsg());
|
||||||
|
logger.info("asn ip复用域 "+action+" 配置响应信息:");
|
||||||
}else {
|
}else {
|
||||||
maatBean.setOpAction(action);
|
maatBean.setOpAction(action);
|
||||||
//调用服务接口下发配置数据
|
//调用服务接口下发配置数据
|
||||||
@@ -2944,7 +2947,8 @@ public abstract class BaseService {
|
|||||||
}
|
}
|
||||||
//调用服务接口下发配置
|
//调用服务接口下发配置
|
||||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3);
|
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3);
|
||||||
logger.info("asn ip复用域删除配置响应信息:"+result.getMsg());
|
logger.info("asn ip复用域删除配置响应信息:");
|
||||||
|
//logger.info("asn ip复用域删除配置响应信息:"+result.getMsg());
|
||||||
}
|
}
|
||||||
long end=System.currentTimeMillis();
|
long end=System.currentTimeMillis();
|
||||||
logger.warn("asnIPRegionSendToMaat finish,cost:"+(end-start));
|
logger.warn("asnIPRegionSendToMaat finish,cost:"+(end-start));
|
||||||
|
|||||||
@@ -172,123 +172,145 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
|||||||
auditAllAsnRegionCfg(entity,auditAsnGroupList,null);
|
auditAllAsnRegionCfg(entity,auditAsnGroupList,null);
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param asnNoMaps 所有asn的信息
|
|
||||||
* @param configGroupInfos asn组织的数据库信息
|
|
||||||
* @param asnOrgMap asn和组织的关系
|
|
||||||
* @param isImportAll 是否导入全量
|
|
||||||
*/
|
|
||||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||||
public void processAsnIp(FunctionServiceDict service,FunctionRegionDict regionDict,List<BaseIpCfg> ipCfgList,List<Map<Long, AsnGroupInfo>> asnNoMaps,String isSend,String isImportAll,Integer requestId, String attribute, String classify){
|
public void saveAsnIp(List<AsnIpCfg> asnIpCfgs){
|
||||||
logger.warn("Start to save asn ip size:"+ipCfgList.size());
|
logger.warn("Start to only save asn ip size:"+asnIpCfgs.size());
|
||||||
long start=System.currentTimeMillis();
|
long start=System.currentTimeMillis();
|
||||||
//List<AsnIpCfg> asnIpCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
|
||||||
Date date=new Date();
|
|
||||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||||
SqlSession batchSqlSession = null;
|
SqlSession batchSqlSession = null;
|
||||||
int index=0;
|
|
||||||
Map<Long,AsnGroupInfo> auditInfo=new HashMap<>();
|
|
||||||
//存储未下发的asno及asnIP
|
|
||||||
Map<Integer,List<AsnIpCfg>> noAuditGroupIds=new HashMap<>();
|
|
||||||
//存储已下发的asnno
|
|
||||||
Map<Integer,List<AsnIpCfg>> auditGroupIds=new HashMap<>();
|
|
||||||
//本次未下发的组信息
|
|
||||||
List<AsnGroupInfo> noAuditGroupList=new ArrayList<AsnGroupInfo>();
|
|
||||||
Long asno=0l;
|
|
||||||
try{
|
try{
|
||||||
List<Integer> regionIds=ConfigServiceUtil.getId(3, ipCfgList.size());
|
if(!StringUtil.isEmpty(asnIpCfgs)){
|
||||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||||
for (BaseIpCfg cfg : ipCfgList) {
|
for (AsnIpCfg cfg : asnIpCfgs) {
|
||||||
AsnIpCfg asnIpCfg=new AsnIpCfg();
|
((AsnIpCfgDao) batchSqlSession.getMapper(AsnIpCfgDao.class)).insert(cfg);
|
||||||
BeanUtils.copyProperties(cfg, asnIpCfg,new String[] {"cfgId"});
|
|
||||||
asnIpCfg.setTableName(AsnIpCfg.getTablename());
|
|
||||||
asnIpCfg.setAction(service==null?0:service.getAction());
|
|
||||||
asnIpCfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
|
||||||
asnIpCfg.setCfgType(regionDict.getConfigRegionValue());
|
|
||||||
asnIpCfg.setCreateTime(date);
|
|
||||||
asnIpCfg.setCreatorId(UserUtils.getUser().getId());
|
|
||||||
asnIpCfg.setDoLog(2);
|
|
||||||
asnIpCfg.setFunctionId(regionDict.getFunctionId());
|
|
||||||
if(isSend.equals("1")) {
|
|
||||||
asnIpCfg.setIsAudit(Constants.AUDIT_YES);
|
|
||||||
asnIpCfg.setIsValid(Constants.VALID_YES);
|
|
||||||
asnIpCfg.setAuditorId(UserUtils.getUser().getId());
|
|
||||||
asnIpCfg.setAuditTime(date);
|
|
||||||
|
|
||||||
}else {
|
|
||||||
asnIpCfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
|
||||||
asnIpCfg.setIsValid(Constants.VALID_NO);
|
|
||||||
}
|
}
|
||||||
asnIpCfg.setIsAreaEffective(0);
|
batchSqlSession.commit();
|
||||||
asnIpCfg.setLable("0");
|
}
|
||||||
asnIpCfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
|
|
||||||
asnIpCfg.setAttribute(attribute);
|
|
||||||
asnIpCfg.setClassify(classify);
|
|
||||||
asnIpCfg.setServiceId(service==null?0:service.getServiceId());
|
|
||||||
asnIpCfg.setRegionId(regionIds.get(index));
|
|
||||||
asno=Long.parseLong(asnIpCfg.getUserRegion1());
|
|
||||||
//设置group id,compileId
|
|
||||||
asnIpCfg.setAsnIpGroup(asnNoMaps.get(2).get(Long.parseLong(asnIpCfg.getUserRegion1())).getGroupId());
|
|
||||||
asnIpCfg.setCompileId(asnNoMaps.get(2).get(Long.parseLong(asnIpCfg.getUserRegion1())).getCompileId());
|
|
||||||
/*if(isSend.equals("1")) {
|
|
||||||
//判断组是否已下发
|
|
||||||
if(asnNoMaps.get(3).keySet().contains(asno)){
|
|
||||||
|
|
||||||
}else{
|
|
||||||
asnNoMaps.get(3).put(asno, asnNoMaps.get(2).get(asno));
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
((AsnIpCfgDao) batchSqlSession.getMapper(AsnIpCfgDao.class)).insert(asnIpCfg);
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
batchSqlSession.commit();
|
|
||||||
|
|
||||||
}finally {
|
}finally {
|
||||||
if(batchSqlSession != null){
|
if(batchSqlSession != null){
|
||||||
batchSqlSession.close();
|
batchSqlSession.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//6、配置取消所有编译[编译取消,编译下的所有group和region都会取消(已和服务端确认)]
|
long end=System.currentTimeMillis();
|
||||||
/*if(!StringUtil.isEmpty(deleteAsnCompile)){
|
logger.warn("end only save asn ip finish,cost:"+(end-start));
|
||||||
long startAudit=System.currentTimeMillis();
|
}
|
||||||
ToMaatBean maatBean = new ToMaatBean();
|
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||||
MaatCfg maatCfg = new MaatCfg();
|
public void auditAsnIp(Map<Long, List<AsnIpCfg>> auditAsnIp,List<Map<Long, AsnGroupInfo>> asnNoMaps,String auditType,int auditSize){
|
||||||
List<MaatCfg> configCompileList = new ArrayList();
|
logger.warn("Start to audit and save asn ip size:"+auditSize);
|
||||||
List<GroupCfg> groupRelationList = new ArrayList();
|
long start=System.currentTimeMillis();
|
||||||
List<IpCfg> ipRegionList = new ArrayList();
|
Date date=new Date();
|
||||||
List<StringCfg> strRegionList = new ArrayList();
|
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||||
List<NumBoundaryCfg> numRegionList = new ArrayList();
|
SqlSession batchSqlSession = null;
|
||||||
List<DigestCfg> digestRegionList = new ArrayList();
|
Long asno=0l;
|
||||||
List<IpCfg> areaIpRegionList = new ArrayList();
|
List<Long> groupIds=Lists.newArrayList(auditAsnIp.size());
|
||||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(600);
|
List<AsnIpCfg> auditList=new ArrayList<>();
|
||||||
Integer serviceId=0;
|
ToMaatBean maatBean = new ToMaatBean();
|
||||||
serviceId=serviceList.get(0).getServiceId();
|
List<MaatCfg> configCompileList = new ArrayList();
|
||||||
for(Entry<Long, AsnGroupInfo> e:deleteAsnCompile.entrySet()) {
|
try{
|
||||||
maatCfg.setCompileId(e.getValue().getCompileId());
|
if(!auditAsnIp.isEmpty()){
|
||||||
maatCfg.setServiceId(serviceId);
|
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||||
maatCfg.setIsValid(0);//无效
|
//maat结构配置
|
||||||
configCompileList.add(maatCfg);
|
if(auditType.equals("maat")){
|
||||||
}
|
//maat参数
|
||||||
maatBean.setConfigCompileList(configCompileList);
|
List<StringCfg> strRegionList = new ArrayList();
|
||||||
maatBean.setAuditTime(createTime);
|
List<NumBoundaryCfg> numRegionList = new ArrayList();
|
||||||
|
List<DigestCfg> digestRegionList = new ArrayList();
|
||||||
|
List<IpCfg> areaIpRegionList = new ArrayList();
|
||||||
|
|
||||||
|
for (Entry<Long, List<AsnIpCfg>> e:auditAsnIp.entrySet()) {
|
||||||
|
List<GroupCfg> groupRelationList = Lists.newArrayList();
|
||||||
|
List<IpCfg> ipRegionList = new ArrayList();
|
||||||
|
|
||||||
|
//分组信息
|
||||||
|
GroupCfg groupCfg=new GroupCfg();
|
||||||
|
groupCfg.setAuditTime(e.getValue().get(0).getAuditTime());
|
||||||
|
groupCfg.setCompileId(e.getValue().get(0).getCompileId());
|
||||||
|
groupCfg.setGroupId(e.getValue().get(0).getAsnIpGroup());
|
||||||
|
groupCfg.setIsCommonGroup(1);
|
||||||
|
groupCfg.setIsValid(e.getValue().get(0).getIsValid());
|
||||||
|
|
||||||
|
groupRelationList.add(groupCfg);
|
||||||
|
|
||||||
|
//域信息
|
||||||
|
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(e.getValue(),Constants.VALID_YES,Integer.parseInt(e.getKey()+"")));
|
||||||
|
|
||||||
|
MaatCfg maatCfg = new MaatCfg();
|
||||||
|
maatCfg.initDefaultValue();
|
||||||
|
BeanUtils.copyProperties(e.getValue().get(0), maatCfg);
|
||||||
|
maatCfg.setAction(e.getValue().get(0).getAction());
|
||||||
|
maatCfg.setAuditTime(e.getValue().get(0).getAuditTime());
|
||||||
|
maatCfg.setStrRegionList(strRegionList);
|
||||||
|
maatCfg.setNumRegionList(numRegionList);
|
||||||
|
maatCfg.setDigestRegionList(digestRegionList);
|
||||||
|
maatCfg.setGroupRelationList(groupRelationList);
|
||||||
|
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
||||||
|
maatCfg.setIpRegionList(ipRegionList);
|
||||||
|
maatCfg.setIsValid(e.getValue().get(0).getIsValid());
|
||||||
|
maatCfg.setCompileId(e.getValue().get(0).getCompileId());
|
||||||
|
// 设置ASN自定义域
|
||||||
|
String userRegion = Constants.ASN_REGION_KEY+"=" +Constants.ASN_KEY+ e.getValue().get(0).getUserRegion1();
|
||||||
|
maatCfg.setUserRegion(userRegion);
|
||||||
|
maatCfg.setGroupNum(groupRelationList.size());
|
||||||
|
configCompileList.add(maatCfg);
|
||||||
|
|
||||||
|
groupIds.add(e.getKey());
|
||||||
|
for (AsnIpCfg cfg : e.getValue()) {
|
||||||
|
((AsnIpCfgDao) batchSqlSession.getMapper(AsnIpCfgDao.class)).insert(cfg);
|
||||||
|
}
|
||||||
|
//组第一次下发,需要更新已下发过的组中
|
||||||
|
asnNoMaps.get(3).put(Long.valueOf(e.getValue().get(0).getUserRegion1()), asnNoMaps.get(2).get(Long.valueOf(e.getValue().get(0).getUserRegion1())));
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
//复用接口
|
||||||
|
for (Entry<Long, List<AsnIpCfg>> e:auditAsnIp.entrySet()) {
|
||||||
|
groupIds.add(e.getKey());
|
||||||
|
for (AsnIpCfg cfg : e.getValue()) {
|
||||||
|
((AsnIpCfgDao) batchSqlSession.getMapper(AsnIpCfgDao.class)).insert(cfg);
|
||||||
|
}
|
||||||
|
auditList.addAll(e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
batchSqlSession.commit();
|
||||||
|
}
|
||||||
|
//第一次走maat配置的下发,需要将asn组修改为有效
|
||||||
|
if(auditType.equals("maat") && !StringUtil.isEmpty(groupIds)){
|
||||||
|
asnGroupInfoDao.updateIsUsedAndIsValid(groupIds, null, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}finally {
|
||||||
|
if(batchSqlSession != null){
|
||||||
|
batchSqlSession.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.warn("Start to audit asn ip ");
|
||||||
|
long startAudit=System.currentTimeMillis();
|
||||||
|
if(auditType.equals("maat")){
|
||||||
|
maatBean.setConfigCompileList(configCompileList);
|
||||||
|
maatBean.setAuditTime(new Date());
|
||||||
maatBean.setCreatorName(UserUtils.getUser().getName());
|
maatBean.setCreatorName(UserUtils.getUser().getName());
|
||||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||||
//调用服务接口取消配置
|
//调用服务接口下发配置数据
|
||||||
String json=gsonToJson(maatBean);
|
String json=gsonToJson(maatBean);
|
||||||
logger.info("ASN IP 业务的编译配置全部失效参数:"+json);
|
//logger.info("asn ip maat结构配置下发配置参数:"+json);
|
||||||
long auditEnd=System.currentTimeMillis();
|
logger.info("asn ip maat结构配置下发配置参数:");
|
||||||
logger.warn("Cancle all ASN compile finish,cost:"+(auditEnd-startAudit));
|
//调用服务接口下发配置
|
||||||
ToMaatResult result = ConfigServiceUtil.put(json,1);
|
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||||
logger.info("ASN IP所有编译取消返回结果:"+result.getMsg());
|
//logger.info("asn ip maat结构配置下发响应信息:"+result.getMsg());
|
||||||
long resultEnd=System.currentTimeMillis();
|
logger.info("asn ip maat结构配置下发响应信息:");
|
||||||
logger.warn("Cancle all ASN compile finish,cost:"+(resultEnd-auditEnd));
|
}else{
|
||||||
}*/
|
if(!StringUtil.isEmpty(auditList)){
|
||||||
|
asnIPRegionSendToMaat(auditList, 1, Constants.OPACTION_POST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
long endAutit=System.currentTimeMillis();
|
||||||
|
logger.warn("End to audit asn ip finish,cost:"+(endAutit-startAudit));
|
||||||
|
|
||||||
long end=System.currentTimeMillis();
|
long end=System.currentTimeMillis();
|
||||||
logger.warn("Save asn ip finish,cost:"+(end-start));
|
logger.warn("end audit and save asn ip finish,cost:"+(end-start));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -358,7 +380,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//4、遍历保存所有的asn_group_info
|
//5、遍历保存所有的asn_group_info
|
||||||
if(!asnNoMaps.isEmpty()){
|
if(!asnNoMaps.isEmpty()){
|
||||||
Map<Long, AsnGroupInfo> newAsnGroup =asnNoMaps.get(0); //【0】 新的asn group info
|
Map<Long, AsnGroupInfo> newAsnGroup =asnNoMaps.get(0); //【0】 新的asn group info
|
||||||
Map<Long, AsnGroupInfo> oldAsnGroup =asnNoMaps.get(1); //【1】 旧的asn group info
|
Map<Long, AsnGroupInfo> oldAsnGroup =asnNoMaps.get(1); //【1】 旧的asn group info
|
||||||
|
|||||||
Reference in New Issue
Block a user