ASN IP 导入并下发功能
This commit is contained in:
@@ -1537,7 +1537,8 @@ public class BaseController {
|
||||
}else if(regionDict.getFunctionId().equals(214)) { // IpSpoofing
|
||||
BlockingQueue<IpSpoofingTemplate> list = ei.getDataList(IpSpoofingTemplate.class );
|
||||
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 );
|
||||
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,null, list);
|
||||
}else {
|
||||
@@ -1605,6 +1606,9 @@ public class BaseController {
|
||||
} else if(regionDict.getFunctionId().equals(563)){// APP Payload
|
||||
BlockingQueue<AppPayloadTemplate> list = ei.getDataList(AppPayloadTemplate.class);
|
||||
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 {
|
||||
BlockingQueue<ComplexStringAllTemplate> list = ei.getDataList(ComplexStringAllTemplate.class
|
||||
);
|
||||
@@ -1654,13 +1658,22 @@ public class BaseController {
|
||||
//处理config_group_info和asn_group_info
|
||||
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
|
||||
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()) {
|
||||
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 {
|
||||
regionIds = ConfigServiceUtil.getId(3,_ipPortCfgs.size());
|
||||
} catch (Exception e) {
|
||||
@@ -1668,60 +1681,109 @@ public class BaseController {
|
||||
logger.info("获取域ID出错");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
int ind=0;
|
||||
index=0;
|
||||
for (BaseIpCfg cfg : _ipPortCfgs) {
|
||||
AsnIpCfg _cfg=new AsnIpCfg();
|
||||
BeanUtils.copyProperties(cfg, _cfg,new String[] {"cfgId"});
|
||||
_cfg.setTableName(AsnIpCfg.getTablename());
|
||||
_cfg.setAction(serviceDict==null?0:serviceDict.getAction());
|
||||
_cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
||||
_cfg.setCfgType(regionDict.getConfigRegionValue());
|
||||
_cfg.setCreateTime(date);
|
||||
_cfg.setCreatorId(UserUtils.getUser().getId());
|
||||
_cfg.setDoLog(2);
|
||||
_cfg.setFunctionId(regionDict.getFunctionId());
|
||||
AsnIpCfg asnIpCfg=new AsnIpCfg();
|
||||
BeanUtils.copyProperties(cfg, asnIpCfg,new String[] {"cfgId"});
|
||||
asnIpCfg.setTableName(AsnIpCfg.getTablename());
|
||||
asnIpCfg.setAction(serviceDict==null?0:serviceDict.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")) {
|
||||
_cfg.setIsAudit(Constants.AUDIT_YES);
|
||||
_cfg.setIsValid(Constants.VALID_YES);
|
||||
_cfg.setAuditorId(UserUtils.getUser().getId());
|
||||
_cfg.setAuditTime(date);
|
||||
asnIpCfg.setIsAudit(Constants.AUDIT_YES);
|
||||
asnIpCfg.setIsValid(Constants.VALID_YES);
|
||||
asnIpCfg.setAuditorId(UserUtils.getUser().getId());
|
||||
asnIpCfg.setAuditTime(date);
|
||||
|
||||
}else {
|
||||
_cfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
||||
_cfg.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.setIsAudit(Constants.AUDIT_NOT_YET);
|
||||
asnIpCfg.setIsValid(Constants.VALID_NO);
|
||||
}
|
||||
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
|
||||
if(asnNoMaps.get(0).containsKey(Long.parseLong(_cfg.getUserRegion1()))) {
|
||||
_cfg.setAsnIpGroup(asnNoMaps.get(0).get(Long.parseLong(_cfg.getUserRegion1())).getGroupId());
|
||||
_cfg.setCompileId(asnNoMaps.get(0).get(Long.parseLong(_cfg.getUserRegion1())).getCompileId());
|
||||
}else if(asnNoMaps.get(1).containsKey(Long.parseLong(_cfg.getUserRegion1()))) {
|
||||
_cfg.setAsnIpGroup(asnNoMaps.get(1).get(Long.parseLong(_cfg.getUserRegion1())).getGroupId());
|
||||
_cfg.setCompileId(asnNoMaps.get(1).get(Long.parseLong(_cfg.getUserRegion1())).getCompileId());
|
||||
}else {
|
||||
//AsnGroupInfo info=AsnCacheUtils.get(Long.parseLong(_cfg.getUserRegion1()));
|
||||
AsnGroupInfo info=asnGroupInfos.get(Long.parseLong(_cfg.getUserRegion1()));
|
||||
if(info!=null) {
|
||||
_cfg.setAsnIpGroup(info.getGroupId());
|
||||
_cfg.setCompileId(info.getCompileId());
|
||||
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(Long.valueOf(asnIpCfg.getUserRegion1()))){
|
||||
//groupId已经在了
|
||||
if(oldAsnIpMap.keySet().contains(Long.valueOf(asnIpCfg.getAsnIpGroup()))){
|
||||
oldAsnIpMap.get(Long.valueOf(asnIpCfg.getAsnIpGroup())).add(asnIpCfg);
|
||||
oldAsnIpIndex++;
|
||||
}else{
|
||||
List list=new ArrayList<>();
|
||||
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();
|
||||
/*asnIpCfgs.clear();*/
|
||||
}
|
||||
}else if(regionDict.getFunctionId().intValue()==214) { // IpSpoofing
|
||||
List<BaseIpCfg> _ipPortCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
@@ -2470,7 +2532,8 @@ public class BaseController {
|
||||
ei.loadInitParams(IpWhitelistTemplate.class, msgProp, regionDict, serviceDict);
|
||||
} else if(regionDict.getFunctionId().equals(214)) { // IpSpoofing
|
||||
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);
|
||||
} else {
|
||||
ei.loadInitParams(IpAllTemplate.class, msgProp, regionDict, serviceDict);
|
||||
@@ -2516,6 +2579,8 @@ public class BaseController {
|
||||
ei.loadInitParams(ComplexStringAllNotDoLogTemplate.class, this.getMsgProp(), regionDict, serviceDict);
|
||||
}else if(regionDict.getFunctionId().equals(563)) {// APP Payload
|
||||
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 {
|
||||
ei.loadInitParams(ComplexStringAllTemplate.class, msgProp, regionDict, serviceDict);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user