多条配置批量下发maat

This commit is contained in:
zhangwei
2018-04-09 17:28:37 +08:00
parent 3e1b3e391d
commit 49fd0be72d

View File

@@ -268,8 +268,12 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
*/ */
@Transactional(readOnly=false,rollbackFor=RuntimeException.class) @Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int auditAppCfg(String[] cfgIds,Integer auditState) throws Exception{ public int auditAppCfg(String[] cfgIds,Integer auditState) throws Exception{
for(String id:cfgIds){ List<AppMaatCfg> jsonList = new ArrayList();
Gson gson=new GsonBuilder().disableHtmlEscaping()
.excludeFieldsWithoutExposeAnnotation()
.create();
boolean sendFlag = false; boolean sendFlag = false;
for(String id:cfgIds){
AppIdCfg appCfg = appCfgDao.getById(Long.parseLong(id)); AppIdCfg appCfg = appCfgDao.getById(Long.parseLong(id));
//给需要修改的配置字段赋值 //给需要修改的配置字段赋值
@@ -293,12 +297,6 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
List<SpecificServiceHostCfg> hostList =new ArrayList(); List<SpecificServiceHostCfg> hostList =new ArrayList();
List<BaseIpCfg> areaList = new ArrayList(); List<BaseIpCfg> areaList = new ArrayList();
ConfigGroupInfo group = null; ConfigGroupInfo group = null;
Gson gson=new GsonBuilder().disableHtmlEscaping()
.excludeFieldsWithoutExposeAnnotation()
.create();
//配置审核状态即将改变后的状态 //配置审核状态即将改变后的状态
if(Constants.AUDIT_NOT_YES==auditState|| if(Constants.AUDIT_NOT_YES==auditState||
Constants.AUDIT_YES==auditState){//审核通过,取消审核通过需要发到maat Constants.AUDIT_YES==auditState){//审核通过,取消审核通过需要发到maat
@@ -427,10 +425,18 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
maatCfg.setAttribute(appCfg.getAttribute()==null?"":appCfg.getAttribute()); maatCfg.setAttribute(appCfg.getAttribute()==null?"":appCfg.getAttribute());
maatCfg.setClassify(appCfg.getClassify()==null?"":appCfg.getClassify()); maatCfg.setClassify(appCfg.getClassify()==null?"":appCfg.getClassify());
maatCfg.setLable(appCfg.getLable()==null?"":appCfg.getLable()); maatCfg.setLable(appCfg.getLable()==null?"":appCfg.getLable());
String json=gson.toJson(maatCfg); jsonList.add(maatCfg);
//下发maat
// new ConvertTool().saveAppConfig(json); //修改appId配置审核下发状态
sendFlag = true; appCfgDao.audit(appCfg);
//修改特定服务IP分组下发状态
specificServiceCfgDao.updateConfigGroupInfobyGroupId(group);
//修改特征表配置审核下发状态
for(AppFeaturesIndex cfg:featuresTableList){
appCfgDao.auditFeaturesTable(cfg.getFeaturesTable(), cfg.getFeaturesCompileId(), appCfg.getIsValid(),
appCfg.getIsAudit(), appCfg.getAuditorId(), appCfg.getAuditTime());
}
}else{//取消审核通过 }else{//取消审核通过
AppMaatCfg maatCfg = new AppMaatCfg(); AppMaatCfg maatCfg = new AppMaatCfg();
@@ -483,17 +489,8 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
maatCfg.setComplexStrCfg(complexList); maatCfg.setComplexStrCfg(complexList);
} }
String json=gson.toJson(maatCfg); jsonList.add(maatCfg);
//下发maat
// new ConvertTool().saveAppConfig(json);
sendFlag = true;
}
}else{
sendFlag = true;
}
if(sendFlag){
//修改appId配置审核下发状态 //修改appId配置审核下发状态
appCfgDao.audit(appCfg); appCfgDao.audit(appCfg);
//修改特定服务IP分组下发状态 //修改特定服务IP分组下发状态
@@ -504,11 +501,22 @@ public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
appCfg.getIsAudit(), appCfg.getAuditorId(), appCfg.getAuditTime()); appCfg.getIsAudit(), appCfg.getAuditorId(), appCfg.getAuditTime());
} }
}
}
}
String json=gson.toJson(jsonList);
//下发maat
// new ConvertTool().saveConfig(json);
sendFlag = true;
if(sendFlag){
return 1;
}else{ }else{
return 0; return 0;
} }
}
return 1;
} }
/** /**
* *