From 3b60b81c7263e856c44295264396ffedf4272676 Mon Sep 17 00:00:00 2001 From: wangxin Date: Mon, 9 Jul 2018 17:36:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=A0=87=E7=AD=BE=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E9=A1=B5=E9=9D=A2=E7=AC=AC=E4=B8=80=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nis/domain/log/NtcServiceReportLog.java | 28 +++ .../com/nis/domain/log/NtcTagReportLog.java | 43 +++++ .../com/nis/domain/log/ReportResultLog.java | 14 +- src/main/java/com/nis/util/Constants.java | 10 ++ .../report/NtcServiceReportController.java | 42 +++++ .../report/NtcTagReportController.java | 159 ++++++++++++++++++ .../service/configuration/IpCfgService.java | 6 +- src/main/webapp/WEB-INF/sitemesh3.xml | 1 + .../webapp/WEB-INF/views/report/label.jsp | 62 +++---- src/main/webapp/WEB-INF/views/report/list.jsp | 39 ++++- 10 files changed, 357 insertions(+), 47 deletions(-) create mode 100644 src/main/java/com/nis/domain/log/NtcServiceReportLog.java create mode 100644 src/main/java/com/nis/domain/log/NtcTagReportLog.java create mode 100644 src/main/java/com/nis/web/controller/report/NtcServiceReportController.java create mode 100644 src/main/java/com/nis/web/controller/report/NtcTagReportController.java diff --git a/src/main/java/com/nis/domain/log/NtcServiceReportLog.java b/src/main/java/com/nis/domain/log/NtcServiceReportLog.java new file mode 100644 index 000000000..c7f6ba984 --- /dev/null +++ b/src/main/java/com/nis/domain/log/NtcServiceReportLog.java @@ -0,0 +1,28 @@ +/** + *@Title: NtcServiceReportLog.java + *@Package com.nis.domain.log + *@Description TODO + *@author dell + *@date 2018年7月9日 上午8:57:01 + *@version 版本号 + */ +package com.nis.domain.log; + +/** + * @ClassName: NtcServiceReportLog.java + * @Description: TODO + * @author (dell) + * @date 2018年7月9日 上午8:57:01 + * @version V1.0 + */ +public class NtcServiceReportLog extends BaseReportLog { + + /** + * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) + * + * @since 1.0.0 + */ + + private static final long serialVersionUID = 5574384523786886920L; + +} diff --git a/src/main/java/com/nis/domain/log/NtcTagReportLog.java b/src/main/java/com/nis/domain/log/NtcTagReportLog.java new file mode 100644 index 000000000..b8ec879d1 --- /dev/null +++ b/src/main/java/com/nis/domain/log/NtcTagReportLog.java @@ -0,0 +1,43 @@ +/** + *@Title: NtcServiceReportLog.java + *@Package com.nis.domain.log + *@Description TODO + *@author dell + *@date 2018年7月9日 上午8:57:01 + *@version 版本号 + */ +package com.nis.domain.log; + +/** + * @ClassName: NtcServiceReportLog.java + * @Description: TODO + * @author (dell) + * @date 2018年7月9日 上午8:57:01 + * @version V1.0 + */ +public class NtcTagReportLog extends BaseReportLog { + + /** + * @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么) + * + * @since 1.0.0 + */ + + private static final long serialVersionUID = 2245672277797057001L; + private Integer tag; + /** + * tag + * @return tag + */ + + public Integer getTag() { + return tag; + } + /** + * @param tag the tag to set + */ + public void setTag(Integer tag) { + this.tag = tag; + } + +} diff --git a/src/main/java/com/nis/domain/log/ReportResultLog.java b/src/main/java/com/nis/domain/log/ReportResultLog.java index 537cfa137..3ec32e7ee 100644 --- a/src/main/java/com/nis/domain/log/ReportResultLog.java +++ b/src/main/java/com/nis/domain/log/ReportResultLog.java @@ -8,6 +8,8 @@ */ package com.nis.domain.log; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Map.Entry; import javax.ws.rs.client.Invocation.Builder; @@ -62,13 +64,13 @@ public class ReportResultLog extends RestfulResult{ public void setData(Page data) { this.data = data; } - public ReportResultLog getReport(String reportUrl,SearchReport searchCondition) throws MaatConvertException{ - if(StringUtils.isBlank(searchCondition.getSearchService())){ - throw new MaatConvertException(""); - } + public ReportResultLog getReport(String reportUrl,SearchReport searchCondition) throws MaatConvertException, UnsupportedEncodingException{ +// if(StringUtils.isBlank(searchCondition.getSearchService())){ +// throw new MaatConvertException(""); +// } String result = null; ReportResultLog bean = null; - StringBuffer url=new StringBuffer(reportUrl+"?"); + StringBuffer url=new StringBuffer(reportUrl); url.append("searchBusinessType=").append(searchCondition.getSearchBusinessType()) .append("&searchService=").append(searchCondition.getSearchService()); if(searchCondition.getSearchCondition()!=null){ @@ -95,7 +97,7 @@ public class ReportResultLog extends RestfulResult{ url.append("&fields=").append(searchCondition.getFields()); } //创建连接 - WebTarget wt = ClientUtil.getWebTarger(url.toString()); + WebTarget wt = ClientUtil.getWebTarger(URLEncoder.encode(url.toString(),"UTF-8")); Builder header = wt.request(MediaType.APPLICATION_JSON); Response response= header.get(); if( response.getStatus() == 200){ diff --git a/src/main/java/com/nis/util/Constants.java b/src/main/java/com/nis/util/Constants.java index 104cffacb..1ba951544 100644 --- a/src/main/java/com/nis/util/Constants.java +++ b/src/main/java/com/nis/util/Constants.java @@ -7,6 +7,16 @@ import java.util.Map; import com.google.gson.GsonBuilder; public final class Constants { + /** + * 报表去重连接符 + */ + public static final String REPORT_TRIM_CONNECTOR="_;_"; + /** + * 报表类型 + */ + public static final int REPORT_TYPE_HOUR=1; + public static final int REPORT_TYPE_DAY=2; + public static final int REPORT_TYPE_MONTH=3; /** * 配置审核下发的类型 maat类型 */ diff --git a/src/main/java/com/nis/web/controller/report/NtcServiceReportController.java b/src/main/java/com/nis/web/controller/report/NtcServiceReportController.java new file mode 100644 index 000000000..87ae977f2 --- /dev/null +++ b/src/main/java/com/nis/web/controller/report/NtcServiceReportController.java @@ -0,0 +1,42 @@ +package com.nis.web.controller.report; + +import java.io.UnsupportedEncodingException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; + +import com.nis.domain.Page; +import com.nis.domain.log.NtcServiceReportLog; +import com.nis.domain.log.ReportResultLog; +import com.nis.domain.log.SearchReport; +import com.nis.exceptions.MaatConvertException; +import com.nis.util.Constants; +import com.nis.web.controller.BaseController; + +@Controller +@RequestMapping("${adminPath}/report") +public class NtcServiceReportController extends BaseController { + @RequestMapping("/ntcLabelReport") + public String list(@ModelAttribute("bean") SearchReport bean,Model model, HttpServletRequest request, HttpServletResponse response) { + initReportCondition(model, bean); + ReportResultLog result=new ReportResultLog<>(); + StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_SERVICE_REPORT+"?"); + try { + result=result.getReport(url.toString(), bean); + } catch (MaatConvertException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + Page page=result.getData(); + model.addAttribute("page", page); + return "/report/list"; + } +} diff --git a/src/main/java/com/nis/web/controller/report/NtcTagReportController.java b/src/main/java/com/nis/web/controller/report/NtcTagReportController.java new file mode 100644 index 000000000..b8d0a274a --- /dev/null +++ b/src/main/java/com/nis/web/controller/report/NtcTagReportController.java @@ -0,0 +1,159 @@ +package com.nis.web.controller.report; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; + +import com.nis.domain.FunctionServiceDict; +import com.nis.domain.Page; +import com.nis.domain.basics.ServiceDictInfo; +import com.nis.domain.log.NtcTagReportLog; +import com.nis.domain.log.ReportResultLog; +import com.nis.domain.log.SearchReport; +import com.nis.util.Constants; +import com.nis.util.DictUtils; +import com.nis.web.controller.BaseController; + +@Controller +@RequestMapping("${adminPath}/report") +public class NtcTagReportController extends BaseController { + @RequestMapping("/ajaxNtcTagReport") + public String list(@ModelAttribute("bean") SearchReport bean,Model model, HttpServletRequest request, HttpServletResponse response) { + initReportCondition(model, bean); + List serviceList = DictUtils.getFunctionServiceDictList(bean.getFunctionId()); + List labels=serviceDictInfoService.findAllLableDict(); + model.addAttribute("labels", labels); + if(bean.getAction()!=null){ + for(FunctionServiceDict service:serviceList){ + if(service.getAction().intValue()==bean.getAction().intValue()){ + bean.setSearchService(service.getServiceId().toString()); + } + } + }else{ + StringBuffer serviceId=new StringBuffer(); + for(int i=0;i result=new ReportResultLog<>(); + StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_SERVICE_REPORT+"?"); + bean.setPageSize(-1); + bean.setFields("tag,sum,reportTime"); + String format=Constants.SEARCH_DATEFORMAT; + SimpleDateFormat sdf=new SimpleDateFormat(format); + Date date=new Date(); + bean.setSearchReportEndTime(sdf.format(date)); + Calendar cal=Calendar.getInstance(); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){ + cal.set(Calendar.HOUR_OF_DAY, 0); + }else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){ + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.DAY_OF_MONTH, 1); + }else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){ + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.DAY_OF_MONTH, 1); + cal.set(Calendar.MONTH, 0); + } + logger.info("search start time "+sdf.format(cal.getTime())); + logger.info("search end time "+sdf.format(date)); + bean.setSearchReportStartTime(sdf.format(cal.getTime())); + List titles=new ArrayList(); + while(cal.getTime().getTime() page=result.getData(); +// List list=page.getList(); +// HashMap trimData=new HashMap<>();//数据累加去重 +// for(NtcTagReportLog report:list){ +// String trimStr=""; +// if(bean.getReportType()==Constants.REPORT_TYPE_HOUR){ +// trimStr=report.getTag().intValue()+Constants.REPORT_TRIM_CONNECTOR+ +// sdf.format(cal.getTime()).substring(0,13); +// +// }else if(bean.getReportType()==Constants.REPORT_TYPE_DAY){ +// trimStr=report.getTag().intValue()+Constants.REPORT_TRIM_CONNECTOR+ +// sdf.format(cal.getTime()).substring(0,10); +// +// }else if(bean.getReportType()==Constants.REPORT_TYPE_MONTH){ +// trimStr=report.getTag().intValue()+Constants.REPORT_TRIM_CONNECTOR+ +// sdf.format(cal.getTime()).substring(0,7); +// } +// if(trimData.containsKey(trimStr)){ +// trimData.put(trimStr, trimData.get(trimStr)+report.getSum().longValue()); +// }else{ +// trimData.put(trimStr, report.getSum().longValue()); +// } +// } +// HashMap> showData=new HashMap<>();//构造数据展示集合 +// for(ServiceDictInfo label:lables){ +// List line= new ArrayList(); +// long total=0; +// for(String title:titles){ +// if(trimData.containsKey(label.getServiceDictId().intValue()+Constants.REPORT_TRIM_CONNECTOR+title)){ +// line.add(trimData.get(label.getServiceDictId().intValue()+Constants.REPORT_TRIM_CONNECTOR+title)); +// total+=trimData.get(label.getServiceDictId().intValue()+Constants.REPORT_TRIM_CONNECTOR+title).longValue(); +// }else{ +// line.add(0l); +// } +// } +// List _line= new ArrayList(); +// _line.add(total); +// _line.addAll(line); +// showData.put(label.getServiceDictId().toString(), _line); +// } +// model.addAttribute("datas", showData); +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } + HashMap> showData=new HashMap<>();//构造数据展示集合 + for(ServiceDictInfo label:labels){ + List line= new ArrayList(); + long total=0l; + for(String title:titles){ + line.add(10000l); + total+=10000l; + } + List _line= new ArrayList(); + _line.add(total); + _line.addAll(line); + showData.put(label.getServiceDictId().toString(), _line); + } + model.addAttribute("datas", showData); + return "/report/label"; + } +} diff --git a/src/main/java/com/nis/web/service/configuration/IpCfgService.java b/src/main/java/com/nis/web/service/configuration/IpCfgService.java index c5d520b65..e41e94697 100644 --- a/src/main/java/com/nis/web/service/configuration/IpCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/IpCfgService.java @@ -310,7 +310,7 @@ public class IpCfgService extends CrudService { maatCfg.initDefaultValue(); BeanUtils.copyProperties(cfg, maatCfg); - if(cfg.getIsAudit()==1){ + if(cfg.getIsAudit()==Constants.AUDIT_YES){ maatBean.setOpAction(Constants.INSERT_ACTION); Map map = cfgConvert(ipRegionList,beans,1,cfg,groupRelationList); groupRelationList=map.get("groupList"); @@ -343,10 +343,10 @@ public class IpCfgService extends CrudService { logger.error("IP白名单配置下发失败",e); throw e; } - }else if(cfg.getIsAudit()==3){ + }else if(cfg.getIsAudit()==Constants.AUDIT_NOT_YES){ maatCfg.setCompileId(cfg.getCompileId()); maatCfg.setServiceId(cfg.getServiceId()); - maatCfg.setIsValid(0);//无效 + maatCfg.setIsValid(Constants.VALID_NO);//无效 configCompileList.add(maatCfg); maatBean.setConfigCompileList(configCompileList); maatBean.setAuditTime(cfg.getAuditTime()); diff --git a/src/main/webapp/WEB-INF/sitemesh3.xml b/src/main/webapp/WEB-INF/sitemesh3.xml index bc2cb8810..d57d007a7 100644 --- a/src/main/webapp/WEB-INF/sitemesh3.xml +++ b/src/main/webapp/WEB-INF/sitemesh3.xml @@ -27,6 +27,7 @@ + /articles/* diff --git a/src/main/webapp/WEB-INF/views/report/label.jsp b/src/main/webapp/WEB-INF/views/report/label.jsp index 7d2cca059..46a92074c 100644 --- a/src/main/webapp/WEB-INF/views/report/label.jsp +++ b/src/main/webapp/WEB-INF/views/report/label.jsp @@ -4,39 +4,29 @@ $(function(){ }); -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
标签总量0点1点2点3点4点5点6点7点8点9点10点11点12点14点15点16点17点18点19点20点21点22点23点
-
${page}
-
\ No newline at end of file + + + + + + + + + + + + + + + + + + + + +
${title}
+ + ${label.itemValue} + + ${cloumn}
+
${page}
diff --git a/src/main/webapp/WEB-INF/views/report/list.jsp b/src/main/webapp/WEB-INF/views/report/list.jsp index ec468546b..977e2c269 100644 --- a/src/main/webapp/WEB-INF/views/report/list.jsp +++ b/src/main/webapp/WEB-INF/views/report/list.jsp @@ -17,6 +17,21 @@ $(".Wdate").attr("value",''); $("#searchForm")[0].reset(); }); + if(!"${bean.reportBusinessType}"){ + $.ajax({ + type:'post', + async:false, + url:'${ctx}/report/ajaxNtcTagReport', + data:{ + "action":$('select[name="action"]').val(), + "reportType":$('input[name="reportType"]:checked').val() + }, + dataType:"html", + success:function(data){ + $("#label").html(data); + } + }); + } $("input[name='reportType']").each(function(){ var type='${bean.reportType}'; if(type && type==$(this).val()){ @@ -25,8 +40,29 @@ }) $("a[data-toggle='tab']").on("click",function(){ $("#reportBusinessType").val($(this).data("bussiness")); + if(!$(this).parent("li").hasClass("active")){ + var action=$('select[name="action"]').val(); + var reportBusinessType=$("#reportBusinessType").val(); + var reportType=$('input[name="reportType"]:checked').val(); + if($(this).data("bussiness")=="label_report"){ + $.ajax({ + type:'post', + async:false, + url:'${ctx}/report/ajaxNtcTagReport', + data:{ + "action":action, + "reportType":reportType + }, + dataType:"html", + success:function(data){ + $("#label").html(data); + } + }); + } + } }); }); + @@ -117,7 +153,6 @@
- <%@include file="/WEB-INF/views/report/label.jsp" %> +
<%@include file="/WEB-INF/views/report/attrType.jsp" %> <%@include file="/WEB-INF/views/report/lwhh.jsp" %> <%@include file="/WEB-INF/views/report/srcIp.jsp" %>