From af4491d73953da1925dd7bcd7828b71d7bf96ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E5=86=AC=E6=A2=85?= Date: Thu, 4 Apr 2019 16:45:18 +0800 Subject: [PATCH 1/4] =?UTF-8?q?ASN=20IPv4=E6=88=96IPv6=E7=9A=84=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E4=BF=AE=E6=94=B9=E4=B8=BA=E4=BD=BF=E7=94=A8qurtz?= =?UTF-8?q?=E6=9D=A5=E5=81=9A=E5=AE=9A=E6=97=B6=EF=BC=9B=20=E6=9A=82?= =?UTF-8?q?=E6=97=B6=E4=B8=8D=E5=BC=80=E6=94=BE=E6=9C=8D=E5=8A=A1=E5=92=8C?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E9=85=8D=E7=BD=AE=E4=B8=8D=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../quartz/ScheduleStatisticASNIPNumJob.java | 137 ++++++++++++++++++ .../resources/applicationContext-quartz.xml | 21 ++- src/main/resources/spring-mvc.xml | 4 - src/main/webapp/WEB-INF/views/home.jsp | 5 +- 4 files changed, 158 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/nis/quartz/ScheduleStatisticASNIPNumJob.java diff --git a/src/main/java/com/nis/quartz/ScheduleStatisticASNIPNumJob.java b/src/main/java/com/nis/quartz/ScheduleStatisticASNIPNumJob.java new file mode 100644 index 000000000..c28a67328 --- /dev/null +++ b/src/main/java/com/nis/quartz/ScheduleStatisticASNIPNumJob.java @@ -0,0 +1,137 @@ +package com.nis.quartz; + + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.apache.ibatis.session.ExecutorType; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; +import org.apache.log4j.Logger; +import org.quartz.DisallowConcurrentExecution; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.quartz.PersistJobDataAfterExecution; + +import com.nis.util.IPUtil; +import com.nis.util.StringUtil; +import com.nis.web.dao.basics.AsnGroupInfoDao; +import com.nis.web.dao.basics.AsnIpCfgDao; +import com.nis.web.service.SpringContextHolder; + +/** + * 定时任务: 定时统计ASN 下IPv4和IPV6的个数 + * 1、每 n s 执行一次(两个小时执行一次) + * 2、单线程执行 + * @author ddm + * + */ +@DisallowConcurrentExecution +@PersistJobDataAfterExecution +public class ScheduleStatisticASNIPNumJob implements Job { + private static final Logger logger = Logger.getLogger(ScheduleStatisticASNIPNumJob.class); + + @Override + public void execute(JobExecutionContext context) throws JobExecutionException { + AsnIpCfgDao asnIpCfgDao = SpringContextHolder.getBean(AsnIpCfgDao.class); + logger.info("定时统计ASN IP个数开始。。。。。。。。。。。。。。"); + long start=System.currentTimeMillis(); + Map> asnNumerMap=new HashMap<>(); + List asnIpList=new ArrayList<>(); + asnIpList=asnIpCfgDao.findAllAsnIpCfgList(); + + getAllASNIPNumber(asnIpList, asnNumerMap); + + updateAllASNIPNumber(asnNumerMap); + + long end=System.currentTimeMillis(); + logger.info("定时统计ASN IP个数结束:耗时("+(end-start)+"/毫秒)。。。。。。。。。。。。。。"); + } + + public void getAllASNIPNumber(List asnIpList,Map> asnNumerMap){ + logger.info("计算ASN IP开始:asn ip size:"+asnIpList.size()+"。。。。。。。。。。。。。。"); + long start=System.currentTimeMillis(); + if(!StringUtil.isEmpty(asnIpList)){ + try { + for (Iterator iterator = asnIpList.iterator(); iterator.hasNext();) { + Map asnIpMap=(Map) iterator.next(); + //groupId + Integer asnGroupId = (Integer)asnIpMap.get("asn_ip_group"); + //ipType(4:v4,6:v6) + Integer ipType= (Integer)asnIpMap.get("ip_type"); + //(1:mask,2:range,3:ip) + //Integer ipPattern= (Integer)asnIpMap.get("ip_pattern"); + //dest_ip_address + String ipAddress= (String)asnIpMap.get("dest_ip_address"); + long IPNumber=0; + if(ipType.equals(4)){ + if(ipAddress.indexOf("/") > -1){ + Integer mask=Integer.parseInt(ipAddress.split("/")[1]); + ipAddress=ipAddress.split("/")[0]; + IPNumber=IPUtil.getIpNum(ipAddress, mask); + }else{ + IPNumber=1; + } + //判断组是否已经存在 + if(asnNumerMap.keySet().contains(asnGroupId)){ + asnNumerMap.get(asnGroupId).put("v4", asnNumerMap.get(asnGroupId).get("v4")+IPNumber); + asnNumerMap.put(asnGroupId, asnNumerMap.get(asnGroupId)); + }else{ + Map map=new HashMap<>(); + map.put("v4", IPNumber); + map.put("v6", 0l); + asnNumerMap.put(asnGroupId, map); + } + }else{ + IPNumber=1; + //判断组是否已经存在 + if(asnNumerMap.keySet().contains(asnGroupId)){ + asnNumerMap.get(asnGroupId).put("v6", asnNumerMap.get(asnGroupId).get("v6")+IPNumber); + asnNumerMap.put(asnGroupId, asnNumerMap.get(asnGroupId)); + }else{ + Map map=new HashMap<>(); + map.put("v4", 0l); + map.put("v6", IPNumber); + asnNumerMap.put(asnGroupId, map); + } + } + } + } catch (Exception e) { + logger.error("计算ASN IP个数失败",e); + } + } + + long end=System.currentTimeMillis(); + logger.info("计算ASN IP个数结束:耗时("+(end-start)+"/毫秒)。。。。。。。。。。。。。。"); + } + public void updateAllASNIPNumber(Map> asnNumerMap) { + logger.info("修改ASN IP个数开始:asn size:"+asnNumerMap.size()+"。。。。。。。。。。。。。。"); + long start=System.currentTimeMillis(); + if(!StringUtil.isEmpty(asnNumerMap)){ + int index=0; + SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class); + SqlSession batchSqlSession = null; + try { + batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, true); + for(Entry> e: asnNumerMap.entrySet()) { + ((AsnGroupInfoDao) batchSqlSession.getMapper(AsnGroupInfoDao.class)).updateIpNum(e.getValue().get("v4"),e.getValue().get("v6"),e.getKey()); + batchSqlSession.commit(); + index++; + } + }catch (Exception e) { + logger.error("修改ASN IP个数失败", e); + } finally { + if(batchSqlSession != null){ + batchSqlSession.close(); + } + } + } + long end=System.currentTimeMillis(); + logger.info("修改ASN IP个数结束:耗时("+(end-start)+"/毫秒)。。。。。。。。。。。。。。"); + } +} diff --git a/src/main/resources/applicationContext-quartz.xml b/src/main/resources/applicationContext-quartz.xml index e597748a0..00485961a 100644 --- a/src/main/resources/applicationContext-quartz.xml +++ b/src/main/resources/applicationContext-quartz.xml @@ -16,7 +16,7 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd" default-lazy-init="true"> - + @@ -35,7 +35,7 @@ - + @@ -51,8 +51,22 @@ + - + + + + + + + + + + + + + + @@ -64,6 +78,7 @@ + diff --git a/src/main/resources/spring-mvc.xml b/src/main/resources/spring-mvc.xml index 83926c54b..8e1808b75 100644 --- a/src/main/resources/spring-mvc.xml +++ b/src/main/resources/spring-mvc.xml @@ -104,10 +104,6 @@ - - - - + + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/service/SysUserWarnService.java b/src/main/java/com/nis/web/service/SysUserWarnService.java index b66abd20c..6bb8fd506 100644 --- a/src/main/java/com/nis/web/service/SysUserWarnService.java +++ b/src/main/java/com/nis/web/service/SysUserWarnService.java @@ -39,7 +39,7 @@ public class SysUserWarnService extends BaseService{ page.setList(allList); return page; } - //根据serviceID和表名查询业务配置的数量 + //查询总的记录数 public Integer getAllInfoCount(){ return sysUserWarnDao.getAllInfoCount(); @@ -69,4 +69,15 @@ public class SysUserWarnService extends BaseService{ return allSum; } + //查询ASN IP 页面配置总量 + public Integer getASNIPTotal(){ + + return sysUserWarnDao.getASNIPTotal(); + } + //查询APP IP 页面配置总量 + public Integer getAPPIPTotal(){ + + return sysUserWarnDao.getAPPIPTotal(); + } + } From 7af6c7c203e6617bee6053a2a2a9f93beab2a089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E5=86=AC=E6=A2=85?= Date: Mon, 8 Apr 2019 13:50:40 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=AF=81=E4=B9=A6=E7=B1=BB=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=8D=95=E8=8E=B7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/configuration/proxy/PxyObjKeyringController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/nis/web/controller/configuration/proxy/PxyObjKeyringController.java b/src/main/java/com/nis/web/controller/configuration/proxy/PxyObjKeyringController.java index 894f18edb..c5059b0d0 100644 --- a/src/main/java/com/nis/web/controller/configuration/proxy/PxyObjKeyringController.java +++ b/src/main/java/com/nis/web/controller/configuration/proxy/PxyObjKeyringController.java @@ -122,7 +122,7 @@ public class PxyObjKeyringController extends BaseController { logger.error("证书文件校验失败", e); if (e instanceof MaatConvertException) { addMessage(redirectAttributes, "error", "request_service_failed"); - } else if (e instanceof MaatConvertException) { + } else if (e instanceof MultiPartNewException) { addMessage(redirectAttributes, "error", e.getMessage()); } else { addMessage(redirectAttributes, "error", "save_failed"); From da9ea20e8f447c5362bb5d7c4d2d5fee027c2b51 Mon Sep 17 00:00:00 2001 From: zhangwenqing Date: Mon, 8 Apr 2019 16:00:14 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9tagsInput=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=A1=86=E9=95=BF=E5=BA=A6=E4=B8=BA1=E6=97=B6?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=BF=9D=E6=8A=A4=E5=90=8D=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../webapp/static/global/scripts/common.js | 59 ++++++++++--------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/src/main/webapp/static/global/scripts/common.js b/src/main/webapp/static/global/scripts/common.js index cbf14de7a..c0a65619d 100644 --- a/src/main/webapp/static/global/scripts/common.js +++ b/src/main/webapp/static/global/scripts/common.js @@ -438,43 +438,48 @@ $(function(){ 'delimiter':'***and***',//特殊字符串分隔与表达式的多关键词 maxCount:4, onAddTag:function(tag,size){ - var reg = new RegExp(/\t|\r|\n/); + var reg = new RegExp(/\t|\r|\n/); if (tag.match(reg)) { $(this).parent(".col-md-6").next("div").html(""); }else{ $(this).parent(".col-md-6").next("div").html(""); } //var keywordValue = ""; - var objNamePrefix = $(this).attr("name").split("cfgKeywords")[0]; - /*$("span[class='tag']").each(function(){ - keywordValue = keywordValue+"***iie***"+$(this).find("span").text().trim(); - }); - $(this).prev("input[name$='cfgKeywords']").val(keywordValue);*/ - exprTypeChecked(objNamePrefix,size,options); - - var tagObj = $(this); - for(var key in protectionData){ - if(tagObj.hasClass(key)){ - protectedListWarn(tagObj,key); - } - } - }, - onRemoveTag:function(tag,size){ - $(this).parent(".col-md-6").next("div").html(""); - //var keywordValue = ""; - var objNamePrefix = $(this).attr("name").split("cfgKeywords")[0]; - /*$("span[class='tag']").each(function(){ + var objNamePrefix = $(this).attr("name").split("cfgKeywords")[0]; + /*$("span[class='tag']").each(function(){ keywordValue = keywordValue+"***iie***"+$(this).find("span").text().trim(); }); $(this).prev("input[name$='cfgKeywords']").val(keywordValue);*/ - exprTypeChecked(objNamePrefix,size,options); + exprTypeChecked(objNamePrefix,size,options); + + if(size == 1){ + var tagObj = $(this); + for(var key in protectionData){ + if(tagObj.hasClass(key)){ + protectedListWarn(tagObj,key); + } + } + } + + }, + onRemoveTag:function(tag,size){ + $(this).parent(".col-md-6").next("div").html(""); + //var keywordValue = ""; + var objNamePrefix = $(this).attr("name").split("cfgKeywords")[0]; + /*$("span[class='tag']").each(function(){ + keywordValue = keywordValue+"***iie***"+$(this).find("span").text().trim(); + }); + $(this).prev("input[name$='cfgKeywords']").val(keywordValue);*/ + exprTypeChecked(objNamePrefix,size,options); - var tagObj = $(this); - for(var key in protectionData){ - if(tagObj.hasClass(key)){ - protectedListWarn(tagObj,key); - } - } + if(size == 1){ + var tagObj = $(this); + for(var key in protectionData){ + if(tagObj.hasClass(key)){ + protectedListWarn(tagObj,key); + } + } + } } }); $(".tagsinput").popover({