summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhangdongxu <[email protected]>2019-01-10 18:14:50 +0800
committerzhangdongxu <[email protected]>2019-01-10 18:14:50 +0800
commit2b97ffc53eb7758b46d7f14bb1cc698fb597ea31 (patch)
treed3c99f0b6e52fa82811b5acf1ca3c3a71c49f773
parent99d3b87e1a037f949430d97e37a96b46136adcba (diff)
1、回调类配置 :IP复用 Dnat业务 添加、删除字段;
2、日志:APP详情接口,添加appId不能为空验证、修改出入口查询条件相关sql; 3、流量统计所有趋势图,过滤最后一个全为0的点
-rw-r--r--src/main/java/com/nis/web/controller/restful/DashboardServiceController.java3
-rw-r--r--src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml12
-rw-r--r--src/main/java/com/nis/web/service/restful/DashboardService.java95
-rw-r--r--src/main/resources/commonSources/applicationConfig-parser.xml4
-rw-r--r--src/main/resources/maatXml/applicationConfig-maatRedis.xml2
5 files changed, 88 insertions, 28 deletions
diff --git a/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java b/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java
index b1b5179..72d616d 100644
--- a/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java
+++ b/src/main/java/com/nis/web/controller/restful/DashboardServiceController.java
@@ -1221,6 +1221,9 @@ public class DashboardServiceController extends BaseRestController {
throw new RestServiceException("searchStartTime和searchEndTime参数必须同时填写",
RestBusinessCode.config_integrity_error.getValue());
}
+ if (StringUtil.isEmpty(entity.getSearchAppId())) {
+ throw new RestServiceException("searchAppId参数不能为空", RestBusinessCode.missing_args.getValue());
+ }
//验证AppId和EntranceId必须是数值
checkNumericCondition(entity.getSearchAppId(),"searchAppId");
checkNumericCondition(entity.getSearchEntranceId(),"searchEntranceId");
diff --git a/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml b/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml
index 9c2f382..fbc7cb1 100644
--- a/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml
+++ b/src/main/java/com/nis/web/dao/dashboard/TrafficAppStatisticDao.xml
@@ -39,7 +39,7 @@
#{item}
</foreach>
</if>
- <if test="entranceId !=null">
+ <if test="entranceId !=null and searchEntranceId != ''">
and entrance_id=#{entranceId}
</if>
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 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})
- 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
order by stat_time
</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
from tbs_ods_ntc_conn_record_log t where
<![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
order by
<choose>
diff --git a/src/main/java/com/nis/web/service/restful/DashboardService.java b/src/main/java/com/nis/web/service/restful/DashboardService.java
index 7a636ab..cf33f1c 100644
--- a/src/main/java/com/nis/web/service/restful/DashboardService.java
+++ b/src/main/java/com/nis/web/service/restful/DashboardService.java
@@ -425,8 +425,6 @@ public class DashboardService extends BaseService {
dateRangeList.add(calendar.getTime());
calendar.add(Calendar.MINUTE, Constants.TREND_TIME_INTERVAL);
}
- // 存放每个时间点的总数
- Map<String, List<Long>> ipCountListMap = new HashMap<String, List<Long>>();
int index1 = 0;
int index2 = 0;
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++) {
NtcEntranceReport ipInfo = entrance2.get(j);
if (ipInfo.getReportTime() != null) {
@@ -466,7 +461,16 @@ public class DashboardService extends BaseService {
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;
listEnt2.add(date.getTime());
listEnt2.add(num2);
@@ -575,17 +579,18 @@ public class DashboardService extends BaseService {
ArrayList<TrafficIpActiveStatistic> ipInfoList = trafficIpActiveStatisticDao
.ipActiveFiveMinute(ipStr.toString(), beginDate, endDate,entranceId);
// 存放每个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;
for (int i = 0; i < dateRangeList.size(); i++) {
// 存放一个时间点中每个IP的总数
- Map<String, Long> ipCountMap = new TreeMap<String, Long>();
+ Map<String, Long> ipCountMap = new LinkedHashMap<String, Long>();
Date date = dateRangeList.get(i);
for (int j = index; j < ipInfoList.size(); j++) {
TrafficIpActiveStatistic ipInfo = ipInfoList.get(j);
if (ipInfo.getStatTime() != null) {
- if (ipInfo.getStatTime().compareTo(date) >= 0 && (i + 1 < dateRangeList.size()
- && ipInfo.getStatTime().compareTo(dateRangeList.get(i + 1)) < 0)) {
+ if (ipInfo.getStatTime().compareTo(date) >= 0 && (i + 1 < dateRangeList.size()?ipInfo.getStatTime().compareTo(dateRangeList.get(i + 1)) < 0:true)) {
Long num = ipInfo.getCount();
if (ipCountMap.containsKey(ipInfo.getIpAddr())) {
num = num + ipCountMap.get(ipInfo.getIpAddr());
@@ -601,7 +606,10 @@ public class DashboardService extends BaseService {
String ip = (String) map.get("ipAddr");
List sumList= new ArrayList();
sumList.add(date.getTime());
-
+ //最后一个时间点
+ if(i+1==dateRangeList.size()&&!StringUtil.isEmpty(ipCountMap.get(ip))){
+ delLastFlag = false ;
+ }
Long sum = 0l;
if (ipCountMap.containsKey(ip)) {
sum = ipCountMap.get(ip);
@@ -628,6 +636,9 @@ public class DashboardService extends BaseService {
List<Long> list = (List) obj;
total+=list.get(1);
}
+ if (delLastFlag) {
+ ipCountListMap.get(ip).remove(ipCountListMap.get(ip).size()-1);
+ }
ipTrafficMap.put("result", ipCountListMap.get(ip));
ipTrafficMap.put("sum", total);
listMap.add(ipTrafficMap);
@@ -1327,19 +1338,30 @@ public class DashboardService extends BaseService {
String key = "trans" + transType + "Type" + entranceId;
listMap.get(key).add(tts);
}
+ //所有的数据最后一个点都为0,删除
+ Boolean delLastFlag = true;
Set<Entry<String, ArrayList<TrafficTransStatistic>>> entrySet = listMap.entrySet();
for (Entry<String, ArrayList<TrafficTransStatistic>> entry : entrySet) {
String key = entry.getKey();
String entranceId = key.substring(key.length() - 1);
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;
}
- 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();
List<List> restList = new ArrayList<List>();
int index = 0;
@@ -1370,6 +1392,10 @@ public class DashboardService extends BaseService {
countList.add(num);
sum+=num;
restList.add(countList);
+ //最后一个时间点
+ if(i+1==dateRangeList.size()&&num!=0l){
+ delLastFlag = false ;
+ }
}
restMap.put("sum", sum);
restMap.put("result", restList);
@@ -1432,8 +1458,6 @@ public class DashboardService extends BaseService {
dateRangeList.add(calendar.getTime());
calendar.add(Calendar.MINUTE, Constants.TREND_TIME_INTERVAL);
}
- // 存放每个时间点的总数
- Map<String, List<Long>> ipCountListMap = new HashMap<String, List<Long>>();
int index = 0;
List resultList = new ArrayList();
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(num);
resultList.add(sumList);
@@ -1495,7 +1524,8 @@ public class DashboardService extends BaseService {
// if (portListTop10 != null && portListTop10.size() > 0) {
// StringBuilder portStr = new StringBuilder();
if (!StringUtil.isEmpty(portStr)) {
- // 如果所有IP在最后一个时间点的count都为0,则移除最后一个点
+ // 如果所有Port在最后一个时间点的count都为0,则移除最后一个点
+ Boolean delLastFlag = true;
// 开始划分时间段,间隔5分钟
List<Date> dateRangeList = new ArrayList<Date>();
Calendar calendar = Calendar.getInstance();
@@ -1507,12 +1537,12 @@ public class DashboardService extends BaseService {
ArrayList<TrafficPortActiveStatistic> portInfoList = trafficPortActiveStatisticDao
.findTrafficPortActive(beginDate, endDate, portStr.toString());
- // 存放每个IP,每个时间点的总数
- Map<String, List<Long>> portCountListMap = new HashMap<String, List<Long>>();
+ // 存放每个Port,每个时间点的总数
+ Map<String, List<Long>> portCountListMap = new LinkedHashMap<String, List<Long>>();
int index = 0;
for (int i = 0; i < dateRangeList.size(); i++) {
// 存放一个时间点中每个IP的总数
- Map<String, Long> portCountMap = new HashMap<String, Long>();
+ Map<String, Long> portCountMap = new LinkedHashMap<String, Long>();
Date date = dateRangeList.get(i);
for (int j = index; j < portInfoList.size(); j++) {
TrafficPortActiveStatistic portInfo = portInfoList.get(j);
@@ -1539,6 +1569,10 @@ public class DashboardService extends BaseService {
sum = portCountMap.get(port);
}
sumList.add(sum);
+ //最后一个时间点
+ if(i+1==dateRangeList.size()&&sum.compareTo(0L)>0){
+ delLastFlag = false ;
+ }
if (portCountListMap.containsKey(port)) {
List list = portCountListMap.get(port);
list.add(sumList);
@@ -1559,6 +1593,10 @@ public class DashboardService extends BaseService {
sum = portCountMap.get(port);
}
sumList.add(sum);
+ //最后一个时间点
+ if(i+1==dateRangeList.size()&&sum.compareTo(0L)>0){
+ delLastFlag = false ;
+ }
if (portCountListMap.containsKey(port)) {
List list = portCountListMap.get(port);
list.add(sumList);
@@ -1580,6 +1618,10 @@ public class DashboardService extends BaseService {
List<Long> list = (List) obj;
total+=list.get(1);
}
+ if (delLastFlag) {
+ List list = portCountListMap.get(port);
+ list.remove(list.size()-1);
+ }
trafficPortActiveMap.put("port", port);
trafficPortActiveMap.put("result", portCountListMap.get(port));
trafficPortActiveMap.put("sum", total);
@@ -1620,9 +1662,8 @@ public class DashboardService extends BaseService {
List sumList = new ArrayList();
Long totalNum = 0L;
for (int i = 0; i < dateRangeList.size(); i++) {
- //存放一个时间点中每个IP的总数
+ //存放一个时间点的总数
List tempList = new ArrayList();
- Map<String, Long> ipCountMap = new HashMap<String, Long>();
Date date = dateRangeList.get(i);
Long sum = 0l;
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;
tempList.add(date.getTime());
tempList.add(sum);
@@ -1662,8 +1708,6 @@ public class DashboardService extends BaseService {
dateRangeList.add(calendar.getTime());
calendar.add(Calendar.MINUTE, 1);
}
- // 存放每个时间点的总数
- Map<String, List<Long>> ipCountListMap = new HashMap<String, List<Long>>();
int index = 0;
List resultSipList = 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(sipNum);
resultSipList.add(sipList);
diff --git a/src/main/resources/commonSources/applicationConfig-parser.xml b/src/main/resources/commonSources/applicationConfig-parser.xml
index 15f1436..36af760 100644
--- a/src/main/resources/commonSources/applicationConfig-parser.xml
+++ b/src/main/resources/commonSources/applicationConfig-parser.xml
@@ -239,8 +239,10 @@
<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="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="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="isValid" dstName="is_valid" isRequired="true" regexp="[1]"/>
<t:field fieldType="String" srcName="effectiveRange" dstName="effective_range" isRequired="true"/>
diff --git a/src/main/resources/maatXml/applicationConfig-maatRedis.xml b/src/main/resources/maatXml/applicationConfig-maatRedis.xml
index 3c72a35..77864e1 100644
--- a/src/main/resources/maatXml/applicationConfig-maatRedis.xml
+++ b/src/main/resources/maatXml/applicationConfig-maatRedis.xml
@@ -184,7 +184,7 @@
<p:maatType service="836">
<p:expressions>
<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:sequences>
<p:operation>1</p:operation>