帮洪庆提交 内容:网站域名统计详情
This commit is contained in:
@@ -256,34 +256,6 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
}
|
||||
return map;
|
||||
}
|
||||
/**
|
||||
* 间隔5分钟数据
|
||||
*/
|
||||
@RequestMapping(value="bandwidthTransThree")
|
||||
@ResponseBody
|
||||
public Map bandwidthTransThree(String beginDate,String endDate){
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
Map map = new HashMap();
|
||||
//String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_BANDWIDTH_TRANS_TWO;
|
||||
//String url="http://192.168.11.78:8080/galaxy/service/log/v1/"+Constants.TRAFFIC_BANDWIDTH_TRANS_THREE;
|
||||
//String url="http://192.168.11.78:8080/galaxy/service/log/v1/"+Constants.TRAFFIC_BANDWIDTH_TRANS_FOUR;
|
||||
String url=Constants.DASHBOARD_URL+Constants.TRAFFIC_BANDWIDTH_TRANS_THREE;
|
||||
//String url=Constants.DASHBOARD_URL+Constants.TRAFFIC_BANDWIDTH_TRANS_FOUR;
|
||||
try {
|
||||
url=urlAddDate(url,beginDate,endDate);
|
||||
|
||||
String string = HttpClientUtil.get(url);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
logger.debug("bandwidthTransThree服务查询数据成功");
|
||||
Map result = (Map)fromJsonList.get("data");
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("带宽详情数据获取错误"+e);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
/**
|
||||
* 协议类型详细列表
|
||||
*/
|
||||
@@ -427,24 +399,77 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
Calendar cal = Calendar. getInstance ();
|
||||
cal.setTime(new Date());
|
||||
String now = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());//获取到完整的时间
|
||||
cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1);
|
||||
cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 12);
|
||||
String oneHoursAgo = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());
|
||||
List<WebsiteDomainTopic> domainList = appCfgService.getDomainDict(new WebsiteDomainTopic());// domain 域名
|
||||
model.addAttribute("domainList", domainList);
|
||||
model.addAttribute("beginDate", oneHoursAgo);
|
||||
model.addAttribute("endDate", now);
|
||||
return "/dashboard/trafficWebTypeList";
|
||||
}
|
||||
@RequestMapping("domainTrans")
|
||||
public String domainTrans(Model model,Integer domain,Integer entranceId,String beginDate,String endDate,String domainName){
|
||||
|
||||
model.addAttribute("domainName", domainName);
|
||||
model.addAttribute("domain", domain);
|
||||
model.addAttribute("entranceId", entranceId);
|
||||
model.addAttribute("beginDate", beginDate);
|
||||
model.addAttribute("endDate", endDate);
|
||||
return "/dashboard/trafficDomainTrans";
|
||||
}
|
||||
@RequestMapping("ajaxDomainTrans")
|
||||
@ResponseBody
|
||||
public List ajaxDomainTrans(String beginDate,String endDate,Integer domain,Integer entranceId,Model model){
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
List list = new ArrayList();
|
||||
try {
|
||||
// String url=Constants.DASHBOARD_URL+Constants.TRAFFIC_IPACTIVE_ONEHOUR;
|
||||
String url = "http://localhost:8088/galaxy-service/service/log/v1/trafficDomainTrans";
|
||||
url=urlAddDate(url, beginDate, endDate);
|
||||
if(domain!=null){
|
||||
url=url+"&domain="+domain;
|
||||
}
|
||||
if(entranceId!=null){
|
||||
url=url+"&entranceId="+entranceId;
|
||||
}
|
||||
String string = HttpClientUtil.get(url);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map<String, Object>>(){}.getType());
|
||||
logger.debug("活跃IP1小时"+fromJsonList);
|
||||
list = (ArrayList) fromJsonList.get("data");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("活跃IP数据获取错误"+e);
|
||||
list.add(Maps.newHashMap("error","request_service_failed"));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* 网站统计图跟表
|
||||
*/
|
||||
@RequestMapping(value="websiteList")
|
||||
@ResponseBody
|
||||
public List websiteList(Model model,@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate){
|
||||
public List websiteList(Integer entranceId,Integer domain,Model model,@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate){
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
List list = new ArrayList();
|
||||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_WEBSITELIST;
|
||||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_WEBSITELIST_NOTIME;
|
||||
// String url = "http://192.168.11.87:8088/galaxy-service/service/log/v1/"+Constants.TRAFFIC_WEBSITELIST;
|
||||
try {
|
||||
url=urlAddDate(url,beginDate,endDate);
|
||||
if(StringUtil.isBlank(beginDate)||StringUtil.isBlank(endDate)){
|
||||
Calendar cal = Calendar. getInstance ();
|
||||
cal.setTime(new Date());
|
||||
endDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());//获取到完整的时间
|
||||
cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 12);
|
||||
beginDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());
|
||||
}
|
||||
url=urlAddDate(url, beginDate, endDate);
|
||||
if(domain!=null){
|
||||
url=url+"&domain="+domain;
|
||||
}
|
||||
if(entranceId!=null){
|
||||
url=url+"&entranceId="+entranceId;
|
||||
}
|
||||
String string = HttpClientUtil.get(url);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||||
@@ -454,15 +479,15 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
DecimalFormat dl = new DecimalFormat("0");
|
||||
DecimalFormat pf = new DecimalFormat("0.00%");
|
||||
Double totalLink=0d;
|
||||
// Double totalLink=0d;
|
||||
Double totalGbyte=0d;
|
||||
Double totalPackets=0d;
|
||||
for (Object object : list) {
|
||||
Map m=(Map)object;
|
||||
Double count=(Double)m.get("count");
|
||||
Double count=(Double)m.get("byteCount");
|
||||
totalGbyte+=count;
|
||||
totalLink+=(Double)m.get("linkNum");
|
||||
totalPackets+=(Double)m.get("packets");
|
||||
// totalLink+=(Double)m.get("linkNum");
|
||||
totalPackets+=(Double)m.get("pktCount");
|
||||
String format = df.format(count/1024/1024/1024);
|
||||
m.put("Gbyte", format);
|
||||
}
|
||||
@@ -475,14 +500,16 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
}
|
||||
for (Object object : list) {
|
||||
Map m=(Map)object;
|
||||
Double perLink = ((Double)m.get("linkNum"))/totalLink;
|
||||
m.put("perLink",pf.format(perLink));
|
||||
Double perPackets = ((Double)m.get("packets"))/totalPackets;
|
||||
// Double perLink = ((Double)m.get("linkNum"))/totalLink;
|
||||
// m.put("perLink",pf.format(perLink));
|
||||
Double perPackets = ((Double)m.get("pktCount"))/totalPackets;
|
||||
m.put("perPackets", pf.format(perPackets));
|
||||
Double perGbyte = ((Double)m.get("count"))/totalGbyte;
|
||||
Double perGbyte = ((Double)m.get("byteCount"))/totalGbyte;
|
||||
m.put("perGbyte", pf.format(perGbyte));
|
||||
if(map.containsKey(Long.parseLong(dl.format(m.get("webId"))))){
|
||||
m.put("website", map.get(Long.parseLong(dl.format(m.get("webId")))));
|
||||
}else{
|
||||
m.put("website", dl.format(m.get("webId")));
|
||||
}
|
||||
}
|
||||
Collections.sort(list, new Comparator<Object>() {
|
||||
@@ -500,10 +527,10 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
}
|
||||
Map m1=(Map)o1;
|
||||
Map m2=(Map)o2;
|
||||
if((Double)m1.get("count")==(Double)m2.get("count")){
|
||||
if((Double)m1.get("byteCount")==(Double)m2.get("byteCount")){
|
||||
return 0;
|
||||
}
|
||||
int result=((Double)m1.get("count")-(Double)m2.get("count"))>0?-1:1;
|
||||
int result=((Double)m1.get("byteCount")-(Double)m2.get("byteCount"))>0?-1:1;
|
||||
return result;
|
||||
}
|
||||
});
|
||||
@@ -523,8 +550,9 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
public List statisticList(Model model,@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate){
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
List list = new ArrayList();
|
||||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_TOPIC_AND_DOMAIN_CHART;
|
||||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_TOPICLIST;
|
||||
//String url = "http://192.168.11.87:8088/galaxy-service/service/log/v1/"+Constants.TRAFFIC_TOPIC_AND_DOMAIN_CHART;
|
||||
//String url = "http://192.168.11.87:8088/galaxy-service/service/log/v1/"+Constants.TRAFFIC_TOPICLIST;
|
||||
Map map=new HashMap();
|
||||
try {
|
||||
url=urlAddDate(url,beginDate,endDate);
|
||||
@@ -557,11 +585,18 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
}
|
||||
}
|
||||
}
|
||||
for(Object object2 : list) {
|
||||
Map m2=(Map) object2;
|
||||
//将总数据赋值给每个实体 方便计算百分比 如果数据都为空 则不返回给页面展示
|
||||
for(int i=list.size()-1;i>=0;i--) {
|
||||
Map m2=(Map) list.get(i);
|
||||
m2.put("allLink", totalLink);
|
||||
m2.put("allPackets",totalPackets);
|
||||
m2.put("allGByte", totalGByte);
|
||||
long parseLong = Long.parseLong(lf.format(m2.get("linkNum")));
|
||||
long parseLong2 = Long.parseLong(lf.format(m2.get("packets")));
|
||||
double parseDouble = Double.parseDouble(lf.format(m2.get("count")));
|
||||
if(parseLong==0&&parseLong2==0&&parseDouble==0) {
|
||||
list.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user