diff --git a/src/main/java/com/nis/domain/restful/NtcAsnRecord.java b/src/main/java/com/nis/domain/restful/NtcAsnRecord.java new file mode 100644 index 0000000..3850f65 --- /dev/null +++ b/src/main/java/com/nis/domain/restful/NtcAsnRecord.java @@ -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; + } +} diff --git a/src/main/java/com/nis/domain/restful/NtcConnRecordPercent.java b/src/main/java/com/nis/domain/restful/NtcConnRecordPercent.java index bd57bf6..6d1b21e 100644 --- a/src/main/java/com/nis/domain/restful/NtcConnRecordPercent.java +++ b/src/main/java/com/nis/domain/restful/NtcConnRecordPercent.java @@ -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; - } } diff --git a/src/main/java/com/nis/domain/restful/NtcIpURLReport.java b/src/main/java/com/nis/domain/restful/NtcIpURLReport.java new file mode 100644 index 0000000..9a25a48 --- /dev/null +++ b/src/main/java/com/nis/domain/restful/NtcIpURLReport.java @@ -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; + } + +} diff --git a/src/main/java/com/nis/domain/restful/NtcURLReport.java b/src/main/java/com/nis/domain/restful/NtcURLReport.java new file mode 100644 index 0000000..38d2fc4 --- /dev/null +++ b/src/main/java/com/nis/domain/restful/NtcURLReport.java @@ -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 { + + /** + * + */ + 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 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 getDataList() { + return dataList; + } + + public void setDataList(List dataList) { + this.dataList = dataList; + } + @JsonIgnore + public String getSearchUrl() { + return searchUrl; + } + + public void setSearchUrl(String searchUrl) { + this.searchUrl = searchUrl; + } + + + +} diff --git a/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java b/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java index 6b0c826..f95ea29 100644 --- a/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java +++ b/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java @@ -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 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 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); + } } diff --git a/src/main/java/com/nis/web/controller/restful/SingleDimensionReport.java b/src/main/java/com/nis/web/controller/restful/SingleDimensionReport.java index 2ce9afb..22bf67a 100644 --- a/src/main/java/com/nis/web/controller/restful/SingleDimensionReport.java +++ b/src/main/java/com/nis/web/controller/restful/SingleDimensionReport.java @@ -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 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(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维度聚合") diff --git a/src/main/java/com/nis/web/dao/NtcReportDao.java b/src/main/java/com/nis/web/dao/NtcReportDao.java index f7aee88..4d550cf 100644 --- a/src/main/java/com/nis/web/dao/NtcReportDao.java +++ b/src/main/java/com/nis/web/dao/NtcReportDao.java @@ -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 findNtcSrcipDomesticReport(NtcSrcipDomesticReport pz); List findNtcDestipCountryReport(NtcDestipCountryReport pz); List findNtcEntranceReport(NtcEntranceReport pz); + List findNtcIpURLReport(NtcURLReport pz); List findAccounList(NtcRadiusReport pz); List findNasIpList(NtcRadiusReport pz); List findNtcRadiusReport(NtcRadiusReport pz); diff --git a/src/main/java/com/nis/web/dao/NtcReportDao.xml b/src/main/java/com/nis/web/dao/NtcReportDao.xml index d32dd3f..a5394a3 100644 --- a/src/main/java/com/nis/web/dao/NtcReportDao.xml +++ b/src/main/java/com/nis/web/dao/NtcReportDao.xml @@ -1,73 +1,106 @@ - + - + - + - + - + - + - - + + - + - - + + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + - + - + SERVICE,SUM,REPORT_TIME - - - - - - - - - - - - - - - + SELECT - - = STR_TO_DATE(#{searchReportStartTime},'%Y-%m-%d %H:%i:%s') AND REPORT_TIME < STR_TO_DATE(#{searchReportEndTime},'%Y-%m-%d %H:%i:%s')]]> + + ${page.fields} - and REPORT_TIME>=DATE_SUB(now(), INTERVAL 1 HOUR) + url, ip_addr,SUM - - - group by NAS_IP order by num desc - - - - + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/impl/LocalLogJDBCByDruid.java b/src/main/java/com/nis/web/dao/impl/LocalLogJDBCByDruid.java index 73d5063..8e2c2ff 100644 --- a/src/main/java/com/nis/web/dao/impl/LocalLogJDBCByDruid.java +++ b/src/main/java/com/nis/web/dao/impl/LocalLogJDBCByDruid.java @@ -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 getNtcAsnRecordData(String sql) throws Exception { + List 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; + + } + /** * 关闭数据库连接 */ diff --git a/src/main/java/com/nis/web/service/LogDataService.java b/src/main/java/com/nis/web/service/LogDataService.java index 9ed2494..5dfc99a 100644 --- a/src/main/java/com/nis/web/service/LogDataService.java +++ b/src/main/java/com/nis/web/service/LogDataService.java @@ -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中对应的表名 * diff --git a/src/main/java/com/nis/web/service/restful/NtcReportService.java b/src/main/java/com/nis/web/service/restful/NtcReportService.java index 3408289..c454962 100644 --- a/src/main/java/com/nis/web/service/restful/NtcReportService.java +++ b/src/main/java/com/nis/web/service/restful/NtcReportService.java @@ -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 findNtcURLReport(Page page, NtcURLReport entity) throws Exception { + entity.setPage(page); + Map> map = new HashMap<>(); + List list = new ArrayList<>(); + + List findNtcIpURLReport = dao.findNtcIpURLReport(entity); + for (NtcIpURLReport ntcIpURLReport : findNtcIpURLReport) { + String url = ntcIpURLReport.getUrl(); + if (map.containsKey(url)) { + map.get(url).add(ntcIpURLReport); + + } else { + List 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 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> restMap = new HashMap>(); - List accountList =dao.findAccounList(entity); + List accountList = dao.findAccounList(entity); restMap.put("accountList", accountList); - List nasIpList =dao.findNasIpList(entity); + List nasIpList = dao.findNasIpList(entity); restMap.put("nasIpList", nasIpList); resultList.add(restMap); - }else{ + } else { resultList = new ArrayList(); List 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; - + } }