From b64d26e7f68ec163585b24ff36d4b2fb12c6c971 Mon Sep 17 00:00:00 2001 From: wangxin Date: Mon, 5 Nov 2018 19:03:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96asn=20ip=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=EF=BC=8C=E5=87=8F=E5=B0=91=E5=BE=AA=E7=8E=AF=E6=AC=A1=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E5=87=8F=E5=B0=91=E8=B0=83=E7=94=A8=E7=BB=BC=E5=90=88?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=8E=A5=E5=8F=A3=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nis/web/controller/BaseController.java | 3 +- .../web/service/basics/AsnIpCfgService.java | 33 ++++++++++--------- src/main/resources/nis.properties | 1 + 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/nis/web/controller/BaseController.java b/src/main/java/com/nis/web/controller/BaseController.java index 1233acf48..b1867f3cb 100644 --- a/src/main/java/com/nis/web/controller/BaseController.java +++ b/src/main/java/com/nis/web/controller/BaseController.java @@ -3352,6 +3352,7 @@ public class BaseController { if (regionDict.getRegionType().equals(1)) {// IP if(regionDict.getFunctionId().intValue()==600) {//ans ip Map> asnIpCfgs=new HashMap<>(); + int total=ipPortCfgs.size(); for (BaseIpCfg cfg : ipPortCfgs) { AsnIpCfg _cfg=new AsnIpCfg(); BeanUtils.copyProperties(cfg, _cfg); @@ -3381,7 +3382,7 @@ public class BaseController { } } ipPortCfgs.clear(); - asnIpCfgService.saveAsnIpBatch(asnIpCfgs); + asnIpCfgService.saveAsnIpBatch(asnIpCfgs,total); }else { List compileIds=Lists.newArrayList(); List regionIds=Lists.newArrayList(); diff --git a/src/main/java/com/nis/web/service/basics/AsnIpCfgService.java b/src/main/java/com/nis/web/service/basics/AsnIpCfgService.java index 5939b8d4a..c55f8ae86 100644 --- a/src/main/java/com/nis/web/service/basics/AsnIpCfgService.java +++ b/src/main/java/com/nis/web/service/basics/AsnIpCfgService.java @@ -60,15 +60,6 @@ public class AsnIpCfgService extends CrudService, AsnIpCfg> { } @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public void save(List entitys){ - Date createTime=new Date(); - List idList=ConfigServiceUtil.getId(3, entitys.size()); - int index=0; - for(AsnIpCfg entity:entitys) { - entity.setCreateTime(createTime); - entity.setCreatorId(entity.getCurrentUser().getId()); - entity.setRegionId(idList.get(index)); - index++; - } this.saveBatch(entitys, AsnIpCfgDao.class); } @Transactional(readOnly=false,rollbackFor=RuntimeException.class) @@ -88,10 +79,12 @@ public class AsnIpCfgService extends CrudService, AsnIpCfg> { } @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public void saveAsnIpBatch(Map> cfgs) { + public void saveAsnIpBatch(Map> cfgs,int total) { List toDelAsnIpCfgs=Lists.newArrayList(); List toSaveAsnIpCfgs=Lists.newArrayList(); List isImportAll=DictUtils.getDictList("IS_ASN_IP_IMPORT_ALL"); + List idList=ConfigServiceUtil.getId(3, total); + int ind=0; for(Entry> entry:cfgs.entrySet()) { Long asnNo=Long.parseLong(entry.getKey()); ConfigGroupInfo configGroupInfo=this.getConfigGroupInfoByAsnNo(asnNo); @@ -101,15 +94,17 @@ public class AsnIpCfgService extends CrudService, AsnIpCfg> { info.setDescription("Create by import excel"); info.setGroupName("Import"+asnNo); info.setGroupType(4); - this.saveAsnGroup(info); - configGroupInfo=this.getConfigGroupInfoByAsnNo(asnNo); + configGroupInfo=this.saveAsnGroup(info); } for(AsnIpCfg cfg:entry.getValue()) { cfg.setAsnIpGroup(configGroupInfo.getGroupId()); + cfg.setRegionId(idList.get(ind)); if(configGroupInfo.getIsIssued()==0) cfg.setIsValid(Constants.VALID_NO); - else + else { cfg.setIsValid(Constants.VALID_YES); + } + ind++; } if(isImportAll.get(0).getItemCode().equals("1")) {//全量下发,删除已有的 if(configGroupInfo.getIsIssued()==1) {//已下发 @@ -166,8 +161,9 @@ public class AsnIpCfgService extends CrudService, AsnIpCfg> { } } @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public void saveAsnGroup(PolicyGroupInfo entity) throws MaatConvertException{ + public ConfigGroupInfo saveAsnGroup(PolicyGroupInfo entity) throws MaatConvertException{ entity.setIsValid(1); + ConfigGroupInfo group=new ConfigGroupInfo(); //新增 Date createTime=new Date(); entity.setCreatorId(UserUtils.getUser().getId()); @@ -183,7 +179,6 @@ public class AsnIpCfgService extends CrudService, AsnIpCfg> { } entity.setServiceGroupId(serviceGroupId); //新增协议分组 - ConfigGroupInfo group = new ConfigGroupInfo(); group.setGroupId(serviceGroupId); group.setGroupName(entity.getGroupName()); group.setIsIssued(0); @@ -192,7 +187,7 @@ public class AsnIpCfgService extends CrudService, AsnIpCfg> { specificServiceCfgDao.insertConfigGroupInfo(group); policyGroupInfoDao.insert(entity); } - + return group; } @Transactional(readOnly=false,rollbackFor=RuntimeException.class) public void saveAsnIpCfg(CfgIndexInfo entity) { @@ -201,6 +196,8 @@ public class AsnIpCfgService extends CrudService, AsnIpCfg> { if(groupInfo==null) { throw new RuntimeException("ConfigGroupInfo is null!"); } + List idList=ConfigServiceUtil.getId(3, entity.getAsnIpCfgs().size()); + int index=0; if(groupInfo.getIsIssued()==1) {//如果已经下发,则需要下到综合服务中 if(entity.getAsnIpCfgs()!=null) { for(AsnIpCfg cfg:entity.getAsnIpCfgs()) { @@ -214,6 +211,8 @@ public class AsnIpCfgService extends CrudService, AsnIpCfg> { cfg.setCreatorId(entity.getCurrentUser().getId()); cfg.setAsnIpGroup(entity.getAsnIpGroup()); cfg.setIsValid(Constants.VALID_YES); + cfg.setRegionId(idList.get(index)); + index++; } } this.save(entity.getAsnIpCfgs()); @@ -226,6 +225,8 @@ public class AsnIpCfgService extends CrudService, AsnIpCfg> { cfg.setCreatorId(entity.getCurrentUser().getId()); cfg.setAsnIpGroup(entity.getAsnIpGroup().intValue()); cfg.setIsValid(Constants.VALID_NO); + cfg.setRegionId(idList.get(index)); + index++; } } this.save(entity.getAsnIpCfgs()); diff --git a/src/main/resources/nis.properties b/src/main/resources/nis.properties index 6b71ee77b..3b81f69b2 100644 --- a/src/main/resources/nis.properties +++ b/src/main/resources/nis.properties @@ -543,4 +543,5 @@ cert_validate_success_info=Successful #ipv4 range\u65b0\u683c\u5f0f0.0.0.1-2 ipv4_ip_range_regexp_new=^(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)-(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$ ipv4_ip_subnet_regexp_original=^(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\.(0|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)/(3[0-2]|1[0-9]|2[0-9]|[0-9])$ +#域名验证正则 domain_regexp=^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$ \ No newline at end of file