From f5e3b17761c9b640b1e0f5dbbf99b9d50d682d83 Mon Sep 17 00:00:00 2001 From: wangxin Date: Wed, 21 Nov 2018 14:08:12 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=B9=B6=E4=B8=8B?= =?UTF-8?q?=E5=8F=91ip=20region=E6=97=B6=E5=85=B6=E9=99=84=E5=B8=A6?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E5=80=BC=E5=9F=9F=E7=9A=84group=20id?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E8=B7=9Fip=E5=9F=9F=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/nis/domain/configuration/BaseCfg.java | 14 +++++++------- .../com/nis/web/controller/BaseController.java | 10 +++++----- src/main/java/com/nis/web/service/BaseService.java | 6 +----- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/nis/domain/configuration/BaseCfg.java b/src/main/java/com/nis/domain/configuration/BaseCfg.java index f3f942d7e..155a044a1 100644 --- a/src/main/java/com/nis/domain/configuration/BaseCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseCfg.java @@ -230,15 +230,15 @@ public class BaseCfg extends BaseEntity implements Cloneable{ protected Integer groupId;//仅用于copy属性使用 protected Integer regionId;//仅用于copy属性使用 - protected Integer numberRegionGroupId;//仅用于copy属性使用 +// protected Integer numberRegionGroupId;//仅用于copy属性使用 protected Integer numberRegionRegionId;//仅用于copy属性使用 - public Integer getNumberRegionGroupId() { - return numberRegionGroupId; - } - public void setNumberRegionGroupId(Integer numberRegionGroupId) { - this.numberRegionGroupId = numberRegionGroupId; - } +// public Integer getNumberRegionGroupId() { +// return numberRegionGroupId; +// } +// public void setNumberRegionGroupId(Integer numberRegionGroupId) { +// this.numberRegionGroupId = numberRegionGroupId; +// } public Integer getNumberRegionRegionId() { return numberRegionRegionId; } diff --git a/src/main/java/com/nis/web/controller/BaseController.java b/src/main/java/com/nis/web/controller/BaseController.java index c7868233f..d6c105e83 100644 --- a/src/main/java/com/nis/web/controller/BaseController.java +++ b/src/main/java/com/nis/web/controller/BaseController.java @@ -1417,7 +1417,7 @@ public class BaseController { List compileIds=Lists.newArrayList(); List regionIds=Lists.newArrayList(); List groupIds=Lists.newArrayList(); - List numRegionGroupIds=Lists.newArrayList(); +// List numRegionGroupIds=Lists.newArrayList(); List numRegionRegionIds=Lists.newArrayList(); if(!regionDict.getFunctionId().equals(405)) {//app ip compileId 从config_group_info中取 try { @@ -1428,7 +1428,7 @@ public class BaseController { } //需要获取数值域的id if(serviceDict!=null&&serviceDict.getProtocolId()!=null) { - numRegionGroupIds = ConfigServiceUtil.getId(2,_ipPortCfgs.size()); +// numRegionGroupIds = ConfigServiceUtil.getId(2,_ipPortCfgs.size()); numRegionRegionIds = ConfigServiceUtil.getId(3,_ipPortCfgs.size()); } } catch (Exception e) { @@ -1468,9 +1468,9 @@ public class BaseController { cfg.setRegionId(regionIds.get(ind)); } if(serviceDict!=null&&serviceDict.getProtocolId()!=null) { - if(numRegionGroupIds!=null&&numRegionGroupIds.size()==_ipPortCfgs.size()) { - cfg.setNumberRegionGroupId(numRegionGroupIds.get(ind)); - } +// if(numRegionGroupIds!=null&&numRegionGroupIds.size()==_ipPortCfgs.size()) { +// cfg.setNumberRegionGroupId(numRegionGroupIds.get(ind)); +// } if(numRegionRegionIds!=null&&numRegionRegionIds.size()==_ipPortCfgs.size()) { cfg.setNumberRegionRegionId(numRegionRegionIds.get(ind)); } diff --git a/src/main/java/com/nis/web/service/BaseService.java b/src/main/java/com/nis/web/service/BaseService.java index 4ecbce585..f9a7affdb 100644 --- a/src/main/java/com/nis/web/service/BaseService.java +++ b/src/main/java/com/nis/web/service/BaseService.java @@ -597,11 +597,7 @@ public abstract class BaseService { if (baseIpCfg.getProtocolId() != null && baseIpCfg.getProtocolId() != 0) { if (numGroupId == 0) { GroupCfg group1 = new GroupCfg(); - if(baseIpCfg.getNumberRegionGroupId()!=null) { - group1.setGroupId(baseIpCfg.getNumberRegionGroupId()); - }else { - group1.setGroupId(ConfigServiceUtil.getId(2, 1).get(0)); - } + group1.setGroupId(groupId); group1.setCompileId(baseIpCfg.getCompileId()); group1.setAuditTime(baseIpCfg.getAuditTime()); group1.setIsValid(baseIpCfg.getIsValid()); From 1f0aafb4bfb44c213b5d9abf3ec9dff896130a4d Mon Sep 17 00:00:00 2001 From: zhanghongqing Date: Wed, 21 Nov 2018 15:14:28 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=AD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=85=B3=E9=97=AD=E8=BF=9E=E6=8E=A5response.close()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/nis/util/ConfigServiceUtil.java | 87 +++++++++++++++++++ .../nis/util/httpclient/HttpClientUtil.java | 8 +- .../configuration/ntc/BgpCfgController.java | 2 +- 3 files changed, 94 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/nis/util/ConfigServiceUtil.java b/src/main/java/com/nis/util/ConfigServiceUtil.java index a3930c4ff..3fdf469e3 100644 --- a/src/main/java/com/nis/util/ConfigServiceUtil.java +++ b/src/main/java/com/nis/util/ConfigServiceUtil.java @@ -134,14 +134,26 @@ public class ConfigServiceUtil { if(!StringUtil.isEmpty(bean.getData())){ list = bean.getData().getPzIdList(); }else{ + if (response != null) { + response.close(); + } throw new MaatConvertException(":"+response.readEntity(String.class)); } }else{ + if (response != null) { + response.close(); + } throw new MaatConvertException(":"+response.readEntity(String.class)); } }else{ + if (response != null) { + response.close(); + } throw new MaatConvertException(":"+response.readEntity(String.class)); } + if (response != null) { + response.close(); + } long end=System.currentTimeMillis(); logger.warn("get ids finish,cost:"+(end-start)); return list; @@ -170,8 +182,14 @@ public class ConfigServiceUtil { JSONObject resObject = JSONObject.fromObject(result,config); bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class); }else{ + if (response != null) { + response.close(); + } throw new MaatConvertException(":"+response.readEntity(String.class)); } + if (response != null) { + response.close(); + } return bean; } /** @@ -195,8 +213,14 @@ public class ConfigServiceUtil { JSONObject resObject = JSONObject.fromObject(result); bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class); }else{ + if (response != null) { + response.close(); + } throw new MaatConvertException(":"+response.readEntity(String.class)); } + if (response != null) { + response.close(); + } return bean; } @@ -221,6 +245,9 @@ public class ConfigServiceUtil { try { response= header.post(Entity.entity(formDataMultiPart, formDataMultiPart.getMediaType())); } catch (Exception e) { + if (response != null) { + response.close(); + } throw new MaatConvertException(""); } if(response != null && response.getStatus() == 200){ @@ -228,8 +255,14 @@ public class ConfigServiceUtil { JSONObject resObject = JSONObject.fromObject(result); bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class); }else{ + if (response != null) { + response.close(); + } throw new MaatConvertException(""); } + if (response != null) { + response.close(); + } return bean; } @@ -257,6 +290,9 @@ public class ConfigServiceUtil { try { response= header.delete(); } catch (Exception e) { + if (response != null) { + response.close(); + } throw new MaatConvertException(""); } if(response != null && response.getStatus() == 200){ @@ -264,8 +300,14 @@ public class ConfigServiceUtil { JSONObject resObject = JSONObject.fromObject(result); bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class); }else{ + if (response != null) { + response.close(); + } throw new MaatConvertException(":"+response.readEntity(String.class)); } + if (response != null) { + response.close(); + } return bean; } @@ -295,6 +337,9 @@ public class ConfigServiceUtil { try { response= header.put(Entity.entity(params, MediaType.APPLICATION_JSON)); } catch (Exception e) { + if (response != null) { + response.close(); + } throw new MaatConvertException(""); } if(response !=null && response.getStatus() == 200){ @@ -302,8 +347,14 @@ public class ConfigServiceUtil { JSONObject resObject = JSONObject.fromObject(result); bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class); }else{ + if (response != null) { + response.close(); + } throw new MaatConvertException(":"+response.readEntity(String.class)); } + if (response != null) { + response.close(); + } return bean; } /** @@ -360,6 +411,9 @@ public class ConfigServiceUtil { try { response= header.post(Entity.entity(formDataMultiPart, formDataMultiPart.getMediaType())); } catch (Exception e) { + if (response != null) { + response.close(); + } throw new MaatConvertException(""); } if(response !=null && response.getStatus() == 200){ @@ -368,8 +422,14 @@ public class ConfigServiceUtil { JSONObject resObject = JSONObject.fromObject(result); bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class); }else{ + if (response != null) { + response.close(); + } throw new MaatConvertException(":"+response.readEntity(String.class)); } + if (response != null) { + response.close(); + } return bean; } /** @@ -393,6 +453,9 @@ public class ConfigServiceUtil { try { response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON)); } catch (Exception e) { + if (response != null) { + response.close(); + } throw new MaatConvertException(""); } if(response !=null && response.getStatus() == 200){ @@ -402,8 +465,14 @@ public class ConfigServiceUtil { JSONObject resObject = JSONObject.fromObject(result,config); bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class); }else{ + if (response != null) { + response.close(); + } throw new MaatConvertException(":"+response.readEntity(String.class)); } + if (response != null) { + response.close(); + } long end=System.currentTimeMillis(); logger.warn("postGroupReuseSources end,cost:"+(end-start)); return bean; @@ -449,13 +518,22 @@ public class ConfigServiceUtil { try { response= header.get(); } catch (Exception e) { + if (response != null) { + response.close(); + } throw new MaatConvertException(""); } if(response !=null && response.getStatus() == 200){ result= response.readEntity(String.class); }else{ + if (response != null) { + response.close(); + } throw new MaatConvertException(":"+response.readEntity(String.class)); } + if (response != null) { + response.close(); + } return result; } public static String getReport(String reportUrl, SearchReport searchCondition) throws MaatConvertException, UnsupportedEncodingException{ @@ -503,13 +581,22 @@ public class ConfigServiceUtil { try { response= header.get(); } catch (Exception e) { + if (response != null) { + response.close(); + } throw new MaatConvertException(""); } if(response !=null && response.getStatus() == 200){ result= response.readEntity(String.class); }else{ + if (response != null) { + response.close(); + } throw new MaatConvertException(":"+response.readEntity(String.class)); } + if (response != null) { + response.close(); + } return result; } public static void main(String[] args) { diff --git a/src/main/java/com/nis/util/httpclient/HttpClientUtil.java b/src/main/java/com/nis/util/httpclient/HttpClientUtil.java index 79e6d4ed6..4d704e425 100644 --- a/src/main/java/com/nis/util/httpclient/HttpClientUtil.java +++ b/src/main/java/com/nis/util/httpclient/HttpClientUtil.java @@ -247,7 +247,7 @@ public class HttpClientUtil { * @param params 参数列表 * @return 查询结果数据json */ - public static String getMsg(String destUrl, Map params, HttpServletRequest req) { + public static String getMsg(String destUrl, Map params, HttpServletRequest req) throws IOException { // RequestContext requestContext = new RequestContext(req); // CloseableHttpResponse response = null; @@ -296,7 +296,11 @@ public class HttpClientUtil { logger.error("获取消息失败,相应内容如下: " + result); logger.error("获取消息失败 ", e); throw new MaatConvertException(":"); - } + }finally { + if (response != null) { + response.close(); + } + } return result; } diff --git a/src/main/java/com/nis/web/controller/configuration/ntc/BgpCfgController.java b/src/main/java/com/nis/web/controller/configuration/ntc/BgpCfgController.java index c06815d58..9d67d9fd7 100644 --- a/src/main/java/com/nis/web/controller/configuration/ntc/BgpCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/ntc/BgpCfgController.java @@ -24,7 +24,7 @@ import com.nis.domain.configuration.ComplexkeywordCfg; import com.nis.domain.configuration.IpPortCfg; import com.nis.domain.configuration.NtcBgpAsCfg; import com.nis.domain.configuration.NtcSubscribeIdCfg; -import com.nis.exception.MaatConvertException; +import com.nis.exceptions.MaatConvertException; import com.nis.util.Constants; import com.nis.util.StringUtils; import com.nis.web.controller.BaseController; From 4adad428beedaaaefd02e1f5abd12df0dc938c69 Mon Sep 17 00:00:00 2001 From: wangxin Date: Wed, 21 Nov 2018 16:20:22 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=EF=BC=881=EF=BC=89=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=89=8D=E5=8F=B0=E5=BC=82=E5=B8=B8=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E4=BF=AE=E6=94=B9=20=EF=BC=882=EF=BC=89ip=20=E4=B8=A2?= =?UTF-8?q?=E5=BC=83=EF=BC=8C=E9=99=90=E9=80=9F=E6=97=B6=E9=9A=90=E8=97=8F?= =?UTF-8?q?asn=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/nis/web/controller/BaseController.java | 2 +- .../webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/nis/web/controller/BaseController.java b/src/main/java/com/nis/web/controller/BaseController.java index d6c105e83..0c1855327 100644 --- a/src/main/java/com/nis/web/controller/BaseController.java +++ b/src/main/java/com/nis/web/controller/BaseController.java @@ -1788,7 +1788,7 @@ public class BaseController { } } if(e instanceof MaatConvertException||e instanceof ServiceException) { - addMessage(redirectAttributes,"error", e.getMessage()); + addMessage(redirectAttributes,"error", "request_service_failed"); }else { addMessage(redirectAttributes,"error", "import_failed"); } diff --git a/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp b/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp index d55375188..1a2c8533c 100644 --- a/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp @@ -57,6 +57,13 @@ $("[class~='boxSolid'][class~='ipPortList']").find(".glyphicon-remove").click(); processAction(isAsn,$(".asn")); } + //隐藏显示asn + if($("[name='action']:checked").val()==32||$("[name='action']:checked").val()==64){ + console.log(111); + $("h4.form-section.asn").addClass("hidden"); + }else{ + $("h4.form-section.asn").removeClass("hidden"); + } $(".glyphicon-plus").on("click",function(){ if($(this).hasClass("ipPortList")){ isAsn=0; @@ -137,6 +144,12 @@ } } */ + //隐藏显示asn + if($(this).val()==32||$(this).val()==64){ + $("h4.form-section.asn").addClass("hidden"); + }else{ + $("h4.form-section.asn").removeClass("hidden"); + } }); $("#serviceId").val($(".action:checked").attr("serviceId")); $("#protocolId").val($(".action:checked").attr("protocolId")); @@ -663,7 +676,7 @@ var showHideIPSECProtocol=function(obj){ -

+

Date: Wed, 21 Nov 2018 16:38:54 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E6=96=87=E4=BB=B6=E5=90=8D=E7=94=B1?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=88=B3=E6=9B=B4=E6=8D=A2=E4=B8=BAUUID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/nis/util/excel/ImportBigExcel.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/nis/util/excel/ImportBigExcel.java b/src/main/java/com/nis/util/excel/ImportBigExcel.java index 8313a5450..a8963131b 100644 --- a/src/main/java/com/nis/util/excel/ImportBigExcel.java +++ b/src/main/java/com/nis/util/excel/ImportBigExcel.java @@ -14,6 +14,7 @@ import java.util.Comparator; import java.util.Date; import java.util.List; import java.util.Properties; +import java.util.UUID; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; @@ -76,7 +77,7 @@ public class ImportBigExcel extends XLSXCovertCSVReader{ */ public ImportBigExcel(MultipartFile multipartFile, Integer headerNum, int sheetIndex) throws InvalidFormatException, IOException { - File upFile=new File(System.currentTimeMillis()+multipartFile.getOriginalFilename()); + File upFile=new File(UUID.randomUUID()+"_"+multipartFile.getOriginalFilename()); upFile.mkdirs(); multipartFile.transferTo(upFile); if (!upFile.exists()){ From 52c2f490cd5424925b88b0ed58e7724efbcc2f02 Mon Sep 17 00:00:00 2001 From: wangxin Date: Wed, 21 Nov 2018 16:56:23 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E5=AF=BC=E5=85=A5drop=20rate=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E6=94=B9=E4=B8=BA0.1=E5=88=B00.9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/nis/util/excel/thread/CheckIpFormatThread.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/nis/util/excel/thread/CheckIpFormatThread.java b/src/main/java/com/nis/util/excel/thread/CheckIpFormatThread.java index b541b4e52..a7cc17803 100644 --- a/src/main/java/com/nis/util/excel/thread/CheckIpFormatThread.java +++ b/src/main/java/com/nis/util/excel/thread/CheckIpFormatThread.java @@ -116,7 +116,7 @@ public class CheckIpFormatThread implements Callable{ } if (!has) { errInfo.append(prop.getProperty("ratelimit") + "." - + String.format(prop.getProperty("must_between"), 0.001, 0.009) + ";"); + + String.format(prop.getProperty("must_between"), 0.1, 0.9) + ";"); } } catch (Exception e) { // TODO: handle exception From 3cf0ac91b3f693b9cfe168e24fbd1aa99901b303 Mon Sep 17 00:00:00 2001 From: wangxin Date: Wed, 21 Nov 2018 17:22:59 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B8=85=E7=90=86asn?= =?UTF-8?q?=E5=8F=B7=E7=BC=93=E5=AD=98=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/nis/util/AsnCacheUtils.java | 6 ++++++ .../java/com/nis/web/controller/sys/DictController.java | 9 +++++++-- src/main/webapp/WEB-INF/views/home.jsp | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/nis/util/AsnCacheUtils.java b/src/main/java/com/nis/util/AsnCacheUtils.java index 257d326c2..b875cf5ee 100644 --- a/src/main/java/com/nis/util/AsnCacheUtils.java +++ b/src/main/java/com/nis/util/AsnCacheUtils.java @@ -48,6 +48,7 @@ public class AsnCacheUtils{ return (Map)element.getObjectValue(); } public static void clearCache() { + logger.warn("clear cache!"); CacheUtils.getCacheManager().removeCache(ASN_NO_CACHE); } /** @@ -147,4 +148,9 @@ public class AsnCacheUtils{ } return cache; } + public static String getCacheName() { + return ASN_NO_CACHE; + } + + } \ No newline at end of file diff --git a/src/main/java/com/nis/web/controller/sys/DictController.java b/src/main/java/com/nis/web/controller/sys/DictController.java index a0285664b..d165ccb31 100644 --- a/src/main/java/com/nis/web/controller/sys/DictController.java +++ b/src/main/java/com/nis/web/controller/sys/DictController.java @@ -14,6 +14,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes; import com.nis.domain.Page; import com.nis.domain.SysDataDictionaryName; +import com.nis.util.AsnCacheUtils; import com.nis.util.CacheUtils; import com.nis.util.Constants; import com.nis.util.StringUtil; @@ -104,8 +105,12 @@ public class DictController extends BaseController { @ResponseBody @RequestMapping(value = {"refreshCache"}) public String refreshCache(String cacheName){ - //删除字典缓存 - CacheUtils.remove(cacheName); + if(cacheName.equals(AsnCacheUtils.getCacheName())) { + AsnCacheUtils.clearCache(); + }else { + //删除字典缓存 + CacheUtils.remove(cacheName); + } return "success"; } diff --git a/src/main/webapp/WEB-INF/views/home.jsp b/src/main/webapp/WEB-INF/views/home.jsp index e4a0622c6..f643efe59 100644 --- a/src/main/webapp/WEB-INF/views/home.jsp +++ b/src/main/webapp/WEB-INF/views/home.jsp @@ -329,6 +329,9 @@ background:#3d3d3d;
  • refresh function region
  • +
  • + refresh ASN no +
  • From 7cd7983671b18ad835aac06b1d6e6e6e9a958bb1 Mon Sep 17 00:00:00 2001 From: wangxin Date: Wed, 21 Nov 2018 18:47:22 +0800 Subject: [PATCH 07/11] =?UTF-8?q?ASN=20IP=E5=88=97=E8=A1=A8=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=20=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6ASN=20IP=20Grou?= =?UTF-8?q?p=E4=BB=8E=E7=BC=93=E5=AD=98=E4=B8=AD=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/nis/util/AsnCacheUtils.java | 13 +++++++++++++ .../nis/web/controller/basics/AsnIpController.java | 3 +++ .../webapp/WEB-INF/views/basics/asnIpCfgList.jsp | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/nis/util/AsnCacheUtils.java b/src/main/java/com/nis/util/AsnCacheUtils.java index b875cf5ee..481074431 100644 --- a/src/main/java/com/nis/util/AsnCacheUtils.java +++ b/src/main/java/com/nis/util/AsnCacheUtils.java @@ -6,6 +6,7 @@ import java.util.Map.Entry; import org.apache.log4j.Logger; +import com.beust.jcommander.internal.Lists; import com.nis.domain.specific.ConfigGroupInfo; import com.nis.web.dao.specific.ConfigGroupInfoDao; import com.nis.web.service.SpringContextHolder; @@ -51,6 +52,18 @@ public class AsnCacheUtils{ logger.warn("clear cache!"); CacheUtils.getCacheManager().removeCache(ASN_NO_CACHE); } + public static List getAllAsnGroup(){ + List configGroupInfos=Lists.newArrayList(); + Cache cache=getCache(ASN_NO_CACHE); + for(Object key:cache.getKeys()) { + Element element = getCache(ASN_NO_CACHE).get(key); + if(element!=null) { + Map map=(Map)element.getObjectValue(); + configGroupInfos.addAll(map.values()); + } + } + return configGroupInfos; + } /** * 初始化缓存 */ diff --git a/src/main/java/com/nis/web/controller/basics/AsnIpController.java b/src/main/java/com/nis/web/controller/basics/AsnIpController.java index 5d77eefe9..bad7cdfdf 100644 --- a/src/main/java/com/nis/web/controller/basics/AsnIpController.java +++ b/src/main/java/com/nis/web/controller/basics/AsnIpController.java @@ -50,6 +50,9 @@ public class AsnIpController extends BaseController{ // List policyGroups=policyGroupInfoService.findPolicyGroupInfosByType(4); // model.addAttribute("policyGroups", policyGroups); + AsnCacheUtils.init(); + List policyGroups=AsnCacheUtils.getAllAsnGroup(); + model.addAttribute("policyGroups", policyGroups); return "/basics/asnIpCfgList"; } @RequestMapping(value = {"/addForm"}) diff --git a/src/main/webapp/WEB-INF/views/basics/asnIpCfgList.jsp b/src/main/webapp/WEB-INF/views/basics/asnIpCfgList.jsp index ad372dab1..9e6903056 100644 --- a/src/main/webapp/WEB-INF/views/basics/asnIpCfgList.jsp +++ b/src/main/webapp/WEB-INF/views/basics/asnIpCfgList.jsp @@ -104,7 +104,7 @@ - + From 5ae19f9125c782e19fb4968c302ca3ee54b53c64 Mon Sep 17 00:00:00 2001 From: zhanghongqing Date: Wed, 21 Nov 2018 19:08:13 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BA=BA=E8=84=B8=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interceptor/MultipartFileIntercepter.java | 2 +- .../configuration/ntc/AvController.java | 51 ++++++++- .../WEB-INF/views/cfg/av/fileSampleForm.jsp | 107 ++++++++++++++++-- 3 files changed, 146 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/nis/interceptor/MultipartFileIntercepter.java b/src/main/java/com/nis/interceptor/MultipartFileIntercepter.java index 23e901244..8b6dce83a 100644 --- a/src/main/java/com/nis/interceptor/MultipartFileIntercepter.java +++ b/src/main/java/com/nis/interceptor/MultipartFileIntercepter.java @@ -140,7 +140,7 @@ public class MultipartFileIntercepter extends CommonsMultipartResolver{ fileTypes=Constants.LOGO_FILE_TYPE; fileMaxSize=Constants.LOGO_SINGLE_FILE_MAX_SIZE; }else if(functionId.equals(632)){ //人脸识别 - fileTypes=Constants.FACE_FILE_TYPE; + fileTypes=Constants.PICTURE_FILE_TYPE;//同图片类型 fileMaxSize=Constants.FACE_SINGLE_FILE_MAX_SIZE; }else if(functionId.equals(570)){ //证书管理 fileTypes=Constants.PUBLIC_FILE_TYPE; diff --git a/src/main/java/com/nis/web/controller/configuration/ntc/AvController.java b/src/main/java/com/nis/web/controller/configuration/ntc/AvController.java index a372dcd75..ed40e4291 100644 --- a/src/main/java/com/nis/web/controller/configuration/ntc/AvController.java +++ b/src/main/java/com/nis/web/controller/configuration/ntc/AvController.java @@ -224,7 +224,6 @@ public class AvController extends BaseController { ||Constants.VIDEO_FILE_TYPE.contains(FileUtils.getSuffix(uploadSrcFile.getName(),false)) ||Constants.VOIP_FILE_TYPE.contains(FileUtils.getSuffix(uploadSrcFile.getName(),false)) ||Constants.SPEAKER_FILE_TYPE.contains(FileUtils.getSuffix(uploadSrcFile.getName(),false)) - ||Constants.FACE_FILE_TYPE.contains(FileUtils.getSuffix(uploadSrcFile.getName(),false)) ){ if(!validateAvDuration(uploadSrcFile)){ addMessage(redirectAttributes,"exceeds_duration_limit"); @@ -616,7 +615,55 @@ public class AvController extends BaseController { } return map; } - + /** + * 上传图片文件,调用脚本压缩图片,返回图片保存路径 + * @param cfg + * @param functionId + * @param redirectAttributes + * @return + */ + @ResponseBody + @RequestMapping(value = {"/sample/faceToPicture"}) + public Map faceToPicture(Model model,@RequestParam("srcFile") CommonsMultipartFile[] srcFile){ + String sep = System.getProperty("file.separator"); + String random = UUID.randomUUID()+""; +// String srcFilePath = Constants.AV_FILE_PATH+"face"+random+sep+"srcFile";//视频源文件保存路径 + String srcFilePath = StringUtils.getUserfilesBaseDir()+"face"+sep+"picFile"+sep+random+sep;//视频生成的关键帧图片文件保存路径 + + FileUtils.createDirectory(srcFilePath); + //保存源文件 + for (CommonsMultipartFile sinFile : srcFile) { + String srcFileAllPath = srcFilePath+sep+random+FileUtils.getSuffix(sinFile.getOriginalFilename(), true);//新的文件名 + File uploadSrcFile = new File(srcFileAllPath); + try { + FileCopyUtils.copy(sinFile.getBytes(), uploadSrcFile); + } catch (IOException e) { + logger.error(e); + e.printStackTrace(); + } + } + + + Map map = new HashMap(); + map.put("picFilePath", srcFilePath); + + //获取图片列表 + Collection files = FileUtils.listFiles(new File(srcFilePath), null, true); + String srcPath = null; + for(File f:files){ + if(srcPath==null){ + srcPath = f.getName(); + }else{ + srcPath += "|"+f.getName(); + } + } + //将图片文件列表赋值给生成样例的源文件路径参数 + map.put("srcPath", srcPath); + map.put("status", 1); + map.put("msg", "success"); + + return map; + } @RequestMapping(value = {"/sample/selectVedioPicture"}) public String selectVedioPicture(Model model,HttpServletRequest request,String picFilePath,String srcPath){ Collection files = FileUtils.listFiles(new File(picFilePath), null, true); diff --git a/src/main/webapp/WEB-INF/views/cfg/av/fileSampleForm.jsp b/src/main/webapp/WEB-INF/views/cfg/av/fileSampleForm.jsp index 9b0545d49..6a4acf5b2 100644 --- a/src/main/webapp/WEB-INF/views/cfg/av/fileSampleForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/av/fileSampleForm.jsp @@ -5,16 +5,16 @@ <spring:message code="${cfgName}"></spring:message>