1.nis配置文件增加图表查询服务接口2.增加统计图表展示及相关插件
This commit is contained in:
@@ -6,7 +6,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -16,6 +15,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.util.CodeDicUtils;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
@@ -26,11 +26,12 @@ import com.nis.web.dao.dashboard.codedic.CodeResult;
|
||||
public class DashboardController extends BaseController{
|
||||
|
||||
|
||||
/**
|
||||
* 跳转到图表界面
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value="logChart")
|
||||
public String logChart(){
|
||||
bsList();
|
||||
systemChart("Google Chrome");
|
||||
|
||||
|
||||
return "/dashboard/dashBoardIndex";
|
||||
}
|
||||
@@ -44,7 +45,7 @@ public class DashboardController extends BaseController{
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
List list = new ArrayList();
|
||||
try {
|
||||
String string = HttpClientUtil.get("http://10.0.6.101:8080/gwall/service/log/v1/trafficIpActive");
|
||||
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");
|
||||
@@ -52,14 +53,13 @@ public class DashboardController extends BaseController{
|
||||
return list;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("活跃ip错误"+e);
|
||||
logger.error("活跃IP错误"+e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* 协议统计
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value="protocol")
|
||||
@ResponseBody
|
||||
public List protocolChart(){
|
||||
@@ -67,13 +67,14 @@ public class DashboardController extends BaseController{
|
||||
List<Map> list = new ArrayList<Map>();
|
||||
List<Map> resultList = new ArrayList<Map>();
|
||||
try {
|
||||
String string = HttpClientUtil.get("http://10.0.6.101:8080/gwall/service/log/v1/trafficProtocol");
|
||||
String string = HttpClientUtil.get(Constants.DASHBOARD_URL+Constants.TRAFFIC_PROTOCOL);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
list = (List<Map>) fromJsonList.get("data");
|
||||
//标签集合
|
||||
List<CodeResult> codeList = CodeDicUtils.getCodeList("protocolCode");
|
||||
//将数字替换为标签文字
|
||||
if(list!=null&&!list.isEmpty()){
|
||||
for (Map map : list) {
|
||||
Double value1 = Double.parseDouble(map.get("protoType").toString());
|
||||
for (CodeResult code : codeList) {
|
||||
@@ -87,6 +88,7 @@ public class DashboardController extends BaseController{
|
||||
}
|
||||
logger.info("协议统计"+fromJsonList);
|
||||
return resultList;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("协议统计错误"+e);
|
||||
@@ -103,13 +105,14 @@ public class DashboardController extends BaseController{
|
||||
List<Map> list = new ArrayList<Map>();
|
||||
List<Map> resultList = new ArrayList<Map>();
|
||||
try {
|
||||
String string = HttpClientUtil.get("http://10.0.6.101:8080/gwall/service/log/v1/trafficApp");
|
||||
String string = HttpClientUtil.get(Constants.DASHBOARD_URL+Constants.TRAFFIC_APP);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
list = (List<Map>) fromJsonList.get("data");
|
||||
//标签集合
|
||||
List<CodeResult> codeList = CodeDicUtils.getCodeList("appCode");
|
||||
//将数字替换为标签文字
|
||||
if(list!=null&&!list.isEmpty()){
|
||||
for (Map map : list) {
|
||||
Double value1 = Double.parseDouble(map.get("appType").toString());
|
||||
for (CodeResult code : codeList) {
|
||||
@@ -123,6 +126,7 @@ public class DashboardController extends BaseController{
|
||||
}
|
||||
logger.info("app流量分析"+fromJsonList);
|
||||
return resultList;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("app流量分析错误"+e);
|
||||
@@ -139,13 +143,14 @@ public class DashboardController extends BaseController{
|
||||
List<Map> list = new ArrayList<Map>();
|
||||
List<Map> resultList = new ArrayList<Map>();
|
||||
try {
|
||||
String string = HttpClientUtil.get("http://10.0.6.101:8080/gwall/service/log/v1/trafficOsList");
|
||||
String string = HttpClientUtil.get(Constants.DASHBOARD_URL+Constants.TRAFFIC_OSLIST);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
list = (List<Map>) fromJsonList.get("data");
|
||||
//标签集合
|
||||
List<CodeResult> codeList = CodeDicUtils.getCodeList("osCode");
|
||||
//将数字替换为标签文字
|
||||
if(list!=null&&!list.isEmpty()){
|
||||
for (Map map : list) {
|
||||
Double value1 = Double.parseDouble(map.get("osType").toString());
|
||||
for (CodeResult code : codeList) {
|
||||
@@ -159,6 +164,7 @@ public class DashboardController extends BaseController{
|
||||
}
|
||||
logger.info("终端用户-获取操作系统列表"+fromJsonList);
|
||||
return resultList;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("终端用户-获取操作系统列表错误"+e);
|
||||
@@ -184,8 +190,11 @@ public class DashboardController extends BaseController{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(os==null){
|
||||
os=Integer.parseInt(osType);//处理为匹配项编码
|
||||
}
|
||||
try {
|
||||
String string = HttpClientUtil.get("http://10.0.6.101:8080/gwall/service/log/v1/trafficBrowserChart?osType="+os);
|
||||
String string = HttpClientUtil.get(Constants.DASHBOARD_URL+Constants.TRAFFIC_BROWSER_CHART+"?osType="+os);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
list = (List<Map>) fromJsonList.get("data");
|
||||
@@ -223,13 +232,14 @@ public class DashboardController extends BaseController{
|
||||
List<Map> list = new ArrayList<Map>();
|
||||
List<Map> resultList = new ArrayList<Map>();
|
||||
try {
|
||||
String string = HttpClientUtil.get("http://10.0.6.101:8080/gwall/service/log/v1/trafficBsList");
|
||||
String string = HttpClientUtil.get(Constants.DASHBOARD_URL+Constants.TRAFFIC_BSLISTL);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
list = (List<Map>) fromJsonList.get("data");
|
||||
//标签集合
|
||||
List<CodeResult> codeList = CodeDicUtils.getCodeList("browserCode");
|
||||
//将数字替换为标签文字
|
||||
if(list!=null&&!list.isEmpty()){
|
||||
for (Map map : list) {
|
||||
Double value1 = Double.parseDouble(map.get("bsType").toString());
|
||||
for (CodeResult code : codeList) {
|
||||
@@ -240,6 +250,7 @@ public class DashboardController extends BaseController{
|
||||
}
|
||||
}
|
||||
resultList.add(map);
|
||||
}
|
||||
}
|
||||
logger.info("终端用户-获取浏览器列表"+fromJsonList);
|
||||
return resultList;
|
||||
@@ -259,7 +270,7 @@ public class DashboardController extends BaseController{
|
||||
List<Map> list = new ArrayList<Map>();
|
||||
List<Map> resultList = new ArrayList<Map>();
|
||||
//标签集合
|
||||
List<CodeResult> codeList1 = CodeDicUtils.getCodeList("bsCode");
|
||||
List<CodeResult> codeList1 = CodeDicUtils.getCodeList("browserCode");
|
||||
//将标签文字转为数字
|
||||
Integer bs=null;
|
||||
for (CodeResult codeResult : codeList1) {
|
||||
@@ -268,8 +279,11 @@ public class DashboardController extends BaseController{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(bs==null){
|
||||
bs=Integer.parseInt(bsType);//处理为匹配项编码
|
||||
}
|
||||
try {
|
||||
String string = HttpClientUtil.get("http://10.0.6.101:8080/gwall/service/log/v1/trafficBrowserChart?bsType="+bs);
|
||||
String string = HttpClientUtil.get(Constants.DASHBOARD_URL+Constants.TRAFFIC_SYSTEM_CHART+"bsType="+bs);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
list = (List<Map>) fromJsonList.get("data");
|
||||
@@ -297,4 +311,93 @@ public class DashboardController extends BaseController{
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
/**
|
||||
* http网站统计
|
||||
*/
|
||||
@RequestMapping(value="websiteList")
|
||||
@ResponseBody
|
||||
public List websiteList(){
|
||||
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_WEBSITELIST);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
list = (List<Map>) fromJsonList.get("data");
|
||||
//标签集合
|
||||
List<CodeResult> codeList = CodeDicUtils.getCodeList("webCode");
|
||||
//将数字替换为标签文字
|
||||
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());
|
||||
if(value1.equals(value2)){
|
||||
map.put("webId", code.getItem());
|
||||
break;
|
||||
}
|
||||
}
|
||||
resultList.add(map);
|
||||
}
|
||||
}
|
||||
logger.info("http网站流量分析数据:"+fromJsonList);
|
||||
return resultList;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("http网站流量分析数据错误:"+e);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
/**
|
||||
* http网站-某个网站的分类统计
|
||||
*/
|
||||
@RequestMapping(value="webTypeChart")
|
||||
@ResponseBody
|
||||
public List webTypeChart(@RequestParam("webId") String webId){
|
||||
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);
|
||||
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");//网站分类字典-未定义?
|
||||
//将数字替换为标签文字
|
||||
if(null!=list&&!list.isEmpty()){
|
||||
for (Map map : list) {
|
||||
Double value1 = Double.parseDouble(map.get("webType").toString());
|
||||
for (CodeResult code : codeList2) {
|
||||
Double value2 = Double.valueOf(code.getCode());
|
||||
if(value1.equals(value2)){
|
||||
map.put("webType", code.getItem());
|
||||
break;
|
||||
}
|
||||
}
|
||||
resultList.add(map);
|
||||
}
|
||||
}
|
||||
logger.info("http某个网站分类流量统计"+fromJsonList);
|
||||
return resultList;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("http某个网站分类流量统计错误"+e);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user