流量统计活跃端口增加上个时间段统计
This commit is contained in:
@@ -73,17 +73,11 @@ public class DashboardServiceController extends BaseRestController {
|
|||||||
AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null);
|
AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null);
|
||||||
List<Map> list = new ArrayList<Map>();
|
List<Map> list = new ArrayList<Map>();
|
||||||
try {
|
try {
|
||||||
List<TrafficPortActiveStatistic> resultList = dashboardService.getPortActiveList();
|
List<Map> resultList = dashboardService.getPortActiveList();
|
||||||
|
|
||||||
if(resultList!=null&&resultList.size()>0) {
|
if(resultList!=null&&resultList.size()>0) {
|
||||||
for (TrafficPortActiveStatistic port : resultList) {
|
list=resultList;
|
||||||
Map map = new HashMap();
|
}
|
||||||
|
|
||||||
map.put("port", port.getPort());
|
|
||||||
map.put("sum", port.getSum());
|
|
||||||
list.add(map);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
auditLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
auditLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||||
|
|||||||
@@ -3,10 +3,13 @@ package com.nis.web.dao.dashboard;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import com.nis.domain.restful.dashboard.TrafficPortActiveStatistic;
|
import com.nis.domain.restful.dashboard.TrafficPortActiveStatistic;
|
||||||
import com.nis.web.dao.MyBatisDao;
|
import com.nis.web.dao.MyBatisDao;
|
||||||
@MyBatisDao
|
@MyBatisDao
|
||||||
public interface TrafficPortActiveStatisticDao {
|
public interface TrafficPortActiveStatisticDao {
|
||||||
|
|
||||||
List<TrafficPortActiveStatistic> getPortActiveList();
|
List<TrafficPortActiveStatistic> getPortActiveList();
|
||||||
|
TrafficPortActiveStatistic getPortActiveOld(@Param("port")Integer port);
|
||||||
}
|
}
|
||||||
@@ -7,10 +7,16 @@
|
|||||||
<result column="sum" jdbcType="BIGINT" property="sum" />
|
<result column="sum" jdbcType="BIGINT" property="sum" />
|
||||||
<result column="stat_time" jdbcType="TIMESTAMP" property="statTime" />
|
<result column="stat_time" jdbcType="TIMESTAMP" property="statTime" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
<!-- 获取当前时间五分钟数据 -->
|
||||||
<select id="getPortActiveList" resultMap="BaseResultMap">
|
<select id="getPortActiveList" resultMap="BaseResultMap">
|
||||||
SELECT port ,SUM(sum) sum from galaxy.traffic_port_active_statistic
|
SELECT port ,SUM(sum) sum from galaxy.traffic_port_active_statistic
|
||||||
WHERE stat_time = (SELECT MAX(stat_time) FROM galaxy.traffic_port_active_statistic)
|
WHERE stat_time = (SELECT MAX(stat_time) FROM galaxy.traffic_port_active_statistic)
|
||||||
GROUP BY port order by sum desc limit 0,10
|
GROUP BY port order by sum desc limit 0,10
|
||||||
</select>
|
</select>
|
||||||
|
<!-- 获取上个时间段的数据 -->
|
||||||
|
<select id="getPortActiveOld" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||||
|
SELECT SUM(sum) sum from galaxy.traffic_port_active_statistic
|
||||||
|
WHERE port=#{port} and stat_time = DATE_SUB((SELECT MAX(stat_time) FROM galaxy.traffic_port_active_statistic),INTERVAL 5 MINUTE)
|
||||||
|
GROUP BY port ORDER BY sum DESC limit 0,10
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -74,10 +74,32 @@ public class DashboardService extends BaseService{
|
|||||||
|
|
||||||
return totalReportList;
|
return totalReportList;
|
||||||
}
|
}
|
||||||
public List<TrafficPortActiveStatistic> getPortActiveList(){
|
/**
|
||||||
|
* 当前时间五分钟数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Map> getPortActiveList(){
|
||||||
|
List<Map> list = new ArrayList<Map>();
|
||||||
List<TrafficPortActiveStatistic> portActiveList = trafficPortActiveStatisticDao.getPortActiveList();
|
List<TrafficPortActiveStatistic> portActiveList = trafficPortActiveStatisticDao.getPortActiveList();
|
||||||
|
//上个时间五分钟数据
|
||||||
|
if(portActiveList!=null&&portActiveList.size()>0) {
|
||||||
|
for (TrafficPortActiveStatistic port : portActiveList) {
|
||||||
|
if(port.getPort()!=null) {
|
||||||
|
Map map = new HashMap();
|
||||||
|
|
||||||
return portActiveList;
|
map.put("port", port.getPort());
|
||||||
|
map.put("sum", port.getSum());
|
||||||
|
TrafficPortActiveStatistic portActiveOld = trafficPortActiveStatisticDao.getPortActiveOld(port.getPort());
|
||||||
|
if(portActiveOld!=null&&portActiveOld.getSum()!=null){
|
||||||
|
map.put("preSum",portActiveOld.getSum());
|
||||||
|
}else{
|
||||||
|
map.put("preSum",0);
|
||||||
|
}
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user