提交误覆盖
This commit is contained in:
@@ -58,8 +58,15 @@ public class DashboardController extends BaseController{
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value="logChart")
|
||||
public String logChart(){
|
||||
|
||||
public String logChart(Model model){
|
||||
// 默认当前时间一小时
|
||||
Calendar cal = Calendar. getInstance ();
|
||||
cal.setTime(new Date());
|
||||
String endDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());//获取到完整的时间
|
||||
cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1);
|
||||
String beginDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());
|
||||
model.addAttribute("beginDate", beginDate);
|
||||
model.addAttribute("endDate", endDate);
|
||||
return "/dashboard/dashBoardIndex";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.nis.web.controller.dashboard;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -35,6 +38,7 @@ import com.google.gson.JsonParseException;
|
||||
import com.google.gson.LongSerializationPolicy;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.configuration.WebsiteDomainTopic;
|
||||
import com.nis.domain.dashboard.TrafficIpActiveStatistic;
|
||||
import com.nis.util.CodeDicUtils;
|
||||
import com.nis.util.Constants;
|
||||
@@ -385,4 +389,99 @@ public class TrafficStatisticsInfoController extends BaseController {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* 网址类型列表
|
||||
*/
|
||||
@RequestMapping("webTypeList")
|
||||
public String webTypeList(Model model){
|
||||
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);
|
||||
String oneHoursAgo = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());
|
||||
model.addAttribute("beginDate", oneHoursAgo);
|
||||
model.addAttribute("endDate", now);
|
||||
return "/dashboard/trafficWebTypeList";
|
||||
}
|
||||
/**
|
||||
* 网站统计图跟表
|
||||
*/
|
||||
@RequestMapping(value="websiteList")
|
||||
@ResponseBody
|
||||
public List websiteList(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 = "http://192.168.11.87:8088/galaxy-service/service/log/v1/"+Constants.TRAFFIC_WEBSITELIST;
|
||||
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("website接口数据"+fromJsonList);
|
||||
list = (ArrayList) fromJsonList.get("data");
|
||||
BigDecimal divisor=new BigDecimal(1024*1024*1024);
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
DecimalFormat dl = new DecimalFormat("0");
|
||||
DecimalFormat pf = new DecimalFormat("0.00%");
|
||||
Double totalLink=0d;
|
||||
Double totalGbyte=0d;
|
||||
Double totalPackets=0d;
|
||||
for (Object object : list) {
|
||||
Map m=(Map)object;
|
||||
Double count=(Double)m.get("count");
|
||||
totalGbyte+=count;
|
||||
totalLink+=(Double)m.get("linkNum");
|
||||
totalPackets+=(Double)m.get("packets");
|
||||
String format = df.format(count/1024/1024/1024);
|
||||
m.put("Gbyte", format);
|
||||
}
|
||||
List<WebsiteDomainTopic> codeList = appCfgService.getDomainDict(new WebsiteDomainTopic());
|
||||
Map<Long, String> map = new HashMap<Long,String>();
|
||||
for (WebsiteDomainTopic websiteDomainTopic : codeList) {
|
||||
if(!map.containsKey(websiteDomainTopic.getWebsiteServiceId())){
|
||||
map.put(websiteDomainTopic.getId(),websiteDomainTopic.getDomain());
|
||||
}
|
||||
}
|
||||
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;
|
||||
m.put("perPackets", pf.format(perPackets));
|
||||
Double perGbyte = ((Double)m.get("count"))/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")))));
|
||||
}
|
||||
}
|
||||
Collections.sort(list, new Comparator<Object>() {
|
||||
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
if(o1==null&&o2!=null){
|
||||
return 1;
|
||||
}
|
||||
if(o1!=null&&o2==null){
|
||||
return -1;
|
||||
}
|
||||
if(o1==null&&o2==null){
|
||||
return 0;
|
||||
}
|
||||
Map m1=(Map)o1;
|
||||
Map m2=(Map)o2;
|
||||
if((Double)m1.get("count")==(Double)m2.get("count")){
|
||||
return 0;
|
||||
}
|
||||
int result=((Double)m1.get("count")-(Double)m2.get("count"))>0?-1:1;
|
||||
return result;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("网站域名数据获取错误"+e);
|
||||
list.add(Maps.newHashMap("error","request_service_failed"));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user