ASN ip,APP特征业务的配置批量取消功能完成
This commit is contained in:
@@ -120,6 +120,7 @@ import com.nis.domain.maat.MaatCfg.NumBoundaryCfg;
|
||||
import com.nis.domain.maat.MaatCfg.StringCfg;
|
||||
import com.nis.domain.maat.ToMaatBean;
|
||||
import com.nis.domain.report.NtcPzReport;
|
||||
import com.nis.domain.specific.ConfigGroupInfo;
|
||||
import com.nis.domain.specific.SpecificServiceCfg;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
//import com.nis.util.AsnCacheUtils;
|
||||
@@ -2696,6 +2697,7 @@ public class BaseController {
|
||||
* @return
|
||||
*/
|
||||
public void auditAll(Page page,Integer auditType,Object entity)throws Exception {
|
||||
long start=System.currentTimeMillis();
|
||||
page.setOrderBy("");
|
||||
page.setPageSize(Constants.MAAT_JSON_SEND_SIZE);
|
||||
page.setPageNo(1);
|
||||
@@ -2721,6 +2723,7 @@ public class BaseController {
|
||||
AppTopicDomainCfg searchAppTopicCfg=new AppTopicDomainCfg();
|
||||
AppFeatureIndex searchAppFeatureIndex=new AppFeatureIndex();
|
||||
AppSslCertCfg searchAppSslCertCfg=new AppSslCertCfg();
|
||||
AsnIpCfg searchAsnIpCfg=new AsnIpCfg();
|
||||
if(entity != null && (entity instanceof CfgIndexInfo)) {
|
||||
BeanUtils.copyProperties(entity, auditBatchCfg);
|
||||
BeanUtils.copyProperties(entity, searchCfg);
|
||||
@@ -2794,6 +2797,10 @@ public class BaseController {
|
||||
BeanUtils.copyProperties(entity, auditBatchCfg);
|
||||
BeanUtils.copyProperties(entity, searchAppSslCertCfg);
|
||||
}
|
||||
if(entity != null && (entity instanceof AsnIpCfg)) {
|
||||
BeanUtils.copyProperties(entity, auditBatchCfg);
|
||||
BeanUtils.copyProperties(entity, searchAsnIpCfg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2835,6 +2842,8 @@ public class BaseController {
|
||||
searchAppFeatureIndex.setIsAudit(0);
|
||||
searchAppSslCertCfg.setIsValid(0);
|
||||
searchAppSslCertCfg.setIsAudit(0);
|
||||
searchAsnIpCfg.setIsValid(0);
|
||||
searchAsnIpCfg.setIsAudit(0);
|
||||
|
||||
auditBatchCfg.setIsAudit(1);
|
||||
auditBatchCfg.setIsValid(1);
|
||||
@@ -2878,6 +2887,8 @@ public class BaseController {
|
||||
searchAppFeatureIndex.setIsAudit(1);
|
||||
searchAppSslCertCfg.setIsValid(1);
|
||||
searchAppSslCertCfg.setIsAudit(1);
|
||||
searchAsnIpCfg.setIsValid(1);
|
||||
searchAsnIpCfg.setIsAudit(1);
|
||||
|
||||
auditBatchCfg.setIsAudit(3);
|
||||
auditBatchCfg.setIsValid(0);
|
||||
@@ -3080,10 +3091,89 @@ public class BaseController {
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//1028 app_ip_cfg
|
||||
//TODO 批量审核通过APP IP需要处理的问题:一批中存在一个APP 所有IP均未下发过的问题?待解决
|
||||
//批量下发时,未下发过的app需要下发正常配置;已下发过的app需要下发ip复用配置(为保证事物,分两种方式下发)
|
||||
if(auditBatchCfg.getServiceId().equals(1028)) {
|
||||
//400 ASN IP
|
||||
if(auditBatchCfg.getServiceId().equals(400)) {
|
||||
//所有已下发的ASN IP组
|
||||
boolean hasData = true;
|
||||
while(hasData){
|
||||
//已下发的ASN IP
|
||||
List<AsnIpCfg> list=asnIpCfgService.findPage(page, searchAsnIpCfg).getList();
|
||||
|
||||
if(!StringUtil.isEmpty(list)){
|
||||
if(auditBatchCfg.getIsValid().equals(1)) {
|
||||
}else {
|
||||
Map<Integer,List> asnIpMap=new HashMap();
|
||||
if(!StringUtil.isEmpty(list)) {
|
||||
for (AsnIpCfg obj : list) {
|
||||
BaseCfg baseCfg=(BaseCfg)obj;
|
||||
if(!StringUtil.isEmpty(asnIpMap.get(obj.getAsnIpGroup()))) {
|
||||
asnIpMap.get(obj.getAsnIpGroup()).add(baseCfg);
|
||||
asnIpMap.put(obj.getAsnIpGroup(), asnIpMap.get(obj.getAsnIpGroup()));
|
||||
}else {
|
||||
List newList=new ArrayList<>();
|
||||
newList.add(baseCfg);
|
||||
asnIpMap.put(obj.getAsnIpGroup(),newList);
|
||||
}
|
||||
}
|
||||
}
|
||||
hasData=commonPolicyService.auditReuseConfigData(page, auditBatchCfg,asnIpMap,hasData);
|
||||
}
|
||||
if(hasData) {
|
||||
page.setPageNo(page.getNext());
|
||||
}
|
||||
}else{
|
||||
hasData = false;
|
||||
}
|
||||
}
|
||||
}else if(auditBatchCfg.getServiceId().equals(1028)) {
|
||||
//所有已下发的app IP组
|
||||
ConfigGroupInfo groupInfo=new ConfigGroupInfo();
|
||||
groupInfo.setIsIssued(1);
|
||||
groupInfo.setGroupType(1);//1:app ip
|
||||
List<ConfigGroupInfo> groupInfos=configGroupInfoService.findAllList(groupInfo);
|
||||
Map<Integer,Integer> groupMap=new HashMap<>();
|
||||
for (ConfigGroupInfo configGroupInfo : groupInfos) {
|
||||
groupMap.put(configGroupInfo.getCompileId(), configGroupInfo.getGroupId());
|
||||
}
|
||||
|
||||
boolean hasData = true;
|
||||
while(hasData){
|
||||
//已下发的APP IP
|
||||
List<AppIpCfg> list=appCfgService.findAppIpList(page, searchAppIpCfg).getList();
|
||||
|
||||
if(!StringUtil.isEmpty(list)){
|
||||
if(auditBatchCfg.getIsValid().equals(1)) {
|
||||
//TODO 批量审核通过APP IP需要处理的问题:一批中存在一个APP 所有IP均未下发过的问题?待解决
|
||||
//批量下发时,未下发过的app需要下发正常配置;已下发过的app需要下发ip复用配置(为保证事物,分两种方式下发)
|
||||
/*hasData=configSynchronizationService.auditDdosMaatData(cfgList,userRegionList,
|
||||
page,auditBatchCfg,list,hasData,true);*/
|
||||
}else {
|
||||
Map<Integer,List> appIpMap=new HashMap();
|
||||
if(!StringUtil.isEmpty(list)) {
|
||||
for (AppIpCfg obj : list) {
|
||||
BaseCfg baseCfg=(BaseCfg)obj;
|
||||
if(!StringUtil.isEmpty(appIpMap.get((groupMap.get(obj.getCompileId()))))) {
|
||||
appIpMap.get(groupMap.get(obj.getCompileId())).add(baseCfg);
|
||||
appIpMap.put(groupMap.get(obj.getCompileId()), appIpMap.get(groupMap.get(obj.getCompileId())));
|
||||
}else {
|
||||
List newList=new ArrayList<>();
|
||||
newList.add(baseCfg);
|
||||
appIpMap.put(groupMap.get(obj.getCompileId()),newList);
|
||||
}
|
||||
}
|
||||
}
|
||||
hasData=commonPolicyService.auditReuseConfigData(page, auditBatchCfg,appIpMap,hasData);
|
||||
}
|
||||
if(hasData) {
|
||||
page.setPageNo(page.getNext());
|
||||
}
|
||||
}else{
|
||||
hasData = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*if(true) {
|
||||
page.setOrderBy("");
|
||||
page.setPageSize(Constants.MAAT_JSON_SEND_SIZE);
|
||||
@@ -3249,6 +3339,8 @@ public class BaseController {
|
||||
BeanUtils.copyProperties(base, entity);
|
||||
}
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.info("配置批量生效/失效耗时:"+(end-start));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
@@ -135,10 +136,10 @@ public class AsnIpController extends BaseController{
|
||||
}
|
||||
}
|
||||
asnIpCfgService.auditIpBatch(asnIpMap,isValid);
|
||||
}/*else {
|
||||
}else {
|
||||
//条件下所有配置审核
|
||||
Page<AsnIpCfg> searchPage=new Page<AsnIpCfg>(request,response,"a");
|
||||
Page<AsnIpCfg> auditPage=new Page<AsnIpCfg>(request,response,"a");
|
||||
Page<AsnIpCfg> searchPage=new Page<AsnIpCfg>(request,response,"r");
|
||||
Page<AsnIpCfg> auditPage=new Page<AsnIpCfg>(request,response,"r");
|
||||
BeanUtils.copyProperties(searchPage, auditPage);
|
||||
try {
|
||||
auditAll(auditPage,isValid , cfg);
|
||||
@@ -154,7 +155,7 @@ public class AsnIpController extends BaseController{
|
||||
}
|
||||
|
||||
return list(model, request, response, cfg);
|
||||
}*/
|
||||
}
|
||||
return "redirect:" + adminPath +"/basics/asn/list?functionId="+cfg.getFunctionId();
|
||||
}
|
||||
@RequestMapping(value = {"/delete"})
|
||||
|
||||
@@ -796,7 +796,7 @@
|
||||
</foreach>
|
||||
</when >
|
||||
<when test=" tableName == 'asn_ip_cfg'">
|
||||
and asn_ip_group in
|
||||
and region_id in
|
||||
<foreach collection="compileIds" index="index" item="compileId" open="(" separator="," close=")">
|
||||
#{compileId}
|
||||
</foreach>
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
@@ -18,6 +19,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.basics.AsnGroupInfo;
|
||||
import com.nis.domain.basics.AsnIpCfg;
|
||||
import com.nis.domain.configuration.AppPolicyCfg;
|
||||
import com.nis.domain.configuration.AreaIpCfg;
|
||||
@@ -40,6 +42,8 @@ import com.nis.domain.configuration.NtcSubscribeIdCfg;
|
||||
import com.nis.domain.configuration.PxyObjKeyring;
|
||||
import com.nis.domain.configuration.PxyObjTrustedCaCert;
|
||||
import com.nis.domain.configuration.PxyObjTrustedCaCrl;
|
||||
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;
|
||||
@@ -88,6 +92,8 @@ public class CommonPolicyService extends CrudService<WebsiteCfgDao, CfgIndexInfo
|
||||
BaseCfg entity,
|
||||
List<BaseCfg> list,
|
||||
boolean hasData)throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{
|
||||
long start=System.currentTimeMillis();
|
||||
long end=System.currentTimeMillis();
|
||||
ToMaatBean maatBean;
|
||||
MaatCfg maatCfg;
|
||||
List<MaatCfg> configCompileList;
|
||||
@@ -160,11 +166,15 @@ public class CommonPolicyService extends CrudService<WebsiteCfgDao, CfgIndexInfo
|
||||
//调用服务接口取消配置
|
||||
String json=gsonToJson(maatBean);
|
||||
if(StringUtil.isEmpty(list)) {
|
||||
logger.info("批量配置取消个数:"+list.size());
|
||||
logger.info("批量配置取消("+page.getPageNo()+"次)个数:"+list.size());
|
||||
}
|
||||
//调用服务接口下发配置
|
||||
logger.info("Maat配置批量失效-下发:start()");
|
||||
start=System.currentTimeMillis();
|
||||
ToMaatResult result = ConfigServiceUtil.put(json,1);
|
||||
end=System.currentTimeMillis();
|
||||
logger.info("配置取消配置响应信息:"+result.getMsg());
|
||||
logger.info("Maat配置批量失效-下发:end("+(end-start)+")");
|
||||
}
|
||||
return hasData;
|
||||
}
|
||||
@@ -177,6 +187,78 @@ public class CommonPolicyService extends CrudService<WebsiteCfgDao, CfgIndexInfo
|
||||
public List<PxyObjTrustedCaCrl> getPxyObjTrustedCrlCfgListByCertId(List certIds){
|
||||
return synchronizationDao.getPxyObjTrustedCrlCfgListByCertId(certIds);
|
||||
}
|
||||
/**
|
||||
* IP复用配置取消
|
||||
* @param cfgList
|
||||
* @param page
|
||||
* @param auditMap
|
||||
* @param hasData
|
||||
* @return
|
||||
*/
|
||||
public boolean auditReuseConfigData(
|
||||
Page page,
|
||||
BaseCfg entity,
|
||||
Map<Integer, List> auditMap,
|
||||
boolean hasData){
|
||||
long start=System.currentTimeMillis();
|
||||
long end=System.currentTimeMillis();
|
||||
long totolSize=0;
|
||||
|
||||
if(page.isLastPage()){
|
||||
hasData = false;
|
||||
}
|
||||
List<Integer> regionIds = new ArrayList();
|
||||
for(Entry<Integer, List> e:auditMap.entrySet()) {
|
||||
List<BaseCfg> list=e.getValue();
|
||||
for (BaseCfg baseCfg : list) {
|
||||
if("asn_ip_cfg".equals(entity.getTableName())) {
|
||||
regionIds.add(baseCfg.getRegionId());
|
||||
}else {
|
||||
regionIds.add(Integer.parseInt(baseCfg.getUserRegion1()));
|
||||
}
|
||||
|
||||
}
|
||||
totolSize=totolSize+list.size();
|
||||
|
||||
}
|
||||
start=System.currentTimeMillis();
|
||||
logger.info("APP IP配置批量失效-数据库状态变更:start()");
|
||||
commonPolicyDao.auditCfgBatch( entity.getTableName(), entity,regionIds,null);
|
||||
end=System.currentTimeMillis();
|
||||
logger.info("APP IP配置批量失效-数据库状态变更:end("+(end-start)+")");
|
||||
|
||||
//已经下发过的,调用分组复用配置删除接口
|
||||
if(!auditMap.isEmpty()) {
|
||||
GroupReuseAddBean maatBean = new GroupReuseAddBean();
|
||||
List<GroupReuseCfg> groupReuseList=new ArrayList<>();
|
||||
GroupReuseCfg groupReuseCfg=new GroupReuseCfg();
|
||||
List<IpCfg> ipRegionList=new ArrayList<>();
|
||||
for (Integer groupId : auditMap.keySet()) {
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(auditMap.get(groupId),Constants.VALID_NO,groupId));
|
||||
}
|
||||
groupReuseCfg.setIpRegionList(ipRegionList);
|
||||
groupReuseCfg.setStrRegionList(null);
|
||||
groupReuseCfg.setNumRegionList(null);
|
||||
groupReuseList.add(groupReuseCfg);
|
||||
maatBean.setGroupReuseCfgList(groupReuseList);
|
||||
maatBean.setAuditTime(new Date());
|
||||
maatBean.setCreatorName(UserUtils.getUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("app协议IP域配置批量取消("+page.getPageNo()+"次):"+ipRegionList.size());
|
||||
//logger.info("app协议IP域配置批量取消:"+json);
|
||||
//调用服务接口下发配置
|
||||
logger.info("APP IP配置批量失效-下发:start()");
|
||||
start=System.currentTimeMillis();
|
||||
ToMaatResult result = ConfigServiceUtil.put(json,3);
|
||||
end=System.currentTimeMillis();
|
||||
logger.info("app协议IP域配置批量取消响应信息:"+result.getMsg());
|
||||
logger.info("APP IP配置批量失效-下发:end("+(end-start)+")");
|
||||
}
|
||||
return hasData;
|
||||
}
|
||||
/**
|
||||
* 回调类配置下发
|
||||
* @param className
|
||||
|
||||
Reference in New Issue
Block a user