更改带宽查询表

This commit is contained in:
zhanghongqing
2018-11-14 18:36:16 +08:00
parent eb57cd7a88
commit ad41ff768f
3 changed files with 12 additions and 14 deletions

View File

@@ -13,6 +13,6 @@ public interface NtcTotalReportDao {
NtcTotalReport getMaxReportTime(); NtcTotalReport getMaxReportTime();
Map getMaxRecvTime(); Map getMaxRecvTime();
List<Map> getTotalReportList(@Param("reportTime") Date reportTime); List<Map> getTotalReportList(@Param("reportTime") Date reportTime);
List<Map> getNetFlowPortInfoNew(@Param("recvTime") Date recvTime); List<Map> getNetFlowPortInfoNew(@Param("statTime") Date recvTime);
List<Map> getNetFlowPortInfoOld(@Param("recvTime") Date recvTime); // List<Map> getNetFlowPortInfoOld(@Param("recvTime") Date recvTime);
} }

View File

@@ -22,7 +22,7 @@
</select> </select>
<!-- 获取带宽最近时间并且有效 --> <!-- 获取带宽最近时间并且有效 -->
<select id="getMaxRecvTime" resultType="java.util.HashMap"> <select id="getMaxRecvTime" resultType="java.util.HashMap">
SELECT MAX(RECV_TIME) recvTime FROM galaxy.TRAFFIC_NETFLOW_PORT_INFO SELECT MAX(stat_time) recvTime FROM galaxy.traffic_trans_statistic
</select> </select>
<select id="getTotalReportList" resultType="java.util.HashMap"> <select id="getTotalReportList" resultType="java.util.HashMap">
SELECT SUM(reject_num) rejectNum,SUM(monitor_num) monitorNum,SUM(c2s_pkt_num) c2sPktNum,SUM(s2c_pkt_num) s2cPktNum,SUM(c2s_byte_len) c2sByteLen,SUM(s2c_byte_len) s2cByteLen,SUM(new_uni_conn_num) newUniConnNum,SUM(live_conn_num) liveConnNum, SELECT SUM(reject_num) rejectNum,SUM(monitor_num) monitorNum,SUM(c2s_pkt_num) c2sPktNum,SUM(s2c_pkt_num) s2cPktNum,SUM(c2s_byte_len) c2sByteLen,SUM(s2c_byte_len) s2cByteLen,SUM(new_uni_conn_num) newUniConnNum,SUM(live_conn_num) liveConnNum,
@@ -30,12 +30,12 @@
where report_time = #{reportTime} where report_time = #{reportTime}
</select> </select>
<select id="getNetFlowPortInfoNew" resultType="java.util.HashMap"> <select id="getNetFlowPortInfoNew" resultType="java.util.HashMap">
SELECT IFNULL(SUM(INOCTETS),0) inoctets ,IFNULL(SUM(OUTOCTETS),0) outoctets FROM galaxy.TRAFFIC_NETFLOW_PORT_INFO SELECT IFNULL(SUM(c2s_byte_len),0) inoctets ,IFNULL(SUM(s2c_byte_len),0) outoctets FROM galaxy.traffic_trans_statistic
where RECV_TIME = #{recvTime} where stat_time = #{statTime}
</select> </select>
<!-- 获取上个时间段的数据 --> <!-- 获取上个时间段的数据 -->
<select id="getNetFlowPortInfoOld" resultType="java.util.HashMap"> <!-- <select id="getNetFlowPortInfoOld" resultType="java.util.HashMap">
SELECT IFNULL(SUM(INOCTETS),0) inoctets ,IFNULL(SUM(OUTOCTETS),0) outoctets FROM galaxy.TRAFFIC_NETFLOW_PORT_INFO SELECT IFNULL(SUM(INOCTETS),0) inoctets ,IFNULL(SUM(OUTOCTETS),0) outoctets FROM galaxy.TRAFFIC_NETFLOW_PORT_INFO
where RECV_TIME = DATE_SUB(#{recvTime},INTERVAL 5 MINUTE) where RECV_TIME = DATE_SUB(#{recvTime},INTERVAL 5 MINUTE)
</select> </select> -->
</mapper> </mapper>

View File

@@ -58,23 +58,21 @@ public class DashboardService extends BaseService{
} }
Map maxRecvtTime = ntcTotalReportDao.getMaxRecvTime(); Map maxRecvtTime = ntcTotalReportDao.getMaxRecvTime();
List<Map> newData = new ArrayList<Map>(); List<Map> newData = new ArrayList<Map>();
List<Map> oldData = new ArrayList<Map>(); // List<Map> oldData = new ArrayList<Map>();
if(maxRecvtTime!=null&&maxRecvtTime.get("recvTime")!=null) { if(maxRecvtTime!=null&&maxRecvtTime.get("recvTime")!=null) {
Date recvTime = (Date) maxRecvtTime.get("recvTime"); Date recvTime = (Date) maxRecvtTime.get("recvTime");
newData = ntcTotalReportDao.getNetFlowPortInfoNew(recvTime); newData = ntcTotalReportDao.getNetFlowPortInfoNew(recvTime);
oldData = ntcTotalReportDao.getNetFlowPortInfoOld(recvTime); // oldData = ntcTotalReportDao.getNetFlowPortInfoOld(recvTime);
} }
//统计带宽的流入流出 单位 五分钟 的 byte //统计带宽的流入流出 单位 五分钟 的 byte
Double inoctets=0d; Double inoctets=0d;
Double outoctets=0d; Double outoctets=0d;
if(newData!=null&&newData.size()>0&&oldData!=null&&oldData.size()>0&&newData.get(0)!=null&&oldData.get(0)!=null){ if(newData!=null&&newData.size()>0&&newData.get(0)!=null){
Double newInoctets=Double.parseDouble(newData.get(0).get("inoctets").toString()) ; Double newInoctets=Double.parseDouble(newData.get(0).get("inoctets").toString()) ;
Double newOutoctets=Double.parseDouble(newData.get(0).get("outoctets").toString()) ; Double newOutoctets=Double.parseDouble(newData.get(0).get("outoctets").toString()) ;
Double oldInoctets=Double.parseDouble(oldData.get(0).get("inoctets").toString());
Double oldOutoctets=Double.parseDouble(oldData.get(0).get("outoctets").toString());
//结果为当前五分钟减去上个五分钟 //结果为当前五分钟减去上个五分钟
inoctets=newInoctets-oldInoctets; inoctets=newInoctets;
outoctets=newOutoctets-oldOutoctets; outoctets=newOutoctets;
if(inoctets<0||outoctets<0){ if(inoctets<0||outoctets<0){
inoctets=0d; inoctets=0d;
outoctets=0d; outoctets=0d;