流量统计活跃端口增加上个时间段统计
This commit is contained in:
@@ -73,17 +73,11 @@ public class DashboardServiceController extends BaseRestController {
|
||||
AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null);
|
||||
List<Map> list = new ArrayList<Map>();
|
||||
try {
|
||||
List<TrafficPortActiveStatistic> resultList = dashboardService.getPortActiveList();
|
||||
|
||||
if (resultList!=null&&resultList.size() > 0) {
|
||||
for (TrafficPortActiveStatistic port : resultList) {
|
||||
Map map = new HashMap();
|
||||
|
||||
map.put("port", port.getPort());
|
||||
map.put("sum", port.getSum());
|
||||
list.add(map);
|
||||
}
|
||||
List<Map> resultList = dashboardService.getPortActiveList();
|
||||
if(resultList!=null&&resultList.size()>0) {
|
||||
list=resultList;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
auditLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
|
||||
@@ -3,10 +3,13 @@ package com.nis.web.dao.dashboard;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.nis.domain.restful.dashboard.TrafficPortActiveStatistic;
|
||||
import com.nis.web.dao.MyBatisDao;
|
||||
@MyBatisDao
|
||||
public interface TrafficPortActiveStatisticDao {
|
||||
|
||||
List<TrafficPortActiveStatistic> getPortActiveList();
|
||||
TrafficPortActiveStatistic getPortActiveOld(@Param("port")Integer port);
|
||||
}
|
||||
@@ -7,10 +7,16 @@
|
||||
<result column="sum" jdbcType="BIGINT" property="sum" />
|
||||
<result column="stat_time" jdbcType="TIMESTAMP" property="statTime" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 获取当前时间五分钟数据 -->
|
||||
<select id="getPortActiveList" resultMap="BaseResultMap">
|
||||
SELECT port ,SUM(sum) sum 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
|
||||
</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>
|
||||
@@ -74,10 +74,32 @@ public class DashboardService extends BaseService{
|
||||
|
||||
return totalReportList;
|
||||
}
|
||||
public List<TrafficPortActiveStatistic> getPortActiveList(){
|
||||
/**
|
||||
* 当前时间五分钟数据
|
||||
* @return
|
||||
*/
|
||||
public List<Map> getPortActiveList(){
|
||||
List<Map> list = new ArrayList<Map>();
|
||||
List<TrafficPortActiveStatistic> portActiveList = trafficPortActiveStatisticDao.getPortActiveList();
|
||||
|
||||
return portActiveList;
|
||||
//上个时间五分钟数据
|
||||
if(portActiveList!=null&&portActiveList.size()>0) {
|
||||
for (TrafficPortActiveStatistic port : portActiveList) {
|
||||
if(port.getPort()!=null) {
|
||||
Map map = new HashMap();
|
||||
|
||||
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