1、回调类配置 :IP复用 Dnat业务 添加、删除字段;

2、日志:APP详情接口,添加appId不能为空验证、修改出入口查询条件相关sql;
3、流量统计所有趋势图,过滤最后一个全为0的点
This commit is contained in:
zhangdongxu
2019-01-10 18:14:50 +08:00
parent 99d3b87e1a
commit 2b97ffc53e
5 changed files with 88 additions and 28 deletions

View File

@@ -1221,6 +1221,9 @@ public class DashboardServiceController extends BaseRestController {
throw new RestServiceException("searchStartTime和searchEndTime参数必须同时填写", throw new RestServiceException("searchStartTime和searchEndTime参数必须同时填写",
RestBusinessCode.config_integrity_error.getValue()); RestBusinessCode.config_integrity_error.getValue());
} }
if (StringUtil.isEmpty(entity.getSearchAppId())) {
throw new RestServiceException("searchAppId参数不能为空", RestBusinessCode.missing_args.getValue());
}
//验证AppId和EntranceId必须是数值 //验证AppId和EntranceId必须是数值
checkNumericCondition(entity.getSearchAppId(),"searchAppId"); checkNumericCondition(entity.getSearchAppId(),"searchAppId");
checkNumericCondition(entity.getSearchEntranceId(),"searchEntranceId"); checkNumericCondition(entity.getSearchEntranceId(),"searchEntranceId");

View File

