asn ip导入入库时,判断是否全量,如果全量才需要删除旧的asnip

(cherry picked from commit 44be854707)
This commit is contained in:
段冬梅
2019-02-18 06:14:17 +00:00
committed by 董晓燕
parent 9445070693
commit 3c42039573

View File

@@ -168,15 +168,25 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
auditAllAsnRegionCfg(entity,auditAsnGroupList,null); auditAllAsnRegionCfg(entity,auditAsnGroupList,null);
}*/ }*/
} }
/**
*
* @param asnIpCfgs
* @param asnIds
* @param isImportAll 增量或者全量
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class) @Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveAsnIp(List<AsnIpCfg> asnIpCfgs,String asnIds){ public void saveAsnIp(List<AsnIpCfg> asnIpCfgs,String asnIds,String isImportAll){
logger.warn("Start to only save asn ip size:"+asnIpCfgs.size()); logger.warn("Start to only save asn ip size:"+asnIpCfgs.size());
long start=System.currentTimeMillis(); long start=System.currentTimeMillis();
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
SqlSession batchSqlSession = null; SqlSession batchSqlSession = null;
try{ try{
if(!StringUtil.isEmpty(asnIpCfgs)){ if(!StringUtil.isEmpty(asnIpCfgs)){
asnIpCfgDao.deleteByAsnId(asnIds); //全量时需要删除asn 下的所有ip
if("1".equals(isImportAll)){
asnIpCfgDao.deleteByAsnId(asnIds);
}
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
for (AsnIpCfg cfg : asnIpCfgs) { for (AsnIpCfg cfg : asnIpCfgs) {
((AsnIpCfgDao) batchSqlSession.getMapper(AsnIpCfgDao.class)).insert(cfg); ((AsnIpCfgDao) batchSqlSession.getMapper(AsnIpCfgDao.class)).insert(cfg);
@@ -292,12 +302,12 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
maatBean.setOpAction(Constants.INSERT_ACTION); maatBean.setOpAction(Constants.INSERT_ACTION);
//调用服务接口下发配置数据 //调用服务接口下发配置数据
String json=gsonToJson(maatBean); String json=gsonToJson(maatBean);
//logger.info("asn ip maat结构配置下发配置参数"+json); logger.info("asn ip maat结构配置下发配置参数"+json);
logger.info("asn ip maat结构配置下发配置参数"); //logger.info("asn ip maat结构配置下发配置参数");
//调用服务接口下发配置 //调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json); ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
//logger.info("asn ip maat结构配置下发响应信息"+result.getMsg()); logger.info("asn ip maat结构配置下发响应信息"+result.getMsg());
logger.info("asn ip maat结构配置下发响应信息"); //logger.info("asn ip maat结构配置下发响应信息");
}else{ }else{
if(!StringUtil.isEmpty(auditList)){ if(!StringUtil.isEmpty(auditList)){
asnIPRegionSendToMaat(auditList, 1, Constants.OPACTION_POST); asnIPRegionSendToMaat(auditList, 1, Constants.OPACTION_POST);