实时报表统计接口实现

This commit is contained in:
zhangdongxu
2018-07-16 14:36:43 +08:00
parent 4f48d3862e
commit 7a262b72a8
11 changed files with 862 additions and 7 deletions

View File

@@ -20,20 +20,27 @@ import com.nis.domain.LogEntity;
import com.nis.domain.Page;
import com.nis.domain.restful.DkBehaviorLog;
import com.nis.domain.restful.NtcAppLog;
import com.nis.domain.restful.NtcAttrTypeReport;
import com.nis.domain.restful.NtcDdosLog;
import com.nis.domain.restful.NtcDestipCountryReport;
import com.nis.domain.restful.NtcDnsLog;
import com.nis.domain.restful.NtcEntranceReport;
import com.nis.domain.restful.NtcFtpLog;
import com.nis.domain.restful.NtcHttpLog;
import com.nis.domain.restful.NtcIpLog;
import com.nis.domain.restful.NtcIpsecLog;
import com.nis.domain.restful.NtcL2tpLog;
import com.nis.domain.restful.NtcLwhhReport;
import com.nis.domain.restful.NtcMailLog;
import com.nis.domain.restful.NtcOpenvpnLog;
import com.nis.domain.restful.NtcPptpLog;
import com.nis.domain.restful.NtcPzReport;
import com.nis.domain.restful.NtcReportEntity;
import com.nis.domain.restful.NtcServiceReport;
import com.nis.domain.restful.NtcSrcipDomesticReport;
import com.nis.domain.restful.NtcSshLog;
import com.nis.domain.restful.NtcSslLog;
import com.nis.domain.restful.NtcTagReport;
import com.nis.restful.RestServiceException;
import com.nis.util.Configurations;
import com.nis.util.Constants;
@@ -918,7 +925,7 @@ public class LogController extends BaseRestController {
try {
resetReportTime(ntcPzReport);
//验证实时报表
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcPzReport, NtcDdosLog.class, page);
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcPzReport, NtcPzReport.class, page);
//验证serachCfgId
ntcReportService.checkNumericCondition(saveLogThread,start,ntcPzReport.getSearchCfgId(),"searchCfgId");
String orderBy = "";
@@ -944,7 +951,261 @@ public class LogController extends BaseRestController {
ntcPzReportPage, 0);
}
@RequestMapping(value = "/ntcServiceReport", method = RequestMethod.GET)
@ApiOperation(value = "业务类型统计查询服务", httpMethod = "GET", notes = "业务类型统计查询服务基于业务类型service维度聚合")
public Map<String, ?> ntcServiceReport(Page page, NtcServiceReport ntcServiceReport, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET,
request, null);
Page<?> reportPage = null;
try {
resetReportTime(ntcServiceReport);
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcServiceReport, NtcServiceReport.class, page);
String orderBy = "";
if (null != page.getOrderBy() && !page.getOrderBy().equals("")) {
orderBy = Page.getOrderBySql(NtcServiceReport.class.getSimpleName(), page.getOrderBy());
} else {
orderBy = "report_time";
}
page.setOrderBy(orderBy);
reportPage = ntcReportService.findNtcServiceReport(new Page<NtcServiceReport>(request, response, NtcServiceReport.class),
ntcServiceReport);
} catch (Exception e) {
saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(saveLogThread, System.currentTimeMillis() - start, "业务类型统计查询失败");
}
throw ((RestServiceException) e);
}
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "业务类型统计查询成功",
reportPage, 0);
}
@RequestMapping(value = "/ntcTagReport", method = RequestMethod.GET)
@ApiOperation(value = "标签统计查询服务", httpMethod = "GET", notes = "标签统计查询服务基于标签与业务类型service维度聚合")
public Map<String, ?> ntcTagReport(Page page, NtcTagReport ntcTagReport, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET,
request, null);
Page<?> reportPage = null;
try {
resetReportTime(ntcTagReport);
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcTagReport, NtcTagReport.class, page);
//验证serachTag
ntcReportService.checkNumericCondition(saveLogThread,start,ntcTagReport.getSearchTag(),"searchTag");
String orderBy = "";
if (null != page.getOrderBy() && !page.getOrderBy().equals("")) {
orderBy = Page.getOrderBySql(NtcTagReport.class.getSimpleName(), page.getOrderBy());
} else {
orderBy = "report_time";
}
page.setOrderBy(orderBy);
reportPage = ntcReportService.findNtcTagReport(new Page<NtcTagReport>(request, response, NtcTagReport.class),
ntcTagReport);
} catch (Exception e) {
saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(saveLogThread, System.currentTimeMillis() - start, "标签统计查询失败");
}
throw ((RestServiceException) e);
}
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "标签统计查询成功",
reportPage, 0);
}
@RequestMapping(value = "/ntcAttrTypeReport", method = RequestMethod.GET)
@ApiOperation(value = "性质统计查询服务", httpMethod = "GET", notes = "性质统计查询服务基于性质与业务类型service维度聚合")
public Map<String, ?> ntcAttrTypeReport(Page page, NtcAttrTypeReport ntcAttrTypeReport, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET,
request, null);
Page<?> reportPage = null;
try {
resetReportTime(ntcAttrTypeReport);
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcAttrTypeReport, NtcAttrTypeReport.class, page);
//验证searchAttrType
ntcReportService.checkNumericCondition(saveLogThread,start,ntcAttrTypeReport.getSearchAttrType(),"searchAttrType");
String orderBy = "";
if (null != page.getOrderBy() && !page.getOrderBy().equals("")) {
orderBy = Page.getOrderBySql(NtcAttrTypeReport.class.getSimpleName(), page.getOrderBy());
} else {
orderBy = "report_time";
}
page.setOrderBy(orderBy);
reportPage = ntcReportService.findNtcAttrTypeReport(new Page<NtcAttrTypeReport>(request, response, NtcAttrTypeReport.class),
ntcAttrTypeReport);
} catch (Exception e) {
saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(saveLogThread, System.currentTimeMillis() - start, "性质统计查询失败");
}
throw ((RestServiceException) e);
}
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "性质统计查询成功",
reportPage, 0);
}
@RequestMapping(value = "/ntcLwhhReport", method = RequestMethod.GET)
@ApiOperation(value = "来文函号统计查询服务", httpMethod = "GET", notes = "来文函号统计查询服务基于来文函号与业务类型service维度聚合")
public Map<String, ?> ntcLwhhReport(Page page, NtcLwhhReport ntcLwhhReport, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET,
request, null);
Page<?> reportPage = null;
try {
resetReportTime(ntcLwhhReport);
//验证实时报表
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcLwhhReport, NtcLwhhReport.class, page);
//验证serachCfgId
ntcReportService.checkNumericCondition(saveLogThread,start,ntcLwhhReport.getSearchLwhh(),"searchLwhh");
String orderBy = "";
if (null != page.getOrderBy() && !page.getOrderBy().equals("")) {
orderBy = Page.getOrderBySql(NtcLwhhReport.class.getSimpleName(), page.getOrderBy());
} else {
orderBy = "report_time";
}
page.setOrderBy(orderBy);
reportPage = ntcReportService.findNtcLwhhReport(new Page<NtcLwhhReport>(request, response, NtcLwhhReport.class),
ntcLwhhReport);
} catch (Exception e) {
saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(saveLogThread, System.currentTimeMillis() - start, "来文函号统计查询失败");
}
throw ((RestServiceException) e);
}
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "来文函号统计查询成功",
reportPage, 0);
}
@RequestMapping(value = "/ntcSrcipDomesticReport", method = RequestMethod.GET)
@ApiOperation(value = "境内源IP统计查询服务", httpMethod = "GET", notes = "境内源IP统计查询服务基于源IP所属省、市与业务类型service维度聚合")
public Map<String, ?> ntcSrcipDomesticReport(Page page, NtcSrcipDomesticReport ntcSrcipDomesticReport, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET,
request, null);
Page<?> reportPage = null;
try {
resetReportTime(ntcSrcipDomesticReport);
//验证实时报表
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcSrcipDomesticReport, NtcSrcipDomesticReport.class, page);
String orderBy = "";
if (null != page.getOrderBy() && !page.getOrderBy().equals("")) {
orderBy = Page.getOrderBySql(NtcSrcipDomesticReport.class.getSimpleName(), page.getOrderBy());
} else {
orderBy = "report_time";
}
page.setOrderBy(orderBy);
reportPage = ntcReportService.findNtcSrcipDomesticReport(new Page<NtcSrcipDomesticReport>(request, response, NtcSrcipDomesticReport.class),
ntcSrcipDomesticReport);
} catch (Exception e) {
saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(saveLogThread, System.currentTimeMillis() - start, "境内源IP统计查询失败");
}
throw ((RestServiceException) e);
}
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "境内源IP统计查询成功",
reportPage, 0);
}
@RequestMapping(value = "/ntcDestipCountryReport", method = RequestMethod.GET)
@ApiOperation(value = "各国家目的IP统计查询服务", httpMethod = "GET", notes = "各国家目的IP统计查询服务基于目的IP所属国家与业务类型service维度聚合")
public Map<String, ?> ntcDestipCountryReport(Page page, NtcDestipCountryReport ntcDestipCountryReport, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET,
request, null);
Page<?> reportPage = null;
try {
resetReportTime(ntcDestipCountryReport);
//验证实时报表
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcDestipCountryReport, NtcDestipCountryReport.class, page);
String orderBy = "";
if (null != page.getOrderBy() && !page.getOrderBy().equals("")) {
orderBy = Page.getOrderBySql(NtcDestipCountryReport.class.getSimpleName(), page.getOrderBy());
} else {
orderBy = "report_time";
}
page.setOrderBy(orderBy);
reportPage = ntcReportService.findNtcDestipCountryReport(new Page<NtcDestipCountryReport>(request, response, NtcDestipCountryReport.class),
ntcDestipCountryReport);
} catch (Exception e) {
saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(saveLogThread, System.currentTimeMillis() - start, "各国家目的IP统计查询失败");
}
throw ((RestServiceException) e);
}
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "各国家目的IP统计查询成功",
reportPage, 0);
}
@RequestMapping(value = "/ntcEntranceReport", method = RequestMethod.GET)
@ApiOperation(value = "运营商局点统计查询服务", httpMethod = "GET", notes = "运营商局点统计查询服务基于出入口与业务类型service维度聚合")
public Map<String, ?> ntcEntranceReport(Page page, NtcEntranceReport ntcEntranceReport, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET,
request, null);
Page<?> reportPage = null;
try {
resetReportTime(ntcEntranceReport);
ntcReportService.queryReportConditionCheck(saveLogThread, start, ntcEntranceReport, NtcEntranceReport.class, page);
//验证searchEntrance
ntcReportService.checkNumericCondition(saveLogThread,start,ntcEntranceReport.getSearchEntrance(),"searchEntrance");
String orderBy = "";
if (null != page.getOrderBy() && !page.getOrderBy().equals("")) {
orderBy = Page.getOrderBySql(NtcEntranceReport.class.getSimpleName(), page.getOrderBy());
} else {
orderBy = "report_time";
}
page.setOrderBy(orderBy);
reportPage = ntcReportService.findNtcEntranceReport(new Page<NtcEntranceReport>(request, response, NtcEntranceReport.class),
ntcEntranceReport);
} catch (Exception e) {
saveLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(saveLogThread, System.currentTimeMillis() - start, "运营商局点统计查询失败");
}
throw ((RestServiceException) e);
}
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "运营商局点统计查询成功",
reportPage, 0);
}
/**
* @Description:
* @author (zdx)