Merge branch 'develop' of https://git.mesalab.cn/K18_NTCS_WEB/NTC.git
into develop Conflicts: src/main/java/com/nis/domain/configuration/CfgIndexInfo.java src/main/resources/nis.properties src/main/webapp/WEB-INF/tags/sys/delRow.tag asn相关功能更改: IP ADDR:增加asn域 1、新增IP ADDR可选asn,如果asn未下发过(is_used=0),下发时asn的group需要标记为commonGroup(groupId为asn组织的groupId,regionId为asn的regionId)。 2、如果所选的asn组(asn组织的groupId)已经下发过(is_used=1),则下发maat时,asn域不需要下发。 3、策略取消时,如果有需要保留的公共组(commongRroupIds),需要将公共组的组号下发。 ASN GROUP: 1、新增asn,如果此asn的组织groupId已下发过(is_used=1),且此组织的groupId已被策略标记过全选(is_audit_all=1),则需要调用公共组域新增的接口,将新增的asn关键字下发。 2、修改asn,如果此asn的组织groupId已下发过(is_used=1),则需要调用公共组域修改的接口,修改已经下发的asn关键字域。 3、删除asn,如果此asn的组织groupId已下发过(is_used=1),则需要调用公共组域删除的接口,删除已经下发的asn关键字域。 ASN IP CFG: 1、新增asn ip,所选asn no的组首次下发(is_valid=0),需要将asn no的groupId标记为公共组;如果asn no非首次下发(is_valid=1),直接调用公共组新增域的接口。 2、修改 生效状态asn ip修改,调用公共组修改域接口直接修改 3、失效 直接调用公共组删除域接口,失效asn ip域
This commit is contained in:
@@ -23,6 +23,8 @@ import com.nis.domain.basics.AsnGroupInfo;
|
||||
import com.nis.domain.basics.AsnIpCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
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;
|
||||
@@ -34,6 +36,7 @@ import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.domain.specific.ConfigGroupInfo;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.CrudDao;
|
||||
import com.nis.web.dao.basics.AsnGroupInfoDao;
|
||||
import com.nis.web.dao.basics.AsnIpCfgDao;
|
||||
@@ -100,6 +103,8 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void update(AsnIpCfg entity){
|
||||
List<AsnIpCfg> auditAsnIpList=new ArrayList<>();
|
||||
List<AsnGroupInfo> auditAsnGroupList=new ArrayList<>();
|
||||
Date editTime=new Date();
|
||||
entity.setEditTime(editTime);
|
||||
entity.setEditorId(entity.getCurrentUser().getId());
|
||||
@@ -114,7 +119,53 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
entity.setCountry(country);
|
||||
entity.setDetail(detail);
|
||||
entity.setCompileId(groupInfo.getCompileId());
|
||||
/**
|
||||
* isvalid=0 and asnNo=false 直接修改
|
||||
* isvalid=0 and asnNo=true 需要下发
|
||||
* isvalid=1 需要下发asnNo下所有的域配置
|
||||
*/
|
||||
/*if(groupInfo.getIsUsed().equals(1) && entity.getIsValid().equals(Constants.VALID_NO)){
|
||||
entity.setAuditTime(editTime);
|
||||
entity.setAuditorId(entity.getCurrentUser().getId());
|
||||
entity.setIsValid(Constants.VALID_YES);
|
||||
entity.setIsAudit(Constants.AUDIT_YES);
|
||||
auditAsnIpList.add(entity);
|
||||
}
|
||||
if(groupInfo.getIsUsed().equals(1) && entity.getIsValid().equals(Constants.VALID_YES)){
|
||||
entity.setAuditTime(editTime);
|
||||
entity.setAuditorId(entity.getCurrentUser().getId());
|
||||
entity.setIsValid(Constants.VALID_YES);
|
||||
entity.setIsAudit(Constants.AUDIT_YES);
|
||||
auditAsnGroupList.add(groupInfo);
|
||||
}*/
|
||||
if(entity.getIsValid() ==1){
|
||||
entity.setAuditTime(editTime);
|
||||
entity.setAuditorId(entity.getCurrentUser().getId());
|
||||
entity.setEditTime(editTime);
|
||||
entity.setEditorId(entity.getCurrentUser().getId());
|
||||
entity.setIsValid(Constants.VALID_YES);
|
||||
entity.setIsAudit(Constants.AUDIT_YES);
|
||||
}else{
|
||||
entity.setEditTime(editTime);
|
||||
entity.setEditorId(entity.getCurrentUser().getId());
|
||||
entity.setIsValid(Constants.VALID_NO);
|
||||
entity.setIsAudit(Constants.VALID_NO);
|
||||
}
|
||||
asnIpCfgDao.update(entity);
|
||||
//ASN下发状态时可以更改,更改之后直接下发
|
||||
if(entity.getIsValid() ==1){
|
||||
auditAsnIpList.add(entity);
|
||||
asnIPRegionSendToMaat(auditAsnIpList,Constants.VALID_YES,Constants.OPACTION_PUT);
|
||||
}
|
||||
//common group 新增下发 ASN IP配置
|
||||
/*if(!StringUtil.isEmpty(auditAsnIpList)){
|
||||
asnIPRegionSendToMaat(auditAsnIpList,Constants.VALID_YES,Constants.OPACTION_POST);
|
||||
}*/
|
||||
|
||||
//common group 修改已下发过的配置,全量下发 ASN NO下的所有有效配置
|
||||
/*if(entity.getIsAudit().equals(Constants.VALID_YES)){
|
||||
auditAllAsnRegionCfg(entity,auditAsnGroupList,null);
|
||||
}*/
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void processGroup(Map<Long,AsnGroupInfo> asnNoMap){
|
||||
@@ -256,11 +307,12 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
}
|
||||
sb.deleteCharAt(sb.toString().lastIndexOf(","));
|
||||
asnIpCfgDao.delete(sb.toString());
|
||||
asnIPRegionSendToMaat(entities,Constants.VALID_NO);
|
||||
asnIPRegionSendToMaat(entities,Constants.VALID_NO,Constants.OPACTION_PUT);
|
||||
}
|
||||
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveAsnIpCfg(CfgIndexInfo entity) {
|
||||
List<AsnIpCfg> auditAsnIpList=new ArrayList<>();
|
||||
Date createTime=new Date();
|
||||
//asn号
|
||||
String userRegion1=entity.getUserRegion1();
|
||||
@@ -301,13 +353,27 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
cfg.setCreateTime(createTime);
|
||||
cfg.setCreatorId(entity.getCurrentUser().getId());
|
||||
cfg.setAsnIpGroup(entity.getAsnIpGroup().intValue());
|
||||
cfg.setIsValid(Constants.VALID_NO);
|
||||
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
||||
cfg.setRegionId(idList.get(index));
|
||||
//TODO 注意:被策略引用并下发过的ASN NO,配置新增后直接下发【此功能暂时不做自动,asnip拥有审核功能】
|
||||
/*if(asnGroupInfo.getIsUsed().equals(1)){
|
||||
cfg.setIsValid(Constants.VALID_YES);
|
||||
cfg.setIsAudit(Constants.AUDIT_YES);
|
||||
cfg.setAuditorId(UserUtils.getUser().getId());
|
||||
cfg.setAuditTime(createTime);
|
||||
auditAsnIpList.add(cfg);
|
||||
}else{*/
|
||||
cfg.setIsValid(Constants.VALID_NO);
|
||||
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
||||
/*}*/
|
||||
index++;
|
||||
}
|
||||
|
||||
}
|
||||
this.save(entity.getAsnIpCfgs());
|
||||
//TODO 注意:被策略引用并下发过的ASN NO,配置新增后直接下发【此功能暂时不做自动,asnip拥有审核功能】
|
||||
/*if(!StringUtil.isEmpty(auditAsnIpList)){
|
||||
asnIPRegionSendToMaat(auditAsnIpList,Constants.VALID_YES,Constants.OPACTION_POST);
|
||||
}*/
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void delete(String ids) {
|
||||
@@ -332,7 +398,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
//已经下发过的,调用分组复用配置删除接口
|
||||
// splitAndSend(issuedList,Constants.VALID_NO);
|
||||
if(issuedList.size() > 0){
|
||||
asnIPRegionSendToMaat(issuedList,Constants.VALID_NO);
|
||||
asnIPRegionSendToMaat(issuedList,Constants.VALID_NO,Constants.OPACTION_PUT);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -440,14 +506,11 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void auditIpBatch(Map<Long,List<AsnIpCfg>> data,Integer isValid) {
|
||||
public void auditIpBatch(List<AsnIpCfg> asnIpCfgs,Long asn,Integer isValid) {
|
||||
List<AsnGroupInfo> auditAsnGroupList=new ArrayList<>();
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
final SqlSession batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
try{
|
||||
for(Entry<Long,List<AsnIpCfg>> enrty:data.entrySet()) {
|
||||
//data.entrySet().stream().forEach( enrty->{
|
||||
Long asn=enrty.getKey();//ans group 的group id
|
||||
List<AsnIpCfg> asnIpCfgs=enrty.getValue();
|
||||
int issuedNum=asnIpCfgs.size();
|
||||
for(int index = 0; index < asnIpCfgs.size();index++){
|
||||
AsnIpCfg t = asnIpCfgs.get(index);
|
||||
@@ -461,6 +524,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
asnGroupInfo.setAsnId(asn);
|
||||
asnGroupInfo=asnGroupInfoDao.getInfoByAsnNo(asnGroupInfo);
|
||||
Integer groupId=asnGroupInfo.getGroupId();
|
||||
|
||||
MaatCfg maatCfg = new MaatCfg();
|
||||
List<MaatCfg> configCompileList = new ArrayList();
|
||||
List<GroupCfg> groupRelationList = new ArrayList();
|
||||
@@ -484,6 +548,8 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
groupCfg.setCompileId(asnGroupInfo.getCompileId());
|
||||
groupCfg.setGroupId(groupId);
|
||||
groupCfg.setIsValid(Constants.VALID_YES);
|
||||
//asnGroupId标记为公共组
|
||||
groupCfg.setIsCommonGroup(1);
|
||||
groupCfg.setAuditTime(asnIpCfgs.get(0).getAuditTime());
|
||||
groupRelationList.add(groupCfg);
|
||||
BeanUtils.copyProperties(asnIpCfgs.get(0), maatCfg);
|
||||
@@ -517,7 +583,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
}else if(asnGroupInfo.getIsValid()==1){//已经下发过,走分组复用
|
||||
asnGroupInfo.setIssuedIPs(issuedNum+0l);
|
||||
asnGroupInfoDao.update(asnGroupInfo);
|
||||
asnIPRegionSendToMaat(asnIpCfgs,isValid);
|
||||
asnIPRegionSendToMaat(asnIpCfgs,isValid,Constants.OPACTION_POST);
|
||||
}else {
|
||||
throw new RuntimeException("asnGroupInfo isValid value is "+asnGroupInfo.getIsValid());
|
||||
}
|
||||
@@ -525,39 +591,34 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
asnGroupInfo.setIssuedIPs(0L-issuedNum);
|
||||
asnGroupInfoDao.update(asnGroupInfo);
|
||||
//已经下发过的,调用分组复用配置删除接口
|
||||
// GroupReuseAddBean maatBean = new GroupReuseAddBean();
|
||||
// List<GroupReuseCfg> groupReuseList=new ArrayList<>();
|
||||
// GroupReuseCfg groupReuseCfg=new GroupReuseCfg();
|
||||
// ipRegionList.addAll(groupReuseCfgAddRemoveConvert(asnIpCfgs,Constants.VALID_NO,groupId));
|
||||
// groupReuseCfg.setIpRegionList(ipRegionList);
|
||||
// groupReuseCfg.setStrRegionList(strRegionList);
|
||||
// groupReuseCfg.setNumRegionList(numRegionList);
|
||||
// groupReuseList.add(groupReuseCfg);
|
||||
// maatBean.setGroupReuseCfgList(groupReuseList);
|
||||
// maatBean.setAuditTime(asnIpCfgs.get(0).getAuditTime());
|
||||
// maatBean.setCreatorName(asnIpCfgs.get(0).getCurrentUser().getName());
|
||||
// maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
// maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
// //调用服务接口下发配置数据
|
||||
// String json=gsonToJson(maatBean);
|
||||
// logger.info("ASN IP域删除配置下发配置参数:"+json);
|
||||
// //调用服务接口下发配置
|
||||
// ToMaatResult result = ConfigServiceUtil.put(json,3);
|
||||
// logger.info("ASN IP域删除配置响应信息:"+result.getMsg());
|
||||
asnIPRegionSendToMaat(asnIpCfgs,isValid);
|
||||
GroupReuseAddBean maatBean = new GroupReuseAddBean();
|
||||
List<GroupReuseCfg> groupReuseList=new ArrayList<>();
|
||||
GroupReuseCfg groupReuseCfg=new GroupReuseCfg();
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(asnIpCfgs,Constants.VALID_NO,groupId));
|
||||
groupReuseCfg.setIpRegionList(ipRegionList);
|
||||
groupReuseCfg.setStrRegionList(strRegionList);
|
||||
groupReuseCfg.setNumRegionList(numRegionList);
|
||||
groupReuseList.add(groupReuseCfg);
|
||||
maatBean.setGroupReuseCfgList(groupReuseList);
|
||||
maatBean.setAuditTime(asnIpCfgs.get(0).getAuditTime());
|
||||
maatBean.setCreatorName(asnIpCfgs.get(0).getCurrentUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("ASN IP域删除配置下发配置参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3);
|
||||
logger.info("ASN IP域删除配置响应信息:"+result.getMsg());
|
||||
//如果一个asn组下没有IP了,修改有效状态
|
||||
//if(hasValidAsnIp(asn)) {
|
||||
// asnGroupInfo.setIsValid(0);
|
||||
// asnGroupInfo.setEditorId(UserUtils.getUser().getId());
|
||||
// asnGroupInfo.setEditTime(new Date());
|
||||
// asnGroupInfoDao.updateValid(asnGroupInfo);
|
||||
//}
|
||||
if(hasValidAsnIp(asn)) {
|
||||
asnGroupInfo.setIsValid(0);
|
||||
asnGroupInfo.setEditorId(UserUtils.getUser().getId());
|
||||
asnGroupInfo.setEditTime(new Date());
|
||||
asnGroupInfoDao.updateValid(asnGroupInfo);
|
||||
}
|
||||
|
||||
}else {
|
||||
throw new RuntimeException("isValid value is "+isValid);
|
||||
}
|
||||
//});
|
||||
}
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
|
||||
Reference in New Issue
Block a user