(1)asn no放入eCache中

(2)导入验证采用多线程验证,优化验证速度
(3)asn ip导入方式调整(未采用多线程,因为redis承受不了)
(4)asn ip列表展示速度优化
(5)导入方式重写:采用csv模式,限制采用xlsx格式,加载80万数据不会内存溢出.
This commit is contained in:
wangxin
2018-11-11 19:36:53 +08:00
parent 40bcfea683
commit 80dde7d6a0
53 changed files with 4831 additions and 2996 deletions

View File

@@ -26,6 +26,7 @@ import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants;
import com.nis.web.dao.basics.AsnIpCfgDao;
import com.nis.web.dao.configuration.AsnPolicyCfgDao;
import com.nis.web.dao.specific.ConfigGroupInfoDao;
import com.nis.web.dao.specific.SpecificServiceCfgDao;
import com.nis.web.security.UserUtils;
import com.nis.web.service.BaseService;
@@ -36,7 +37,8 @@ public class AsnPolicyCfgService extends BaseService {
@Autowired
private AsnIpCfgDao asnIpCfgDao;
@Autowired
private SpecificServiceCfgDao specificServiceCfgDao;
//private SpecificServiceCfgDao specificServiceCfgDao;
private ConfigGroupInfoDao configGroupInfoDao;
/**
* @param page
* @param entity
@@ -96,124 +98,125 @@ public class AsnPolicyCfgService extends BaseService {
* @param ids cfgId
* @param functionId
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void audit(Integer isAudit,Integer isValid,Integer functionId,String id,Date auditTime){
CfgIndexInfo entity=asnPolicyCfgDao.get(Long.valueOf(id));
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(auditTime);
asnPolicyCfgDao.updateCfgIndexInfo(entity);
ToMaatBean maatBean = new ToMaatBean();
MaatCfg maatCfg = new MaatCfg();
List<MaatCfg> configCompileList = new ArrayList<>();
List<GroupCfg> groupRelationList = new ArrayList<>();
List<IpCfg> ipRegionList = new ArrayList<>();
List<StringCfg> strRegionList = new ArrayList<>();
List<NumBoundaryCfg> numRegionList = new ArrayList<>();
List<DigestCfg> digestRegionList = new ArrayList<>();
List<IpCfg> areaIpRegionList = new ArrayList<>();
if(isAudit==Constants.AUDIT_YES) {
ConfigGroupInfo group=specificServiceCfgDao.getConfigGroupInfoByGroupId(Integer.parseInt(entity.getUserRegion1()));
if(group.getIsIssued()==1) {//复用,值下编译跟分组
maatCfg.initDefaultValue();
BeanUtils.copyProperties(entity, maatCfg);
maatCfg.setAction(entity.getAction());
maatCfg.setAuditTime(entity.getAuditTime());
maatCfg.setIpRegionList(ipRegionList);
maatCfg.setStrRegionList(strRegionList);
maatCfg.setNumRegionList(numRegionList);
maatCfg.setDigestRegionList(digestRegionList);
maatCfg.setGroupRelationList(groupRelationList);
maatCfg.setAreaIpRegionList(areaIpRegionList);
maatCfg.setIsValid(entity.getIsValid());
//group
GroupCfg groupCfg=new GroupCfg();
groupCfg.setCompileId(entity.getCompileId());
groupCfg.setGroupId(Integer.parseInt(entity.getUserRegion1()));
groupCfg.setIsValid(Constants.VALID_YES);
groupCfg.setAuditTime(auditTime);
groupRelationList.add(groupCfg);
maatCfg.setGroupNum(groupRelationList.size());
configCompileList.add(maatCfg);
maatBean.setConfigCompileList(configCompileList);
maatBean.setAuditTime(entity.getAuditTime());
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.INSERT_ACTION);
//调用服务接口下发配置数据
String json=gsonToJson(maatBean);
logger.info("asn策略组复用配置下发配置参数"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
logger.info("asn策略组复用配置下发响应信息"+result.getMsg());
}else {//首次下发
maatCfg.initDefaultValue();
BeanUtils.copyProperties(entity, maatCfg);
maatCfg.setAction(entity.getAction());
maatCfg.setAuditTime(entity.getAuditTime());
maatCfg.setStrRegionList(strRegionList);
maatCfg.setNumRegionList(numRegionList);
maatCfg.setDigestRegionList(digestRegionList);
maatCfg.setGroupRelationList(groupRelationList);
maatCfg.setAreaIpRegionList(areaIpRegionList);
maatCfg.setIsValid(entity.getIsValid());
//group
GroupCfg groupCfg=new GroupCfg();
groupCfg.setCompileId(entity.getCompileId());
groupCfg.setGroupId(Integer.parseInt(entity.getUserRegion1()));
groupCfg.setIsValid(Constants.VALID_YES);
groupCfg.setAuditTime(auditTime);
groupRelationList.add(groupCfg);
maatCfg.setGroupNum(groupRelationList.size());
//region
//查询asn group id下所有的 ip
AsnIpCfg asnIpCfg=new AsnIpCfg();
asnIpCfg.setAsnIpGroup(Integer.parseInt(entity.getUserRegion1()));
List<AsnIpCfg> allAsnIpCfgs=asnIpCfgDao.findAllList(asnIpCfg);
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(allAsnIpCfgs,Constants.VALID_YES,null));
maatCfg.setIpRegionList(ipRegionList);
configCompileList.add(maatCfg);
maatBean.setConfigCompileList(configCompileList);
maatBean.setAuditTime(entity.getAuditTime());
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.INSERT_ACTION);
//调用服务接口下发配置数据
String json=gsonToJson(maatBean);
logger.info("asn策略配置下发配置参数"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
logger.info("asn策略配置下发响应信息"+result.getMsg());
ConfigGroupInfo info=new ConfigGroupInfo();
info.setIsIssued(1);
info.setGroupId(Integer.parseInt(entity.getUserRegion1()));
specificServiceCfgDao.updateConfigGroupInfobyGroupId(info);
AsnIpCfg cfg=new AsnIpCfg();
cfg.setIsValid(Constants.VALID_YES);
cfg.setAsnIpGroup(Integer.parseInt(entity.getUserRegion1()));
asnIpCfgDao.updateIssued(cfg);
}
}else if(isAudit==Constants.AUDIT_NOT_YES) {//取消审核通过
maatCfg.setCompileId(entity.getCompileId());
maatCfg.setServiceId(entity.getServiceId());
maatCfg.setIsValid(0);//无效
configCompileList.add(maatCfg);
maatBean.setConfigCompileList(configCompileList);
maatBean.setAuditTime(entity.getAuditTime());
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.UPDATE_ACTION);
//调用服务接口取消配置
String json=gsonToJson(maatBean);
logger.info("asn策略取消下发配置参数"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.put(json,1);
logger.info("asn策略取消配置响应信息"+result.getMsg());
}else {
throw new RuntimeException("unknown isAudit value "+isAudit);
}
}
// @Transactional(readOnly=false,rollbackFor=RuntimeException.class)
// @Deprecated
// public void audit(Integer isAudit,Integer isValid,Integer functionId,String id,Date auditTime){
// CfgIndexInfo entity=asnPolicyCfgDao.get(Long.valueOf(id));
// entity.setIsAudit(isAudit);
// entity.setIsValid(isValid);
// entity.setAuditorId(UserUtils.getUser().getId());
// entity.setAuditTime(auditTime);
// asnPolicyCfgDao.updateCfgIndexInfo(entity);
// ToMaatBean maatBean = new ToMaatBean();
// MaatCfg maatCfg = new MaatCfg();
// List<MaatCfg> configCompileList = new ArrayList<>();
// List<GroupCfg> groupRelationList = new ArrayList<>();
// List<IpCfg> ipRegionList = new ArrayList<>();
// List<StringCfg> strRegionList = new ArrayList<>();
// List<NumBoundaryCfg> numRegionList = new ArrayList<>();
// List<DigestCfg> digestRegionList = new ArrayList<>();
// List<IpCfg> areaIpRegionList = new ArrayList<>();
// if(isAudit==Constants.AUDIT_YES) {
// ConfigGroupInfo group=configGroupInfoDao.getConfigGroupInfoByGroupId(Integer.parseInt(entity.getUserRegion1()));
// if(group.getIsIssued()==1) {//复用,值下编译跟分组
// maatCfg.initDefaultValue();
// BeanUtils.copyProperties(entity, maatCfg);
// maatCfg.setAction(entity.getAction());
// maatCfg.setAuditTime(entity.getAuditTime());
// maatCfg.setIpRegionList(ipRegionList);
// maatCfg.setStrRegionList(strRegionList);
// maatCfg.setNumRegionList(numRegionList);
// maatCfg.setDigestRegionList(digestRegionList);
// maatCfg.setGroupRelationList(groupRelationList);
// maatCfg.setAreaIpRegionList(areaIpRegionList);
// maatCfg.setIsValid(entity.getIsValid());
// //group
// GroupCfg groupCfg=new GroupCfg();
// groupCfg.setCompileId(entity.getCompileId());
// groupCfg.setGroupId(Integer.parseInt(entity.getUserRegion1()));
// groupCfg.setIsValid(Constants.VALID_YES);
// groupCfg.setAuditTime(auditTime);
// groupRelationList.add(groupCfg);
// maatCfg.setGroupNum(groupRelationList.size());
// configCompileList.add(maatCfg);
// maatBean.setConfigCompileList(configCompileList);
// maatBean.setAuditTime(entity.getAuditTime());
// maatBean.setCreatorName(entity.getCurrentUser().getName());
// maatBean.setVersion(Constants.MAAT_VERSION);
// maatBean.setOpAction(Constants.INSERT_ACTION);
// //调用服务接口下发配置数据
// String json=gsonToJson(maatBean);
// logger.info("asn策略组复用配置下发配置参数"+json);
// //调用服务接口下发配置
// ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
// logger.info("asn策略组复用配置下发响应信息"+result.getMsg());
// }else {//首次下发
// maatCfg.initDefaultValue();
// BeanUtils.copyProperties(entity, maatCfg);
// maatCfg.setAction(entity.getAction());
// maatCfg.setAuditTime(entity.getAuditTime());
// maatCfg.setStrRegionList(strRegionList);
// maatCfg.setNumRegionList(numRegionList);
// maatCfg.setDigestRegionList(digestRegionList);
// maatCfg.setGroupRelationList(groupRelationList);
// maatCfg.setAreaIpRegionList(areaIpRegionList);
// maatCfg.setIsValid(entity.getIsValid());
// //group
// GroupCfg groupCfg=new GroupCfg();
// groupCfg.setCompileId(entity.getCompileId());
// groupCfg.setGroupId(Integer.parseInt(entity.getUserRegion1()));
// groupCfg.setIsValid(Constants.VALID_YES);
// groupCfg.setAuditTime(auditTime);
// groupRelationList.add(groupCfg);
// maatCfg.setGroupNum(groupRelationList.size());
// //region
// //查询asn group id下所有的 ip
// AsnIpCfg asnIpCfg=new AsnIpCfg();
// asnIpCfg.setAsnIpGroup(Integer.parseInt(entity.getUserRegion1()));
// List<AsnIpCfg> allAsnIpCfgs=asnIpCfgDao.findAllList(asnIpCfg);
// ipRegionList.addAll(groupReuseCfgAddRemoveConvert(allAsnIpCfgs,Constants.VALID_YES,null));
// maatCfg.setIpRegionList(ipRegionList);
// configCompileList.add(maatCfg);
// maatBean.setConfigCompileList(configCompileList);
// maatBean.setAuditTime(entity.getAuditTime());
// maatBean.setCreatorName(entity.getCurrentUser().getName());
// maatBean.setVersion(Constants.MAAT_VERSION);
// maatBean.setOpAction(Constants.INSERT_ACTION);
//
// //调用服务接口下发配置数据
// String json=gsonToJson(maatBean);
// logger.info("asn策略配置下发配置参数"+json);
// //调用服务接口下发配置
// ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
// logger.info("asn策略配置下发响应信息"+result.getMsg());
// ConfigGroupInfo info=new ConfigGroupInfo();
// info.setIsIssued(1);
// info.setGroupId(Integer.parseInt(entity.getUserRegion1()));
// configGroupInfoDao.updateConfigGroupInfobyGroupId(info);
// AsnIpCfg cfg=new AsnIpCfg();
// cfg.setIsValid(Constants.VALID_YES);
// cfg.setAsnIpGroup(Integer.parseInt(entity.getUserRegion1()));
// asnIpCfgDao.updateIssued(cfg);
// }
// }else if(isAudit==Constants.AUDIT_NOT_YES) {//取消审核通过
// maatCfg.setCompileId(entity.getCompileId());
// maatCfg.setServiceId(entity.getServiceId());
// maatCfg.setIsValid(0);//无效
// configCompileList.add(maatCfg);
// maatBean.setConfigCompileList(configCompileList);
// maatBean.setAuditTime(entity.getAuditTime());
// maatBean.setCreatorName(entity.getCurrentUser().getName());
// maatBean.setVersion(Constants.MAAT_VERSION);
// maatBean.setOpAction(Constants.UPDATE_ACTION);
// //调用服务接口取消配置
// String json=gsonToJson(maatBean);
// logger.info("asn策略取消下发配置参数"+json);
// //调用服务接口下发配置
// ToMaatResult result = ConfigServiceUtil.put(json,1);
// logger.info("asn策略取消配置响应信息"+result.getMsg());
// }else {
// throw new RuntimeException("unknown isAudit value "+isAudit);
// }
//
// }
}