(1)index 跟子配置保存放到service同一个事务中
(2)修复是否下发选项隐藏导致的空指针异常
This commit is contained in:
@@ -319,65 +319,7 @@ public class AppCfgService extends BaseService {
|
||||
}
|
||||
}
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void savePolicyList(List<AppPolicyCfg> appPolicyCfgs){
|
||||
for (AppPolicyCfg appPolicyCfg : appPolicyCfgs) {
|
||||
appCfgDao.insertAppPolicyCfg(appPolicyCfg);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 同一个app下的ip批量保存
|
||||
* @param cfgs
|
||||
* @param specificServiceCfg
|
||||
* @throws Exception
|
||||
*/
|
||||
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
|
||||
public void saveAppIpCfg(List<BaseIpCfg> cfgs,SpecificServiceCfg specificServiceCfg){
|
||||
logger.warn("Start to save IP");
|
||||
long start=System.currentTimeMillis();
|
||||
ConfigGroupInfo configGroupInfo=configGroupInfoDao.getConfigGroupInfoByGroupId(specificServiceCfg.getGroupId());
|
||||
if(configGroupInfo==null) {//一般特定服务的组号是新增之后就有的,不会进入这一步。
|
||||
Integer groupId = ConfigServiceUtil.getId(2, 1).get(0);
|
||||
Integer compileId=ConfigServiceUtil.getId(1, 1).get(0);
|
||||
specificServiceCfg.setGroupId(groupId);
|
||||
configGroupInfo = new ConfigGroupInfo();
|
||||
configGroupInfo.setGroupId(specificServiceCfg.getGroupId());
|
||||
configGroupInfo.setGroupName(specificServiceCfg.getSpecServiceName());
|
||||
configGroupInfo.setIsIssued(0);
|
||||
configGroupInfo.setGroupType(1);
|
||||
configGroupInfo.setCompileId(compileId);
|
||||
configGroupInfoDao.insertConfigGroupInfo(configGroupInfo);
|
||||
//更新group_id
|
||||
specificServiceCfg.setOpTime(new Date());
|
||||
specificServiceCfgDao.update(specificServiceCfg);
|
||||
}
|
||||
Integer compileId = configGroupInfo.getCompileId();
|
||||
// Varibles maxPacket=asnIpCfgDao.getVaribles("max_allowed_packet");
|
||||
List<AppIpCfg> tempList=Lists.newArrayList();
|
||||
int len=0;
|
||||
for(BaseIpCfg cfg:cfgs) {
|
||||
AppIpCfg entity=new AppIpCfg();
|
||||
BeanUtils.copyProperties(cfg, entity);
|
||||
entity.setCompileId(compileId);
|
||||
int tempLen=entity.toString().getBytes(Charset.forName("UTF-8")).length;
|
||||
if((len+tempLen)<Constants.MAX_ALLOWED_PACKET) {
|
||||
tempList.add(entity);
|
||||
len+=tempLen;
|
||||
}else {
|
||||
appCfgDao.insertAppIpCfgBatch(tempList);
|
||||
tempList.clear();
|
||||
tempList.add(entity);
|
||||
len=tempLen;
|
||||
}
|
||||
}
|
||||
if(tempList.size()>0) {
|
||||
logger.warn("save ip size:"+tempList.size());
|
||||
appCfgDao.insertAppIpCfgBatch(tempList);
|
||||
tempList.clear();
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("Save IP finish,cost:"+(end-start));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
|
||||
public void saveOrUpdateAppIpCfg(AppIpCfg entity) throws Exception {
|
||||
// 设置区域运营商信息
|
||||
@@ -2128,51 +2070,4 @@ public class AppCfgService extends BaseService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入配置时数据批量入库
|
||||
* @param listPage
|
||||
*/
|
||||
public void saveAppDomainCfgBatch(List<BaseStringCfg<?>> data) {
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(int index = 0; index < data.size();index++){
|
||||
BaseStringCfg<?> entity = data.get(index);
|
||||
AppDomainCfg cfg=new AppDomainCfg();
|
||||
BeanUtils.copyProperties(entity, cfg);
|
||||
((AppCfgDao) batchSqlSession.getMapper(AppCfgDao.class)).insertAppDomainCfgBatch(cfg);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入配置时数据批量入库
|
||||
* @param listPage
|
||||
*/
|
||||
public void saveAppHttpCfgBatch(List<ComplexkeywordCfg> data) {
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(int index = 0; index < data.size();index++){
|
||||
ComplexkeywordCfg entity = data.get(index);
|
||||
AppHttpCfg cfg=new AppHttpCfg();
|
||||
BeanUtils.copyProperties(entity, cfg);
|
||||
((AppCfgDao) batchSqlSession.getMapper(AppCfgDao.class)).insertAppHttpCfgBatch(cfg);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user