1:新增url统计查询的接口

2:新增ASN通联关系(源,目的)查询接口
This commit is contained in:
renkaige
2018-12-16 11:10:25 +06:00
parent e9f838998b
commit 630be99456
11 changed files with 859 additions and 248 deletions

View File

@@ -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中对应的表名
*

View File

@@ -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;
}
}