1:新增url统计查询的接口
2:新增ASN通联关系(源,目的)查询接口
This commit is contained in:
77
src/main/java/com/nis/domain/restful/NtcAsnRecord.java
Normal file
77
src/main/java/com/nis/domain/restful/NtcAsnRecord.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package com.nis.domain.restful;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ClassName:NtcAsnRecord
|
||||
* @Description:TODO(这里用一句话描述这个类的作用)
|
||||
* @author rkg
|
||||
* @date 2018年12月12日 下午2:00:16
|
||||
* @version V1.0
|
||||
*/
|
||||
public class NtcAsnRecord implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String bps;
|
||||
private String pps;
|
||||
private String sAsn;
|
||||
private String dAsn;
|
||||
private String searchFoundStartTime;// 开始发现时间
|
||||
private String searchFoundEndTime;// 结束发现时间
|
||||
|
||||
public String getBps() {
|
||||
return bps;
|
||||
}
|
||||
|
||||
public void setBps(String bps) {
|
||||
this.bps = bps;
|
||||
}
|
||||
|
||||
public String getPps() {
|
||||
return pps;
|
||||
}
|
||||
|
||||
public void setPps(String pps) {
|
||||
this.pps = pps;
|
||||
}
|
||||
|
||||
public String getsAsn() {
|
||||
return sAsn;
|
||||
}
|
||||
|
||||
public void setsAsn(String sAsn) {
|
||||
this.sAsn = sAsn;
|
||||
}
|
||||
|
||||
public String getdAsn() {
|
||||
return dAsn;
|
||||
}
|
||||
|
||||
public void setdAsn(String dAsn) {
|
||||
this.dAsn = dAsn;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchFoundStartTime() {
|
||||
return searchFoundStartTime;
|
||||
}
|
||||
|
||||
public void setSearchFoundStartTime(String searchFoundStartTime) {
|
||||
this.searchFoundStartTime = searchFoundStartTime;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchFoundEndTime() {
|
||||
return searchFoundEndTime;
|
||||
}
|
||||
|
||||
public void setSearchFoundEndTime(String searchFoundEndTime) {
|
||||
this.searchFoundEndTime = searchFoundEndTime;
|
||||
}
|
||||
}
|
||||
@@ -14,13 +14,16 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
*/
|
||||
public class NtcConnRecordPercent implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String bps;
|
||||
private String bpsPercent;
|
||||
private String pps;
|
||||
private String ppsPercent;
|
||||
private String searchFoundStartTime;// 开始发现时间
|
||||
private String searchFoundEndTime;// 结束发现时间
|
||||
private String searchStreamDir;// 流类型
|
||||
|
||||
public String getBps() {
|
||||
return bps;
|
||||
@@ -71,13 +74,4 @@ public class NtcConnRecordPercent implements Serializable {
|
||||
public void setSearchFoundEndTime(String searchFoundEndTime) {
|
||||
this.searchFoundEndTime = searchFoundEndTime;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getSearchStreamDir() {
|
||||
return searchStreamDir;
|
||||
}
|
||||
|
||||
public void setSearchStreamDir(String searchStreamDir) {
|
||||
this.searchStreamDir = searchStreamDir;
|
||||
}
|
||||
}
|
||||
|
||||
46
src/main/java/com/nis/domain/restful/NtcIpURLReport.java
Normal file
46
src/main/java/com/nis/domain/restful/NtcIpURLReport.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package com.nis.domain.restful;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||
|
||||
public class NtcIpURLReport implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty(value = "日志数量", required = true)
|
||||
private Long sum;
|
||||
@ApiModelProperty(value = "ip地址", required = true)
|
||||
private String ipAddr;
|
||||
@ApiModelProperty(value = "url", required = true)
|
||||
private String url;
|
||||
|
||||
public Long getSum() {
|
||||
return sum;
|
||||
}
|
||||
|
||||
public void setSum(Long sum) {
|
||||
this.sum = sum;
|
||||
}
|
||||
|
||||
public String getIpAddr() {
|
||||
return ipAddr;
|
||||
}
|
||||
|
||||
public void setIpAddr(String ipAddr) {
|
||||
this.ipAddr = ipAddr;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
}
|
||||
58
src/main/java/com/nis/domain/restful/NtcURLReport.java
Normal file
58
src/main/java/com/nis/domain/restful/NtcURLReport.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package com.nis.domain.restful;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||
|
||||
public class NtcURLReport extends NtcReportEntity<NtcURLReport> {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty(value = "url", required = true)
|
||||
private String url;
|
||||
@ApiModelProperty(value = "日志数量", required = true)
|
||||
private Long urlCount;
|
||||
@ApiModelProperty(value = "ip数量列表", required = true)
|
||||
private List<NtcIpURLReport> dataList;
|
||||
|
||||
|
||||
private String searchUrl;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Long getUrlCount() {
|
||||
return urlCount;
|
||||
}
|
||||
|
||||
public void setUrlCount(Long urlCount) {
|
||||
this.urlCount = urlCount;
|
||||
}
|
||||
|
||||
public List<NtcIpURLReport> getDataList() {
|
||||
return dataList;
|
||||
}
|
||||
|
||||
public void setDataList(List<NtcIpURLReport> dataList) {
|
||||
this.dataList = dataList;
|
||||
}
|
||||
@JsonIgnore
|
||||
public String getSearchUrl() {
|
||||
return searchUrl;
|
||||
}
|
||||
|
||||
public void setSearchUrl(String searchUrl) {
|
||||
this.searchUrl = searchUrl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.NtcAppLog;
|
||||
import com.nis.domain.restful.NtcAsnRecord;
|
||||
import com.nis.domain.restful.NtcBgpLog;
|
||||
import com.nis.domain.restful.NtcCollectRadiusLog;
|
||||
import com.nis.domain.restful.NtcCollectVoipLog;
|
||||
@@ -733,7 +734,7 @@ public class NtcLogSearchController extends BaseRestController {
|
||||
if (!StringUtil.isBlank(ntcConnRecordPercent.getSearchFoundEndTime())) {
|
||||
sdf.setLenient(false);
|
||||
sdf.parse(ntcConnRecordPercent.getSearchFoundEndTime());
|
||||
}else {
|
||||
} else {
|
||||
throw new RestServiceException("searchFoundEndTime参数不能为空",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
@@ -749,7 +750,7 @@ public class NtcLogSearchController extends BaseRestController {
|
||||
if (!StringUtil.isBlank(ntcConnRecordPercent.getSearchFoundStartTime())) {
|
||||
sdf.setLenient(false);
|
||||
sdf.parse(ntcConnRecordPercent.getSearchFoundStartTime());
|
||||
}else {
|
||||
} else {
|
||||
throw new RestServiceException("searchFoundStartTime参数不能为空",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
@@ -779,4 +780,70 @@ public class NtcLogSearchController extends BaseRestController {
|
||||
return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "通联关系日志百分比检索成功",
|
||||
ntcConnRecordPercent, 0);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/ntcAsnRecord", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "ASN通联关系(源,目的)查询", httpMethod = "GET", notes = "对日志功能“ASN通联关系(源,目的)查询”提供数据基础查询服务")
|
||||
public Map<String, ?> ntcAsnRecord(Page page, NtcAsnRecord ntcAsnRecord, Model model, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
long start = System.currentTimeMillis();
|
||||
AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
|
||||
null);
|
||||
try {
|
||||
if (StringUtil.isEmpty(ntcAsnRecord.getSearchFoundStartTime())
|
||||
&& StringUtil.isEmpty(ntcAsnRecord.getSearchFoundEndTime())) {
|
||||
Map<String, String> map = DateUtils.getLocalTime(null, null, Constants.LOG_LOCAL_TIME, "minute");
|
||||
ntcAsnRecord.setSearchFoundStartTime(map.get("startTime"));
|
||||
ntcAsnRecord.setSearchFoundEndTime(map.get("endTime"));
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(ntcAsnRecord.getSearchFoundEndTime())) {
|
||||
sdf.setLenient(false);
|
||||
sdf.parse(ntcAsnRecord.getSearchFoundEndTime());
|
||||
} else {
|
||||
throw new RestServiceException("searchFoundEndTime参数不能为空",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
throw new RestServiceException("searchFoundEndTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
throw new RestServiceException("searchFoundEndTime参数错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(ntcAsnRecord.getSearchFoundStartTime())) {
|
||||
sdf.setLenient(false);
|
||||
sdf.parse(ntcAsnRecord.getSearchFoundStartTime());
|
||||
} else {
|
||||
throw new RestServiceException("searchFoundStartTime参数不能为空",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
throw new RestServiceException("searchFoundStartTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
throw new RestServiceException("searchFoundStartTime参数错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
logDataService.getNtcAsnRecord(page, ntcAsnRecord);
|
||||
} catch (Exception e) {
|
||||
auditLogThread.setExceptionInfo("ASN通联关系(源,目的)日志检索失败:" + e.getMessage());
|
||||
logger.error("ASN通联关系(源,目的)检索失败:" + ExceptionUtil.getExceptionMsg(e));
|
||||
if (e instanceof RestServiceException) {
|
||||
throw new RestServiceException(auditLogThread, System.currentTimeMillis() - start,
|
||||
"ASN通联关系(源,目的)检索失败:" + e.getMessage(), ((RestServiceException) e).getErrorCode());
|
||||
} else if (e instanceof ServiceRuntimeException) {
|
||||
throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
|
||||
"ASN通联关系(源,目的)检索失败:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
|
||||
} else {
|
||||
throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
|
||||
"ASN通联关系(源,目的)检索失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
||||
}
|
||||
}
|
||||
return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "ASN通联关系(源,目的)检索成功",
|
||||
page, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.nis.domain.restful.NtcReportEntity;
|
||||
import com.nis.domain.restful.NtcServiceReport;
|
||||
import com.nis.domain.restful.NtcSrcipDomesticReport;
|
||||
import com.nis.domain.restful.NtcTagReport;
|
||||
import com.nis.domain.restful.NtcURLReport;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.restful.ServiceRuntimeException;
|
||||
@@ -395,6 +396,69 @@ public class SingleDimensionReport extends BaseRestController {
|
||||
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "运营商局点统计查询成功", reportPage,
|
||||
0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/ntcURLReport", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "URL统计查询服务", httpMethod = "GET", notes = "URL统计查询服务")
|
||||
public Map<String, ?> ntcURLReport(Page page, NtcURLReport urlReport, Model model,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
long start = System.currentTimeMillis();
|
||||
AuditLogThread saveLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
|
||||
null);
|
||||
|
||||
Page<?> reportPage = null;
|
||||
try {
|
||||
resetReportTime(urlReport,false);
|
||||
ntcReportService.queryReportConditionCheck(saveLogThread, start, urlReport, NtcURLReport.class,
|
||||
page);
|
||||
String orderBy = "";
|
||||
if (null != page.getOrderBy() && !page.getOrderBy().equals("")) {
|
||||
orderBy = Page.getOrderBySql(NtcURLReport.class.getSimpleName(), page.getOrderBy());
|
||||
} else {
|
||||
orderBy = "report_time";
|
||||
}
|
||||
page.setOrderBy(orderBy);
|
||||
reportPage = ntcReportService.findNtcURLReport(
|
||||
new Page<NtcURLReport>(request, response, NtcURLReport.class), urlReport);
|
||||
} catch (Exception e) {
|
||||
saveLogThread.setExceptionInfo("URL统计查询失败:"+e.getMessage());
|
||||
logger.error("URL统计查询失败:"+ExceptionUtil.getExceptionMsg(e));
|
||||
if (e instanceof RestServiceException) {
|
||||
throw new RestServiceException(saveLogThread, System.currentTimeMillis() - start,
|
||||
"URL统计查询失败:" + e.getMessage(), ((RestServiceException) e).getErrorCode());
|
||||
} else if (e instanceof ServiceRuntimeException) {
|
||||
throw new ServiceRuntimeException(saveLogThread, System.currentTimeMillis() - start,
|
||||
"URL统计查询失败:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
|
||||
} else {
|
||||
throw new ServiceRuntimeException(saveLogThread, System.currentTimeMillis() - start,
|
||||
"URL统计查询失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return serviceLogResponse(saveLogThread, System.currentTimeMillis() - start, request, "URL统计查询成功", reportPage,
|
||||
0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/ntcRadiusReport", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "用户行为统计查询服务", httpMethod = "GET", notes = "用户行为统计查询服务,基于用户名或接入IP维度聚合")
|
||||
|
||||
@@ -5,12 +5,14 @@ import java.util.List;
|
||||
import com.nis.domain.restful.NtcAttrTypeReport;
|
||||
import com.nis.domain.restful.NtcDestipCountryReport;
|
||||
import com.nis.domain.restful.NtcEntranceReport;
|
||||
import com.nis.domain.restful.NtcIpURLReport;
|
||||
import com.nis.domain.restful.NtcLwhhReport;
|
||||
import com.nis.domain.restful.NtcPzReport;
|
||||
import com.nis.domain.restful.NtcRadiusReport;
|
||||
import com.nis.domain.restful.NtcServiceReport;
|
||||
import com.nis.domain.restful.NtcSrcipDomesticReport;
|
||||
import com.nis.domain.restful.NtcTagReport;
|
||||
import com.nis.domain.restful.NtcURLReport;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -30,6 +32,7 @@ public interface NtcReportDao extends CrudDao {
|
||||
List<NtcSrcipDomesticReport> findNtcSrcipDomesticReport(NtcSrcipDomesticReport pz);
|
||||
List<NtcDestipCountryReport> findNtcDestipCountryReport(NtcDestipCountryReport pz);
|
||||
List<NtcEntranceReport> findNtcEntranceReport(NtcEntranceReport pz);
|
||||
List<NtcIpURLReport> findNtcIpURLReport(NtcURLReport pz);
|
||||
List<NtcRadiusReport> findAccounList(NtcRadiusReport pz);
|
||||
List<NtcRadiusReport> findNasIpList(NtcRadiusReport pz);
|
||||
List<NtcRadiusReport> findNtcRadiusReport(NtcRadiusReport pz);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,6 +13,7 @@ import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -25,8 +26,10 @@ import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.NtcAsnRecord;
|
||||
import com.nis.domain.restful.NtcConnRecordPercent;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
import com.zdjizhi.utils.CommonUtil;
|
||||
import com.zdjizhi.utils.StringUtil;
|
||||
|
||||
/**
|
||||
@@ -48,6 +51,9 @@ import com.zdjizhi.utils.StringUtil;
|
||||
@Repository
|
||||
public class LocalLogJDBCByDruid {
|
||||
private final static Logger logger = LoggerFactory.getLogger(LocalLogJDBCByDruid.class);
|
||||
|
||||
static NumberFormat num = NumberFormat.getPercentInstance();
|
||||
|
||||
static DruidDataSource datasource = null;
|
||||
Connection conn = null;
|
||||
ResultSet rs = null;
|
||||
@@ -111,6 +117,15 @@ public class LocalLogJDBCByDruid {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单向,流量包数和流量字节数在总的流量包数和字节数的占比
|
||||
*
|
||||
* @param ntcConnRecordPercent
|
||||
* @param sql
|
||||
* @param isPersent
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public NtcConnRecordPercent getNtcConnRecordPercentData(NtcConnRecordPercent ntcConnRecordPercent, String sql,
|
||||
boolean isPersent) throws Exception {
|
||||
try {
|
||||
@@ -119,7 +134,6 @@ public class LocalLogJDBCByDruid {
|
||||
st = conn.createStatement();
|
||||
logger.info("开始执行日志查询语句sql={}", sql);
|
||||
rs = st.executeQuery(sql);
|
||||
NumberFormat num = NumberFormat.getPercentInstance();
|
||||
num.setMinimumFractionDigits(2);// 保留两位小数
|
||||
while (rs.next()) {
|
||||
if (isPersent) {
|
||||
@@ -127,7 +141,7 @@ public class LocalLogJDBCByDruid {
|
||||
if (!allBps.equals("0")) {
|
||||
ntcConnRecordPercent.setBpsPercent(
|
||||
num.format(Double.valueOf(ntcConnRecordPercent.getBps()) / Double.valueOf(allBps)));
|
||||
ntcConnRecordPercent.setBps(num.format(Double.valueOf(ntcConnRecordPercent.getBps())));
|
||||
ntcConnRecordPercent.setBps(subStr(ntcConnRecordPercent.getBps()));
|
||||
} else {
|
||||
ntcConnRecordPercent.setBpsPercent("0%");
|
||||
}
|
||||
@@ -135,7 +149,7 @@ public class LocalLogJDBCByDruid {
|
||||
if (!allPps.equals("0")) {
|
||||
ntcConnRecordPercent.setPpsPercent(
|
||||
num.format(Double.valueOf(ntcConnRecordPercent.getPps()) / Double.valueOf(allPps)));
|
||||
ntcConnRecordPercent.setPps(num.format(Double.valueOf(ntcConnRecordPercent.getPps())));
|
||||
ntcConnRecordPercent.setPps(subStr(ntcConnRecordPercent.getPps()));
|
||||
} else {
|
||||
ntcConnRecordPercent.setPpsPercent("0%");
|
||||
}
|
||||
@@ -144,6 +158,7 @@ public class LocalLogJDBCByDruid {
|
||||
String pps = rs.getString("pps");
|
||||
ntcConnRecordPercent.setBps(bps);
|
||||
ntcConnRecordPercent.setPps(pps);
|
||||
|
||||
}
|
||||
}
|
||||
logger.info("执行日志查询语句成功,sql={}", sql);
|
||||
@@ -153,6 +168,58 @@ public class LocalLogJDBCByDruid {
|
||||
return ntcConnRecordPercent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取asn,源目的的流量包数和字节数
|
||||
*
|
||||
* @param ntcAsnRecord
|
||||
* @param sql
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<NtcAsnRecord> getNtcAsnRecordData(String sql) throws Exception {
|
||||
List<NtcAsnRecord> list = new LinkedList<>();
|
||||
try {
|
||||
conn = getConnection();
|
||||
logger.info("连接数据中心日志库成功--------------------------");
|
||||
st = conn.createStatement();
|
||||
logger.info("开始执行日志查询语句sql={}", sql);
|
||||
rs = st.executeQuery(sql);
|
||||
num.setMinimumFractionDigits(2);// 保留两位小数
|
||||
while (rs.next()) {
|
||||
NtcAsnRecord ntcAsnRecord = new NtcAsnRecord();
|
||||
String bps = rs.getString("bps");
|
||||
String pps = rs.getString("pps");
|
||||
ntcAsnRecord.setBps(subStr(bps));
|
||||
ntcAsnRecord.setPps(subStr(pps));
|
||||
ntcAsnRecord.setdAsn(rs.getString("d_asn"));
|
||||
ntcAsnRecord.setsAsn(rs.getString("s_asn"));
|
||||
list.add(ntcAsnRecord);
|
||||
}
|
||||
logger.info("执行日志查询语句成功,sql={}", sql);
|
||||
} finally {
|
||||
closeConn();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 截取字符串后两位
|
||||
*
|
||||
* @param val
|
||||
* @return
|
||||
*/
|
||||
public String subStr(String val) {
|
||||
if (val != null && val.contains(".")) {
|
||||
int length = val.indexOf(".") + 3;
|
||||
if (val.length() > length) {
|
||||
return val.substring(0, length);
|
||||
}
|
||||
|
||||
}
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭数据库连接
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.nis.web.service;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -19,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.NtcAsnRecord;
|
||||
import com.nis.domain.restful.NtcConnRecordPercent;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
@@ -55,7 +55,6 @@ public class LogDataService {
|
||||
}
|
||||
|
||||
public NtcConnRecordPercent getNtcConnRecordPercent(NtcConnRecordPercent ntcConnRecordPercent) throws Exception {
|
||||
|
||||
long startTime = sdf.parse(ntcConnRecordPercent.getSearchFoundStartTime().toString().trim()).getTime() / 1000;
|
||||
long endTime = sdf.parse(ntcConnRecordPercent.getSearchFoundEndTime().toString().trim()).getTime() / 1000;
|
||||
if (endTime - startTime < 0) {
|
||||
@@ -69,7 +68,7 @@ public class LogDataService {
|
||||
sql.append(" AS pps , SUM(c2s_byte_num + s2c_byte_num)*8/");
|
||||
sql.append(second);
|
||||
sql.append(
|
||||
" AS bps FROM tbs_ods_ntc_conn_record_log_local_1 t WHERE found_time IN ( SELECT DISTINCT found_time FROM tbs_ods_ntc_conn_record_log_local_1 WHERE found_time >= ");
|
||||
" AS bps FROM tbs_ods_ntc_conn_record_log_local t WHERE found_time IN ( SELECT DISTINCT found_time FROM tbs_ods_ntc_conn_record_log_local WHERE found_time >= ");
|
||||
sql.append(startTime);
|
||||
sql.append(" and found_time< ");
|
||||
sql.append(endTime);
|
||||
@@ -82,6 +81,39 @@ public class LogDataService {
|
||||
return ntcConnRecordPercent;
|
||||
}
|
||||
|
||||
public void getNtcAsnRecord(Page page, NtcAsnRecord ntcAsnRecord) throws Exception {
|
||||
long startTime = sdf.parse(ntcAsnRecord.getSearchFoundStartTime().toString().trim()).getTime() / 1000;
|
||||
long endTime = sdf.parse(ntcAsnRecord.getSearchFoundEndTime().toString().trim()).getTime() / 1000;
|
||||
if (endTime - startTime < 0) {
|
||||
throw new RestServiceException("searchFoundStartTime() can not exceed searchFoundEndTime",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
long second = endTime - startTime;
|
||||
StringBuffer sql = new StringBuffer();
|
||||
sql.append("SELECT SUM(s2c_pkt_num + s2c_pkt_num)*8/");
|
||||
sql.append(second);
|
||||
sql.append(" AS pps , SUM(c2s_byte_num + s2c_byte_num)*8/");
|
||||
sql.append(second);
|
||||
sql.append(
|
||||
" AS bps,d_asn,s_asn FROM tbs_ods_ntc_conn_record_log_local t WHERE found_time IN ( SELECT DISTINCT found_time FROM tbs_ods_ntc_conn_record_log_local WHERE found_time >= ");
|
||||
sql.append(startTime);
|
||||
sql.append(" and found_time< ");
|
||||
sql.append(endTime);
|
||||
StringBuffer countSql = new StringBuffer();
|
||||
countSql.append("select count(1) from (");
|
||||
countSql.append(sql);
|
||||
countSql.append(" ) group by s_asn,d_asn)");
|
||||
|
||||
Integer startNum = (page.getPageNo() - 1) * page.getPageSize();
|
||||
Integer limitCount = startNum + page.getPageSize();
|
||||
|
||||
sql.append(" limit " + limitCount + " ) group by s_asn,d_asn limit " + startNum + "," + page.getPageSize());
|
||||
|
||||
localLogJDBCByDruid.getCount(page, countSql.toString());
|
||||
|
||||
page.setList(localLogJDBCByDruid.getNtcAsnRecordData(sql.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类名加对应的标识获取hive或者clickhouse中对应的表名
|
||||
*
|
||||
|
||||
@@ -14,12 +14,14 @@ import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.NtcAttrTypeReport;
|
||||
import com.nis.domain.restful.NtcDestipCountryReport;
|
||||
import com.nis.domain.restful.NtcEntranceReport;
|
||||
import com.nis.domain.restful.NtcIpURLReport;
|
||||
import com.nis.domain.restful.NtcLwhhReport;
|
||||
import com.nis.domain.restful.NtcPzReport;
|
||||
import com.nis.domain.restful.NtcRadiusReport;
|
||||
import com.nis.domain.restful.NtcServiceReport;
|
||||
import com.nis.domain.restful.NtcSrcipDomesticReport;
|
||||
import com.nis.domain.restful.NtcTagReport;
|
||||
import com.nis.domain.restful.NtcURLReport;
|
||||
import com.nis.web.dao.NtcReportDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
|
||||
@@ -53,7 +55,7 @@ public class NtcReportService extends BaseLogService {
|
||||
pageTotal.setCount(restList.size());
|
||||
pageTotal.setList(restList);
|
||||
return pageTotal;
|
||||
} else{
|
||||
} else {
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -105,41 +107,73 @@ public class NtcReportService extends BaseLogService {
|
||||
page.setList(dao.findNtcEntranceReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Page<NtcURLReport> findNtcURLReport(Page<NtcURLReport> page, NtcURLReport entity) throws Exception {
|
||||
entity.setPage(page);
|
||||
Map<String, List<NtcIpURLReport>> map = new HashMap<>();
|
||||
List<NtcURLReport> list = new ArrayList<>();
|
||||
|
||||
List<NtcIpURLReport> findNtcIpURLReport = dao.findNtcIpURLReport(entity);
|
||||
for (NtcIpURLReport ntcIpURLReport : findNtcIpURLReport) {
|
||||
String url = ntcIpURLReport.getUrl();
|
||||
if (map.containsKey(url)) {
|
||||
map.get(url).add(ntcIpURLReport);
|
||||
|
||||
} else {
|
||||
List<NtcIpURLReport> ipUrlList = new ArrayList<>();
|
||||
ipUrlList.add(ntcIpURLReport);
|
||||
map.put(url, ipUrlList);
|
||||
}
|
||||
}
|
||||
|
||||
for (String url : map.keySet()) {
|
||||
NtcURLReport ntcURLReport = new NtcURLReport();
|
||||
ntcURLReport.setUrl(url);
|
||||
long count = 0l;
|
||||
List<NtcIpURLReport> list2 = map.get(url);
|
||||
for (NtcIpURLReport ntcIpURLReport : list2) {
|
||||
count += ntcIpURLReport.getSum();
|
||||
}
|
||||
ntcURLReport.setUrlCount(count);
|
||||
ntcURLReport.setDataList(list2);
|
||||
list.add(ntcURLReport);
|
||||
}
|
||||
page.setList(list);
|
||||
return page;
|
||||
}
|
||||
|
||||
public List findNtcRadiusReport(NtcRadiusReport entity) throws Exception {
|
||||
List resultList = null;
|
||||
if ("1".equals(entity.getSearchBusinessType())) {
|
||||
resultList = new ArrayList<Map>();
|
||||
Map<String, List<NtcRadiusReport>> restMap = new HashMap<String, List<NtcRadiusReport>>();
|
||||
List<NtcRadiusReport> accountList =dao.findAccounList(entity);
|
||||
List<NtcRadiusReport> accountList = dao.findAccounList(entity);
|
||||
restMap.put("accountList", accountList);
|
||||
List<NtcRadiusReport> nasIpList =dao.findNasIpList(entity);
|
||||
List<NtcRadiusReport> nasIpList = dao.findNasIpList(entity);
|
||||
restMap.put("nasIpList", nasIpList);
|
||||
resultList.add(restMap);
|
||||
}else{
|
||||
} else {
|
||||
resultList = new ArrayList<NtcRadiusReport>();
|
||||
List<NtcRadiusReport> list = dao.findNtcRadiusReport(entity);
|
||||
|
||||
|
||||
String regionName = "nasIp";
|
||||
if ("3".equals(entity.getSearchBusinessType())) {
|
||||
regionName="account";
|
||||
regionName = "account";
|
||||
}
|
||||
PropertyDescriptor pd= new PropertyDescriptor(regionName, NtcRadiusReport.class);
|
||||
PropertyDescriptor pd = new PropertyDescriptor(regionName, NtcRadiusReport.class);
|
||||
Method method = pd.getReadMethod();
|
||||
NtcRadiusReport temp = null;
|
||||
Object tempVal =null;
|
||||
Object tempVal = null;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (i>0) {
|
||||
if (i > 0) {
|
||||
NtcRadiusReport obj = list.get(i);
|
||||
Object objVal = method.invoke(obj);
|
||||
if (objVal!=null && tempVal!=null && !objVal.toString().equals(tempVal.toString())) {
|
||||
if (objVal != null && tempVal != null && !objVal.toString().equals(tempVal.toString())) {
|
||||
temp = obj;
|
||||
tempVal = method.invoke(temp);
|
||||
resultList.add(obj);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
temp = list.get(i);
|
||||
tempVal = method.invoke(temp);
|
||||
resultList.add(list.get(i));
|
||||
@@ -147,6 +181,6 @@ public class NtcReportService extends BaseLogService {
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user