@@ -39,7 +39,7 @@
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="entranceId !=null"> <if test="entranceId !=null and searchEntranceId != ''">
and entrance_id=#{entranceId} and entrance_id=#{entranceId}
</if> </if>
GROUP BY app_type ) p GROUP BY app_type ) p
@@ -49,7 +49,10 @@
<select id="getAppTrend" parameterType="com.nis.domain.restful.dashboard.TrafficAppFocusStatistic" resultType="com.nis.domain.restful.dashboard.TrafficAppFocusStatistic"> <select id="getAppTrend" parameterType="com.nis.domain.restful.dashboard.TrafficAppFocusStatistic" resultType="com.nis.domain.restful.dashboard.TrafficAppFocusStatistic">
select stat_time time, max(unique_sip_num) sipNum,max(unique_dip_num) dipNum from traffic_app_focus_statistic t where select stat_time time, max(unique_sip_num) sipNum,max(unique_dip_num) dipNum from traffic_app_focus_statistic t where
<![CDATA[ stat_time>= toDateTime(#{searchStartTime}) and stat_time< toDateTime(#{searchEndTime}) <![CDATA[ stat_time>= toDateTime(#{searchStartTime}) and stat_time< toDateTime(#{searchEndTime})
and app_id=toInt64(#{searchAppId}) and entrance_id=toInt64(#{searchEntranceId}) ]]> and app_id=toInt64(#{searchAppId}) ]]>
<if test="searchEntranceId !=null and searchEntranceId != ''">
<![CDATA[and entrance_id=toInt64(#{searchEntranceId}) ]]>
</if>
group by stat_time group by stat_time
order by stat_time order by stat_time
</select> </select>
@@ -58,7 +61,10 @@
select s_ip ipAddr, sum(c2s_byte_num + s2c_byte_num) byteNum, sum(c2s_pkt_num + s2c_pkt_num) pktNum, count(s_ip) logNum select s_ip ipAddr, sum(c2s_byte_num + s2c_byte_num) byteNum, sum(c2s_pkt_num + s2c_pkt_num) pktNum, count(s_ip) logNum
from tbs_ods_ntc_conn_record_log t where from tbs_ods_ntc_conn_record_log t where
<![CDATA[ found_time>= toDateTime(#{searchStartTime}) and found_time< toDateTime(#{searchEndTime}) <![CDATA[ found_time>= toDateTime(#{searchStartTime}) and found_time< toDateTime(#{searchEndTime})
and app_id=toInt64(#{searchAppId}) and entrance_id=toInt64(#{searchEntranceId}) ]]> and app_id=toInt64(#{searchAppId}) ]]>
<if test="searchEntranceId !=null and searchEntranceId != ''">
<![CDATA[and entrance_id=toInt64(#{searchEntranceId}) ]]>
</if>
group by s_ip group by s_ip
order by order by
<choose> <choose>

View File

@@ -425,8 +425,6 @@ public class DashboardService extends BaseService {
dateRangeList.add(calendar.getTime()); dateRangeList.add(calendar.getTime());
calendar.add(Calendar.MINUTE, Constants.TREND_TIME_INTERVAL); calendar.add(Calendar.MINUTE, Constants.TREND_TIME_INTERVAL);
} }
// 存放每个时间点的总数
Map<String, List<Long>> ipCountListMap = new HashMap<String, List<Long>>();
int index1 = 0; int index1 = 0;
int index2 = 0; int index2 = 0;
List sumList1 = new ArrayList(); List sumList1 = new ArrayList();
@@ -452,10 +450,7 @@ public class DashboardService extends BaseService {
} }
} }
} }
sumEnt1+=num1;
listEnt1.add(date.getTime());
listEnt1.add(num1);
sumList1.add(listEnt1);
for (int j = index2; j < entrance2.size(); j++) { for (int j = index2; j < entrance2.size(); j++) {
NtcEntranceReport ipInfo = entrance2.get(j); NtcEntranceReport ipInfo = entrance2.get(j);
if (ipInfo.getReportTime() != null) { if (ipInfo.getReportTime() != null) {
@@ -466,7 +461,16 @@ public class DashboardService extends BaseService {
break; break;
} }
} }
}
//最后一个时间点,全为0 直接跳过不存入列表
if(i+1==dateRangeList.size()&&num1.compareTo(0L)==0&&num2.compareTo(0L)==0){
break;
} }
sumEnt1+=num1;
listEnt1.add(date.getTime());
listEnt1.add(num1);
sumList1.add(listEnt1);
sumEnt2+=num2; sumEnt2+=num2;
listEnt2.add(date.getTime()); listEnt2.add(date.getTime());
listEnt2.add(num2); listEnt2.add(num2);
@@ -575,17 +579,18 @@ public class DashboardService extends BaseService {
ArrayList<TrafficIpActiveStatistic> ipInfoList = trafficIpActiveStatisticDao ArrayList<TrafficIpActiveStatistic> ipInfoList = trafficIpActiveStatisticDao
.ipActiveFiveMinute(ipStr.toString(), beginDate, endDate,entranceId); .ipActiveFiveMinute(ipStr.toString(), beginDate, endDate,entranceId);
// 存放每个IP每个时间点的总数 // 存放每个IP每个时间点的总数
Map<String, List> ipCountListMap = new HashMap<String, List>(); Map<String, List> ipCountListMap = new LinkedHashMap<String, List>();
//如果所有IP的最后一个点都为0删除
Boolean delLastFlag = true;
int index = 0; int index = 0;
for (int i = 0; i < dateRangeList.size(); i++) { for (int i = 0; i < dateRangeList.size(); i++) {
// 存放一个时间点中每个IP的总数 // 存放一个时间点中每个IP的总数
Map<String, Long> ipCountMap = new TreeMap<String, Long>(); Map<String, Long> ipCountMap = new LinkedHashMap<String, Long>();
Date date = dateRangeList.get(i); Date date = dateRangeList.get(i);
for (int j = index; j < ipInfoList.size(); j++) { for (int j = index; j < ipInfoList.size(); j++) {
TrafficIpActiveStatistic ipInfo = ipInfoList.get(j); TrafficIpActiveStatistic ipInfo = ipInfoList.get(j);
if (ipInfo.getStatTime() != null) { if (ipInfo.getStatTime() != null) {
if (ipInfo.getStatTime().compareTo(date) >= 0 && (i + 1 < dateRangeList.size() if (ipInfo.getStatTime().compareTo(date) >= 0 && (i + 1 < dateRangeList.size()?ipInfo.getStatTime().compareTo(dateRangeList.get(i + 1)) < 0:true)) {
&& ipInfo.getStatTime().compareTo(dateRangeList.get(i + 1)) < 0)) {
Long num = ipInfo.getCount(); Long num = ipInfo.getCount();
if (ipCountMap.containsKey(ipInfo.getIpAddr())) { if (ipCountMap.containsKey(ipInfo.getIpAddr())) {
num = num + ipCountMap.get(ipInfo.getIpAddr()); num = num + ipCountMap.get(ipInfo.getIpAddr());
@@ -601,7 +606,10 @@ public class DashboardService extends BaseService {
String ip = (String) map.get("ipAddr"); String ip = (String) map.get("ipAddr");
List sumList= new ArrayList(); List sumList= new ArrayList();
sumList.add(date.getTime()); sumList.add(date.getTime());
//最后一个时间点
if(i+1==dateRangeList.size()&&!StringUtil.isEmpty(ipCountMap.get(ip))){
delLastFlag = false ;
}
Long sum = 0l; Long sum = 0l;
if (ipCountMap.containsKey(ip)) { if (ipCountMap.containsKey(ip)) {
sum = ipCountMap.get(ip); sum = ipCountMap.get(ip);
@@ -628,6 +636,9 @@ public class DashboardService extends BaseService {
List<Long> list = (List) obj; List<Long> list = (List) obj;
total+=list.get(1); total+=list.get(1);
} }
if (delLastFlag) {
ipCountListMap.get(ip).remove(ipCountListMap.get(ip).size()-1);
}
ipTrafficMap.put("result", ipCountListMap.get(ip)); ipTrafficMap.put("result", ipCountListMap.get(ip));
ipTrafficMap.put("sum", total); ipTrafficMap.put("sum", total);
listMap.add(ipTrafficMap); listMap.add(ipTrafficMap);
@@ -1327,19 +1338,30 @@ public class DashboardService extends BaseService {
String key = "trans" + transType + "Type" + entranceId; String key = "trans" + transType + "Type" + entranceId;
listMap.get(key).add(tts); listMap.get(key).add(tts);
} }
//所有的数据最后一个点都为0删除
Boolean delLastFlag = true;
Set<Entry<String, ArrayList<TrafficTransStatistic>>> entrySet = listMap.entrySet(); Set<Entry<String, ArrayList<TrafficTransStatistic>>> entrySet = listMap.entrySet();
for (Entry<String, ArrayList<TrafficTransStatistic>> entry : entrySet) { for (Entry<String, ArrayList<TrafficTransStatistic>> entry : entrySet) {
String key = entry.getKey(); String key = entry.getKey();
String entranceId = key.substring(key.length() - 1); String entranceId = key.substring(key.length() - 1);
ArrayList<TrafficTransStatistic> value = entry.getValue(); ArrayList<TrafficTransStatistic> value = entry.getValue();
resultMap.put(key, getNewData(dateRangeList,value,searchQuotaType)); resultMap.put(key, getNewData(dateRangeList,value,searchQuotaType,delLastFlag));
}
//删除最后一个点
if (delLastFlag) {
Iterator iterator = resultMap.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next()+"";
List list = (List) resultMap.get(key).get("result");
list.remove(list.size()-1);
}
} }
} }
} }
return resultMap; return resultMap;
} }
private Map getNewData(List<Date> dateRangeList,List<TrafficTransStatistic> bandwidthList,String searchQuotaType) { private Map getNewData(List<Date> dateRangeList,List<TrafficTransStatistic> bandwidthList,String searchQuotaType,Boolean delLastFlag) {
Map restMap = new HashMap(); Map restMap = new HashMap();
List<List> restList = new ArrayList<List>(); List<List> restList = new ArrayList<List>();
int index = 0; int index = 0;
@@ -1370,6 +1392,10 @@ public class DashboardService extends BaseService {
countList.add(num); countList.add(num);
sum+=num; sum+=num;
restList.add(countList); restList.add(countList);
//最后一个时间点
if(i+1==dateRangeList.size()&&num!=0l){
delLastFlag = false ;
}
} }
restMap.put("sum", sum); restMap.put("sum", sum);
restMap.put("result", restList); restMap.put("result", restList);
@@ -1432,8 +1458,6 @@ public class DashboardService extends BaseService {
dateRangeList.add(calendar.getTime()); dateRangeList.add(calendar.getTime());
calendar.add(Calendar.MINUTE, Constants.TREND_TIME_INTERVAL); calendar.add(Calendar.MINUTE, Constants.TREND_TIME_INTERVAL);
} }
// 存放每个时间点的总数
Map<String, List<Long>> ipCountListMap = new HashMap<String, List<Long>>();
int index = 0; int index = 0;
List resultList = new ArrayList(); List resultList = new ArrayList();
Long total = 0L; Long total = 0L;
@@ -1453,6 +1477,11 @@ public class DashboardService extends BaseService {
} }
} }
} }
//最后一个时间点值为0不记录
if(i+1==dateRangeList.size()&&num.compareTo(0L)==0){
break;
}
sumList.add(date.getTime()); sumList.add(date.getTime());
sumList.add(num); sumList.add(num);
resultList.add(sumList); resultList.add(sumList);
@@ -1495,7 +1524,8 @@ public class DashboardService extends BaseService {
// if (portListTop10 != null && portListTop10.size() > 0) { // if (portListTop10 != null && portListTop10.size() > 0) {
// StringBuilder portStr = new StringBuilder(); // StringBuilder portStr = new StringBuilder();
if (!StringUtil.isEmpty(portStr)) { if (!StringUtil.isEmpty(portStr)) {
// 如果所有IP在最后一个时间点的count都为0则移除最后一个点 // 如果所有Port在最后一个时间点的count都为0则移除最后一个点
Boolean delLastFlag = true;
// 开始划分时间段,间隔5分钟 // 开始划分时间段,间隔5分钟
List<Date> dateRangeList = new ArrayList<Date>(); List<Date> dateRangeList = new ArrayList<Date>();
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
@@ -1507,12 +1537,12 @@ public class DashboardService extends BaseService {
ArrayList<TrafficPortActiveStatistic> portInfoList = trafficPortActiveStatisticDao ArrayList<TrafficPortActiveStatistic> portInfoList = trafficPortActiveStatisticDao
.findTrafficPortActive(beginDate, endDate, portStr.toString()); .findTrafficPortActive(beginDate, endDate, portStr.toString());
// 存放每个IP每个时间点的总数 // 存放每个Port,每个时间点的总数
Map<String, List<Long>> portCountListMap = new HashMap<String, List<Long>>(); Map<String, List<Long>> portCountListMap = new LinkedHashMap<String, List<Long>>();
int index = 0; int index = 0;
for (int i = 0; i < dateRangeList.size(); i++) { for (int i = 0; i < dateRangeList.size(); i++) {
// 存放一个时间点中每个IP的总数 // 存放一个时间点中每个IP的总数
Map<String, Long> portCountMap = new HashMap<String, Long>(); Map<String, Long> portCountMap = new LinkedHashMap<String, Long>();
Date date = dateRangeList.get(i); Date date = dateRangeList.get(i);
for (int j = index; j < portInfoList.size(); j++) { for (int j = index; j < portInfoList.size(); j++) {
TrafficPortActiveStatistic portInfo = portInfoList.get(j); TrafficPortActiveStatistic portInfo = portInfoList.get(j);
@@ -1539,6 +1569,10 @@ public class DashboardService extends BaseService {
sum = portCountMap.get(port); sum = portCountMap.get(port);
} }
sumList.add(sum); sumList.add(sum);
//最后一个时间点
if(i+1==dateRangeList.size()&&sum.compareTo(0L)>0){
delLastFlag = false ;
}
if (portCountListMap.containsKey(port)) { if (portCountListMap.containsKey(port)) {
List list = portCountListMap.get(port); List list = portCountListMap.get(port);
list.add(sumList); list.add(sumList);
@@ -1559,6 +1593,10 @@ public class DashboardService extends BaseService {
sum = portCountMap.get(port); sum = portCountMap.get(port);
} }
sumList.add(sum); sumList.add(sum);
//最后一个时间点
if(i+1==dateRangeList.size()&&sum.compareTo(0L)>0){
delLastFlag = false ;
}
if (portCountListMap.containsKey(port)) { if (portCountListMap.containsKey(port)) {
List list = portCountListMap.get(port); List list = portCountListMap.get(port);
list.add(sumList); list.add(sumList);
@@ -1580,6 +1618,10 @@ public class DashboardService extends BaseService {
List<Long> list = (List) obj; List<Long> list = (List) obj;
total+=list.get(1); total+=list.get(1);
} }
if (delLastFlag) {
List list = portCountListMap.get(port);
list.remove(list.size()-1);
}
trafficPortActiveMap.put("port", port); trafficPortActiveMap.put("port", port);
trafficPortActiveMap.put("result", portCountListMap.get(port)); trafficPortActiveMap.put("result", portCountListMap.get(port));
trafficPortActiveMap.put("sum", total); trafficPortActiveMap.put("sum", total);
@@ -1620,9 +1662,8 @@ public class DashboardService extends BaseService {
List sumList = new ArrayList(); List sumList = new ArrayList();
Long totalNum = 0L; Long totalNum = 0L;
for (int i = 0; i < dateRangeList.size(); i++) { for (int i = 0; i < dateRangeList.size(); i++) {
//存放一个时间点中每个IP的总数 //存放一个时间点的总数
List tempList = new ArrayList(); List tempList = new ArrayList();
Map<String, Long> ipCountMap = new HashMap<String, Long>();
Date date = dateRangeList.get(i); Date date = dateRangeList.get(i);
Long sum = 0l; Long sum = 0l;
for (int j = index; j < list.size(); j++) { for (int j = index; j < list.size(); j++) {
@@ -1636,6 +1677,11 @@ public class DashboardService extends BaseService {
} }
} }
} }
//最后一个时间点值为0不记录
if(i+1==dateRangeList.size()&&sum.compareTo(0L)==0){
break;
}
totalNum+=sum; totalNum+=sum;
tempList.add(date.getTime()); tempList.add(date.getTime());
tempList.add(sum); tempList.add(sum);
@@ -1662,8 +1708,6 @@ public class DashboardService extends BaseService {
dateRangeList.add(calendar.getTime()); dateRangeList.add(calendar.getTime());
calendar.add(Calendar.MINUTE, 1); calendar.add(Calendar.MINUTE, 1);
} }
// 存放每个时间点的总数
Map<String, List<Long>> ipCountListMap = new HashMap<String, List<Long>>();
int index = 0; int index = 0;
List resultSipList = new ArrayList(); List resultSipList = new ArrayList();
List resultDipList = new ArrayList(); List resultDipList = new ArrayList();
@@ -1688,6 +1732,11 @@ public class DashboardService extends BaseService {
} }
} }
} }
//最后一个时间点
if(i+1==dateRangeList.size()&&sipNum.compareTo(0L)==0&&dipNum.compareTo(0L)==0){
break;
}
sipList.add(date.getTime()); sipList.add(date.getTime());
sipList.add(sipNum); sipList.add(sipNum);
resultSipList.add(sipList); resultSipList.add(sipList);

View File

@@ -239,8 +239,10 @@
<t:field fieldType="String" srcName="originalDestIp" dstName="original_dest_ip" isRequired="true"/> <t:field fieldType="String" srcName="originalDestIp" dstName="original_dest_ip" isRequired="true"/>
<t:field fieldType="String" srcName="originalDestPort" dstName="original_dest_port" isRequired="true"/> <t:field fieldType="String" srcName="originalDestPort" dstName="original_dest_port" isRequired="true"/>
<t:field fieldType="String" srcName="originalProtocol" dstName="original_protocol" isRequired="true"/> <t:field fieldType="String" srcName="originalProtocol" dstName="original_protocol" isRequired="true"/>
<t:field fieldType="String" srcName="translatedDestIp" dstName="translated_dest_ip" isRequired="true"/> <!-- <t:field fieldType="String" srcName="translatedDestIp" dstName="translated_dest_ip" isRequired="true"/> -->
<t:field fieldType="String" srcName="translatedDestPort" dstName="translated_dest_port" isRequired="true"/> <t:field fieldType="String" srcName="translatedDestPort" dstName="translated_dest_port" isRequired="true"/>
<t:field fieldType="String" srcName="translatedUserType" dstName="translated_user_type" isRequired="true"/>
<t:field fieldType="String" srcName="translatedUserId" dstName="translated_user_id" isRequired="true"/>
<t:field fieldType="Number" srcName="doLog" dstName="do_log" isRequired="true" regexp="[0|1|2]"/> <t:field fieldType="Number" srcName="doLog" dstName="do_log" isRequired="true" regexp="[0|1|2]"/>
<t:field fieldType="Number" srcName="isValid" dstName="is_valid" isRequired="true" regexp="[1]"/> <t:field fieldType="Number" srcName="isValid" dstName="is_valid" isRequired="true" regexp="[1]"/>
<t:field fieldType="String" srcName="effectiveRange" dstName="effective_range" isRequired="true"/> <t:field fieldType="String" srcName="effectiveRange" dstName="effective_range" isRequired="true"/>

View File

@@ -184,7 +184,7 @@
<p:maatType service="836"> <p:maatType service="836">
<p:expressions> <p:expressions>
<p:keyExpression>EFFECTIVE_RULE;:;{un_maat_table_name};,;[cfg_id]</p:keyExpression> <p:keyExpression>EFFECTIVE_RULE;:;{un_maat_table_name};,;[cfg_id]</p:keyExpression>
<p:valueExpression>[cfg_id];\t;[original_addr_type];\t;[original_dest_ip];\t;[original_dest_port];\t;[original_protocol];\t;[translated_dest_ip];\t;[translated_dest_port];\t;[do_log];\t;[action];\t;[service];\t;[is_valid];\t;[effective_range];\t;[op_time];&amp;nbsp;0;\n</p:valueExpression> <p:valueExpression>[cfg_id];\t;[original_addr_type];\t;[original_dest_ip];\t;[original_dest_port];\t;[original_protocol];\t;[translated_dest_port];\t;[translated_user_type];\t;[translated_user_id];\t;[do_log];\t;[action];\t;[service];\t;[is_valid];\t;[effective_range];\t;[op_time];&amp;nbsp;0;\n</p:valueExpression>
</p:expressions> </p:expressions>
<p:sequences> <p:sequences>
<p:operation>1</p:operation> <p:operation>1</p:operation>