1650 lines
64 KiB
Java
1650 lines
64 KiB
Java
package com.nis.web.controller.dashboard;
|
||
|
||
import java.net.URISyntaxException;
|
||
import java.text.DecimalFormat;
|
||
import java.text.ParseException;
|
||
import java.text.SimpleDateFormat;
|
||
import java.util.ArrayList;
|
||
import java.util.Calendar;
|
||
import java.util.Date;
|
||
import java.util.HashMap;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
import java.util.Properties;
|
||
|
||
import javax.servlet.http.HttpServletRequest;
|
||
import javax.servlet.http.HttpServletResponse;
|
||
|
||
import org.apache.http.client.utils.URIBuilder;
|
||
import org.joda.time.DateTime;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.stereotype.Controller;
|
||
import org.springframework.ui.Model;
|
||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||
import org.springframework.web.bind.annotation.RequestMapping;
|
||
import org.springframework.web.bind.annotation.RequestParam;
|
||
import org.springframework.web.bind.annotation.ResponseBody;
|
||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||
|
||
import com.beust.jcommander.internal.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.SysUser;
|
||
import com.nis.domain.configuration.WebsiteDomainTopic;
|
||
import com.nis.domain.dashboard.ConfigStatistic;
|
||
import com.nis.domain.maat.LogRecvData;
|
||
import com.nis.util.CodeDicUtils;
|
||
import com.nis.util.Constants;
|
||
import com.nis.util.DateUtils;
|
||
import com.nis.util.LogUtils;
|
||
import com.nis.util.ServiceConfigTemplateUtil;
|
||
import com.nis.util.StringUtil;
|
||
import com.nis.util.StringUtils;
|
||
import com.nis.util.httpclient.HttpClientUtil;
|
||
import com.nis.web.controller.BaseController;
|
||
import com.nis.web.dao.dashboard.codedic.CodeResult;
|
||
import com.nis.web.security.UserUtils;
|
||
import com.nis.web.service.configuration.statistics.ConfigStatisticService;
|
||
|
||
import net.sf.json.JSONObject;
|
||
|
||
@Controller
|
||
@RequestMapping("${adminPath}/dashboard/traffic")
|
||
public class ConfigStatisticsController extends BaseController {
|
||
|
||
@Autowired
|
||
protected ConfigStatisticService configStatisticService;
|
||
|
||
@RequestMapping(value="/commonNewList")
|
||
public String configStatistic(Model model,String concent,String detail,String dimension,String area,
|
||
String operator,String timeSize,String chartType,String beginDate,String endDate){
|
||
if (StringUtils.isNotBlank(beginDate) && StringUtils.isNotBlank(endDate)) {
|
||
model.addAttribute("beginDate", beginDate);
|
||
model.addAttribute("endDate", endDate);
|
||
}else{
|
||
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());
|
||
if(concent ==null || concent.equals("1")){
|
||
ConfigStatistic entity=new ConfigStatistic();
|
||
entity.setBeginDate(oneHoursAgo);
|
||
entity.setEndDate(now);
|
||
model.addAttribute("log", entity);
|
||
}else{
|
||
model.addAttribute("beginDate", oneHoursAgo);
|
||
model.addAttribute("endDate", now);
|
||
}
|
||
}
|
||
model.addAttribute("concent", concent);
|
||
model.addAttribute("detail", detail);
|
||
model.addAttribute("dimension", dimension);
|
||
model.addAttribute("area", area);
|
||
model.addAttribute("operator", operator);
|
||
model.addAttribute("timeSize", timeSize);
|
||
model.addAttribute("chartType", chartType);
|
||
return "/dashboard/commonNew";
|
||
}
|
||
/**
|
||
* BandWidth 数据查询
|
||
*/
|
||
@RequestMapping(value="bandWidthTransThreeNew")
|
||
@ResponseBody
|
||
public Map bandWidthTransThree(String beginDate,String endDate,String searchQuotaType,String searchDirection,
|
||
String timeSize,Integer [] operator,Model model,HttpServletRequest request){
|
||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
Map map = new HashMap();
|
||
String url=Constants.DASHBOARD_URL+Constants.TRAFFIC_BANDWIDTH_TRANS_THREE_NEW;
|
||
try {
|
||
url=urlAddDate(url,beginDate,endDate);
|
||
url=url+"&searchQuotaType="+searchQuotaType;
|
||
|
||
if(!StringUtil.isEmpty(searchDirection)) {
|
||
url=url+"&searchDirection="+searchDirection;
|
||
}
|
||
if(!StringUtil.isEmpty(timeSize)) {
|
||
url=url+"&searchBusinessType="+timeSize;
|
||
}
|
||
if(operator!=null){
|
||
for (Integer oper : operator) {
|
||
if(oper!=null){
|
||
url=url+"&deviceId="+oper;
|
||
}
|
||
}
|
||
}
|
||
String string = HttpClientUtil.get(url);
|
||
Gson gson = new GsonBuilder().create();
|
||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||
// logger.debug("bandWidthTransThreeNew服务查询数据成功");
|
||
Map result = (Map)fromJsonList.get("data");
|
||
model.addAttribute("searchDirection", searchDirection);
|
||
return result;
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.error("带宽详情数据获取错误"+e);
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
return map;
|
||
}
|
||
// 配置统计列表数据查询
|
||
@RequestMapping(value = { "/configStatistic" })
|
||
public String configStatisticList(@ModelAttribute("log") ConfigStatistic log, Model model, HttpServletRequest request,
|
||
HttpServletResponse response) {
|
||
try {
|
||
PageLog<ConfigStatistic> page = new PageLog<ConfigStatistic>(request, response);
|
||
Map<String, Object> params = new HashMap<String, Object>();
|
||
params.put("pageSize", page.getPageSize());
|
||
params.put("pageNo", page.getPageNo());
|
||
if(page.getOrderBy().equals("") || page.getOrderBy() ==null){
|
||
params.put("orderBy", "sum desc");
|
||
}else{
|
||
params.put("orderBy", page.getOrderBy());
|
||
}
|
||
// 判断请求参数
|
||
if (StringUtils.isNotBlank(log.getBeginDate())
|
||
&& StringUtils.isNotBlank(log.getEndDate())) {
|
||
params.put("searchReportStartTime", log.getBeginDate());
|
||
params.put("searchReportEndTime", log.getEndDate());
|
||
} else {
|
||
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());
|
||
|
||
params.put("searchReportStartTime", beginDate);
|
||
params.put("searchReportEndTime", endDate);
|
||
log.setBeginDate(beginDate);
|
||
log.setEndDate(endDate);
|
||
}
|
||
if(!StringUtil.isEmpty(log.getTime())) {
|
||
if(log.getTime().equals("1")){
|
||
params.put("searchBusinessType", "2");
|
||
}/*else{
|
||
params.put("searchBusinessType", log.getTime());
|
||
}*/else if(log.getTime().equals("2")){
|
||
params.put("searchBusinessType", "3");
|
||
}else if(log.getTime().equals("3")){
|
||
params.put("searchBusinessType", "4");
|
||
}else if(log.getTime().equals("4")){
|
||
params.put("searchBusinessType", "5");
|
||
}else if(log.getTime().equals("5")){
|
||
params.put("searchBusinessType", "6");
|
||
}
|
||
}else{
|
||
params.put("searchBusinessType", "2");
|
||
}
|
||
String url = Constants.LOG_BASE_URL+Constants.NTC_PZ_COUNT_REPORT;
|
||
String recv = HttpClientUtil.getMsg(url, params, request);
|
||
if (StringUtils.isNotBlank(recv)) {
|
||
Gson gson = new GsonBuilder().create();
|
||
LogRecvData<ConfigStatistic> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<ConfigStatistic>>() {
|
||
}.getType());
|
||
if (fromJson.getStatus().intValue() == 200) {
|
||
Page<ConfigStatistic> data = fromJson.getData();
|
||
//查询配置描述
|
||
for (ConfigStatistic entity1 : data.getList()) {
|
||
entity1.setServiceId(String.valueOf(entity1.getService()));
|
||
//获取界面配置的所有业务信息
|
||
List<Map<String, Object>> serviceList = ServiceConfigTemplateUtil.getServiceList();
|
||
for (Map<String, Object> map1 : serviceList) {
|
||
if(entity1.getServiceId().equals(map1.get("id").toString())){
|
||
entity1.setTableName(map1.get("tableName").toString());
|
||
break;
|
||
}
|
||
}
|
||
String cfgDesc="";
|
||
if(entity1.getServiceId().equals("400")){//ASN IP(特殊的业务,需单独查询)
|
||
cfgDesc = configStatisticService.getASNIPCfgDesc(entity1.getCfgId());
|
||
}else if(entity1.getServiceId().equals("1028")){// APP IP
|
||
cfgDesc = configStatisticService.getAPPIPCfgDesc(entity1.getCfgId());
|
||
}else{
|
||
cfgDesc = configStatisticService.getCfgDescByCfgId(entity1);
|
||
}
|
||
entity1.setCfgDesc(cfgDesc);
|
||
}
|
||
page.setCount(data.getCount());
|
||
page.setLast(data.getLast());
|
||
page.setList(data.getList());
|
||
model.addAttribute("page", page);
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
logger.error("查询失败", e);
|
||
addMessageLog(model, e.getMessage());
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
|
||
model.addAttribute("concent", "1");
|
||
return "/dashboard/commonNew";
|
||
}
|
||
|
||
// 配置统计列表内容导出
|
||
@RequestMapping(value = "configStatisticListExport")
|
||
public void asnExport(@ModelAttribute("log") ConfigStatistic log, Model model, String hColumns, String type,
|
||
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
|
||
try {
|
||
// export data info
|
||
List<String> titleList = new ArrayList<String>();
|
||
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
|
||
Map<String, List> dataMap = new HashMap<String, List>();
|
||
Map<String, String> noExportMap = new HashMap<String, String>();
|
||
// ---------------------------
|
||
PageLog<ConfigStatistic> page = new PageLog<ConfigStatistic>(request, response);
|
||
page.setPageSize(-1);
|
||
Map<String, Object> params = new HashMap<String, Object>();
|
||
params.put("pageSize", page.getPageSize());
|
||
params.put("orderBy", "sum desc");
|
||
// 判断请求参数
|
||
if (StringUtils.isNotBlank(log.getBeginDate())
|
||
&& StringUtils.isNotBlank(log.getEndDate())) {
|
||
params.put("searchReportStartTime", log.getBeginDate());
|
||
params.put("searchReportEndTime", log.getEndDate());
|
||
} else {
|
||
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());
|
||
|
||
params.put("searchReportStartTime", beginDate);
|
||
params.put("searchReportEndTime", endDate);
|
||
log.setBeginDate(beginDate);
|
||
log.setEndDate(endDate);
|
||
}
|
||
if(!StringUtil.isEmpty(log.getTime())) {
|
||
if(log.getTime().equals("1")){
|
||
params.put("searchBusinessType", "2");
|
||
}else if(log.getTime().equals("2")){
|
||
params.put("searchBusinessType", "3");
|
||
}else if(log.getTime().equals("3")){
|
||
params.put("searchBusinessType", "4");
|
||
}else if(log.getTime().equals("4")){
|
||
params.put("searchBusinessType", "5");
|
||
}else if(log.getTime().equals("5")){
|
||
params.put("searchBusinessType", "6");
|
||
}
|
||
}else{
|
||
params.put("searchBusinessType", "2");
|
||
}
|
||
String url = Constants.LOG_BASE_URL+Constants.NTC_PZ_COUNT_REPORT;
|
||
String recv = HttpClientUtil.getMsg(url, params, request);
|
||
List<ConfigStatistic> list = new ArrayList<ConfigStatistic>();
|
||
if (StringUtils.isNotBlank(recv)) {
|
||
Gson gson = new GsonBuilder().create();
|
||
LogRecvData<ConfigStatistic> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<ConfigStatistic>>() {
|
||
}.getType());
|
||
if (fromJson.getStatus().intValue() == 200) {
|
||
Page<ConfigStatistic> data = fromJson.getData();
|
||
list = data.getList();
|
||
//查询配置描述
|
||
for (ConfigStatistic entity1 : list) {
|
||
entity1.setServiceId(String.valueOf(entity1.getService()));
|
||
//获取界面配置的所有业务信息
|
||
List<Map<String, Object>> serviceList = ServiceConfigTemplateUtil.getServiceList();
|
||
for (Map<String, Object> map1 : serviceList) {
|
||
if(entity1.getServiceId().equals(map1.get("id").toString())){
|
||
entity1.setTableName(map1.get("tableName").toString());
|
||
break;
|
||
}
|
||
}
|
||
String cfgDesc="";
|
||
if(entity1.getServiceId().equals("400")){//ASN IP(特殊的业务,需单独查询)
|
||
cfgDesc = configStatisticService.getASNIPCfgDesc(entity1.getCfgId());
|
||
}else if(entity1.getServiceId().equals("1028")){// APP IP
|
||
cfgDesc = configStatisticService.getAPPIPCfgDesc(entity1.getCfgId());
|
||
}else{
|
||
cfgDesc = configStatisticService.getCfgDescByCfgId(entity1);
|
||
}
|
||
entity1.setCfgDesc(cfgDesc);
|
||
}
|
||
}
|
||
}
|
||
//
|
||
titleList.add("config_statistics");
|
||
classMap.put("config_statistics", ConfigStatistic.class);
|
||
SysUser user = UserUtils.getUser();
|
||
hColumns += ",s_asn,d_asn,action,found_time,recv_time,entrance_id,clj_ip,transport_layer_protocol,addr_type,server_ip,"
|
||
+ "client_ip,server_port,client_port,deviceid,link_id,encap_type,direction,inner_smac,inner_dmac,"
|
||
+ "stream_type,nest_addr_list,server_locate,client_locate,s_subscribe_id,d_subscribe_id,user_region,scene_file,";
|
||
|
||
String cfgIndexInfoNoExport = "," + hColumns;
|
||
noExportMap.put("config_statistics", cfgIndexInfoNoExport);
|
||
|
||
Properties msgProp = getMsgProp();
|
||
ConfigStatistic configStatistic = new ConfigStatistic();
|
||
long sums = 0;
|
||
for (ConfigStatistic entity : list) {
|
||
if (null != entity.getSum() && !"".equals(entity.getSum())) {
|
||
sums += entity.getSum();
|
||
}
|
||
|
||
}
|
||
String report_total = msgProp.getProperty("report_total");
|
||
configStatistic.setCfgId(report_total);
|
||
configStatistic.setCfgDesc("--");
|
||
configStatistic.setSum(sums);
|
||
list.add(configStatistic);
|
||
|
||
dataMap.put("config_statistics", list);
|
||
String timeRange=msgProp.getProperty("config_statistics","config_statistics");
|
||
if(log.getBeginDate()!=null){
|
||
timeRange+=" "+msgProp.getProperty("begin_date")+":"+log.getBeginDate();
|
||
}
|
||
if(log.getEndDate()!=null){
|
||
timeRange+=" "+msgProp.getProperty("end_date")+":"+log.getEndDate();
|
||
}
|
||
noExportMap.put("timeRange", timeRange);
|
||
|
||
/* } */
|
||
if ("csv".equals(type)) {
|
||
this._exportCsv(model, request, response, redirectAttributes, "Configuration_Statistics", titleList, classMap,
|
||
dataMap, noExportMap);
|
||
} else {
|
||
this._export(model, request, response, redirectAttributes, "Configuration_Statistics", titleList, classMap,
|
||
dataMap, noExportMap);
|
||
}
|
||
} catch (Exception e) {
|
||
logger.error("Configuration_Statistics export failed", e);
|
||
addMessage(redirectAttributes, "error", "export_failed");
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
}
|
||
@RequestMapping("configTrans")
|
||
public String configTrans(Model model,Integer cfgId,String beginDate,String endDate,String timeSize,String chartType,String cfgDesc){
|
||
model.addAttribute("timeSize", timeSize);
|
||
model.addAttribute("cfgId", cfgId);
|
||
model.addAttribute("beginDate", beginDate);
|
||
model.addAttribute("endDate", endDate);
|
||
model.addAttribute("chartType_1", chartType);
|
||
if(!cfgDesc.equals("undefined") && !cfgDesc.equals("") && cfgDesc !=null){
|
||
model.addAttribute("cfgDesc", cfgDesc);
|
||
}else{
|
||
model.addAttribute("cfgDesc", "");
|
||
}
|
||
return "/dashboard/configStatisticTrans";
|
||
}
|
||
/**
|
||
*配置统计图表数据查询
|
||
*/
|
||
@RequestMapping("ajaxConfigStatistic")
|
||
@ResponseBody
|
||
public List ajaxConfigStatistic(String cfgId,String timeSize,String cfgDesc,@RequestParam(required=false)String beginDate,
|
||
@RequestParam(required=false)String endDate,Model model,HttpServletRequest request){
|
||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
List resultList = new ArrayList();
|
||
String url = Constants.LOG_BASE_URL+Constants.NTC_PZ_REPORT;
|
||
url=url+"?pageSize=-1&searchCfgId="+cfgId;
|
||
if(!StringUtil.isEmpty(timeSize)) {
|
||
if(timeSize.equals("1")){
|
||
url=url+"&searchBusinessType=2";
|
||
}else if(timeSize.equals("2")){
|
||
url=url+"&searchBusinessType=3";
|
||
}else if(timeSize.equals("3")){
|
||
url=url+"&searchBusinessType=4";
|
||
}else if(timeSize.equals("4")){
|
||
url=url+"&searchBusinessType=5";
|
||
}else if(timeSize.equals("5")){
|
||
url=url+"&searchBusinessType=6";
|
||
}
|
||
}else{
|
||
url=url+"&searchBusinessType=2";
|
||
}
|
||
try {
|
||
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) - 1);
|
||
beginDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());
|
||
}
|
||
URIBuilder uriBuilder = new URIBuilder(url);
|
||
uriBuilder.addParameter("searchReportStartTime",beginDate);
|
||
uriBuilder.addParameter("searchReportEndTime",endDate);
|
||
url=uriBuilder.toString();
|
||
|
||
String json = HttpClientUtil.get(url);
|
||
Gson gson = new GsonBuilder().create();
|
||
fromJsonList = gson.fromJson(json, new TypeToken<Map>(){}.getType());
|
||
fromJsonList=(Map<String, Object>) fromJsonList.get("data");
|
||
logger.debug("配置ID趋势数据"+fromJsonList);
|
||
JSONObject obj=JSONObject.fromObject(json);
|
||
resultList =getList(fromJsonList);
|
||
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
resultList.add(Maps.newHashMap("error","request_service_failed"));
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
return resultList;
|
||
}
|
||
|
||
public List getList(Map<String, Object> dateList){
|
||
List<Map<String,Object>> resultList = new ArrayList<Map<String,Object>>();
|
||
try {
|
||
List<Map<String, Object>> mapList=(List<Map<String, Object>>) dateList.get("list");
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
Map<String, Object> maps=new HashMap<String,Object>();
|
||
List<Double[]> list=new ArrayList<Double[]>();
|
||
Double total=0.0;
|
||
for (Map<String, Object> map : mapList) {
|
||
Double[] logs=new Double[2];
|
||
Double sum=Double.valueOf(String.valueOf(map.get("sum")));
|
||
Double date=Double.valueOf(sdf.parse(String.valueOf(map.get("reportTime"))).getTime());
|
||
total+=sum;
|
||
logs[0]=date;
|
||
logs[1]=sum;
|
||
list.add(logs);
|
||
}
|
||
maps.put("sum",total);
|
||
maps.put("result", list);
|
||
resultList.add(maps);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
return resultList;
|
||
}
|
||
|
||
// Rules Type (监测 阻断)
|
||
@RequestMapping(value={"newtrafficBlockMonitorList"})
|
||
public String serviceBlockList(@RequestParam("searchAction")String searchAction,Model model,String concent,
|
||
String detail,String dimension,String area,String operator,String timeSize,String chartType,String beginDate,String endDate){
|
||
if (StringUtils.isNotBlank(beginDate) && StringUtils.isNotBlank(endDate)) {
|
||
model.addAttribute("beginDate", beginDate);
|
||
model.addAttribute("endDate", endDate);
|
||
}else{
|
||
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);
|
||
|
||
}
|
||
model.addAttribute("searchAction", searchAction);
|
||
model.addAttribute("concent", concent);
|
||
model.addAttribute("detail", detail);
|
||
model.addAttribute("dimension", dimension);
|
||
model.addAttribute("area", area);
|
||
model.addAttribute("operator", operator);
|
||
model.addAttribute("timeSize", timeSize);
|
||
model.addAttribute("chartType", chartType);
|
||
return "/dashboard/commonNew";
|
||
}
|
||
|
||
/**
|
||
* Rules Type (监测 阻断)数据查询
|
||
*/
|
||
@RequestMapping(value="actionEntranceTransNew")
|
||
@ResponseBody
|
||
public List actionTrans(String beginDate,String endDate,String timeSize,String entranceId,@RequestParam("searchAction")String searchAction,HttpServletRequest request){
|
||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
List resultList = new ArrayList();
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
String url = Constants.DASHBOARD_URL+Constants.NTC_ACTION_ENTRANCE_REPORT_NEW;
|
||
url=url+"?searchAction="+searchAction;
|
||
try {
|
||
url = urlAddDate(url,beginDate,endDate);
|
||
if(!StringUtil.isEmpty(timeSize)) {
|
||
url=url+"&searchBusinessType="+timeSize;
|
||
}
|
||
if(entranceId.equals("astana")){
|
||
url=url+"&searchEntranceId="+1;
|
||
}else if(entranceId.equals("almaty")){
|
||
url=url+"&searchEntranceId="+2;
|
||
}
|
||
String string = HttpClientUtil.get(url);
|
||
Gson gson = new GsonBuilder().create();
|
||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||
// logger.debug(searchAction+"动作数据"+fromJsonList);
|
||
resultList = (ArrayList) fromJsonList.get("data");
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.error(searchAction+"动作详情数据获取错误"+e);
|
||
resultList.add(Maps.newHashMap("error","request_service_failed"));
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
*
|
||
*
|
||
* url路径时间参数格式化
|
||
* @param url
|
||
* @param beginDate
|
||
* @param endDate
|
||
* @return
|
||
* @throws URISyntaxException
|
||
*/
|
||
public String urlAddDate(String url,String beginDate,String endDate) throws URISyntaxException{
|
||
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) - 1);
|
||
beginDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());
|
||
}
|
||
URIBuilder uriBuilder = new URIBuilder(url);
|
||
uriBuilder.addParameter("beginDate",beginDate);
|
||
uriBuilder.addParameter("endDate",endDate);
|
||
return uriBuilder.toString();
|
||
}
|
||
|
||
//根据时间粒度格式化时间格式(5分钟 小时 天 月 年)
|
||
public static String getFormatMinute(String timeSize ,Date date) {
|
||
DateTime dateTime = new DateTime(date);
|
||
if(timeSize.equals("1")){
|
||
int minute = dateTime.getMinuteOfHour();
|
||
int formatMinute = minute % 5;
|
||
minute = minute - formatMinute;
|
||
dateTime = dateTime.withMinuteOfHour(minute).withSecondOfMinute(0).withMillisOfSecond(0);
|
||
return dateTime.toString("yyyy-MM-dd HH:mm:ss");
|
||
}else if(timeSize.equals("2")){
|
||
return dateTime.withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0).toString("yyyy-MM-dd HH:mm:ss");
|
||
}else if(timeSize.equals("3")){
|
||
return dateTime.withMillisOfDay(0).toString("yyyy-MM-dd HH:mm:ss");
|
||
}else if(timeSize.equals("4")){
|
||
return dateTime.dayOfMonth().withMinimumValue().millisOfDay().withMinimumValue().toString("yyyy-MM-dd HH:mm:ss");
|
||
}else{
|
||
return dateTime.withMonthOfYear(1).withDayOfMonth(1).millisOfDay().withMinimumValue().toString("yyyy-MM-dd HH:mm:ss");
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 协议统计图和列数据
|
||
*/
|
||
@RequestMapping(value="protocolListNew")
|
||
@ResponseBody
|
||
public List protocolListNew(Model model,Integer entranceId,Integer[] protoType,String timeSize,Integer[] operator,
|
||
@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate,HttpServletRequest request){
|
||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
List list = new ArrayList();
|
||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_PROTOCOL_STATISTIC_NEW;
|
||
try {
|
||
url=urlAddDate(url,beginDate,endDate);
|
||
if(protoType!=null){
|
||
for (Integer dom : protoType) {
|
||
if(dom!=null){
|
||
url=url+"&protoType="+dom;
|
||
}
|
||
}
|
||
}
|
||
if(operator!=null){
|
||
for (Integer oper : operator) {
|
||
if(oper!=null){
|
||
url=url+"&deviceId="+oper;
|
||
}
|
||
}
|
||
}
|
||
if(!StringUtil.isEmpty(timeSize)) {
|
||
|
||
url=url+"&searchBusinessType="+timeSize;
|
||
}else{
|
||
url=url+"&searchBusinessType=1";
|
||
}
|
||
if(entranceId!=null){
|
||
url=url+"&entranceId="+entranceId;
|
||
}
|
||
/*if (!StringUtil.isEmpty(searchQuotaType)) {
|
||
url=url+"&searchQuotaType="+searchQuotaType;
|
||
}*/
|
||
String string = HttpClientUtil.get(url);
|
||
Gson gson = new GsonBuilder().create();
|
||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||
list = (ArrayList) fromJsonList.get("data");
|
||
Long totalSUnq=0l;
|
||
Long totalDUnq=0l;
|
||
Long totalLink=0l;
|
||
Long totalPackets=0l;
|
||
Double totalGByte=0d;
|
||
DecimalFormat lf = new DecimalFormat("0");
|
||
DecimalFormat f = new DecimalFormat("0.00");
|
||
DecimalFormat df = new DecimalFormat("0.0000000000");
|
||
List<CodeResult> protocolCodeList = CodeDicUtils.getCodeList("protocolCode");
|
||
//两个时间段之间的秒数
|
||
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
|
||
if(!StringUtil.isEmpty(list)){
|
||
for (Object object : list) {
|
||
Map m=(Map) object;
|
||
Double value1 = Double.parseDouble(m.get("protoId").toString());
|
||
m.put("protocolId", lf.format(m.get("protoId")));
|
||
totalGByte+=Double.parseDouble(m.get("GByte").toString());
|
||
m.put("GByte", df.format(m.get("GByte")));
|
||
m.put("sUnqNum", lf.format(m.get("sUnqNum")));
|
||
totalSUnq+=Long.parseLong( m.get("sUnqNum").toString());
|
||
m.put("dUnqNum", lf.format(m.get("dUnqNum")));
|
||
totalDUnq+=Long.parseLong( m.get("dUnqNum").toString());
|
||
m.put("packets", lf.format(m.get("packets")));
|
||
m.put("linkNum", lf.format(m.get("linkNum")));
|
||
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
|
||
m.put("pps",lf.format(avgPacket));
|
||
double avgByte=Double.parseDouble(m.get("GByte").toString())*8/allSeconds;
|
||
m.put("bps",f.format(avgByte));
|
||
totalLink+=Long.parseLong( m.get("linkNum").toString());
|
||
totalPackets+=Long.parseLong(m.get("packets").toString());
|
||
//
|
||
for (CodeResult code : protocolCodeList) {
|
||
Double value3 = Double.valueOf(code.getCode());
|
||
if(value1.equals(value3)){
|
||
m.put("protocolType", code.getItem());
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
for (Object object : list) {
|
||
Map m=(Map) object;
|
||
m.put("totalSUnq", totalSUnq);
|
||
m.put("totalDUnq", totalDUnq);
|
||
m.put("totalLink", totalLink);
|
||
m.put("totalPackets", totalPackets);
|
||
m.put("totalGByte", totalGByte);
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.error("协议数据获取错误"+e);
|
||
list.add(Maps.newHashMap("error","request_service_failed"));
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
//跳转协议类型趋势图页面
|
||
@RequestMapping("protocolsTrans")
|
||
public String protocolsTrans(Model model,String protocolId,String protocolType,String beginDate,String endDate,
|
||
String timeSize,String chartType,String dimension,String area,String operator){
|
||
model.addAttribute("timeSize", timeSize);
|
||
model.addAttribute("protocolId", protocolId);
|
||
model.addAttribute("protocolType", protocolType);
|
||
model.addAttribute("beginDate", beginDate);
|
||
model.addAttribute("endDate", endDate);
|
||
model.addAttribute("chartType_1", chartType);
|
||
model.addAttribute("dimension", dimension);
|
||
model.addAttribute("operator", operator);
|
||
model.addAttribute("area", area);
|
||
return "/dashboard/newProtocolsTrans";
|
||
}
|
||
/**
|
||
*Protocols图表数据查询
|
||
*/
|
||
@RequestMapping("ajaxProtocolsStatistic")
|
||
@ResponseBody
|
||
public List ajaxProtocolsStatistic(String protocolType,String protocolId,String timeSize,String area,String dimension,Integer[] operator,
|
||
@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate,Model model,HttpServletRequest request){
|
||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
List resultList = new ArrayList();
|
||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_PROTOCOL_STATISTIC_NEW;
|
||
try {
|
||
url=urlAddDate(url,beginDate,endDate);
|
||
url=url+"&protoType="+protocolId;
|
||
if(!StringUtil.isEmpty(timeSize)) {
|
||
url=url+"&searchBusinessType="+timeSize;
|
||
}else{
|
||
url=url+"&searchBusinessType=1";
|
||
}
|
||
if(!StringUtil.isEmpty(area)){
|
||
url=url+"&entranceId="+area;
|
||
}
|
||
if(operator!=null){
|
||
for (Integer oper : operator) {
|
||
if(oper!=null){
|
||
url=url+"&deviceId="+oper;
|
||
}
|
||
}
|
||
}
|
||
if(dimension.equals("bps")){
|
||
url=url+"&searchQuotaType=1";
|
||
}else if(dimension.equals("pps")){
|
||
url=url+"&searchQuotaType=2";
|
||
}else if(dimension.equals("link count")){
|
||
url=url+"&searchQuotaType=3";
|
||
}else if(dimension.equals("uniq client ip count")){
|
||
url=url+"&searchQuotaType=4";
|
||
}else if(dimension.equals("uniq server ip count")){
|
||
url=url+"&searchQuotaType=5";
|
||
}
|
||
String json = HttpClientUtil.get(url);
|
||
Gson gson = new GsonBuilder().create();
|
||
fromJsonList = gson.fromJson(json, new TypeToken<Map>(){}.getType());
|
||
|
||
List<Map<String,Object>> resultLists = new ArrayList<Map<String,Object>>();
|
||
List<Map<String, Object>> mapList=(List<Map<String, Object>>) fromJsonList.get("data");
|
||
Map<String, Object> maps=new HashMap<String,Object>();
|
||
List<Double[]> list=new ArrayList<Double[]>();
|
||
Double total=0.0;
|
||
for (Map<String, Object> map : mapList) {
|
||
Double[] logs=new Double[2];
|
||
Double sum=Double.valueOf(String.valueOf(map.get("sum")));
|
||
Double date=Double.valueOf(String.valueOf(map.get("reportTime")));
|
||
total+=sum;
|
||
logs[0]=date;
|
||
logs[1]=sum;
|
||
list.add(logs);
|
||
}
|
||
maps.put("sum",total);
|
||
maps.put("result", list);
|
||
resultLists.add(maps);
|
||
|
||
resultList=resultLists;
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
resultList.add(Maps.newHashMap("error","request_service_failed"));
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* App详情统计图跟表
|
||
*/
|
||
@RequestMapping(value="appListNew")
|
||
@ResponseBody
|
||
public List appListNew(Integer entranceId,@RequestParam(value="appType",required=false)Integer[] appType,String timeSize,Integer[] operator,
|
||
@RequestParam(value="beginDate",required=false)String beginDate,@RequestParam(value="endDate",required=false)String endDate,HttpServletRequest request){
|
||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
List list = new ArrayList();
|
||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_APP_STATISTIC_NEW;
|
||
try {
|
||
url=urlAddDate(url,beginDate,endDate);
|
||
if(appType!=null){
|
||
for (Integer dom : appType) {
|
||
if(dom!=null){
|
||
url=url+"&appType="+dom;
|
||
}
|
||
}
|
||
}
|
||
if(operator!=null){
|
||
for (Integer oper : operator) {
|
||
if(oper!=null){
|
||
url=url+"&deviceId="+oper;
|
||
}
|
||
}
|
||
}
|
||
if(!StringUtil.isEmpty(timeSize)) {
|
||
url=url+"&searchBusinessType="+timeSize;
|
||
}else{
|
||
url=url+"&searchBusinessType=1";
|
||
}
|
||
if(entranceId!=null){
|
||
url=url+"&entranceId="+entranceId;
|
||
}
|
||
/*if (!StringUtil.isEmpty(searchQuotaType)) {
|
||
url=url+"&searchQuotaType="+searchQuotaType;
|
||
}*/
|
||
String string = HttpClientUtil.get(url);
|
||
Gson gson = new GsonBuilder().create();
|
||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||
list = (ArrayList) fromJsonList.get("data");
|
||
Long totalSUnq=0l;
|
||
Long totalDUnq=0l;
|
||
Long totalLink=0l;
|
||
Long totalPackets=0l;
|
||
Double totalGByte=0d;
|
||
DecimalFormat lf = new DecimalFormat("0");
|
||
DecimalFormat f = new DecimalFormat("0.00");
|
||
DecimalFormat df = new DecimalFormat("0.0000000000");
|
||
//两个时间段之间的秒数
|
||
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
|
||
List<CodeResult> appCodeList = CodeDicUtils.getCodeList("appCode");
|
||
if(!StringUtil.isEmpty(list)){
|
||
for (Object object : list) {
|
||
Map m=(Map) object;
|
||
Double value1 = Double.parseDouble(m.get("appId").toString());
|
||
m.put("appId", lf.format(m.get("appId")));
|
||
totalGByte+=Double.parseDouble(m.get("GByte").toString());
|
||
m.put("GByte", df.format(m.get("GByte")));
|
||
m.put("sUnqNum", lf.format(m.get("sUnqNum")));
|
||
totalSUnq+=Long.parseLong( m.get("sUnqNum").toString());
|
||
m.put("dUnqNum", lf.format(m.get("dUnqNum")));
|
||
totalDUnq+=Long.parseLong( m.get("dUnqNum").toString());
|
||
m.put("packets", lf.format(m.get("packets")));
|
||
m.put("linkNum", lf.format(m.get("linkNum")));
|
||
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
|
||
m.put("pps",lf.format(avgPacket));
|
||
double avgByte=Double.parseDouble(m.get("GByte").toString())*8/allSeconds;
|
||
m.put("bps",f.format(avgByte));
|
||
totalLink+=Long.parseLong( m.get("linkNum").toString());
|
||
totalPackets+=Long.parseLong(m.get("packets").toString());
|
||
// 协议没匹配的匹配app码表
|
||
for (CodeResult code : appCodeList) {
|
||
Double value3 = Double.valueOf(code.getCode());
|
||
if(value1.equals(value3)){
|
||
m.put("appType", code.getItem());
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
for (Object object : list) {
|
||
Map m=(Map) object;
|
||
m.put("totalSUnq", totalSUnq);
|
||
m.put("totalDUnq", totalDUnq);
|
||
m.put("totalLink", totalLink);
|
||
m.put("totalPackets", totalPackets);
|
||
m.put("totalGByte", totalGByte);
|
||
}
|
||
}
|
||
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.error("app 数据获取错误"+e);
|
||
list.add(Maps.newHashMap("error","request_service_failed"));
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
//跳转APP趋势图页面
|
||
@RequestMapping("appTransList")
|
||
public String appTransList(Model model,String appId,String appType,String beginDate,String endDate,
|
||
String timeSize,String chartType,String dimension,String area,String operator){
|
||
model.addAttribute("timeSize", timeSize);
|
||
model.addAttribute("appId", appId);
|
||
model.addAttribute("appType", appType);
|
||
model.addAttribute("beginDate", beginDate);
|
||
model.addAttribute("endDate", endDate);
|
||
model.addAttribute("operator", operator);
|
||
model.addAttribute("chartType_1", chartType);
|
||
model.addAttribute("dimension", dimension);
|
||
model.addAttribute("area", area);
|
||
return "/dashboard/newAppTrans";
|
||
}
|
||
/**
|
||
*APP 图表数据查询
|
||
*/
|
||
@RequestMapping("ajaxAppStatistic")
|
||
@ResponseBody
|
||
public List ajaxAppStatistic(String appId,String appType,String timeSize,String area,String dimension,Integer[] operator,
|
||
@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate,Model model,HttpServletRequest request){
|
||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
List resultList = new ArrayList();
|
||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_APP_STATISTIC_NEW;
|
||
try {
|
||
url=urlAddDate(url,beginDate,endDate);
|
||
url=url+"&appType="+appId;
|
||
if(!StringUtil.isEmpty(timeSize)) {//时间粒度
|
||
url=url+"&searchBusinessType="+timeSize;
|
||
}else{
|
||
url=url+"&searchBusinessType=1";
|
||
}
|
||
if(operator!=null){
|
||
for (Integer oper : operator) {
|
||
if(oper!=null){
|
||
url=url+"&deviceId="+oper;
|
||
}
|
||
}
|
||
}
|
||
if(!StringUtil.isEmpty(area)){//地域
|
||
url=url+"&entranceId="+area;
|
||
}
|
||
if(dimension.equals("bps")){//统计维度
|
||
url=url+"&searchQuotaType=1";
|
||
}else if(dimension.equals("pps")){
|
||
url=url+"&searchQuotaType=2";
|
||
}else if(dimension.equals("link count")){
|
||
url=url+"&searchQuotaType=3";
|
||
}else if(dimension.equals("uniq client ip count")){
|
||
url=url+"&searchQuotaType=4";
|
||
}else if(dimension.equals("uniq server ip count")){
|
||
url=url+"&searchQuotaType=5";
|
||
}
|
||
String json = HttpClientUtil.get(url);
|
||
Gson gson = new GsonBuilder().create();
|
||
fromJsonList = gson.fromJson(json, new TypeToken<Map>(){}.getType());
|
||
|
||
List<Map<String,Object>> resultLists = new ArrayList<Map<String,Object>>();
|
||
List<Map<String, Object>> mapList=(List<Map<String, Object>>) fromJsonList.get("data");
|
||
Map<String, Object> maps=new HashMap<String,Object>();
|
||
List<Double[]> list=new ArrayList<Double[]>();
|
||
Double total=0.0;
|
||
for (Map<String, Object> map : mapList) {
|
||
Double[] logs=new Double[2];
|
||
Double sum=Double.valueOf(String.valueOf(map.get("sum")));
|
||
Double date=Double.valueOf(String.valueOf(map.get("reportTime")));
|
||
total+=sum;
|
||
logs[0]=date;
|
||
logs[1]=sum;
|
||
list.add(logs);
|
||
}
|
||
maps.put("sum",total);
|
||
maps.put("result", list);
|
||
resultLists.add(maps);
|
||
resultList=resultLists;
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
resultList.add(Maps.newHashMap("error","request_service_failed"));
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* domain统计图跟表
|
||
*/
|
||
@RequestMapping(value="domainListNew")
|
||
@ResponseBody
|
||
public List domainListNew(Integer entranceId,Integer[] domain,Model model,String timeSize,Integer[] operator,
|
||
@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate,HttpServletRequest request){
|
||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
List list = new ArrayList();
|
||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_DOMAIN_STATISTIC_NEW;
|
||
try {
|
||
url=urlAddDate(url, beginDate, endDate);
|
||
if(domain!=null){
|
||
for (Integer dom : domain) {
|
||
if(dom!=null){
|
||
url=url+"&domain="+dom;
|
||
}
|
||
}
|
||
}
|
||
if(operator!=null){
|
||
for (Integer oper : operator) {
|
||
if(oper!=null){
|
||
url=url+"&deviceId="+oper;
|
||
}
|
||
}
|
||
}
|
||
if(!StringUtil.isEmpty(timeSize)) {
|
||
url=url+"&searchBusinessType="+timeSize;
|
||
}else{
|
||
url=url+"&searchBusinessType=1";
|
||
}
|
||
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());
|
||
list = (ArrayList) fromJsonList.get("data");
|
||
Long totalSUnq=0l;
|
||
Long totalDUnq=0l;
|
||
Long totalLink=0l;
|
||
Long totalPackets=0l;
|
||
Double totalGByte=0d;
|
||
DecimalFormat lf = new DecimalFormat("0");
|
||
DecimalFormat f = new DecimalFormat("0.00");
|
||
DecimalFormat df = new DecimalFormat("0.0000000000");
|
||
//两个时间段之间的秒数
|
||
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
|
||
List<CodeResult> domainCodeList = CodeDicUtils.getCodeList("domainCode");
|
||
if(!StringUtil.isEmpty(list)){
|
||
for (Object object : list) {
|
||
Map m=(Map) object;
|
||
Double value1 = Double.parseDouble(m.get("domainId").toString());
|
||
m.put("domain", lf.format(m.get("domainId")));
|
||
totalGByte+=Double.parseDouble(m.get("GByte").toString());
|
||
m.put("GByte", df.format(m.get("GByte")));
|
||
m.put("sUnqNum", lf.format(m.get("sUnqNum")));
|
||
totalSUnq+=Long.parseLong( m.get("sUnqNum").toString());
|
||
m.put("dUnqNum", lf.format(m.get("dUnqNum")));
|
||
totalDUnq+=Long.parseLong( m.get("dUnqNum").toString());
|
||
m.put("packets", lf.format(m.get("packets")));
|
||
m.put("linkNum", lf.format(m.get("linkNum")));
|
||
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
|
||
m.put("pps",lf.format(avgPacket));
|
||
double avgByte=Double.parseDouble(m.get("GByte").toString())*8/allSeconds;
|
||
m.put("bps",f.format(avgByte));
|
||
totalLink+=Long.parseLong( m.get("linkNum").toString());
|
||
totalPackets+=Long.parseLong(m.get("packets").toString());
|
||
// 协议没匹配的匹配app码表
|
||
for (CodeResult code : domainCodeList) {
|
||
Double value3 = Double.valueOf(code.getCode());
|
||
if(value1.equals(value3)){
|
||
m.put("domainName", code.getItem());
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
for (Object object : list) {
|
||
Map m=(Map) object;
|
||
m.put("totalSUnq", totalSUnq);
|
||
m.put("totalDUnq", totalDUnq);
|
||
m.put("totalLink", totalLink);
|
||
m.put("totalPackets", totalPackets);
|
||
m.put("totalGByte", totalGByte);
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.error("域名数据获取错误"+e);
|
||
list.add(Maps.newHashMap("error","request_service_failed"));
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
//跳转Domain趋势图页面
|
||
@RequestMapping("domainTransList")
|
||
public String domainTransList(Model model,String domain,String domainName,String beginDate,String endDate,
|
||
String timeSize,String chartType,String dimension,String area,String operator){
|
||
model.addAttribute("timeSize", timeSize);
|
||
model.addAttribute("domainName", domainName);
|
||
model.addAttribute("domain", domain);
|
||
model.addAttribute("beginDate", beginDate);
|
||
model.addAttribute("endDate", endDate);
|
||
model.addAttribute("chartType_1", chartType);
|
||
model.addAttribute("operator", operator);
|
||
model.addAttribute("dimension", dimension);
|
||
model.addAttribute("area", area);
|
||
return "/dashboard/newDomainTrans";
|
||
}
|
||
|
||
/**
|
||
*Domain 图表数据查询
|
||
*/
|
||
@RequestMapping("ajaxDomainStatistic")
|
||
@ResponseBody
|
||
public List ajaxDomainStatistic(String domain,String domainName,String timeSize,String area,String dimension,Integer[] operator,
|
||
@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate,Model model,HttpServletRequest request){
|
||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
List resultList = new ArrayList();
|
||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
String url = Constants.LOG_BASE_URL+Constants.TRAFFIC_DOMAIN_STATISTIC_NEW;
|
||
try {
|
||
url=urlAddDate(url,beginDate,endDate);
|
||
url=url+"&domain="+domain;
|
||
if(operator!=null){
|
||
for (Integer oper : operator) {
|
||
if(oper!=null){
|
||
url=url+"&deviceId="+oper;
|
||
}
|
||
}
|
||
}
|
||
if(!StringUtil.isEmpty(timeSize)) {
|
||
url=url+"&searchBusinessType="+timeSize;
|
||
}else{
|
||
url=url+"&searchBusinessType=1";
|
||
}
|
||
if(!StringUtil.isEmpty(area)){//地域
|
||
url=url+"&entranceId="+area;
|
||
}
|
||
if(dimension.equals("bps")){//统计维度
|
||
url=url+"&searchQuotaType=1";
|
||
}else if(dimension.equals("pps")){
|
||
url=url+"&searchQuotaType=2";
|
||
}else if(dimension.equals("link count")){
|
||
url=url+"&searchQuotaType=3";
|
||
}else if(dimension.equals("uniq client ip count")){
|
||
url=url+"&searchQuotaType=4";
|
||
}else if(dimension.equals("uniq server ip count")){
|
||
url=url+"&searchQuotaType=5";
|
||
}
|
||
|
||
String json = HttpClientUtil.get(url);
|
||
Gson gson = new GsonBuilder().create();
|
||
fromJsonList = gson.fromJson(json, new TypeToken<Map>(){}.getType());
|
||
|
||
List<Map<String,Object>> resultLists = new ArrayList<Map<String,Object>>();
|
||
List<Map<String, Object>> mapList=(List<Map<String, Object>>) fromJsonList.get("data");
|
||
Map<String, Object> maps=new HashMap<String,Object>();
|
||
List<Double[]> list=new ArrayList<Double[]>();
|
||
Double total=0.0;
|
||
for (Map<String, Object> map : mapList) {
|
||
Double[] logs=new Double[2];
|
||
Double sum=Double.valueOf(String.valueOf(map.get("sum")));
|
||
Double date=Double.valueOf(String.valueOf(map.get("reportTime")));
|
||
total+=sum;
|
||
logs[0]=date;
|
||
logs[1]=sum;
|
||
list.add(logs);
|
||
}
|
||
maps.put("sum",total);
|
||
maps.put("result", list);
|
||
resultLists.add(maps);
|
||
resultList=resultLists;
|
||
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
resultList.add(Maps.newHashMap("error","request_service_failed"));
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
return resultList;
|
||
}
|
||
/**
|
||
* Active Client IP 统计图跟列表
|
||
*/
|
||
@RequestMapping(value="activeClientIPListNew")
|
||
@ResponseBody
|
||
public List activeClientIPListNew(Integer entranceId,String timeSize,@RequestParam(value="beginDate",required=false)String beginDate,
|
||
Integer[] operator,@RequestParam(value="endDate",required=false)String endDate,String dimension,HttpServletRequest request){
|
||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
List list = new ArrayList();
|
||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_SOURCE_IP_STATISTIC_NEW;
|
||
try {
|
||
url=urlAddDate(url,beginDate,endDate);
|
||
url=url+"&flagId=0";
|
||
if(!StringUtil.isEmpty(timeSize)) {
|
||
url=url+"&searchBusinessType="+timeSize;
|
||
}else{
|
||
url=url+"&searchBusinessType=1";
|
||
}
|
||
if(operator!=null){
|
||
for (Integer oper : operator) {
|
||
if(oper!=null){
|
||
url=url+"&deviceId="+oper;
|
||
}
|
||
}
|
||
}
|
||
if(entranceId!=null){
|
||
url=url+"&entranceId="+entranceId;
|
||
}
|
||
if(dimension.equals("bps")){//统计维度
|
||
url=url+"&searchQuotaType=1";
|
||
}else if(dimension.equals("pps")){
|
||
url=url+"&searchQuotaType=2";
|
||
}else if(dimension.equals("link count")){
|
||
url=url+"&searchQuotaType=3";
|
||
}
|
||
String string = HttpClientUtil.get(url);
|
||
Gson gson = new GsonBuilder().create();
|
||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||
list = (ArrayList) fromJsonList.get("data");
|
||
Long totalLink=0l;
|
||
Long totalPackets=0l;
|
||
Double totalGByte=0d;
|
||
DecimalFormat lf = new DecimalFormat("0");
|
||
DecimalFormat f = new DecimalFormat("0.00");
|
||
DecimalFormat df = new DecimalFormat("0.0000000000");
|
||
//两个时间段之间的秒数
|
||
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
|
||
if(!StringUtil.isEmpty(list)){
|
||
for (Object object : list) {
|
||
Map m=(Map) object;
|
||
// Double value1 = Double.parseDouble(m.get("sIp").toString());
|
||
m.put("sIp", m.get("sIp"));
|
||
totalGByte+=Double.parseDouble(m.get("GByte").toString());
|
||
m.put("GByte", df.format(m.get("GByte")));
|
||
m.put("packets", lf.format(m.get("packets")));
|
||
m.put("linkNum", lf.format(m.get("linkNum")));
|
||
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
|
||
m.put("pps",lf.format(avgPacket));
|
||
double avgByte=Double.parseDouble(m.get("GByte").toString())*8/allSeconds;
|
||
m.put("bps",f.format(avgByte));
|
||
totalLink+=Long.parseLong( m.get("linkNum").toString());
|
||
totalPackets+=Long.parseLong(m.get("packets").toString());
|
||
}
|
||
for (Object object : list) {
|
||
Map m=(Map) object;
|
||
m.put("totalLink", totalLink);
|
||
m.put("totalPackets", totalPackets);
|
||
m.put("totalGByte", totalGByte);
|
||
}
|
||
}
|
||
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.error("ClientIP据获取错误"+e);
|
||
list.add(Maps.newHashMap("error","request_service_failed"));
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
//跳转client IP趋势图页面
|
||
@RequestMapping("clientIPTransList")
|
||
public String clientIPTransList(Model model,String sIp,String beginDate,String endDate,String timeSize,
|
||
String chartType,String dimension,String area,String operator){
|
||
model.addAttribute("timeSize", timeSize);
|
||
model.addAttribute("sIp", sIp);
|
||
model.addAttribute("beginDate", beginDate);
|
||
model.addAttribute("endDate", endDate);
|
||
model.addAttribute("chartType_1", chartType);
|
||
model.addAttribute("operator", operator);
|
||
model.addAttribute("dimension", dimension);
|
||
model.addAttribute("area", area);
|
||
return "/dashboard/newActiveClientIPTrans";
|
||
}
|
||
/**
|
||
*client IP 图表数据查询
|
||
*/
|
||
@RequestMapping("ajaxClientIPStatistic")
|
||
@ResponseBody
|
||
public List ajaxClientIPStatistic(String sIp,String timeSize,String area,String dimension,Integer[] operator,
|
||
@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate,Model model,HttpServletRequest request){
|
||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
List resultList = new ArrayList();
|
||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_SOURCE_IP_STATISTIC_NEW;
|
||
try {
|
||
url=urlAddDate(url,beginDate,endDate);
|
||
url=url+"&sIp="+sIp;
|
||
if(!StringUtil.isEmpty(timeSize)) {//时间粒度
|
||
url=url+"&searchBusinessType="+timeSize;
|
||
}else{
|
||
url=url+"&searchBusinessType=1";
|
||
}
|
||
if(operator!=null){
|
||
for (Integer oper : operator) {
|
||
if(oper!=null){
|
||
url=url+"&deviceId="+oper;
|
||
}
|
||
}
|
||
}
|
||
if(!StringUtil.isEmpty(area)){//地域
|
||
url=url+"&entranceId="+area;
|
||
}
|
||
if(dimension.equals("bps")){//统计维度
|
||
url=url+"&searchQuotaType=1";
|
||
}else if(dimension.equals("pps")){
|
||
url=url+"&searchQuotaType=2";
|
||
}else if(dimension.equals("link count")){
|
||
url=url+"&searchQuotaType=3";
|
||
}
|
||
String json = HttpClientUtil.get(url);
|
||
Gson gson = new GsonBuilder().create();
|
||
fromJsonList = gson.fromJson(json, new TypeToken<Map>(){}.getType());
|
||
|
||
List<Map<String,Object>> resultLists = new ArrayList<Map<String,Object>>();
|
||
List<Map<String, Object>> mapList=(List<Map<String, Object>>) fromJsonList.get("data");
|
||
Map<String, Object> maps=new HashMap<String,Object>();
|
||
List<Double[]> list=new ArrayList<Double[]>();
|
||
Double total=0.0;
|
||
for (Map<String, Object> map : mapList) {
|
||
Double[] logs=new Double[2];
|
||
Double sum=Double.valueOf(String.valueOf(map.get("sum")));
|
||
Double date=Double.valueOf(String.valueOf(map.get("reportTime")));
|
||
total+=sum;
|
||
logs[0]=date;
|
||
logs[1]=sum;
|
||
list.add(logs);
|
||
}
|
||
maps.put("sum",total);
|
||
maps.put("result", list);
|
||
resultLists.add(maps);
|
||
resultList=resultLists;
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
resultList.add(Maps.newHashMap("error","request_service_failed"));
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
return resultList;
|
||
}
|
||
/**
|
||
* Active Server IP 统计图跟列表
|
||
*/
|
||
@RequestMapping(value="activeServerIPListNew")
|
||
@ResponseBody
|
||
public List activeServerIPListNew(Integer entranceId,String timeSize,@RequestParam(value="beginDate",required=false)String beginDate,
|
||
@RequestParam(value="endDate",required=false)String endDate,String dimension,Integer[] operator,HttpServletRequest request){
|
||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
List list = new ArrayList();
|
||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_DEST_IP_STATISTIC_NEW;
|
||
try {
|
||
url=urlAddDate(url,beginDate,endDate);
|
||
url=url+"&flagId=0";
|
||
if(!StringUtil.isEmpty(timeSize)) {
|
||
url=url+"&searchBusinessType="+timeSize;
|
||
}else{
|
||
url=url+"&searchBusinessType=1";
|
||
}
|
||
if(entranceId!=null){
|
||
url=url+"&entranceId="+entranceId;
|
||
}
|
||
if(operator!=null){
|
||
for (Integer oper : operator) {
|
||
if(oper!=null){
|
||
url=url+"&deviceId="+oper;
|
||
}
|
||
}
|
||
}
|
||
if(dimension.equals("bps")){//统计维度
|
||
url=url+"&searchQuotaType=1";
|
||
}else if(dimension.equals("pps")){
|
||
url=url+"&searchQuotaType=2";
|
||
}else if(dimension.equals("link count")){
|
||
url=url+"&searchQuotaType=3";
|
||
}
|
||
String string = HttpClientUtil.get(url);
|
||
Gson gson = new GsonBuilder().create();
|
||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||
list = (ArrayList) fromJsonList.get("data");
|
||
Long totalLink=0l;
|
||
Long totalPackets=0l;
|
||
Double totalGByte=0d;
|
||
DecimalFormat lf = new DecimalFormat("0");
|
||
DecimalFormat f = new DecimalFormat("0.00");
|
||
DecimalFormat df = new DecimalFormat("0.0000000000");
|
||
//两个时间段之间的秒数
|
||
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
|
||
if(!StringUtil.isEmpty(list)){
|
||
for (Object object : list) {
|
||
Map m=(Map) object;
|
||
m.put("dIp", m.get("dIp"));
|
||
totalGByte+=Double.parseDouble(m.get("GByte").toString());
|
||
m.put("GByte", df.format(m.get("GByte")));
|
||
m.put("packets", lf.format(m.get("packets")));
|
||
m.put("linkNum", lf.format(m.get("linkNum")));
|
||
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
|
||
m.put("pps",lf.format(avgPacket));
|
||
double avgByte=Double.parseDouble(m.get("GByte").toString())*8/allSeconds;
|
||
m.put("bps",f.format(avgByte));
|
||
totalLink+=Long.parseLong( m.get("linkNum").toString());
|
||
totalPackets+=Long.parseLong(m.get("packets").toString());
|
||
}
|
||
for (Object object : list) {
|
||
Map m=(Map) object;
|
||
m.put("totalLink", totalLink);
|
||
m.put("totalPackets", totalPackets);
|
||
m.put("totalGByte", totalGByte);
|
||
}
|
||
}
|
||
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.error("ServerIP数据获取错误"+e);
|
||
list.add(Maps.newHashMap("error","request_service_failed"));
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
//跳转server IP趋势图页面
|
||
@RequestMapping("serverIPTransList")
|
||
public String serverIPTransList(Model model,String dIp,String beginDate,String endDate,String timeSize,String operator,String chartType,String dimension,String area){
|
||
model.addAttribute("timeSize", timeSize);
|
||
model.addAttribute("dIp", dIp);
|
||
model.addAttribute("beginDate", beginDate);
|
||
model.addAttribute("endDate", endDate);
|
||
model.addAttribute("chartType_1", chartType);
|
||
model.addAttribute("operator", operator);
|
||
model.addAttribute("dimension", dimension);
|
||
model.addAttribute("area", area);
|
||
return "/dashboard/newActiveServerIPTrans";
|
||
}
|
||
/**
|
||
*server IP 图表数据查询
|
||
*/
|
||
@RequestMapping("ajaxServerIPStatistic")
|
||
@ResponseBody
|
||
public List ajaxServerIPStatistic(String dIp,String timeSize,String area,String dimension,Integer[] operator,
|
||
@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate,Model model,HttpServletRequest request){
|
||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
List resultList = new ArrayList();
|
||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_DEST_IP_STATISTIC_NEW;
|
||
try {
|
||
url=urlAddDate(url,beginDate,endDate);
|
||
url=url+"&dIp="+dIp;
|
||
if(!StringUtil.isEmpty(timeSize)) {//时间粒度
|
||
url=url+"&searchBusinessType="+timeSize;
|
||
}else{
|
||
url=url+"&searchBusinessType=1";
|
||
}
|
||
|
||
if(!StringUtil.isEmpty(area)){//地域
|
||
url=url+"&entranceId="+area;
|
||
}
|
||
if(operator!=null){
|
||
for (Integer oper : operator) {
|
||
if(oper!=null){
|
||
url=url+"&deviceId="+oper;
|
||
}
|
||
}
|
||
}
|
||
if(dimension.equals("bps")){//统计维度
|
||
url=url+"&searchQuotaType=1";
|
||
}else if(dimension.equals("pps")){
|
||
url=url+"&searchQuotaType=2";
|
||
}else if(dimension.equals("link count")){
|
||
url=url+"&searchQuotaType=3";
|
||
}
|
||
String json = HttpClientUtil.get(url);
|
||
Gson gson = new GsonBuilder().create();
|
||
fromJsonList = gson.fromJson(json, new TypeToken<Map>(){}.getType());
|
||
|
||
List<Map<String,Object>> resultLists = new ArrayList<Map<String,Object>>();
|
||
List<Map<String, Object>> mapList=(List<Map<String, Object>>) fromJsonList.get("data");
|
||
Map<String, Object> maps=new HashMap<String,Object>();
|
||
List<Double[]> list=new ArrayList<Double[]>();
|
||
Double total=0.0;
|
||
for (Map<String, Object> map : mapList) {
|
||
Double[] logs=new Double[2];
|
||
Double sum=Double.valueOf(String.valueOf(map.get("sum")));
|
||
Double date=Double.valueOf(String.valueOf(map.get("reportTime")));
|
||
total+=sum;
|
||
logs[0]=date;
|
||
logs[1]=sum;
|
||
list.add(logs);
|
||
}
|
||
maps.put("sum",total);
|
||
maps.put("result", list);
|
||
resultLists.add(maps);
|
||
resultList=resultLists;
|
||
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
resultList.add(Maps.newHashMap("error","request_service_failed"));
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
return resultList;
|
||
}
|
||
|
||
/**
|
||
* SubscriberID 统计图跟列表
|
||
*/
|
||
@RequestMapping(value="subscriberIDListNew")
|
||
@ResponseBody
|
||
public List activeSubscriberIDListNew(Integer entranceId,String timeSize,@RequestParam(value="beginDate",required=false)String beginDate,
|
||
@RequestParam(value="endDate",required=false)String endDate,String dimension,Integer[] operator,HttpServletRequest request){
|
||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
List list = new ArrayList();
|
||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_SUBSCRIBER_ID_STATISTIC_NEW;
|
||
try {
|
||
url=urlAddDate(url,beginDate,endDate);
|
||
url=url+"&flagId=0";
|
||
if(!StringUtil.isEmpty(timeSize)) {
|
||
url=url+"&searchBusinessType="+timeSize;
|
||
}else{
|
||
url=url+"&searchBusinessType=1";
|
||
}
|
||
if(entranceId!=null){
|
||
url=url+"&entranceId="+entranceId;
|
||
}
|
||
if(operator!=null){
|
||
for (Integer oper : operator) {
|
||
if(oper!=null){
|
||
url=url+"&deviceId="+oper;
|
||
}
|
||
}
|
||
}
|
||
if(dimension.equals("bps")){//统计维度
|
||
url=url+"&searchQuotaType=1";
|
||
}else if(dimension.equals("pps")){
|
||
url=url+"&searchQuotaType=2";
|
||
}else if(dimension.equals("link count")){
|
||
url=url+"&searchQuotaType=3";
|
||
}
|
||
String string = HttpClientUtil.get(url);
|
||
Gson gson = new GsonBuilder().create();
|
||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
||
list = (ArrayList) fromJsonList.get("data");
|
||
Long totalLink=0l;
|
||
Long totalPackets=0l;
|
||
Double totalGByte=0d;
|
||
DecimalFormat lf = new DecimalFormat("0");
|
||
DecimalFormat f = new DecimalFormat("0.00");
|
||
DecimalFormat df = new DecimalFormat("0.0000000000");
|
||
//两个时间段之间的秒数
|
||
double allSeconds = DateUtils.getSecondsOfTwoDate(sdf.parse(beginDate),sdf.parse(endDate));
|
||
if(!StringUtil.isEmpty(list)){
|
||
for (Object object : list) {
|
||
Map m=(Map) object;
|
||
m.put("subscribeId", m.get("subscribeId"));
|
||
totalGByte+=Double.parseDouble(m.get("GByte").toString());
|
||
m.put("GByte", df.format(m.get("GByte")));
|
||
m.put("packets", lf.format(m.get("packets")));
|
||
m.put("linkNum", lf.format(m.get("linkNum")));
|
||
double avgPacket=Double.parseDouble(m.get("packets").toString())/allSeconds;
|
||
m.put("pps",lf.format(avgPacket));
|
||
double avgByte=Double.parseDouble(m.get("GByte").toString())*8/allSeconds;
|
||
m.put("bps",f.format(avgByte));
|
||
totalLink+=Long.parseLong( m.get("linkNum").toString());
|
||
totalPackets+=Long.parseLong(m.get("packets").toString());
|
||
}
|
||
for (Object object : list) {
|
||
Map m=(Map) object;
|
||
m.put("totalLink", totalLink);
|
||
m.put("totalPackets", totalPackets);
|
||
m.put("totalGByte", totalGByte);
|
||
}
|
||
}
|
||
|
||
/* Map m = new HashMap();
|
||
m.put("subscribeId", "123");
|
||
m.put("GByte", df.format(933749.61));
|
||
m.put("packets", lf.format(986834603595l));
|
||
m.put("linkNum", lf.format(390387318474l));
|
||
m.put("pps",lf.format(380723));
|
||
m.put("bps",f.format(2.88));
|
||
totalLink+=Long.parseLong("390387318474");
|
||
totalPackets+=Long.parseLong("986834603595");
|
||
totalGByte+=Double.parseDouble("933749.61");
|
||
|
||
Map m1 = new HashMap();
|
||
m1.put("subscribeId", "456");
|
||
m1.put("GByte", df.format(29563.84));
|
||
m1.put("packets", lf.format(43623009686l));
|
||
m1.put("linkNum", lf.format(11121127992l));
|
||
m1.put("pps",lf.format(16830));
|
||
m1.put("bps",f.format(0.09));
|
||
totalLink+=Long.parseLong("11121127992");
|
||
totalPackets+=Long.parseLong("43623009686");
|
||
totalGByte+=Double.parseDouble("29563.84");
|
||
|
||
m.put("totalLink", totalLink);
|
||
m.put("totalPackets", totalPackets);
|
||
m.put("totalGByte", totalGByte);
|
||
|
||
m1.put("totalLink", totalLink);
|
||
m1.put("totalPackets", totalPackets);
|
||
m1.put("totalGByte", totalGByte);
|
||
|
||
list.add(m);
|
||
list.add(m1);*/
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.error("SubscriberID数据获取错误"+e);
|
||
list.add(Maps.newHashMap("error","request_service_failed"));
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
//跳转SubscriberID趋势图页面
|
||
@RequestMapping("subscriberIDTransList")
|
||
public String subscriberIDTransList(Model model,String subscribeId,String beginDate,String endDate,String timeSize,String operator,String chartType,String dimension,String area){
|
||
model.addAttribute("timeSize", timeSize);
|
||
model.addAttribute("subscribeId", subscribeId);
|
||
model.addAttribute("beginDate", beginDate);
|
||
model.addAttribute("endDate", endDate);
|
||
model.addAttribute("chartType_1", chartType);
|
||
model.addAttribute("operator", operator);
|
||
model.addAttribute("dimension", dimension);
|
||
model.addAttribute("area", area);
|
||
return "/dashboard/newSubscriberIDTrans";
|
||
}
|
||
|
||
/**
|
||
*SubscriberID 图表数据查询
|
||
*/
|
||
@RequestMapping("ajaxSubscriberIDStatistic")
|
||
@ResponseBody
|
||
public List ajaxSubscriberIDStatistic(String subscribeId,String timeSize,String area,String dimension,Integer[] operator,
|
||
@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate,Model model,HttpServletRequest request){
|
||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||
List resultList = new ArrayList();
|
||
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_SUBSCRIBER_ID_STATISTIC_NEW;
|
||
try {
|
||
url=urlAddDate(url,beginDate,endDate);
|
||
url=url+"&subscribeId="+subscribeId;
|
||
if(!StringUtil.isEmpty(timeSize)) {//时间粒度
|
||
/*if(timeSize.equals("1")){
|
||
url=url+"&searchBusinessType=2";
|
||
}else{
|
||
url=url+"&searchBusinessType="+timeSize;
|
||
}*/
|
||
url=url+"&searchBusinessType="+timeSize;
|
||
}else{
|
||
url=url+"&searchBusinessType=1";
|
||
}
|
||
|
||
if(!StringUtil.isEmpty(area)){//地域
|
||
url=url+"&entranceId="+area;
|
||
}
|
||
if(operator!=null){
|
||
for (Integer oper : operator) {
|
||
if(oper!=null){
|
||
url=url+"&deviceId="+oper;
|
||
}
|
||
}
|
||
}
|
||
if(dimension.equals("bps")){//统计维度
|
||
url=url+"&searchQuotaType=1";
|
||
}else if(dimension.equals("pps")){
|
||
url=url+"&searchQuotaType=2";
|
||
}else if(dimension.equals("link count")){
|
||
url=url+"&searchQuotaType=3";
|
||
}
|
||
String json = HttpClientUtil.get(url);
|
||
Gson gson = new GsonBuilder().create();
|
||
fromJsonList = gson.fromJson(json, new TypeToken<Map>(){}.getType());
|
||
|
||
List<Map<String,Object>> resultLists = new ArrayList<Map<String,Object>>();
|
||
List<Map<String, Object>> mapList=(List<Map<String, Object>>) fromJsonList.get("data");
|
||
Map<String, Object> maps=new HashMap<String,Object>();
|
||
List<Double[]> list=new ArrayList<Double[]>();
|
||
Double total=0.0;
|
||
for (Map<String, Object> map : mapList) {
|
||
Double[] logs=new Double[2];
|
||
Double sum=Double.valueOf(String.valueOf(map.get("sum")));
|
||
Double date=Double.valueOf(String.valueOf(map.get("reportTime")));
|
||
total+=sum;
|
||
logs[0]=date;
|
||
logs[1]=sum;
|
||
list.add(logs);
|
||
}
|
||
maps.put("sum",total);
|
||
maps.put("result", list);
|
||
resultLists.add(maps);
|
||
resultList=resultLists;
|
||
/*List<Map<String, Object>> s= new ArrayList<Map<String, Object>>();
|
||
Map<String, Object> s1=new HashMap<>();
|
||
s1.put("sum", "800");
|
||
s1.put("reportTime", "2019-05-17 07:00:00");
|
||
Map<String, Object> s2=new HashMap<>();
|
||
s2.put("sum", "600");
|
||
s2.put("reportTime", "2019-05-17 08:00:00");
|
||
Map<String, Object> s3=new HashMap<>();
|
||
s3.put("sum", "900");
|
||
s3.put("reportTime", "2019-05-17 09:00:00");
|
||
|
||
s.add(s1);
|
||
s.add(s2);
|
||
s.add(s3);
|
||
fromJsonList.put("list", s);
|
||
resultList =getList(fromJsonList);*/
|
||
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
resultList.add(Maps.newHashMap("error","request_service_failed"));
|
||
LogUtils.saveLog(request, null, e, null);
|
||
}
|
||
return resultList;
|
||
}
|
||
}
|