This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
k18-ntcs-web-argus-service/src/main/java/com/nis/web/service/restful/DashboardService.java

260 lines
8.0 KiB
Java
Raw Normal View History

2018-07-13 19:39:04 +08:00
package com.nis.web.service.restful;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nis.domain.Page;
import com.nis.domain.restful.dashboard.TrafficHttpStatistic;
import com.nis.domain.restful.dashboard.TrafficIpActiveStatistic;
import com.nis.domain.restful.dashboard.TrafficPortActiveStatistic;
2018-07-13 19:39:04 +08:00
import com.nis.domain.restful.dashboard.TrafficUaStatistic;
import com.nis.web.dao.dashboard.NtcTotalReportDao;
2018-07-13 19:39:04 +08:00
import com.nis.web.dao.dashboard.TrafficAppStatisticDao;
import com.nis.web.dao.dashboard.TrafficHttpStatisticDao;
import com.nis.web.dao.dashboard.TrafficIpActiveStatisticDao;
import com.nis.web.dao.dashboard.TrafficPortActiveStatisticDao;
2018-07-13 19:39:04 +08:00
import com.nis.web.dao.dashboard.TrafficProtocolStatisticDao;
import com.nis.web.dao.dashboard.TrafficUaStatisticDao;
import com.nis.web.service.BaseService;
@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;
@Autowired
public NtcTotalReportDao ntcTotalReportDao;
@Autowired
public TrafficPortActiveStatisticDao trafficPortActiveStatisticDao;
/**
* 流量统计 数据显示
* @return Map
*/
public List<Map> getTotalReportList(){
List<Map> totalReportList = ntcTotalReportDao.getTotalReportList();
return totalReportList;
}
public List<TrafficPortActiveStatistic> getPortActiveList(){
List<TrafficPortActiveStatistic> portActiveList = trafficPortActiveStatisticDao.getPortActiveList();
return portActiveList;
}
2018-07-13 19:39:04 +08:00
/**
* 分页查询活跃IPtop100
* @return
*/
public Page<TrafficIpActiveStatistic> getList(Page<TrafficIpActiveStatistic> page,TrafficIpActiveStatistic entry){
// 设置分页参数
entry.setPage(page);
// 执行分页查询
page.setList(trafficIpActiveStatisticDao.getList(entry));
return page;
}
public List<LinkedHashMap> ipActiveChart(){
ArrayList<LinkedHashMap> list = trafficIpActiveStatisticDao.ipActiveChart();
return list;
}
public List<Map> protocolChart() {
List<Map> list = trafficProtocolStatisticDao.protocolChart();
return list;
}
public List<Map> appChart() {
List<Map> list = trafficAppStatisticDao.appChart();
return list;
}
// 操作系统列表 排名TOP10
2018-07-13 19:39:04 +08:00
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<Map> systemList(){
List<Map> result = new ArrayList<Map>();
List<TrafficUaStatistic> list = trafficUaStatisticDao.systemList();
Integer preCount=0;
2018-07-13 19:39:04 +08:00
for (TrafficUaStatistic ua : list) {
Map map = new HashMap();
map.put("osType",ua.getOsType());
map.put("count",ua.getCount());
map.put("pktNum",ua.getPktNum());
map.put("byteLen",ua.getByteLen());
preCount = trafficUaStatisticDao.preSystemListCount(ua.getOsType());//上个时段的量 用于与现在对比
if(preCount!=null){
map.put("preCount",preCount);
}else{
map.put("preCount",0);
}
2018-07-13 19:39:04 +08:00
result.add(map);
}
2018-07-13 19:39:04 +08:00
return result;
}
public List<Map> getBrowserBySystem(Integer osType ){
List<Map> list = trafficUaStatisticDao.getBrowserBySystem(osType);
List bsType = new ArrayList();
//查新固定操系统下的除了TOP10以外的others
if(list!=null&& list.size()>0){
for (Map map : list) {
bsType.add(map.get("bsType"));
}
Map others = new HashMap();
others = trafficUaStatisticDao.systemOthers(bsType,osType);
if(others!=null&&others.size()>0){
others.put("bsType", "-1");
list.add(others);
}
}
2018-07-13 19:39:04 +08:00
return list;
}
public List<Map> browserList() {
List<Map> result = new ArrayList<Map>();
List<TrafficUaStatistic> list = trafficUaStatisticDao.browserList();
Integer preCount=0;
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",ua.getPktNum());
map.put("byteLen",ua.getByteLen());
preCount = trafficUaStatisticDao.preBrowserListCount(ua.getBsType());//上个时段的量 用于与现在对比
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> getSystemBybrowser(Integer bsType ){
List<Map> list = trafficUaStatisticDao.getSystemBybrowser(bsType);
List osType = new ArrayList();
//查询固定操系统下的除了TOP10以外的others
if(list!=null&& list.size()>0){
for (Map map : list) {
osType.add(map.get("osType"));
}
Map others = new HashMap();
others = trafficUaStatisticDao.browserOthers(osType,bsType);
if(others!=null&&others.size()>0){
others.put("osType", "-1");
list.add(others);
}
}
2018-07-13 19:39:04 +08:00
return list;
}
public List<Map> websiteList() {
List<Map> result = new ArrayList<Map>();
List<TrafficHttpStatistic> list = trafficHttpStatisticDao.websiteList();
Integer preCount=0;
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",website.getPktNum());
map.put("byteLen",website.getByteLen());
preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWebId());//上个时段的量 用于与现在对比
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;
}
/**
* 根据网站服务查询子域名
* @param websiteServiceId
* @return list
*/
public List<Map> getDomainByWebsiteServiceId(Integer websiteServiceId ){
List<Map> list = trafficHttpStatisticDao.getDomainByWebsiteServiceId(websiteServiceId);
List webIdList = new ArrayList();
//查询固定网站下的域名除了TOP10以外的others域名
if(list!=null&& list.size()>0){
for (Map map : list) {
webIdList.add(map.get("webId"));
}
Map others = new HashMap();
others = trafficHttpStatisticDao.websiteDomainOthers(webIdList,websiteServiceId);
if(others!=null&&others.size()>0){
others.put("webId", "-1");
list.add(others);
}
}
2018-07-13 19:39:04 +08:00
return list;
}
/**
获取网站列表
* @return
*/
@SuppressWarnings("unchecked")
public List<Map> getDomainByWebsiteList(){
List<TrafficHttpStatistic> websiteList = trafficHttpStatisticDao.getDomainByWebsiteList();
List<Map> result = new ArrayList<Map>();
if(websiteList!=null&&websiteList.size()>0){
Integer preCount=0;
for (TrafficHttpStatistic website : websiteList) {
Map map = new HashMap();
map.put("websiteServiceId",website.getWesiteServiceId());
map.put("count",website.getCount());
map.put("pktNum",website.getPktNum());
map.put("byteLen",website.getByteLen());
2018-09-26 09:48:45 +08:00
preCount = trafficHttpStatisticDao.preWebsiteListCount(website.getWesiteServiceId());//上个时段的量 用于与现在对比
if(preCount!=null){
map.put("preCount",preCount);
}else{
map.put("preCount",0);
}
result.add(map);
}
}
return result;
}
/**
*主题网站分类域名
*
* **/
public List<Map> getTopicAndDomainList(){
//按照主题分类 获得主题
List<Map> topicList = trafficHttpStatisticDao.getDomainByTopicList();
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"));
m.put("domainData", domainList);
}
}
}
return topicList;
}
2018-07-13 19:39:04 +08:00
}