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 8564b63..a897499 100644 --- a/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java +++ b/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java @@ -70,13 +70,20 @@ public class DashboardServiceController extends BaseRestController { */ @RequestMapping(value = "ntcActionEntranceReport", method = RequestMethod.GET) @ApiOperation(value = "根据不同动作统计总量汇聚", httpMethod = "GET", notes = "对应流量统计info滚动条动作类型详情数据显示") - public Map ntcTotalReport(Model model, HttpServletRequest request, HttpServletResponse response,String searchAction) { + public Map ntcTotalReport(Model model, HttpServletRequest request, HttpServletResponse response,String searchAction,String beginDate,String endDate) { long start = System.currentTimeMillis(); AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null); List list = new ArrayList(); try { - List resultList = dashboardService.getActionTrans(searchAction); + if(StringUtils.isEmpty(beginDate)||StringUtils.isEmpty(endDate)) { + Calendar cal = Calendar. getInstance (); + cal.setTime(new Date()); + endDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(cal.getTime());//获取到完整的时间 + cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1); + beginDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(cal.getTime()); + } + List resultList = dashboardService.getActionTrans(beginDate,endDate,searchAction); if (resultList!=null&&resultList.size() > 0) { list = resultList; } @@ -206,12 +213,12 @@ public class DashboardServiceController extends BaseRestController { */ @RequestMapping(value="trafficProtocolList", method = RequestMethod.GET) @ApiOperation(value = "协议统计占比与报表", httpMethod = "GET", notes = "对应协议统计详情占比与报表") - public Map trafficProtocolList(String searchFoundStartTime,String searchFoundEndTime,Model model, HttpServletRequest request, HttpServletResponse response){ + public Map trafficProtocolList(String beginDate,String endDate,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 { - List ipActiveList = dashboardService.getProtocolList(searchFoundStartTime,searchFoundEndTime); + List ipActiveList = dashboardService.getProtocolList(beginDate,endDate); if (ipActiveList!=null&&ipActiveList.size() > 0) { String jsonString = JsonMapper.toJsonString(ipActiveList); list = (java.util.List) JsonMapper.fromJsonList(jsonString,HashMap.class); @@ -329,12 +336,12 @@ public class DashboardServiceController extends BaseRestController { */ @RequestMapping(value="trafficAppList", method = RequestMethod.GET) @ApiOperation(value = "App统计占比与报表", httpMethod = "GET", notes = "对应App统计详情占比与报表") - public Map trafficAppList(String searchFoundStartTime,String searchFoundEndTime,Model model, HttpServletRequest request, HttpServletResponse response){ + public Map trafficAppList(String beginDate,String endDate,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 { - List appList = dashboardService.getAppList(searchFoundStartTime,searchFoundEndTime); + List appList = dashboardService.getAppList(beginDate,endDate); if (appList!=null&&appList.size() > 0) { String jsonString = JsonMapper.toJsonString(appList); list = (java.util.List) JsonMapper.fromJsonList(jsonString,HashMap.class); diff --git a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java index adecd45..a69287c 100644 --- a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.java @@ -19,5 +19,5 @@ public interface NtcTotalReportDao { List getBandwidthTrans(@Param("entranceId") Integer entranceId,@Param("beginDate") String beginDate,@Param("endDate") String endDate,@Param("addrType") String addrType,@Param("transType") Integer transType); Map getEntranceMaxReportTime(); - List getActionTrans(@Param("reportTime") Date reportTime,@Param("entranceId") Integer entranceId,@Param("serviceSql") String serviceSql); + List getActionTrans(@Param("beginDate") String beginDate,@Param("endDate") String endDate ,@Param("entranceId") Integer entranceId,@Param("serviceSql") String serviceSql); } \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml index 7a7926c..f6c39cd 100644 --- a/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml +++ b/src/main/java/com/nis/web/dao/dashboard/NtcTotalReportDao.xml @@ -89,7 +89,7 @@ SELECT report_time reportTime FROM ntc_entrance_report order by report_time desc limit 1 - + select sum(sum) sum,report_time time from ntc_entrance_report r where + =#{beginDate}]]> + and entrance_id=#{entranceId} + group by report_time order by report_time \ No newline at end of file diff --git a/src/main/java/com/nis/web/service/restful/DashboardService.java b/src/main/java/com/nis/web/service/restful/DashboardService.java index a10cf18..302bd66 100644 --- a/src/main/java/com/nis/web/service/restful/DashboardService.java +++ b/src/main/java/com/nis/web/service/restful/DashboardService.java @@ -169,16 +169,16 @@ public class DashboardService extends BaseService { Map m= new HashMap(); int inter=1000*60*5;// 间隔时间为五分钟 // 开始时间,结束时间 时间戳 - Long b = dateToStamp(endDate); - Long e = dateToStamp(beginDate); + Long b = dateToStamp(beginDate); + Long e = dateToStamp(endDate); int num=0; Long pointTime=b; - while(pointTime>e){ + while(pointTime=e){ break; //停止 } for (TrafficTransStatistic tt : bandwidthList) { @@ -192,17 +192,29 @@ public class DashboardService extends BaseService { sumG=sumG+ tt.getGbps(); } } - timeList.add(stampToDate(pointTime)); - linkList.add(sumL); - gbpsList.add(sumG); - ppsList.add(sumP); + // 在结束时间只有当值大于0时才记录数据,防止折线降为0引起误会 + if(pointTime>=e-inter&&sumL>0) { + linkList.add(sumL); + } + if(pointTime>=e-inter&&sumP>0) { + ppsList.add(sumP); + } + if(pointTime>=e-inter&&sumG>0) { + gbpsList.add(sumG); + } + if(pointTime>=e-inter&&(sumL>0||sumG>0||sumP>0)) { + timeList.add(stampToDate(pointTime)); + } + if(pointTimee){ + while(pointTime=e){ break; //停止 } for (Map map : li) { @@ -245,7 +257,7 @@ public class DashboardService extends BaseService { rm.put("time", stampToDate(pointTime)); rm.put("sum", sum); num=num+1; - pointTime =b-inter*num; + pointTime =b+inter*num; resList.add(rm); } return resList; @@ -281,7 +293,7 @@ public class DashboardService extends BaseService { /** * 根据service 动作查询近五分钟变化趋势 entrance 默认为1,2 */ - public List getActionTrans(String serviceType) { + public List getActionTrans(String begin,String end,String serviceType) { String sql = ""; String sqlBlock = "((service>=16 and service<=40) or (service>=258 and service<=273) or (service=576))"; // 阻断 String sqlMonitor = "((service>=128 and service<=152) or (service>=384 and service<=513) or (service=592) or (service>=848 and service<=1030) or (service=1152))"; // 监测 @@ -297,36 +309,65 @@ public class DashboardService extends BaseService { ArrayList listMap = new ArrayList(); List entrance1 = new ArrayList(); List entrance2 = new ArrayList(); - Map maxReportTime = ntcTotalReportDao.getEntranceMaxReportTime(); - if (maxReportTime != null && maxReportTime.get("reportTime") != null) { - Date reportTime = (Date) maxReportTime.get("reportTime"); HashMap m1 = new HashMap(); HashMap m2 = new HashMap(); - entrance1 = ntcTotalReportDao.getActionTrans(reportTime, 1, sql); - entrance2 = ntcTotalReportDao.getActionTrans(reportTime, 2, sql); + entrance1 = ntcTotalReportDao.getActionTrans(begin,end, 1, sql); + entrance2 = ntcTotalReportDao.getActionTrans(begin,end, 2, sql); List timeList = new ArrayList(); List sumList1 = new ArrayList(); List sumList2 = new ArrayList(); - // entrance 为1的趋势 - if (entrance1 != null && entrance1.size() > 0) { - for (NtcEntranceReport tt : entrance1) { - if (tt.getTime() != null && tt.getSum() != null) { - timeList.add(tt.getTime()); - sumList1.add(tt.getSum()); - + + Map m= new HashMap(); + int inter=1000*60*5;// 间隔时间为五分钟 + // 开始时间,结束时间 时间戳 + Long b = dateToStamp(begin); + Long e = dateToStamp(end); + int num=0; + Long pointTime=b; + while(pointTime=e){ + break; //停止 + } + for (NtcEntranceReport e1 : entrance1) { + // 实际时间 + String time= e1.getTime(); + Long t = dateToStamp(time); + if(t>=pointTime&&t 0) { - for (NtcEntranceReport tt : entrance2) { - if (tt.getTime() != null && tt.getSum() != null) { -// timeList.add(tt.getTime()); - sumList2.add(tt.getSum()); + for (NtcEntranceReport e2 : entrance2) { + // 实际时间 + String time= e2.getTime(); + Long t = dateToStamp(time); + if(t>=pointTime&&t=e-inter&&sum1>0) { + sumList1.add(sum1); + } + if(pointTime>=e-inter&&sum2>0) { + sumList2.add(sum2); + } + if(pointTime>=e-inter&&(sum1>0||sum2>0)) { + timeList.add(stampToDate(pointTime)); + } + if(pointTime