协议,app详情增加时间条件查询,

This commit is contained in:
zhanghongqing
2018-12-08 06:27:21 +08:00
parent d1d15575ef
commit 455e4a38a9
6 changed files with 42 additions and 14 deletions

View File

@@ -166,12 +166,12 @@ public class DashboardServiceController extends BaseRestController {
*/
@RequestMapping(value="trafficProtocolList", method = RequestMethod.GET)
@ApiOperation(value = "协议统计占比与报表", httpMethod = "GET", notes = "对应协议统计详情占比与报表")
public Map<String,?> trafficProtocolList(Model model, HttpServletRequest request, HttpServletResponse response){
public Map<String,?> trafficProtocolList(String searchFoundStartTime,String searchFoundEndTime,Model model, HttpServletRequest request, HttpServletResponse response){
long start = System.currentTimeMillis();
AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null);
List<HashMap> list = new ArrayList<HashMap>();
try {
List<Map> ipActiveList = dashboardService.getProtocolList();
List<Map> ipActiveList = dashboardService.getProtocolList(searchFoundStartTime,searchFoundEndTime);
if (ipActiveList!=null&&ipActiveList.size() > 0) {
String jsonString = JsonMapper.toJsonString(ipActiveList);
list = (java.util.List<HashMap>) JsonMapper.fromJsonList(jsonString,HashMap.class);
@@ -289,12 +289,12 @@ public class DashboardServiceController extends BaseRestController {
*/
@RequestMapping(value="trafficAppList", method = RequestMethod.GET)
@ApiOperation(value = "App统计占比与报表", httpMethod = "GET", notes = "对应App统计详情占比与报表")
public Map<String,?> trafficAppList(Model model, HttpServletRequest request, HttpServletResponse response){
public Map<String,?> trafficAppList(String searchFoundStartTime,String searchFoundEndTime,Model model, HttpServletRequest request, HttpServletResponse response){
long start = System.currentTimeMillis();
AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null);
List<HashMap> list = new ArrayList<HashMap>();
try {
List<Map> appList = dashboardService.getAppList();
List<Map> appList = dashboardService.getAppList(searchFoundStartTime,searchFoundEndTime);
if (appList!=null&&appList.size() > 0) {
String jsonString = JsonMapper.toJsonString(appList);
list = (java.util.List<HashMap>) JsonMapper.fromJsonList(jsonString,HashMap.class);

View File

@@ -13,5 +13,5 @@ public interface TrafficAppStatisticDao {
TrafficAppStatistic getMaxStatTime();
List<Map> appChart(@Param("statTime")Date statTime);
List<Map> getAppList(@Param("statTime")Date statTime);
List<Map> getAppList(@Param("statTime")Date statTime,@Param("beginTime")String beginTime,@Param("endTime")String endTime);
}

View File

@@ -36,11 +36,25 @@
SELECT x.appType ,SUM(x.link_num) AS linkNum,SUM(x.pkt) AS packets,
(SUM(x.byte)/1024/1024/1024) AS GByte FROM
( SELECT app_type appType,SUM(link_num) link_num,SUM(c2s_byte_len+s2c_byte_len) byte,SUM(c2s_pkt_num+s2c_pkt_num) pkt FROM traffic_app_statistic
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_app_statistic WHERE entrance_id=1 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=1
where
<if test="beginTime==null or endTime==null">
stat_time > DATE_SUB((SELECT stat_time FROM traffic_app_statistic WHERE entrance_id=1 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR)
</if>
<if test="beginTime!=null and endTime!=null">
stat_time >= #{beginTime} and stat_time &lt;= #{endTime}
</if>
and entrance_id=1
GROUP BY appType
UNION ALL
SELECT app_type appType,SUM(link_num) link_num,SUM(c2s_byte_len+s2c_byte_len) byte,SUM(c2s_pkt_num+s2c_pkt_num) pkt FROM traffic_app_statistic
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_app_statistic WHERE entrance_id=2 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=2
where
<if test="beginTime==null or endTime==null">
stat_time > DATE_SUB((SELECT stat_time FROM traffic_app_statistic WHERE entrance_id=2 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR)
</if>
<if test="beginTime!=null and endTime!=null">
stat_time >= #{beginTime} and stat_time &lt;= #{endTime}
</if>
and entrance_id=2
GROUP BY appType
) x
GROUP BY x.appType ) p

View File

@@ -13,5 +13,5 @@ public interface TrafficProtocolStatisticDao {
TrafficProtocolStatistic getMaxStatTime();
List<Map> protocolChart(@Param("statTime")Date statTime);
List<Map> getProtocolList(@Param("statTime")Date statTime);
List<Map> getProtocolList(@Param("statTime")Date statTime,@Param("beginTime")String beginTime,@Param("endTime")String endTime);
}

View File

@@ -37,11 +37,25 @@
SELECT x.protoType ,SUM(x.link_num) AS linkNum,SUM(x.pkt) AS packets,
(SUM(x.byte)/1024/1024/1024) AS GByte FROM
( SELECT proto_type protoType,SUM(link_num) link_num,SUM(c2s_byte_len+s2c_byte_len) byte,SUM(c2s_pkt_num+s2c_pkt_num) pkt FROM traffic_protocol_statistic
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_protocol_statistic WHERE entrance_id=1 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=1
where
<if test="beginTime==null or endTime==null">
stat_time > DATE_SUB((SELECT stat_time FROM traffic_protocol_statistic WHERE entrance_id=1 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR)
</if>
<if test="beginTime!=null and endTime!=null">
stat_time >= #{beginTime} and stat_time &lt;= #{endTime}
</if>
and entrance_id=1
GROUP BY protoType
UNION ALL
SELECT proto_type protoType,SUM(link_num) link_num,SUM(c2s_byte_len+s2c_byte_len) byte,SUM(c2s_pkt_num+s2c_pkt_num) pkt FROM traffic_protocol_statistic
where stat_time > DATE_SUB((SELECT stat_time FROM traffic_protocol_statistic WHERE entrance_id=2 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR) and entrance_id=2
where
<if test="beginTime==null or endTime==null">
stat_time > DATE_SUB((SELECT stat_time FROM traffic_protocol_statistic WHERE entrance_id=2 ORDER BY stat_time DESC LIMIT 0,1),INTERVAL 1 HOUR)
</if>
<if test="beginTime!=null and endTime!=null">
stat_time >= #{beginTime} and stat_time &lt;= #{endTime}
</if>
and entrance_id=2
GROUP BY protoType
) x
GROUP BY x.protoType ) p

View File

@@ -306,12 +306,12 @@ public class DashboardService extends BaseService{
* 协议统计报表
* @return
*/
public List<Map> getProtocolList(){
public List<Map> getProtocolList(String startTime,String endTime){
TrafficProtocolStatistic maxStatTime = trafficProtocolStatisticDao.getMaxStatTime();
List<Map> list=new ArrayList<Map>();
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
Date statTime = maxStatTime.getStatTime();
list = trafficProtocolStatisticDao.getProtocolList(statTime);
list = trafficProtocolStatisticDao.getProtocolList(statTime,startTime,endTime);
}
return list;
}
@@ -339,12 +339,12 @@ public class DashboardService extends BaseService{
* App统计报表
* @return
*/
public List<Map> getAppList(){
public List<Map> getAppList(String startTime,String endTime){
TrafficAppStatistic maxStatTime = trafficAppStatisticDao.getMaxStatTime();
List<Map> list=new ArrayList<Map>();
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
Date statTime = maxStatTime.getStatTime();
list = trafficAppStatisticDao.getAppList(statTime);
list = trafficAppStatisticDao.getAppList(statTime,startTime,endTime);
}
return list;
}