From 38c662f87c8ee54043a714336ade4f30ff4ac17d Mon Sep 17 00:00:00 2001 From: zhanghongqing Date: Mon, 17 Dec 2018 17:15:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../restful/DashboardServiceController.java | 85 +++++++++++++++---- 1 file changed, 67 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java b/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java index e2f1812..7c00e30 100644 --- a/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java +++ b/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java @@ -626,7 +626,7 @@ public class DashboardServiceController extends BaseRestController { @RequestMapping(value = "trafficWebsiteList", method = RequestMethod.GET) @ApiOperation(value = "网站流量分析统计", httpMethod = "GET", notes = "对应网站http分类显示") - public Map trafficWebsiteList(@RequestParam String beginDate, @RequestParam String endDate, Model model, HttpServletRequest request, + public Map trafficWebsiteList( Model model, HttpServletRequest request, HttpServletResponse response) { long start = System.currentTimeMillis(); @@ -634,14 +634,10 @@ public class DashboardServiceController extends BaseRestController { null); List list = new ArrayList(); try { - if (!StringUtils.isEmpty(beginDate) && !StringUtils.isEmpty(endDate)) { - Date begin = DateUtils.parseDate(beginDate); - Date end = DateUtils.parseDate(endDate); - // 带查询时间查询所有 - List websiteChart = dashboardService.getWebsiteDetails(begin, end); - if (websiteChart != null && websiteChart.size() > 0) { - list = websiteChart; - } + // 不带时间默认top10 + List websiteChart = dashboardService.getWebsiteTop10(); + if (websiteChart != null && websiteChart.size() > 0) { + list = websiteChart; } } catch (Exception e) { @@ -663,8 +659,8 @@ public class DashboardServiceController extends BaseRestController { } @RequestMapping(value = "trafficWebsiteListNoTime", method = RequestMethod.GET) - @ApiOperation(value = "网站流量分析统计", httpMethod = "GET", notes = "对应网站http分类显示") - public Map trafficWebsiteListNoTime(Model model, HttpServletRequest request, + @ApiOperation(value = "网站流量分析详情统计", httpMethod = "GET", notes = "对应网站http分类显示") + public Map trafficWebsiteListNoTime(@RequestParam String beginDate, @RequestParam String endDate,Model model, HttpServletRequest request, HttpServletResponse response) { long start = System.currentTimeMillis(); @@ -672,10 +668,25 @@ public class DashboardServiceController extends BaseRestController { null); List list = new ArrayList(); try { - // 不带时间默认top10 - List websiteChart = dashboardService.getWebsiteTop10(); - if (websiteChart != null && websiteChart.size() > 0) { - list = websiteChart; + if (!StringUtils.isEmpty(beginDate) && !StringUtils.isEmpty(endDate)) { + Date begin = DateUtils.parseDate(beginDate); + Date end = DateUtils.parseDate(endDate); + // 带查询时间查询所有 + List websiteChart = dashboardService.getWebsiteDetails(begin, end); + if (websiteChart != null && websiteChart.size() > 0) { + list = websiteChart; + } + }else { + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date()); + Date begin1 = cal.getTime();// 获取到完整的时间 + cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1); + Date end1 = cal.getTime(); + // 带查询时间查询所有 + List websiteChart = dashboardService.getWebsiteDetails(begin1, end1); + if (websiteChart != null && websiteChart.size() > 0) { + list = websiteChart; + } } } catch (Exception e) { @@ -742,9 +753,42 @@ public class DashboardServiceController extends BaseRestController { @RequestMapping(value = "trafficTopicAndDomainChart", method = RequestMethod.GET) @ApiOperation(value = "HTTP网站主题分类分析统计", httpMethod = "GET", notes = "对应某个网站主题类型分类统计图") - public Map trafficTopicAndDomainChart(String beginDate, String endDate, Model model, + public Map trafficTopicAndDomainChart( Model model, HttpServletRequest request, HttpServletResponse response) { + long start = System.currentTimeMillis(); + AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, + null); + List list = new ArrayList(); + try { + // 不带时间默认top10 + List websiteChart = dashboardService.getTopicTop10(); + if (websiteChart != null && websiteChart.size() > 0) { + list = websiteChart; + } + } catch (Exception e) { + auditLogThread.setExceptionInfo("HTTP网站主题分类分析数据检索失败:" + e.getMessage()); + logger.error("HTTP网站主题分类分析数据检索失败:" + ExceptionUtil.getExceptionMsg(e)); + if (e instanceof RestServiceException) { + throw new RestServiceException(auditLogThread, System.currentTimeMillis() - start, + "HTTP网站主题分类分析数据检索失败:" + e.getMessage(), ((RestServiceException) e).getErrorCode()); + } else if (e instanceof ServiceRuntimeException) { + throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start, + "HTTP网站主题分类分析数据检索失败:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode()); + } else { + throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start, + "HTTP网站主题分类分析数据检索失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue()); + } + } + return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "HTTP网站主题分类分析数据检索成功", + list, 0); + } + + @RequestMapping(value = "trafficTopicList", method = RequestMethod.GET) + @ApiOperation(value = "HTTP网站主题详情", httpMethod = "GET", notes = "对应某个网站主题类型分类统计") + public Map trafficTopicList(String beginDate, String endDate, Model model, + HttpServletRequest request, HttpServletResponse response) { + long start = System.currentTimeMillis(); AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null); @@ -759,8 +803,13 @@ public class DashboardServiceController extends BaseRestController { list = websiteChart; } } else { - // 不带时间默认top10 - List websiteChart = dashboardService.getTopicTop10(); + Calendar cal = Calendar.getInstance(); + cal.setTime(new Date()); + Date begin1 = cal.getTime();// 获取到完整的时间 + cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1); + Date end1 = cal.getTime(); + // 带查询时间查询所有 + List websiteChart = dashboardService.getTopicDetails(begin1, end1); if (websiteChart != null && websiteChart.size() > 0) { list = websiteChart; }