优化Traffic和IP top10趋势图统计功能

This commit is contained in:
zhangdongxu
2018-12-22 21:41:54 +08:00
parent 1ecac8aae8
commit 007e8e14bf
5 changed files with 206 additions and 218 deletions

View File

@@ -212,76 +212,15 @@ public class DashboardServiceController extends BaseRestController {
String[] transTypes=dashboardService.getFiledTypeByName("trans_type");
long start = System.currentTimeMillis();
AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null);
Map<String,List<HashMap>> resultMap=new HashMap<String,List<HashMap>>();
Map<String, Map> resultMap=new HashMap<String,Map>();
try {
if(StringUtils.isEmpty(beginDate)||StringUtils.isEmpty(endDate)) {
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());
}
String addrType=null;
Integer transType=null;
if(addrTypes!=null){
for(int i=0;i<addrTypes.length;i++){
addrType=addrTypes[i];
List<HashMap> resultList = dashboardService.getBandwidthTrans(addrType, transType,beginDate,endDate);
if (resultList!=null&&resultList.size() > 0) {
resultMap.put("ipv"+addrType+"Type1", resultList);
}
resultList = dashboardService.getBandwidthTrans2(addrType, transType,beginDate,endDate);
if (resultList!=null&&resultList.size() > 0) {
resultMap.put("ipv"+addrType+"Type2", resultList);
}
addrType=null;
}
}
if(transTypes!=null){
for(int i=0;i<transTypes.length;i++){
transType=Integer.valueOf(transTypes[i]);
List<HashMap> resultList = dashboardService.getBandwidthTrans(addrType, transType,beginDate,endDate);
if (resultList!=null&&resultList.size() > 0) {
resultMap.put("trans"+transType+"Type1", resultList);
}
resultList = dashboardService.getBandwidthTrans2(addrType, transType,beginDate,endDate);
if (resultList!=null&&resultList.size() > 0) {
resultMap.put("trans"+transType+"Type2", resultList);
}
transType=null;
}
}
} catch (Exception e) {
auditLogThread.setExceptionInfo("带宽实时统计数据检索失败:"+e.getMessage());
logger.error("带宽实时统计数据检索失败:"+ExceptionUtil.getExceptionMsg(e));
if (e instanceof RestServiceException) {
throw new RestServiceException(auditLogThread, System.currentTimeMillis() - start,
"带宽实时统计数据检索失败:" + e.getMessage(), ((RestServiceException) e).getErrorCode());
} else if (e instanceof ServiceRuntimeException) {
throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
"带宽实时统计数据检索失败:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
} else {
throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
"带宽实时统计数据检索失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
}
}
return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "带宽实时统计数据检索成功",resultMap, 0);
}
/**
* 根据ip46,协议tcpudp查询带宽
*/
@RequestMapping(value = "trafficBandwidthTransFour", method = RequestMethod.GET)
@ApiOperation(value = "带宽根据ip46,协议tcp,udp查询详情", httpMethod = "GET", notes = "对应带宽根据IPv4,6,协议tcp,udp统计数据显示")
public Map<String,?> trafficBandwidthTransFour(String beginDate,String endDate,Model model, HttpServletRequest request, HttpServletResponse response) {
String[] addrTypes=dashboardService.getFiledTypeByName("addr_type");
String[] transTypes=dashboardService.getFiledTypeByName("trans_type");
long start = System.currentTimeMillis();
AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null);
Map<String, List<HashMap>> resultMap=new HashMap<String, List<HashMap>>();
try {
resultMap = dashboardService.getBandwidthTransEntrance(beginDate, endDate);
} catch (Exception e) {
@@ -499,7 +438,7 @@ public class DashboardServiceController extends BaseRestController {
long start = System.currentTimeMillis();
AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
List<HashMap> list = new ArrayList<HashMap>();
List<Map> list = new ArrayList<Map>();
try {
Date begin = null;
Date end = null;
@@ -507,7 +446,7 @@ public class DashboardServiceController extends BaseRestController {
begin = DateUtils.parseDate(beginDate);
end = DateUtils.parseDate(endDate);
}
List<HashMap> ipActiveChart = dashboardService.ipActiveFiveMinute(begin, end);
List<Map> ipActiveChart = dashboardService.ipActiveFiveMinute(begin, end);
if (ipActiveChart != null && ipActiveChart.size() > 0) {
list = ipActiveChart;
}