流量统计新增端口,主题图
This commit is contained in:
@@ -666,6 +666,9 @@ public final class Constants {
|
||||
public static final String TRAFFIC_SYSTEM_CHART=Configurations.getStringProperty("trafficSystemChart","trafficSystemChart");
|
||||
public static final String TRAFFIC_WEBSITELIST=Configurations.getStringProperty("trafficWebsiteList","trafficWebsiteList");
|
||||
public static final String TRAFFIC_WEBTYPECHART=Configurations.getStringProperty("trafficWebTypeChart","trafficWebTypeChart");
|
||||
public static final String TRAFFIC_PORT_ACTIVE=Configurations.getStringProperty("trafficPortActive","trafficPortActive");
|
||||
public static final String TRAFFIC_TOPIC_AND_DOMAIN_CHART=Configurations.getStringProperty("trafficTopicAndDomainChart","trafficTopicAndDomainChart");
|
||||
public static final String NTC_TOTAL_REPORT=Configurations.getStringProperty("ntcTotalReport","ntcTotalReport");
|
||||
|
||||
/**
|
||||
* httpclient 工具超时时间设置
|
||||
|
||||
@@ -15,13 +15,17 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.SysDataDictionaryItem;
|
||||
import com.nis.domain.configuration.WebsiteDomainTopic;
|
||||
import com.nis.util.CodeDicUtils;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
@@ -42,6 +46,27 @@ public class DashboardController extends BaseController{
|
||||
return "/dashboard/dashBoardIndex";
|
||||
}
|
||||
|
||||
/**
|
||||
* 活跃端口 TOP10
|
||||
*/
|
||||
@RequestMapping(value="portActive")
|
||||
@ResponseBody
|
||||
public List portActive(){
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
List list = new ArrayList();
|
||||
try {
|
||||
String string = HttpClientUtil.get(Constants.DASHBOARD_URL+Constants.TRAFFIC_PORT_ACTIVE);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
list = (ArrayList) fromJsonList.get("data");
|
||||
logger.info("活跃端口数据"+fromJsonList);
|
||||
return list;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("活跃端口数据错误"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* 活跃IP TOP10
|
||||
*/
|
||||
@@ -54,9 +79,9 @@ public class DashboardController extends BaseController{
|
||||
String string = HttpClientUtil.get(Constants.DASHBOARD_URL+Constants.TRAFFIC_IPACTIVE);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
list = (ArrayList) fromJsonList.get("data");
|
||||
logger.info("活跃IP数据"+fromJsonList);
|
||||
return list;
|
||||
list = (ArrayList) fromJsonList.get("data");
|
||||
return list;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("活跃IP错误"+e);
|
||||
@@ -332,15 +357,21 @@ public class DashboardController extends BaseController{
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
list = (List<Map>) fromJsonList.get("data");
|
||||
//标签集合
|
||||
List<CodeResult> codeList = CodeDicUtils.getCodeList("webCode");
|
||||
// List<CodeResult> codeList = CodeDicUtils.getCodeList("webCode");
|
||||
List<SysDataDictionaryItem> codeList = DictUtils.getDictList("WEBSITE_SERVER");
|
||||
//将数字替换为标签文字
|
||||
if(list!=null&&!list.isEmpty()){
|
||||
for (Map map : list) {
|
||||
Double value1 = Double.parseDouble(map.get("webId").toString());
|
||||
for (CodeResult code : codeList) {
|
||||
Double value2 = Double.valueOf(code.getCode());
|
||||
Double value1=0d;
|
||||
if(StringUtil.isBlank(map.get("websiteServiceId").toString())){
|
||||
value1=268435455d;
|
||||
}else{
|
||||
value1 = Double.parseDouble(map.get("websiteServiceId").toString());
|
||||
}
|
||||
for (SysDataDictionaryItem code : codeList) {
|
||||
Double value2 = Double.valueOf(code.getItemCode());
|
||||
if(value1.equals(value2)){
|
||||
map.put("webId", code.getItem());
|
||||
map.put("websiteService", code.getItemValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -356,57 +387,122 @@ public class DashboardController extends BaseController{
|
||||
return resultList;
|
||||
}
|
||||
/**
|
||||
* http网站-某个网站的分类统计
|
||||
* http网站-某个网站的子域名统计
|
||||
*/
|
||||
@RequestMapping(value="webTypeChart")
|
||||
@ResponseBody
|
||||
public List webTypeChart(@RequestParam("webId") String webId){
|
||||
public List webTypeChart(@RequestParam("websiteServiceId") String websiteServiceId){
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
List<Map> list = new ArrayList<Map>();
|
||||
List<Map> resultList = new ArrayList<Map>();
|
||||
//标签集合
|
||||
List<CodeResult> codeList1 = CodeDicUtils.getCodeList("webCode");
|
||||
//将标签文字转为数字
|
||||
Integer web=null;
|
||||
for (CodeResult codeResult : codeList1) {
|
||||
if(webId.equalsIgnoreCase(codeResult.getItem())){
|
||||
web=Integer.parseInt(codeResult.getCode());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(web==null){
|
||||
web=Integer.parseInt(webId);//处理为匹配项编码
|
||||
}
|
||||
try {
|
||||
String string = HttpClientUtil.get(Constants.DASHBOARD_URL+Constants.TRAFFIC_WEBTYPECHART+"?webId="+web);
|
||||
String string = HttpClientUtil.get(Constants.DASHBOARD_URL+Constants.TRAFFIC_WEBTYPECHART+"?websiteServiceId="+websiteServiceId);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
list = (List<Map>) fromJsonList.get("data");
|
||||
//标签集合
|
||||
List<CodeResult> codeList2 = CodeDicUtils.getCodeList("webCode");//网站分类字典-未定义?
|
||||
// List<CodeResult> codeList2 = CodeDicUtils.getCodeList("webCode");//网站子域名表获取域名domain
|
||||
List<WebsiteDomainTopic> domainList = appCfgService.getDomainDict(new WebsiteDomainTopic());
|
||||
if(list!=null&&list.size()>0&&domainList!=null&&domainList.size()>0){
|
||||
for (Map dataMap : list) {
|
||||
for (WebsiteDomainTopic wdt : domainList) {
|
||||
// Map<String, Object> map = Maps.newHashMap();
|
||||
if(wdt!=null){
|
||||
String domain = wdt.getDomain();
|
||||
Double domainId = wdt.getId().doubleValue();
|
||||
Double webId = Double.parseDouble(dataMap.get("webId").toString());
|
||||
//10个域名之外的为others webId设为-1外
|
||||
if(dataMap.get("webId").toString().equals("-1")){
|
||||
dataMap.put("domain", "Others");
|
||||
break;
|
||||
}
|
||||
if(domainId.equals(webId)){
|
||||
dataMap.put("domain", domain);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
resultList.add(dataMap);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("http某个网站子域名流量统计"+fromJsonList);
|
||||
return resultList;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("http某个网站子域名流量统计错误"+e);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* http网站主题跟域名统计
|
||||
*/
|
||||
@RequestMapping(value="topicAndDomainList")
|
||||
@ResponseBody
|
||||
public List topicAndDomainList(){
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
List<Map> list = new ArrayList<Map>();
|
||||
List<Map> resultList = new ArrayList<Map>();
|
||||
try {
|
||||
String string = HttpClientUtil.get(Constants.DASHBOARD_URL+Constants.TRAFFIC_TOPIC_AND_DOMAIN_CHART);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
list = (List<Map>) fromJsonList.get("data");
|
||||
List<SysDataDictionaryItem> codeList = DictUtils.getDictList("TOPIC");
|
||||
//将数字替换为标签文字
|
||||
if(null!=list&&!list.isEmpty()){
|
||||
List<WebsiteDomainTopic> domainList = appCfgService.getDomainDict(new WebsiteDomainTopic());
|
||||
if(list!=null&&!list.isEmpty()){
|
||||
for (Map map : list) {
|
||||
Double value1 = Double.parseDouble(map.get("webType").toString());
|
||||
for (CodeResult code : codeList2) {
|
||||
Double value2 = Double.valueOf(code.getCode());
|
||||
Double value1=0d;
|
||||
if(StringUtil.isBlank(map.get("topicId").toString())){
|
||||
value1=268435455d;
|
||||
}else{
|
||||
value1 = Double.parseDouble(map.get("topicId").toString());
|
||||
}
|
||||
for (SysDataDictionaryItem code : codeList) {
|
||||
Double value2 = Double.valueOf(code.getItemCode());
|
||||
if(value1.equals(value2)){
|
||||
map.put("webType", code.getItem());
|
||||
map.put("topic", code.getItemValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
//将domain添加名称
|
||||
List<Map> dataDomainList = (List<Map>)map.get("domainData");
|
||||
if(dataDomainList!=null&&dataDomainList.size()>0&&domainList!=null&&domainList.size()>0){
|
||||
for (WebsiteDomainTopic wdt : domainList) {
|
||||
for (Map dataMap : dataDomainList) {
|
||||
if(wdt!=null){
|
||||
String domain = wdt.getDomain();
|
||||
Double domainId = wdt.getId().doubleValue();
|
||||
Double webId = Double.parseDouble(dataMap.get("webId").toString());
|
||||
//10个域名之外的为others webId设为-1
|
||||
// if(dataMap.get("webId").toString().equals("-1")){
|
||||
// dataMap.put("domain", "Others");
|
||||
// break;
|
||||
// }
|
||||
if(domainId.equals(webId)){
|
||||
dataMap.put("domain", domain);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resultList.add(map);
|
||||
}
|
||||
}
|
||||
logger.info("http某个网站分类流量统计"+fromJsonList);
|
||||
logger.info("http网站主题流量分析数据:"+fromJsonList);
|
||||
return resultList;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("http某个网站分类流量统计错误"+e);
|
||||
logger.error("http网站主题流量分析数据错误:"+e);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value="webTypeList")
|
||||
public String ipActiveList( HttpServletRequest request, HttpServletResponse response, Model model){
|
||||
PageLog<TrafficIpActiveStatistic> page = new PageLog<TrafficIpActiveStatistic>(request, response);
|
||||
@@ -440,7 +536,7 @@ public class DashboardController extends BaseController{
|
||||
return "/dashboard/trafficBandwidthList";
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////test
|
||||
@RequestMapping(value="showChart")
|
||||
public String showChart(@ModelAttribute("entry") TrafficIpActiveStatistic entry, Model model){
|
||||
String ipAddr="1.1.1.1";
|
||||
|
||||
Reference in New Issue
Block a user