2018-07-13 19:39:04 +08:00
|
|
|
|
package com.nis.web.service.restful;
|
|
|
|
|
|
|
2018-12-01 13:19:30 +06:00
|
|
|
|
import com.beust.jcommander.internal.Maps;
|
|
|
|
|
|
import com.nis.domain.restful.dashboard.*;
|
|
|
|
|
|
import com.nis.web.dao.dashboard.*;
|
|
|
|
|
|
import com.nis.web.service.BaseService;
|
|
|
|
|
|
import com.zdjizhi.utils.StringUtil;
|
2018-07-13 19:39:04 +08:00
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
2018-12-01 13:19:30 +06:00
|
|
|
|
import java.util.*;
|
2018-07-13 19:39:04 +08:00
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
|
public class DashboardService extends BaseService{
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
public TrafficIpActiveStatisticDao trafficIpActiveStatisticDao;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
public TrafficProtocolStatisticDao trafficProtocolStatisticDao;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
public TrafficAppStatisticDao trafficAppStatisticDao;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
public TrafficUaStatisticDao trafficUaStatisticDao;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
public TrafficHttpStatisticDao trafficHttpStatisticDao;
|
2018-09-21 20:56:01 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
public NtcTotalReportDao ntcTotalReportDao;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
public TrafficPortActiveStatisticDao trafficPortActiveStatisticDao;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 流量统计 数据显示
|
2018-12-04 11:59:01 +08:00
|
|
|
|
* info:先查询最近时间,根据时间条件查询数据 效率提高
|
2018-09-21 20:56:01 +08:00
|
|
|
|
*/
|
|
|
|
|
|
public List<Map> getTotalReportList(){
|
2018-10-26 14:41:27 +08:00
|
|
|
|
List<Map> totalReportList =new ArrayList<Map>();
|
2018-12-04 11:59:01 +08:00
|
|
|
|
List<Map> newData = new ArrayList<Map>();
|
|
|
|
|
|
// 流量统计阻断丢弃回流等数据显示最近时间
|
2018-10-26 14:41:27 +08:00
|
|
|
|
NtcTotalReport maxReportTime = ntcTotalReportDao.getMaxReportTime();
|
|
|
|
|
|
if(maxReportTime!=null&&maxReportTime.getReportTime()!=null) {
|
|
|
|
|
|
Date reportTime = maxReportTime.getReportTime();
|
2018-12-04 11:59:01 +08:00
|
|
|
|
totalReportList = ntcTotalReportDao.getTotalReportList(reportTime);// 返回阻断,监测等結果
|
2018-10-26 14:41:27 +08:00
|
|
|
|
}
|
2018-12-04 11:59:01 +08:00
|
|
|
|
Map maxRecvtTime = ntcTotalReportDao.getMaxStatTime();
|
|
|
|
|
|
if(maxRecvtTime!=null && maxRecvtTime.get("statTime")!=null) {
|
2018-11-16 11:08:50 +08:00
|
|
|
|
Date recvTime = (Date) maxRecvtTime.get("statTime");
|
2018-10-26 14:41:27 +08:00
|
|
|
|
newData = ntcTotalReportDao.getNetFlowPortInfoNew(recvTime);
|
|
|
|
|
|
}
|
2018-12-04 11:59:01 +08:00
|
|
|
|
// 统计带宽的流入流出 单位 五分钟 的 byte
|
2018-12-01 13:19:30 +06:00
|
|
|
|
if(StringUtil.isNotEmpty(newData)){
|
|
|
|
|
|
Double inoctets = Double.parseDouble(newData.get(0).get("inoctets").toString()) ;
|
|
|
|
|
|
Double outoctets = Double.parseDouble(newData.get(0).get("outoctets").toString()) ;
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtil.isEmpty(totalReportList)) {
|
|
|
|
|
|
Map valueMap = Maps.newHashMap();
|
|
|
|
|
|
valueMap.put("inoctets", inoctets);
|
|
|
|
|
|
valueMap.put("outoctets", outoctets);
|
|
|
|
|
|
totalReportList.add(valueMap);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
totalReportList.get(0).put("inoctets", inoctets);
|
|
|
|
|
|
totalReportList.get(0).put("outoctets", outoctets);
|
2018-09-26 16:29:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-09-21 20:56:01 +08:00
|
|
|
|
return totalReportList;
|
|
|
|
|
|
}
|
2018-10-23 11:05:35 +08:00
|
|
|
|
/**
|
2018-12-04 11:59:01 +08:00
|
|
|
|
* 根据ip46,协议tcp,udp查询带宽
|
|
|
|
|
|
* @param addrType
|
|
|
|
|
|
* @param transType
|
2018-10-23 11:05:35 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-12-04 11:59:01 +08:00
|
|
|
|
public List<HashMap> getBandwidthTrans(String addrType,Integer transType) {
|
|
|
|
|
|
ArrayList<HashMap> listMap=new ArrayList<HashMap>();
|
|
|
|
|
|
List<TrafficTransStatistic> bandwidthList = new ArrayList<TrafficTransStatistic>();
|
|
|
|
|
|
Map maxStatTime = ntcTotalReportDao.getMaxStatTime();
|
|
|
|
|
|
if(maxStatTime!=null && maxStatTime.get("statTime")!=null) {
|
|
|
|
|
|
Date stat = (Date) maxStatTime.get("statTime");
|
|
|
|
|
|
HashMap m = new HashMap();
|
|
|
|
|
|
bandwidthList=ntcTotalReportDao.getBandwidthTrans(stat, addrType, transType);
|
|
|
|
|
|
List timeList = new ArrayList();
|
|
|
|
|
|
List linkList = new ArrayList();
|
|
|
|
|
|
List gbpsList = new ArrayList();
|
|
|
|
|
|
List ppsList = new ArrayList();
|
|
|
|
|
|
if(bandwidthList!=null&&bandwidthList.size()>0) {
|
|
|
|
|
|
for (TrafficTransStatistic tt : bandwidthList) {
|
|
|
|
|
|
if(tt.getTime()!=null) {
|
|
|
|
|
|
timeList.add(tt.getTime());
|
|
|
|
|
|
if(tt.getLinkNum()!=null) {
|
|
|
|
|
|
linkList.add(tt.getLinkNum());
|
|
|
|
|
|
}
|
|
|
|
|
|
if(tt.getPps()!=null) {
|
|
|
|
|
|
ppsList.add(tt.getPps());
|
|
|
|
|
|
}
|
|
|
|
|
|
if(tt.getGbps()!=null) {
|
|
|
|
|
|
gbpsList.add(tt.getGbps());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
m.put("linkNum",linkList);
|
|
|
|
|
|
m.put("gbps",linkList);
|
|
|
|
|
|
m.put("pps",linkList);
|
|
|
|
|
|
m.put("statTime",timeList);
|
|
|
|
|
|
listMap.add(m);
|
|
|
|
|
|
}
|
|
|
|
|
|
return listMap;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 最近活跃端口时间五分钟数据
|
|
|
|
|
|
* @return List
|
|
|
|
|
|
*/
|
2018-10-23 11:05:35 +08:00
|
|
|
|
public List<Map> getPortActiveList(){
|
|
|
|
|
|
List<Map> list = new ArrayList<Map>();
|
2018-10-26 14:41:27 +08:00
|
|
|
|
TrafficPortActiveStatistic maxStatTime = trafficPortActiveStatisticDao.getMaxStatTime();
|
|
|
|
|
|
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
|
|
|
|
|
|
Date statTime = maxStatTime.getStatTime();
|
|
|
|
|
|
List<TrafficPortActiveStatistic> portActiveList = trafficPortActiveStatisticDao.getPortActiveList(statTime);
|
|
|
|
|
|
//上个时间五分钟数据
|
|
|
|
|
|
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(),statTime);
|
|
|
|
|
|
if(portActiveOld!=null&&portActiveOld.getSum()!=null){
|
|
|
|
|
|
map.put("preSum",portActiveOld.getSum());
|
|
|
|
|
|
}else{
|
|
|
|
|
|
map.put("preSum",0);
|
|
|
|
|
|
}
|
|
|
|
|
|
list.add(map);
|
2018-10-23 11:05:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return list;
|
2018-09-21 20:56:01 +08:00
|
|
|
|
}
|
2018-07-13 19:39:04 +08:00
|
|
|
|
|
2018-12-04 11:59:01 +08:00
|
|
|
|
|
2018-07-13 19:39:04 +08:00
|
|
|
|
/**
|
2018-12-04 11:59:01 +08:00
|
|
|
|
* 活跃IP最近五分钟数据TOP10
|
2018-07-13 19:39:04 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-10-12 17:45:45 +08:00
|
|
|
|
public List<HashMap> ipActiveFiveMinute(){
|
2018-10-26 14:41:27 +08:00
|
|
|
|
TrafficIpActiveStatistic maxStatTime = trafficIpActiveStatisticDao.getMaxStatTime();
|
2018-10-12 17:45:45 +08:00
|
|
|
|
ArrayList<HashMap> listMap=new ArrayList<HashMap>();
|
2018-10-26 14:41:27 +08:00
|
|
|
|
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
|
|
|
|
|
|
Date statTime = maxStatTime.getStatTime();
|
2018-12-04 11:59:01 +08:00
|
|
|
|
// 查询最近五分钟TOP10
|
2018-10-26 14:41:27 +08:00
|
|
|
|
ArrayList<LinkedHashMap> list = trafficIpActiveStatisticDao.ipActiveChart(statTime);
|
|
|
|
|
|
if(list!=null&&list.size()>0) {
|
|
|
|
|
|
for (LinkedHashMap map : list) {
|
|
|
|
|
|
HashMap m = new HashMap();
|
|
|
|
|
|
if(map.get("ipAddr")!=null) {
|
|
|
|
|
|
String ipAddr = (String) map.get("ipAddr");
|
|
|
|
|
|
m.put("ipAddr", ipAddr);
|
2018-12-04 11:59:01 +08:00
|
|
|
|
// 根据五分钟TOP10IP,查询TOP10中每个IP最近一小时的变化
|
|
|
|
|
|
ArrayList<TrafficIpActiveStatistic> ipList = trafficIpActiveStatisticDao.ipActiveFiveMinute(ipAddr,statTime);
|
2018-10-26 14:41:27 +08:00
|
|
|
|
List linkList = new ArrayList();
|
|
|
|
|
|
List timeList = new ArrayList();
|
|
|
|
|
|
if(ipList!=null&&ipList.size()>0) {
|
|
|
|
|
|
for (TrafficIpActiveStatistic ip : ipList) {
|
|
|
|
|
|
if(ip.getLinkNum()!=null&&ip.getTime()!=null) {
|
|
|
|
|
|
linkList.add(ip.getLinkNum());
|
|
|
|
|
|
timeList.add(ip.getTime());
|
|
|
|
|
|
}
|
2018-10-12 17:45:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-26 14:41:27 +08:00
|
|
|
|
m.put("linkNum",linkList);
|
|
|
|
|
|
m.put("statTime",timeList);
|
|
|
|
|
|
listMap.add(m);
|
2018-10-12 17:45:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return listMap;
|
|
|
|
|
|
}
|
2018-12-04 11:59:01 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 根据活跃IP最近五分钟TOP10,查询近1小时最大值
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-10-12 17:45:45 +08:00
|
|
|
|
public List<HashMap> ipActiveOneHour(){
|
2018-10-26 14:41:27 +08:00
|
|
|
|
TrafficIpActiveStatistic maxStatTime = trafficIpActiveStatisticDao.getMaxStatTime();
|
2018-10-12 17:45:45 +08:00
|
|
|
|
ArrayList<HashMap> listMap=new ArrayList<HashMap>();
|
2018-10-26 14:41:27 +08:00
|
|
|
|
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
|
|
|
|
|
|
Date statTime = maxStatTime.getStatTime();
|
|
|
|
|
|
ArrayList<LinkedHashMap> list = trafficIpActiveStatisticDao.ipActiveChart(statTime);
|
|
|
|
|
|
if(list!=null&&list.size()>0) {
|
|
|
|
|
|
for (LinkedHashMap map : list) {
|
|
|
|
|
|
if(map.get("ipAddr")!=null) {
|
|
|
|
|
|
String ipAddr = (String) map.get("ipAddr");
|
|
|
|
|
|
ArrayList<HashMap> iplList = trafficIpActiveStatisticDao.ipActiveOneHour(ipAddr,statTime);
|
|
|
|
|
|
listMap.add(iplList.get(0));
|
|
|
|
|
|
}
|
2018-10-12 17:45:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return listMap;
|
|
|
|
|
|
}
|
2018-10-26 14:41:27 +08:00
|
|
|
|
@SuppressWarnings("rawtypes")
|
2018-07-13 19:39:04 +08:00
|
|
|
|
public List<LinkedHashMap> ipActiveChart(){
|
2018-10-26 14:41:27 +08:00
|
|
|
|
TrafficIpActiveStatistic maxStatTime = trafficIpActiveStatisticDao.getMaxStatTime();
|
|
|
|
|
|
ArrayList<LinkedHashMap> list = new ArrayList<>();
|
|
|
|
|
|
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
|
|
|
|
|
|
Date statTime = maxStatTime.getStatTime();
|
|
|
|
|
|
list = trafficIpActiveStatisticDao.ipActiveChart(statTime);
|
|
|
|
|
|
if(list!=null&&list.size()>0) {
|
|
|
|
|
|
for (LinkedHashMap map : list) {
|
|
|
|
|
|
if(map.get("ipAddr")!=null) {
|
|
|
|
|
|
Map m = new LinkedHashMap();
|
|
|
|
|
|
map.put("pktNum",0);
|
|
|
|
|
|
map.put("byteLen",0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-13 19:39:04 +08:00
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Map> protocolChart() {
|
2018-10-26 14:41:27 +08:00
|
|
|
|
TrafficProtocolStatistic maxStatTime = trafficProtocolStatisticDao.getMaxStatTime();
|
|
|
|
|
|
List<Map> list=new ArrayList<Map>();
|
|
|
|
|
|
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
|
|
|
|
|
|
Date statTime = maxStatTime.getStatTime();
|
|
|
|
|
|
list = trafficProtocolStatisticDao.protocolChart(statTime);
|
|
|
|
|
|
//当不查询包,字节时 设为0
|
|
|
|
|
|
if(list!=null&&list.size()>0) {
|
|
|
|
|
|
Map map = new HashMap();
|
|
|
|
|
|
map.put("pktNum",0);
|
|
|
|
|
|
map.put("byteLen",0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-13 19:39:04 +08:00
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Map> appChart() {
|
2018-10-26 14:41:27 +08:00
|
|
|
|
List<Map> list=new ArrayList<Map>();
|
|
|
|
|
|
TrafficAppStatistic maxStatTime = trafficAppStatisticDao.getMaxStatTime();
|
|
|
|
|
|
if(maxStatTime!=null&&maxStatTime.getStatTime()!=null) {
|
|
|
|
|
|
Date statTime = maxStatTime.getStatTime();
|
|
|
|
|
|
list = trafficAppStatisticDao.appChart(statTime);
|
|
|
|
|
|
//当不查询包,字节时 设为0
|
|
|
|
|
|
if(list!=null&&list.size()>0) {
|
|
|
|
|
|
Map map = new HashMap();
|
|
|
|
|
|
map.put("pktNum",0);
|
|
|
|
|
|
map.put("byteLen",0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-13 19:39:04 +08:00
|
|
|
|
return list;
|
|
|
|
|
|
}
|
2018-07-23 17:44:18 +08:00
|
|
|
|
|
|
|
|
|
|
// 操作系统列表 排名TOP10
|
2018-07-13 19:39:04 +08:00
|
|
|
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
|
|
|
|
public List<Map> systemList(){
|
|
|
|
|
|
List<Map> result = new ArrayList<Map>();
|
2018-10-26 14:41:27 +08:00
|
|
|
|
TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime();
|
|
|
|
|
|
if(maxStatTime!=null) {
|
|
|
|
|
|
Date statTime = maxStatTime.getStatTime();
|
|
|
|
|
|
List<TrafficUaStatistic> list = trafficUaStatisticDao.systemList(statTime);
|
2018-12-01 16:45:46 +08:00
|
|
|
|
Long preCount=0l;
|
2018-10-26 14:41:27 +08:00
|
|
|
|
for (TrafficUaStatistic ua : list) {
|
|
|
|
|
|
Map map = new HashMap();
|
|
|
|
|
|
map.put("osType",ua.getOsType());
|
|
|
|
|
|
map.put("count",ua.getCount());
|
|
|
|
|
|
map.put("pktNum",0);
|
|
|
|
|
|
map.put("byteLen",0);
|
|
|
|
|
|
preCount = trafficUaStatisticDao.preSystemListCount(ua.getOsType(),statTime);//上个时段的量 用于与现在对比
|
|
|
|
|
|
if(preCount!=null){
|
|
|
|
|
|
map.put("preCount",preCount);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
map.put("preCount",0);
|
|
|
|
|
|
}
|
|
|
|
|
|
result.add(map);
|
|
|
|
|
|
}
|
2018-07-13 19:39:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
public List<Map> getBrowserBySystem(Integer osType ){
|
2018-10-26 14:41:27 +08:00
|
|
|
|
List<Map> list = new ArrayList<Map>();
|
|
|
|
|
|
TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime();
|
|
|
|
|
|
if(maxStatTime!=null) {
|
|
|
|
|
|
Date statTime = maxStatTime.getStatTime();
|
|
|
|
|
|
list = trafficUaStatisticDao.getBrowserBySystem(osType,statTime);
|
|
|
|
|
|
List bsType = new ArrayList();
|
|
|
|
|
|
//查新固定操系统下的除了TOP10以外的others
|
|
|
|
|
|
if(list!=null&& list.size()>0){
|
|
|
|
|
|
for (Map map : list) {
|
|
|
|
|
|
bsType.add(map.get("bsType"));
|
|
|
|
|
|
}
|
2018-11-16 16:28:14 +08:00
|
|
|
|
if(list.size()>10) {
|
|
|
|
|
|
Map others = new HashMap();
|
|
|
|
|
|
others = trafficUaStatisticDao.systemOthers(bsType,osType,statTime);
|
|
|
|
|
|
if(others!=null&&others.size()>0){
|
|
|
|
|
|
others.put("bsType", "-1");
|
|
|
|
|
|
list.add(others);
|
|
|
|
|
|
}
|
2018-10-26 14:41:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-23 17:44:18 +08:00
|
|
|
|
}
|
2018-07-13 19:39:04 +08:00
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Map> browserList() {
|
|
|
|
|
|
List<Map> result = new ArrayList<Map>();
|
2018-10-26 14:41:27 +08:00
|
|
|
|
TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime();
|
|
|
|
|
|
if(maxStatTime!=null) {
|
|
|
|
|
|
Date statTime = maxStatTime.getStatTime();
|
|
|
|
|
|
List<TrafficUaStatistic> list = trafficUaStatisticDao.browserList(statTime);
|
2018-12-01 16:45:46 +08:00
|
|
|
|
Long preCount=0l;
|
2018-10-26 14:41:27 +08:00
|
|
|
|
if(list!=null&&list.size()>0){
|
|
|
|
|
|
for (TrafficUaStatistic ua : list) {
|
|
|
|
|
|
Map map = new HashMap();
|
|
|
|
|
|
map.put("bsType",ua.getBsType());
|
|
|
|
|
|
map.put("count",ua.getCount());
|
|
|
|
|
|
map.put("pktNum",0);
|
|
|
|
|
|
map.put("byteLen",0);
|
|
|
|
|
|
preCount = trafficUaStatisticDao.preBrowserListCount(ua.getBsType(),statTime);//上个时段的量 用于与现在对比
|
|
|
|
|
|
if(preCount!=null){
|
|
|
|
|
|
map.put("preCount",preCount);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
map.put("preCount",0);
|
|
|
|
|
|
}
|
|
|
|
|
|
result.add(map);
|
|
|
|
|
|
}
|
2018-09-21 20:56:01 +08:00
|
|
|
|
}
|
2018-07-23 17:44:18 +08:00
|
|
|
|
}
|
2018-07-13 19:39:04 +08:00
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
public List<Map> getSystemBybrowser(Integer bsType ){
|
2018-10-26 14:41:27 +08:00
|
|
|
|
List<Map> list = new ArrayList<Map>();
|
|
|
|
|
|
TrafficUaStatistic maxStatTime = trafficUaStatisticDao.getMaxStatTime();
|
|
|
|
|
|
if(maxStatTime!=null) {
|
|
|
|
|
|
Date statTime = maxStatTime.getStatTime();
|
|
|
|
|
|
list = trafficUaStatisticDao.getSystemBybrowser(bsType,statTime);
|
|
|
|
|
|
List osType = new ArrayList();
|
|
|
|
|
|
//查询固定操系统下的除了TOP10以外的others
|
|
|
|
|
|
if(list!=null&& list.size()>0){
|
|
|
|
|
|
for (Map map : list) {
|
|
|
|
|
|
osType.add(map.get("osType"));
|
|
|
|
|
|
}
|
2018-11-16 16:28:14 +08:00
|
|
|
|
if(list.size()>10) {
|
|
|
|
|
|
Map others = new HashMap();
|
|
|
|
|
|
others = trafficUaStatisticDao.browserOthers(osType,bsType,statTime);
|
|
|
|
|
|
if(others!=null&&others.size()>0){
|
|
|
|
|
|
others.put("osType", "-1");
|
|
|
|
|
|
list.add(others);
|
|
|
|
|
|
}
|
2018-10-26 14:41:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-23 17:44:18 +08:00
|
|
|
|
}
|
2018-07-13 19:39:04 +08:00
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
public List<Map> websiteList() {
|
|
|
|
|
|
List<Map> result = new ArrayList<Map>();
|
2018-10-26 14:41:27 +08:00
|
|
|
|
TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime();
|
|
|
|
|
|
if(maxStatTime!=null) {
|
|
|
|
|
|
List<TrafficHttpStatistic> list = trafficHttpStatisticDao.websiteList(maxStatTime.getStatTime());
|
2018-12-01 16:45:46 +08:00
|
|
|
|
Long preCount=0l;
|
2018-10-26 14:41:27 +08:00
|
|
|
|
if(list!=null&&list.size()>0){
|
|
|
|
|
|
for (TrafficHttpStatistic website : list) {
|
|
|
|
|
|
Map map = new HashMap();
|
|
|
|
|
|
map.put("webId",website.getWebId());
|
|
|
|
|
|
map.put("count",website.getCount());
|
|
|
|
|
|
map.put("pktNum",0);
|
|
|
|
|
|
map.put("byteLen",0);
|
|
|
|
|
|
preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWebId(),maxStatTime.getStatTime());//上个时段的量 用于与现在对比
|
|
|
|
|
|
if(preCount!=null){
|
|
|
|
|
|
map.put("preCount",preCount);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
map.put("preCount",0);
|
|
|
|
|
|
}
|
|
|
|
|
|
result.add(map);
|
2018-09-21 20:56:01 +08:00
|
|
|
|
}
|
2018-10-26 14:41:27 +08:00
|
|
|
|
}
|
2018-07-13 19:39:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
2018-09-21 20:56:01 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 根据网站服务查询子域名
|
|
|
|
|
|
* @param websiteServiceId
|
|
|
|
|
|
* @return list
|
|
|
|
|
|
*/
|
|
|
|
|
|
public List<Map> getDomainByWebsiteServiceId(Integer websiteServiceId ){
|
2018-10-26 14:41:27 +08:00
|
|
|
|
List<Map> list = new ArrayList<Map>();
|
|
|
|
|
|
TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime();
|
|
|
|
|
|
if(maxStatTime!=null) {
|
|
|
|
|
|
Date statTime = maxStatTime.getStatTime();
|
|
|
|
|
|
list = trafficHttpStatisticDao.getDomainByWebsiteServiceId(websiteServiceId,statTime);
|
|
|
|
|
|
List webIdList = new ArrayList();
|
|
|
|
|
|
//查询固定网站下的域名除了TOP10以外的others域名
|
|
|
|
|
|
if(list!=null&& list.size()>0){
|
|
|
|
|
|
for (Map map : list) {
|
|
|
|
|
|
webIdList.add(map.get("webId"));
|
|
|
|
|
|
}
|
2018-11-16 16:28:14 +08:00
|
|
|
|
if(list.size()>10) {
|
|
|
|
|
|
Map others = new HashMap();
|
|
|
|
|
|
others = trafficHttpStatisticDao.websiteDomainOthers(webIdList,websiteServiceId,statTime);
|
|
|
|
|
|
if(others!=null&&others.size()>0){
|
|
|
|
|
|
others.put("webId", "-1");
|
|
|
|
|
|
list.add(others);
|
|
|
|
|
|
}
|
2018-10-26 14:41:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-23 17:44:18 +08:00
|
|
|
|
}
|
2018-07-13 19:39:04 +08:00
|
|
|
|
return list;
|
|
|
|
|
|
}
|
2018-09-21 20:56:01 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
获取网站列表
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
|
public List<Map> getDomainByWebsiteList(){
|
|
|
|
|
|
List<Map> result = new ArrayList<Map>();
|
2018-10-26 14:41:27 +08:00
|
|
|
|
TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime();
|
|
|
|
|
|
if(maxStatTime!=null) {
|
|
|
|
|
|
Date statTime = maxStatTime.getStatTime();
|
|
|
|
|
|
List<TrafficHttpStatistic> websiteList = trafficHttpStatisticDao.getDomainByWebsiteList(statTime);
|
|
|
|
|
|
if(websiteList!=null&&websiteList.size()>0){
|
2018-12-01 16:45:46 +08:00
|
|
|
|
Long preCount=0l;
|
2018-10-26 14:41:27 +08:00
|
|
|
|
for (TrafficHttpStatistic website : websiteList) {
|
|
|
|
|
|
Map map = new HashMap();
|
|
|
|
|
|
map.put("websiteServiceId",website.getWesiteServiceId());
|
|
|
|
|
|
map.put("count",website.getCount());
|
|
|
|
|
|
map.put("pktNum",0);
|
|
|
|
|
|
map.put("byteLen",0);
|
|
|
|
|
|
preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWesiteServiceId(),statTime);//上个时段的量 用于与现在对比
|
|
|
|
|
|
if(preCount!=null){
|
|
|
|
|
|
map.put("preCount",preCount);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
map.put("preCount",0);
|
|
|
|
|
|
}
|
|
|
|
|
|
result.add(map);
|
2018-09-21 20:56:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*主题网站分类,域名
|
|
|
|
|
|
*
|
|
|
|
|
|
* **/
|
|
|
|
|
|
public List<Map> getTopicAndDomainList(){
|
2018-10-26 14:41:27 +08:00
|
|
|
|
List<Map> topicList = new ArrayList<Map>();
|
|
|
|
|
|
TrafficHttpStatistic maxStatTime = trafficHttpStatisticDao.getMaxStatTime();
|
|
|
|
|
|
if(maxStatTime!=null) {
|
|
|
|
|
|
Date statTime = maxStatTime.getStatTime();
|
|
|
|
|
|
//按照主题分类 获得主题
|
|
|
|
|
|
topicList = trafficHttpStatisticDao.getDomainByTopicList(statTime);
|
|
|
|
|
|
if(topicList!=null&&topicList.size()>0){
|
|
|
|
|
|
for (Map m : topicList) {
|
|
|
|
|
|
List<Map> domainList= new ArrayList<Map>();
|
|
|
|
|
|
if(m!=null&&m.get("topicId")!=null){
|
|
|
|
|
|
domainList = trafficHttpStatisticDao.getDomainByTopicId(m.get("topicId"),statTime);
|
|
|
|
|
|
m.put("domainData", domainList);
|
|
|
|
|
|
}
|
2018-09-21 20:56:01 +08:00
|
|
|
|
}
|
2018-10-26 14:41:27 +08:00
|
|
|
|
}
|
2018-09-21 20:56:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
return topicList;
|
|
|
|
|
|
}
|
2018-07-13 19:39:04 +08:00
|
|
|
|
}
|