157 lines
7.1 KiB
Java
157 lines
7.1 KiB
Java
package com.nis.web.controller.restful;
|
||
|
||
import java.util.Map;
|
||
|
||
import javax.servlet.http.HttpServletRequest;
|
||
import javax.servlet.http.HttpServletResponse;
|
||
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.http.HttpStatus;
|
||
import org.springframework.validation.annotation.Validated;
|
||
import org.springframework.web.bind.annotation.RequestMapping;
|
||
import org.springframework.web.bind.annotation.RequestMethod;
|
||
import org.springframework.web.bind.annotation.RequestParam;
|
||
import org.springframework.web.bind.annotation.RestController;
|
||
|
||
import com.nis.domain.Page;
|
||
import com.nis.domain.restful.CfgLogInfo;
|
||
import com.nis.domain.restful.DropInfo;
|
||
import com.nis.domain.restful.NtcAreaHomeReport;
|
||
import com.nis.restful.RestBusinessCode;
|
||
import com.nis.restful.RestResult;
|
||
import com.nis.restful.RestServiceException;
|
||
import com.nis.restful.ServiceRuntimeException;
|
||
import com.nis.util.Constants;
|
||
import com.nis.web.controller.BaseRestController;
|
||
import com.nis.web.service.AuditLogThread;
|
||
import com.nis.web.service.ServicesRequestLogService;
|
||
import com.nis.web.service.restful.SystemHomePageService;
|
||
import com.wordnik.swagger.annotations.Api;
|
||
import com.wordnik.swagger.annotations.ApiOperation;
|
||
|
||
/**
|
||
* @Description 系统首页整体图API(1.地域流量API 2.配置统计API 3.日志统计API 4.丢弃量API)
|
||
* @author dell
|
||
* @date 2018年12月5日10:34:03
|
||
*
|
||
*/
|
||
@RestController
|
||
@RequestMapping("${servicePath}")
|
||
@Api(value = "SystemHomePageController", description = "系统首页整体图接口")
|
||
@SuppressWarnings("all")
|
||
public class SystemHomePageController extends BaseRestController {
|
||
|
||
@Autowired
|
||
ServicesRequestLogService servicesRequestLogService;
|
||
|
||
@Autowired
|
||
SystemHomePageService systemHomePageService;
|
||
|
||
@RequestMapping(value = "/log/v1/trafficAreaStat", method = RequestMethod.GET)
|
||
@ApiOperation(value = "地域流量获取", httpMethod = "GET", notes = "对地域流量获取服务信息进行查询", response = Map.class)
|
||
public Map<String, ?> trafficAreaStat(NtcAreaHomeReport ntcAreaHomeReport, HttpServletRequest request, HttpServletResponse response) {
|
||
/*public Map<String, ?> trafficAreaStat(String searchReportStartTime, String searchReportEndTime,
|
||
HttpServletRequest request, HttpServletResponse response) {*/
|
||
long start = System.currentTimeMillis();
|
||
|
||
AuditLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
|
||
null);
|
||
Page<NtcAreaHomeReport> trafficAreaStatPage = null;
|
||
|
||
try {
|
||
trafficAreaStatPage = systemHomePageService.getTrafficAreaStat(ntcAreaHomeReport);
|
||
} catch (Exception e) {
|
||
saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||
e.printStackTrace();
|
||
logger.error(e.getMessage());
|
||
if (!(e instanceof RestServiceException)) {
|
||
throw new ServiceRuntimeException(saveLogThread, System.currentTimeMillis() - start,
|
||
"获取地域流量失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
||
} else {
|
||
throw ((RestServiceException) e);
|
||
}
|
||
}
|
||
|
||
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "获取地域流量成功",
|
||
trafficAreaStatPage, 0);
|
||
}
|
||
|
||
@RequestMapping(value = "/log/v1/logServiceTopn", method = RequestMethod.GET)
|
||
@ApiOperation(value = "日志TOP5业务统计量获取", httpMethod = "GET", notes = "对日志TOP5业务统计量信息进行查询", response = Map.class)
|
||
//public Map<String, ?> cfgSortLogStat(String searchReportStartTime, String searchReportEndTime,
|
||
public Map<String, ?> cfgSortLogStat(CfgLogInfo cfgLogInfo,
|
||
HttpServletRequest request, HttpServletResponse response) {
|
||
long start = System.currentTimeMillis();
|
||
|
||
AuditLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
|
||
null);
|
||
Page<CfgLogInfo> cfgSortLogStat = null;
|
||
if(cfgLogInfo!=null){
|
||
if(cfgLogInfo.getSearchService() == null || "".equals(cfgLogInfo.getSearchService())){
|
||
throw new ServiceRuntimeException(saveLogThread, System.currentTimeMillis() - start,
|
||
"error TOPN searchService parm !",RestBusinessCode.param_formate_error.getValue());
|
||
}
|
||
if(cfgLogInfo.getSearchReportStartTime() == null || "".equals(cfgLogInfo.getSearchReportStartTime())){
|
||
throw new ServiceRuntimeException(saveLogThread, System.currentTimeMillis() - start,
|
||
" loss TOPN searchReportStartTime parm !",RestBusinessCode.param_formate_error.getValue());
|
||
}
|
||
if(cfgLogInfo.getSearchReportEndTime() == null || "".equals(cfgLogInfo.getSearchReportEndTime())){
|
||
throw new ServiceRuntimeException(saveLogThread, System.currentTimeMillis() - start,
|
||
"loss TOPN searchReportEndTime parm!",RestBusinessCode.param_formate_error.getValue());
|
||
}
|
||
if(cfgLogInfo.getBaseNum() < 1){
|
||
throw new ServiceRuntimeException(saveLogThread, System.currentTimeMillis() - start,
|
||
"error TOPN baseNum parm!",RestBusinessCode.param_formate_error.getValue());
|
||
}
|
||
}
|
||
try {
|
||
cfgSortLogStat = systemHomePageService.getCfgSortLogStat(cfgLogInfo);
|
||
} catch (Exception e) {
|
||
saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||
e.printStackTrace();
|
||
logger.error(e.getMessage());
|
||
if (!(e instanceof RestServiceException)) {
|
||
throw new ServiceRuntimeException(saveLogThread, System.currentTimeMillis() - start,
|
||
"获取TOP5Service失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
||
} else {
|
||
throw ((RestServiceException) e);
|
||
}
|
||
}
|
||
|
||
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "获取TOP5Service趋势统计数据成功",
|
||
cfgSortLogStat, 0);
|
||
}
|
||
|
||
@RequestMapping(value = "/log/v1/blockAndDropStat", method = RequestMethod.GET)
|
||
@ApiOperation(value = "丢弃量获取", httpMethod = "GET", notes = "对阻断和丢弃量进行查询", response = Map.class)
|
||
/*public Map<String, ?> blockAndDropStat(String searchReportStartTime, String searchReportEndTime,
|
||
int searchBusinessType, HttpServletRequest request,
|
||
HttpServletResponse response) {*/
|
||
public Map<String, ?> blockAndDropStat(DropInfo dropInfo, HttpServletRequest request,
|
||
HttpServletResponse response) {
|
||
long start = System.currentTimeMillis();
|
||
|
||
AuditLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
|
||
null);
|
||
//if(searchBusinessType == 0)searchBusinessType = 1;
|
||
Page<DropInfo> dropInfoList=null;
|
||
try {
|
||
dropInfoList = systemHomePageService.getBlockAndDropStat(dropInfo, request, response);
|
||
} catch (Exception e) {
|
||
saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||
e.printStackTrace();
|
||
logger.error(e.getMessage());
|
||
if (!(e instanceof RestServiceException)) {
|
||
throw new ServiceRuntimeException(saveLogThread, System.currentTimeMillis() - start,
|
||
"获取丢弃量失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
||
} else {
|
||
throw ((RestServiceException) e);
|
||
}
|
||
}
|
||
|
||
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "获取丢弃量成功", dropInfoList, 0);
|
||
|
||
}
|
||
|
||
}
|