实时报表 用户行为统计导出功能
This commit is contained in:
@@ -1,27 +1,29 @@
|
|||||||
package com.nis.domain.dashboard;
|
package com.nis.domain.dashboard;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.nis.util.excel.ExcelField;
|
||||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
public class NtcRadiusReport implements Serializable{
|
public class NtcRadiusReport {
|
||||||
|
|
||||||
private static final long serialVersionUID = 7635016645942704971L;
|
// @JsonInclude(value = Include.NON_NULL)
|
||||||
@JsonInclude(value = Include.NON_NULL)
|
// @ApiModelProperty(value = "接入IP", required = true)
|
||||||
@ApiModelProperty(value = "接入IP", required = true)
|
@ExcelField(title = "ip_address_control", sort = 2)
|
||||||
protected String nasIp;
|
protected String nasIp;
|
||||||
@JsonInclude(value = Include.NON_NULL)
|
// @JsonInclude(value = Include.NON_NULL)
|
||||||
@ApiModelProperty(value = "用户名", required = true)
|
// @ApiModelProperty(value = "用户名", required = true)
|
||||||
|
@ExcelField(title = "account", sort = 1)
|
||||||
protected String account;
|
protected String account;
|
||||||
@JsonInclude(value = Include.NON_NULL)
|
// @JsonInclude(value = Include.NON_NULL)
|
||||||
@ApiModelProperty(value = "次数", required = true)
|
// @ApiModelProperty(value = "次数", required = true)
|
||||||
|
@ExcelField(title = "visits", sort = 3)
|
||||||
protected Long num;
|
protected Long num;
|
||||||
@JsonInclude(value = Include.NON_NULL)
|
// @JsonInclude(value = Include.NON_NULL)
|
||||||
@ApiModelProperty(value = "统计时间", required = true)
|
// @ApiModelProperty(value = "统计时间", required = true)
|
||||||
|
@ExcelField(title = "stat_time", sort = 4)
|
||||||
protected String reportTime;
|
protected String reportTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,6 +69,16 @@ public class NtcRadiusReport implements Serializable{
|
|||||||
return reportTime;
|
return reportTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "NtcRadiusReport [nasIp=" + nasIp + ", account=" + account + ", num=" + num + ", reportTime="
|
||||||
|
+ reportTime + ", searchBusinessType=" + searchBusinessType + ", searchFoundStartTime="
|
||||||
|
+ searchFoundStartTime + ", searchFoundEndTime=" + searchFoundEndTime
|
||||||
|
+ ", searchReportStartTimeCluster=" + searchReportStartTimeCluster + ", searchReportEndTimeCluster="
|
||||||
|
+ searchReportEndTimeCluster + ", searchNasIp=" + searchNasIp + ", searchAccount=" + searchAccount
|
||||||
|
+ ", groupType=" + groupType + "]";
|
||||||
|
}
|
||||||
|
|
||||||
public void setReportTime(String reportTime) {
|
public void setReportTime(String reportTime) {
|
||||||
this.reportTime = reportTime;
|
this.reportTime = reportTime;
|
||||||
}
|
}
|
||||||
@@ -74,11 +86,11 @@ public class NtcRadiusReport implements Serializable{
|
|||||||
public String getSearchBusinessType() {
|
public String getSearchBusinessType() {
|
||||||
return searchBusinessType;
|
return searchBusinessType;
|
||||||
}
|
}
|
||||||
@JsonIgnore
|
|
||||||
public void setSearchBusinessType(String searchBusinessType) {
|
public void setSearchBusinessType(String searchBusinessType) {
|
||||||
this.searchBusinessType = searchBusinessType;
|
this.searchBusinessType = searchBusinessType;
|
||||||
}
|
}
|
||||||
@JsonIgnore
|
|
||||||
public String getSearchFoundStartTime() {
|
public String getSearchFoundStartTime() {
|
||||||
return searchFoundStartTime;
|
return searchFoundStartTime;
|
||||||
}
|
}
|
||||||
@@ -86,7 +98,7 @@ public class NtcRadiusReport implements Serializable{
|
|||||||
public void setSearchFoundStartTime(String searchFoundStartTime) {
|
public void setSearchFoundStartTime(String searchFoundStartTime) {
|
||||||
this.searchFoundStartTime = searchFoundStartTime;
|
this.searchFoundStartTime = searchFoundStartTime;
|
||||||
}
|
}
|
||||||
@JsonIgnore
|
|
||||||
public String getSearchFoundEndTime() {
|
public String getSearchFoundEndTime() {
|
||||||
return searchFoundEndTime;
|
return searchFoundEndTime;
|
||||||
}
|
}
|
||||||
@@ -95,16 +107,14 @@ public class NtcRadiusReport implements Serializable{
|
|||||||
this.searchFoundEndTime = searchFoundEndTime;
|
this.searchFoundEndTime = searchFoundEndTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public Long getSearchReportStartTimeCluster() {
|
public Long getSearchReportStartTimeCluster() {
|
||||||
return searchReportStartTimeCluster;
|
return searchReportStartTimeCluster;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSearchReportStartTimeCluster(
|
public void setSearchReportStartTimeCluster(Long searchReportStartTimeCluster) {
|
||||||
Long searchReportStartTimeCluster) {
|
|
||||||
this.searchReportStartTimeCluster = searchReportStartTimeCluster;
|
this.searchReportStartTimeCluster = searchReportStartTimeCluster;
|
||||||
}
|
}
|
||||||
@JsonIgnore
|
|
||||||
public Long getSearchReportEndTimeCluster() {
|
public Long getSearchReportEndTimeCluster() {
|
||||||
return searchReportEndTimeCluster;
|
return searchReportEndTimeCluster;
|
||||||
}
|
}
|
||||||
@@ -112,7 +122,7 @@ public class NtcRadiusReport implements Serializable{
|
|||||||
public void setSearchReportEndTimeCluster(Long searchReportEndTimeCluster) {
|
public void setSearchReportEndTimeCluster(Long searchReportEndTimeCluster) {
|
||||||
this.searchReportEndTimeCluster = searchReportEndTimeCluster;
|
this.searchReportEndTimeCluster = searchReportEndTimeCluster;
|
||||||
}
|
}
|
||||||
@JsonIgnore
|
|
||||||
public String getSearchNasIp() {
|
public String getSearchNasIp() {
|
||||||
return searchNasIp;
|
return searchNasIp;
|
||||||
}
|
}
|
||||||
@@ -120,7 +130,7 @@ public class NtcRadiusReport implements Serializable{
|
|||||||
public void setSearchNasIp(String searchNasIp) {
|
public void setSearchNasIp(String searchNasIp) {
|
||||||
this.searchNasIp = searchNasIp;
|
this.searchNasIp = searchNasIp;
|
||||||
}
|
}
|
||||||
@JsonIgnore
|
|
||||||
public String getSearchAccount() {
|
public String getSearchAccount() {
|
||||||
return searchAccount;
|
return searchAccount;
|
||||||
}
|
}
|
||||||
@@ -128,11 +138,11 @@ public class NtcRadiusReport implements Serializable{
|
|||||||
public void setSearchAccount(String searchAccount) {
|
public void setSearchAccount(String searchAccount) {
|
||||||
this.searchAccount = searchAccount;
|
this.searchAccount = searchAccount;
|
||||||
}
|
}
|
||||||
@JsonIgnore
|
|
||||||
public String getGroupType() {
|
public String getGroupType() {
|
||||||
return groupType;
|
return groupType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroupType(String groupType) {
|
public void setGroupType(String groupType) {
|
||||||
this.groupType = groupType;
|
this.groupType = groupType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,13 +6,16 @@ import java.util.ArrayList;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
@@ -23,20 +26,30 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.reflect.TypeToken;
|
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.dashboard.NtcRadiusReport;
|
import com.nis.domain.dashboard.NtcRadiusReport;
|
||||||
|
import com.nis.domain.log.BaseLogEntity;
|
||||||
|
import com.nis.domain.maat.LogRecvData;
|
||||||
|
import com.nis.domain.report.NtcAsnRecord;
|
||||||
|
import com.nis.domain.report.NtcIpRangeReport;
|
||||||
import com.nis.util.Constants;
|
import com.nis.util.Constants;
|
||||||
import com.nis.util.DateUtils;
|
import com.nis.util.DateUtils;
|
||||||
import com.nis.util.StringUtil;
|
import com.nis.util.StringUtil;
|
||||||
import com.nis.util.httpclient.HttpClientUtil;
|
import com.nis.util.httpclient.HttpClientUtil;
|
||||||
import com.nis.web.controller.BaseController;
|
import com.nis.web.controller.BaseController;
|
||||||
|
import com.nis.web.security.UserUtils;
|
||||||
|
|
||||||
@Controller
|
import net.sf.json.JSONObject;
|
||||||
|
|
||||||
|
@Controller
|
||||||
@RequestMapping("${adminPath}/traffic")
|
@RequestMapping("${adminPath}/traffic")
|
||||||
public class TrafficStatisticsReportController extends BaseController {
|
public class TrafficStatisticsReportController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户行为查询
|
* 用户行为查询
|
||||||
|
*
|
||||||
* @param bean
|
* @param bean
|
||||||
* @param model
|
* @param model
|
||||||
* @param request
|
* @param request
|
||||||
@@ -44,140 +57,382 @@ public class TrafficStatisticsReportController extends BaseController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("userBehavior")
|
@RequestMapping("userBehavior")
|
||||||
public String list(@ModelAttribute("log") NtcRadiusReport bean,Model model, HttpServletRequest request, HttpServletResponse response,RedirectAttributes redirectAttributes) {
|
public String list(@ModelAttribute("log") NtcRadiusReport bean, Model model, HttpServletRequest request,
|
||||||
|
HttpServletResponse response, RedirectAttributes redirectAttributes) {
|
||||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||||
Map<String, Object> userJsonList = new HashMap<String, Object>();
|
Map<String, Object> userJsonList = new HashMap<String, Object>();
|
||||||
Map<String, Object> ipJsonList = new HashMap<String, Object>();
|
Map<String, Object> ipJsonList = new HashMap<String, Object>();
|
||||||
String searchBusinessType = bean.getSearchBusinessType();
|
String searchBusinessType = bean.getSearchBusinessType();
|
||||||
if("2".endsWith(searchBusinessType)) {
|
if ("2".endsWith(searchBusinessType)) {
|
||||||
model.addAttribute("searchBusinessType", 2);// 用户查询
|
model.addAttribute("searchBusinessType", 2);// 用户查询
|
||||||
}
|
}
|
||||||
if("3".endsWith(searchBusinessType)) {
|
if ("3".endsWith(searchBusinessType)) {
|
||||||
model.addAttribute("searchBusinessType", 3);// IP查询
|
model.addAttribute("searchBusinessType", 3);// IP查询
|
||||||
}
|
}
|
||||||
String url = Constants.DASHBOARD_URL+Constants.NTC_RADIUS_REPORT;
|
String url = Constants.DASHBOARD_URL + Constants.NTC_RADIUS_REPORT;
|
||||||
String statTime = bean.getSearchFoundStartTime();
|
String statTime = bean.getSearchFoundStartTime();
|
||||||
String endTime = bean.getSearchFoundEndTime();
|
String endTime = bean.getSearchFoundEndTime();
|
||||||
String account = bean.getAccount();
|
String account = bean.getAccount();
|
||||||
String nasIp = bean.getNasIp();
|
String nasIp = bean.getNasIp();
|
||||||
String destUrl = url+ "?searchBusinessType=1";
|
String destUrl = url + "?searchBusinessType=1";
|
||||||
String userUrl = url+ "?searchBusinessType=2";
|
String userUrl = url + "?searchBusinessType=2";
|
||||||
String ipUrl =url + "?searchBusinessType=3";
|
String ipUrl = url + "?searchBusinessType=3";
|
||||||
List list = new ArrayList();
|
List list = new ArrayList();
|
||||||
List userList = new ArrayList();
|
List userList = new ArrayList();
|
||||||
List ipList = new ArrayList();
|
List ipList = new ArrayList();
|
||||||
try {
|
try {
|
||||||
if(StringUtil.isBlank(statTime)&&StringUtil.isBlank(endTime)) {
|
if (StringUtil.isBlank(statTime) && StringUtil.isBlank(endTime)) {
|
||||||
// 设置默认时间为1小时
|
// 设置默认时间为1小时
|
||||||
// statTime=DateUtils.getDate()+" 00:00:00"; // 默认今天
|
// statTime=DateUtils.getDate()+" 00:00:00"; // 默认今天
|
||||||
// endTime=DateUtils.getDateTime();
|
// endTime=DateUtils.getDateTime();
|
||||||
|
|
||||||
Calendar cal = Calendar. getInstance ();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.setTime(new Date());
|
cal.setTime(new Date());
|
||||||
endTime = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(cal.getTime());//获取到完整的时间
|
endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").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) - 1);
|
||||||
statTime = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(cal.getTime());
|
statTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.getTime());
|
||||||
bean.setSearchFoundStartTime(statTime);
|
bean.setSearchFoundStartTime(statTime);
|
||||||
bean.setSearchFoundEndTime(endTime);
|
bean.setSearchFoundEndTime(endTime);
|
||||||
statTime=URLEncoder.encode(statTime, "UTF-8");
|
statTime = URLEncoder.encode(statTime, "UTF-8");
|
||||||
endTime=URLEncoder.encode(endTime, "UTF-8");
|
endTime = URLEncoder.encode(endTime, "UTF-8");
|
||||||
String paramUrl="&searchReportStartTime="+statTime+"&searchReportEndTime="+endTime;
|
String paramUrl = "&searchReportStartTime=" + statTime + "&searchReportEndTime=" + endTime;
|
||||||
destUrl=destUrl+paramUrl;
|
destUrl = destUrl + paramUrl;
|
||||||
userUrl=userUrl+paramUrl;
|
userUrl = userUrl + paramUrl;
|
||||||
ipUrl=ipUrl+paramUrl;
|
ipUrl = ipUrl + paramUrl;
|
||||||
}else {
|
} else {
|
||||||
statTime=URLEncoder.encode(statTime, "UTF-8");
|
statTime = URLEncoder.encode(statTime, "UTF-8");
|
||||||
endTime=URLEncoder.encode(endTime, "UTF-8");
|
endTime = URLEncoder.encode(endTime, "UTF-8");
|
||||||
String paramUrl="&searchReportStartTime="+statTime+"&searchReportEndTime="+endTime;
|
String paramUrl = "&searchReportStartTime=" + statTime + "&searchReportEndTime=" + endTime;
|
||||||
destUrl=destUrl+paramUrl;
|
destUrl = destUrl + paramUrl;
|
||||||
userUrl=userUrl+paramUrl;
|
userUrl = userUrl + paramUrl;
|
||||||
ipUrl=ipUrl+paramUrl;
|
ipUrl = ipUrl + paramUrl;
|
||||||
}
|
}
|
||||||
model.addAttribute("nowTime", DateUtils.getDateTime());
|
model.addAttribute("nowTime", DateUtils.getDateTime());
|
||||||
// 用户及IP数据
|
// 用户及IP数据
|
||||||
String string = HttpClientUtil.get(destUrl);
|
String string = HttpClientUtil.get(destUrl);
|
||||||
Gson gson = new GsonBuilder().create();
|
Gson gson = new GsonBuilder().create();
|
||||||
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
|
fromJsonList = gson.fromJson(string, new TypeToken<Map>() {
|
||||||
|
}.getType());
|
||||||
list = (ArrayList) fromJsonList.get("data");
|
list = (ArrayList) fromJsonList.get("data");
|
||||||
Map map = (Map) list.get(0);
|
Map map = (Map) list.get(0);
|
||||||
List nasIpList=(List) map.get("nasIpList");
|
List nasIpList = (List) map.get("nasIpList");
|
||||||
List accountList=(List) map.get("accountList");
|
List accountList = (List) map.get("accountList");
|
||||||
if (!StringUtil.isEmpty(nasIpList)&&nasIpList.size()>0) {
|
if (!StringUtil.isEmpty(nasIpList) && nasIpList.size() > 0) {
|
||||||
List newNasIpList = new ArrayList();
|
List newNasIpList = new ArrayList();
|
||||||
for (int i = 0; i < nasIpList.size(); i++) {
|
for (int i = 0; i < nasIpList.size(); i++) {
|
||||||
newNasIpList.add(nasIpList.get(i));
|
newNasIpList.add(nasIpList.get(i));
|
||||||
if (i+1>=10) {
|
if (i + 1 >= 10) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nasIpList = newNasIpList;
|
nasIpList = newNasIpList;
|
||||||
}
|
}
|
||||||
if (!StringUtil.isEmpty(accountList)&&accountList.size()>0) {
|
if (!StringUtil.isEmpty(accountList) && accountList.size() > 0) {
|
||||||
List newAccountList = new ArrayList();
|
List newAccountList = new ArrayList();
|
||||||
for (int i = 0; i < accountList.size(); i++) {
|
for (int i = 0; i < accountList.size(); i++) {
|
||||||
newAccountList.add(accountList.get(i));
|
newAccountList.add(accountList.get(i));
|
||||||
if (i+1>=10) {
|
if (i + 1 >= 10) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
accountList = newAccountList;
|
accountList = newAccountList;
|
||||||
}
|
}
|
||||||
System.out.println("-------------------:"+nasIpList.size()+"+++"+accountList.size()+"==================");
|
System.out.println(
|
||||||
|
"-------------------:" + nasIpList.size() + "+++" + accountList.size() + "==================");
|
||||||
model.addAttribute("nasIpList", nasIpList);
|
model.addAttribute("nasIpList", nasIpList);
|
||||||
model.addAttribute("accountList", accountList);
|
model.addAttribute("accountList", accountList);
|
||||||
if(StringUtil.isBlank(account)&&accountList!=null&&accountList.size()>0&&!"3".equals(searchBusinessType)) {
|
if (StringUtil.isBlank(account) && accountList != null && accountList.size() > 0
|
||||||
|
&& !"3".equals(searchBusinessType)) {
|
||||||
Map accountMap = (Map) accountList.get(0);
|
Map accountMap = (Map) accountList.get(0);
|
||||||
String firstAccount="";
|
String firstAccount = "";
|
||||||
if(accountMap!=null&&accountMap.get("account")!=null){
|
if (accountMap != null && accountMap.get("account") != null) {
|
||||||
firstAccount=(String) accountMap.get("account");
|
firstAccount = (String) accountMap.get("account");
|
||||||
String userString = HttpClientUtil.get(userUrl+"&searchAccount="+firstAccount);
|
String userString = HttpClientUtil.get(userUrl + "&searchAccount=" + firstAccount);
|
||||||
// 指定用户 查询
|
// 指定用户 查询
|
||||||
Gson usergson = new GsonBuilder().create();
|
Gson usergson = new GsonBuilder().create();
|
||||||
userJsonList = usergson.fromJson(userString, new TypeToken<Map>(){}.getType());
|
userJsonList = usergson.fromJson(userString, new TypeToken<Map>() {
|
||||||
|
}.getType());
|
||||||
userList = (ArrayList) userJsonList.get("data");
|
userList = (ArrayList) userJsonList.get("data");
|
||||||
}
|
}
|
||||||
model.addAttribute("userList", userList);
|
model.addAttribute("userList", userList);
|
||||||
model.addAttribute("searchAccount", firstAccount);
|
model.addAttribute("searchAccount", firstAccount);
|
||||||
}
|
}
|
||||||
if(StringUtil.isBlank(nasIp)&&nasIpList!=null&&nasIpList.size()>0&&!"2".equals(searchBusinessType)) {
|
if (StringUtil.isBlank(nasIp) && nasIpList != null && nasIpList.size() > 0
|
||||||
|
&& !"2".equals(searchBusinessType)) {
|
||||||
Map ipMap = (Map) nasIpList.get(0);
|
Map ipMap = (Map) nasIpList.get(0);
|
||||||
String firstIp="";
|
String firstIp = "";
|
||||||
if(ipMap!=null&&ipMap.get("nasIp")!=null){
|
if (ipMap != null && ipMap.get("nasIp") != null) {
|
||||||
firstIp=(String) ipMap.get("nasIp");
|
firstIp = (String) ipMap.get("nasIp");
|
||||||
String ipString = HttpClientUtil.get(ipUrl+"&searchNasIp="+firstIp);
|
String ipString = HttpClientUtil.get(ipUrl + "&searchNasIp=" + firstIp);
|
||||||
// 指定IP查询
|
// 指定IP查询
|
||||||
Gson ipgson = new GsonBuilder().create();
|
Gson ipgson = new GsonBuilder().create();
|
||||||
ipJsonList = ipgson.fromJson(ipString, new TypeToken<Map>(){}.getType());
|
ipJsonList = ipgson.fromJson(ipString, new TypeToken<Map>() {
|
||||||
|
}.getType());
|
||||||
ipList = (ArrayList) ipJsonList.get("data");
|
ipList = (ArrayList) ipJsonList.get("data");
|
||||||
}
|
}
|
||||||
model.addAttribute("ipList", ipList);
|
model.addAttribute("ipList", ipList);
|
||||||
model.addAttribute("searchNasIp", firstIp);
|
model.addAttribute("searchNasIp", firstIp);
|
||||||
|
|
||||||
}
|
}
|
||||||
if("2".endsWith(searchBusinessType)&&!StringUtil.isBlank(account)) {
|
if ("2".endsWith(searchBusinessType) && !StringUtil.isBlank(account)) {
|
||||||
|
|
||||||
String userString = HttpClientUtil.get(userUrl+"&searchAccount="+account);
|
String userString = HttpClientUtil.get(userUrl + "&searchAccount=" + account);
|
||||||
// 指定用户 查询
|
// 指定用户 查询
|
||||||
Gson usergson = new GsonBuilder().create();
|
Gson usergson = new GsonBuilder().create();
|
||||||
userJsonList = usergson.fromJson(userString, new TypeToken<Map>(){}.getType());
|
userJsonList = usergson.fromJson(userString, new TypeToken<Map>() {
|
||||||
|
}.getType());
|
||||||
userList = (ArrayList) userJsonList.get("data");
|
userList = (ArrayList) userJsonList.get("data");
|
||||||
model.addAttribute("userList", userList);
|
model.addAttribute("userList", userList);
|
||||||
model.addAttribute("searchAccount", account);
|
model.addAttribute("searchAccount", account);
|
||||||
}
|
}
|
||||||
if ("3".endsWith(searchBusinessType)&&!StringUtil.isBlank(nasIp)) {
|
if ("3".endsWith(searchBusinessType) && !StringUtil.isBlank(nasIp)) {
|
||||||
String ipString = HttpClientUtil.get(ipUrl+"&searchNasIp="+nasIp);
|
String ipString = HttpClientUtil.get(ipUrl + "&searchNasIp=" + nasIp);
|
||||||
// 指定IP查询
|
// 指定IP查询
|
||||||
Gson ipgson = new GsonBuilder().create();
|
Gson ipgson = new GsonBuilder().create();
|
||||||
ipJsonList = ipgson.fromJson(ipString, new TypeToken<Map>(){}.getType());
|
ipJsonList = ipgson.fromJson(ipString, new TypeToken<Map>() {
|
||||||
|
}.getType());
|
||||||
ipList = (ArrayList) ipJsonList.get("data");
|
ipList = (ArrayList) ipJsonList.get("data");
|
||||||
model.addAttribute("ipList", ipList);
|
model.addAttribute("ipList", ipList);
|
||||||
model.addAttribute("searchNasIp", nasIp);
|
model.addAttribute("searchNasIp", nasIp);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
addMessage(redirectAttributes,"error","request_service_failed");
|
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||||
}
|
}
|
||||||
return "/dashboard/trafficUserBehavior";
|
return "/dashboard/trafficUserBehavior";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 用户行为导出
|
||||||
|
@RequestMapping(value = "userBehaviorExport")
|
||||||
|
public void userBehaviorExport(@ModelAttribute("log") NtcRadiusReport bean, Model model, String hColumns,
|
||||||
|
String type, HttpServletRequest request, HttpServletResponse response,
|
||||||
|
RedirectAttributes redirectAttributes) {
|
||||||
|
|
||||||
|
List<NtcRadiusReport> exportList = new ArrayList<NtcRadiusReport>();
|
||||||
|
|
||||||
|
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||||
|
Map<String, Object> userJsonList = new HashMap<String, Object>();
|
||||||
|
Map<String, Object> ipJsonList = new HashMap<String, Object>();
|
||||||
|
String searchBusinessType = bean.getSearchBusinessType();
|
||||||
|
if ("2".endsWith(searchBusinessType)) {
|
||||||
|
model.addAttribute("searchBusinessType", 2);// 用户查询
|
||||||
|
}
|
||||||
|
if ("3".endsWith(searchBusinessType)) {
|
||||||
|
model.addAttribute("searchBusinessType", 3);// IP查询
|
||||||
|
}
|
||||||
|
String url = Constants.DASHBOARD_URL + Constants.NTC_RADIUS_REPORT;
|
||||||
|
String statTime = bean.getSearchFoundStartTime();
|
||||||
|
String endTime = bean.getSearchFoundEndTime();
|
||||||
|
String account = bean.getAccount();
|
||||||
|
String nasIp = bean.getNasIp();
|
||||||
|
String destUrl = url + "?searchBusinessType=1";
|
||||||
|
String userUrl = url + "?searchBusinessType=2";
|
||||||
|
String ipUrl = url + "?searchBusinessType=3";
|
||||||
|
List list = new ArrayList();
|
||||||
|
List userList = new ArrayList();
|
||||||
|
List ipList = new ArrayList();
|
||||||
|
try {
|
||||||
|
if (StringUtil.isBlank(statTime) && StringUtil.isBlank(endTime)) {
|
||||||
|
// 设置默认时间为1小时
|
||||||
|
// statTime=DateUtils.getDate()+" 00:00:00"; // 默认今天
|
||||||
|
// endTime=DateUtils.getDateTime();
|
||||||
|
|
||||||
|
Calendar cal = Calendar.getInstance();
|
||||||
|
cal.setTime(new Date());
|
||||||
|
endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.getTime());// 获取到完整的时间
|
||||||
|
cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1);
|
||||||
|
statTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.getTime());
|
||||||
|
bean.setSearchFoundStartTime(statTime);
|
||||||
|
bean.setSearchFoundEndTime(endTime);
|
||||||
|
statTime = URLEncoder.encode(statTime, "UTF-8");
|
||||||
|
endTime = URLEncoder.encode(endTime, "UTF-8");
|
||||||
|
String paramUrl = "&searchReportStartTime=" + statTime + "&searchReportEndTime=" + endTime;
|
||||||
|
destUrl = destUrl + paramUrl;
|
||||||
|
userUrl = userUrl + paramUrl;
|
||||||
|
ipUrl = ipUrl + paramUrl;
|
||||||
|
} else {
|
||||||
|
statTime = URLEncoder.encode(statTime, "UTF-8");
|
||||||
|
endTime = URLEncoder.encode(endTime, "UTF-8");
|
||||||
|
String paramUrl = "&searchReportStartTime=" + statTime + "&searchReportEndTime=" + endTime;
|
||||||
|
destUrl = destUrl + paramUrl;
|
||||||
|
userUrl = userUrl + paramUrl;
|
||||||
|
ipUrl = ipUrl + paramUrl;
|
||||||
|
}
|
||||||
|
model.addAttribute("nowTime", DateUtils.getDateTime());
|
||||||
|
// 用户及IP数据
|
||||||
|
String string = HttpClientUtil.get(destUrl);
|
||||||
|
Gson gson = new GsonBuilder().create();
|
||||||
|
fromJsonList = gson.fromJson(string, new TypeToken<Map>() {
|
||||||
|
}.getType());
|
||||||
|
list = (ArrayList) fromJsonList.get("data");
|
||||||
|
Map map = (Map) list.get(0);
|
||||||
|
List nasIpList = (List) map.get("nasIpList");
|
||||||
|
List accountList = (List) map.get("accountList");
|
||||||
|
if (!StringUtil.isEmpty(nasIpList) && nasIpList.size() > 0) {
|
||||||
|
List newNasIpList = new ArrayList();
|
||||||
|
for (int i = 0; i < nasIpList.size(); i++) {
|
||||||
|
newNasIpList.add(nasIpList.get(i));
|
||||||
|
if (i + 1 >= 10) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nasIpList = newNasIpList;
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(accountList) && accountList.size() > 0) {
|
||||||
|
List newAccountList = new ArrayList();
|
||||||
|
for (int i = 0; i < accountList.size(); i++) {
|
||||||
|
newAccountList.add(accountList.get(i));
|
||||||
|
if (i + 1 >= 10) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
accountList = newAccountList;
|
||||||
|
}
|
||||||
|
System.out.println(
|
||||||
|
"-------------------:" + nasIpList.size() + "+++" + accountList.size() + "==================");
|
||||||
|
model.addAttribute("nasIpList", nasIpList);
|
||||||
|
model.addAttribute("accountList", accountList);
|
||||||
|
if (StringUtil.isBlank(account) && accountList != null && accountList.size() > 0
|
||||||
|
&& !"3".equals(searchBusinessType)) {
|
||||||
|
Map accountMap = (Map) accountList.get(0);
|
||||||
|
String firstAccount = "";
|
||||||
|
if (accountMap != null && accountMap.get("account") != null) {
|
||||||
|
firstAccount = (String) accountMap.get("account");
|
||||||
|
String userString = HttpClientUtil.get(userUrl + "&searchAccount=" + firstAccount);
|
||||||
|
// 指定用户 查询
|
||||||
|
Gson usergson = new GsonBuilder().create();
|
||||||
|
userJsonList = usergson.fromJson(userString, new TypeToken<Map>() {
|
||||||
|
}.getType());
|
||||||
|
userList = (ArrayList) userJsonList.get("data");
|
||||||
|
|
||||||
|
for (int i = 0; i < userList.size(); i++) {
|
||||||
|
JSONObject fromObject = JSONObject.fromObject(userList.get(i));
|
||||||
|
NtcRadiusReport stu = (NtcRadiusReport) JSONObject.toBean(fromObject, NtcRadiusReport.class);
|
||||||
|
exportList.add(stu);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
model.addAttribute("userList", userList);
|
||||||
|
model.addAttribute("searchAccount", firstAccount);
|
||||||
|
}
|
||||||
|
if (StringUtil.isBlank(nasIp) && nasIpList != null && nasIpList.size() > 0
|
||||||
|
&& !"2".equals(searchBusinessType)) {
|
||||||
|
Map ipMap = (Map) nasIpList.get(0);
|
||||||
|
String firstIp = "";
|
||||||
|
if (ipMap != null && ipMap.get("nasIp") != null) {
|
||||||
|
firstIp = (String) ipMap.get("nasIp");
|
||||||
|
String ipString = HttpClientUtil.get(ipUrl + "&searchNasIp=" + firstIp);
|
||||||
|
// 指定IP查询
|
||||||
|
Gson ipgson = new GsonBuilder().create();
|
||||||
|
ipJsonList = ipgson.fromJson(ipString, new TypeToken<Map>() {
|
||||||
|
}.getType());
|
||||||
|
ipList = (ArrayList) ipJsonList.get("data");
|
||||||
|
|
||||||
|
for (int i = 0; i < ipList.size(); i++) {
|
||||||
|
JSONObject fromObject = JSONObject.fromObject(ipList.get(i));
|
||||||
|
NtcRadiusReport stu = (NtcRadiusReport) JSONObject.toBean(fromObject, NtcRadiusReport.class);
|
||||||
|
exportList.add(stu);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
model.addAttribute("ipList", ipList);
|
||||||
|
model.addAttribute("searchNasIp", firstIp);
|
||||||
|
|
||||||
|
}
|
||||||
|
if ("2".endsWith(searchBusinessType) && !StringUtil.isBlank(account)) {
|
||||||
|
|
||||||
|
String userString = HttpClientUtil.get(userUrl + "&searchAccount=" + account);
|
||||||
|
// 指定用户 查询
|
||||||
|
Gson usergson = new GsonBuilder().create();
|
||||||
|
userJsonList = usergson.fromJson(userString, new TypeToken<Map>() {
|
||||||
|
}.getType());
|
||||||
|
userList = (ArrayList) userJsonList.get("data");
|
||||||
|
|
||||||
|
for (int i = 0; i < userList.size(); i++) {
|
||||||
|
JSONObject fromObject = JSONObject.fromObject(userList.get(i));
|
||||||
|
NtcRadiusReport stu = (NtcRadiusReport) JSONObject.toBean(fromObject, NtcRadiusReport.class);
|
||||||
|
exportList.add(stu);
|
||||||
|
}
|
||||||
|
|
||||||
|
model.addAttribute("userList", userList);
|
||||||
|
model.addAttribute("searchAccount", account);
|
||||||
|
}
|
||||||
|
if ("3".endsWith(searchBusinessType) && !StringUtil.isBlank(nasIp)) {
|
||||||
|
String ipString = HttpClientUtil.get(ipUrl + "&searchNasIp=" + nasIp);
|
||||||
|
// 指定IP查询
|
||||||
|
Gson ipgson = new GsonBuilder().create();
|
||||||
|
ipJsonList = ipgson.fromJson(ipString, new TypeToken<Map>() {
|
||||||
|
}.getType());
|
||||||
|
ipList = (ArrayList) ipJsonList.get("data");
|
||||||
|
|
||||||
|
for (int i = 0; i < ipList.size(); i++) {
|
||||||
|
JSONObject fromObject = JSONObject.fromObject(ipList.get(i));
|
||||||
|
NtcRadiusReport stu = (NtcRadiusReport) JSONObject.toBean(fromObject, NtcRadiusReport.class);
|
||||||
|
exportList.add(stu);
|
||||||
|
}
|
||||||
|
|
||||||
|
model.addAttribute("ipList", ipList);
|
||||||
|
model.addAttribute("searchNasIp", nasIp);
|
||||||
|
}
|
||||||
|
|
||||||
|
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>();
|
||||||
|
|
||||||
|
titleList.add("traffic_user_behavior");
|
||||||
|
classMap.put("traffic_user_behavior", NtcRadiusReport.class);
|
||||||
|
|
||||||
|
Properties msgProp = getMsgProp();
|
||||||
|
NtcRadiusReport ntcRadiusReport = new NtcRadiusReport();
|
||||||
|
long nums = 0;
|
||||||
|
for (NtcRadiusReport entity : exportList) {
|
||||||
|
if (null != entity.getNum()) {
|
||||||
|
nums += entity.getNum();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String report_total = msgProp.getProperty("report_total");
|
||||||
|
ntcRadiusReport.setAccount(report_total);
|
||||||
|
ntcRadiusReport.setNum(nums);
|
||||||
|
ntcRadiusReport.setNasIp(" 一 ");
|
||||||
|
ntcRadiusReport.setReportTime(" 一 ");
|
||||||
|
|
||||||
|
exportList.add(ntcRadiusReport);
|
||||||
|
|
||||||
|
dataMap.put("traffic_user_behavior", exportList);
|
||||||
|
|
||||||
|
String cfgIndexInfoNoExport = "";
|
||||||
|
noExportMap.put("traffic_user_behavior", cfgIndexInfoNoExport);
|
||||||
|
String timeRange = initLogMap(bean, "traffic_user_behavior");
|
||||||
|
noExportMap.put("timeRange", timeRange);
|
||||||
|
|
||||||
|
if ("csv".equals(type)) {
|
||||||
|
this._exportCsv(model, request, response, redirectAttributes, "traffic_user_behavior", titleList,
|
||||||
|
classMap, dataMap, noExportMap);
|
||||||
|
} else {
|
||||||
|
this._export(model, request, response, redirectAttributes, "traffic_user_behavior", titleList, classMap,
|
||||||
|
dataMap, noExportMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
addMessage(redirectAttributes, "error", "request_service_failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String initLogMap(NtcRadiusReport log, String title) {
|
||||||
|
Properties msgProp = getMsgProp();
|
||||||
|
String logTime = msgProp.getProperty(title, title);
|
||||||
|
;
|
||||||
|
if (log.getSearchFoundStartTime() != null) {
|
||||||
|
logTime += " " + msgProp.getProperty("begin_date") + ":" + log.getSearchFoundStartTime();
|
||||||
|
}
|
||||||
|
if (log.getSearchFoundEndTime() != null) {
|
||||||
|
logTime += " " + msgProp.getProperty("end_date") + ":" + log.getSearchFoundStartTime();
|
||||||
|
}
|
||||||
|
return logTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,6 +233,35 @@
|
|||||||
<button type="button" class="btn blue" onClick="return searchList()"> <i class="fa fa-search"></i> <spring:message code="search"/> </button>
|
<button type="button" class="btn blue" onClick="return searchList()"> <i class="fa fa-search"></i> <spring:message code="search"/> </button>
|
||||||
<button type="button" class="btn btn-default" id="resetBtn" > <i class="fa fa-refresh"></i> <spring:message code="reset"/> </button>
|
<button type="button" class="btn btn-default" id="resetBtn" > <i class="fa fa-refresh"></i> <spring:message code="reset"/> </button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="pull-right">
|
||||||
|
|
||||||
|
<div class="btn-group">
|
||||||
|
<button type="button"
|
||||||
|
class="btn btn-default dropdown-toggle"
|
||||||
|
data-toggle="dropdown">
|
||||||
|
<i class="fa fa-wrench"></i>
|
||||||
|
<spring:message code="export"></spring:message>
|
||||||
|
<i class="fa fa-angle-down"></i>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu pull-right"
|
||||||
|
style="min-width: 110px;">
|
||||||
|
<li><sys:delRow
|
||||||
|
url="${ctx}/traffic/userBehaviorExport?type=excel"
|
||||||
|
searchUrl="${ctx}/traffic/userBehavior" id="contentTable"
|
||||||
|
maxRow="10000" label="excel"></sys:delRow></li>
|
||||||
|
<li><sys:delRow
|
||||||
|
url="${ctx}/traffic/userBehaviorExport?type=csv"
|
||||||
|
searchUrl="${ctx}/traffic/userBehavior" id="contentTable"
|
||||||
|
maxRow="10000" label="csv"></sys:delRow></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a class="btn btn-icon-only btn-default setfields tooltips"
|
||||||
|
data-container="body" data-placement="top"
|
||||||
|
data-original-title=<spring:message code="custom_columns"/>
|
||||||
|
href="javascript:;"> <i class="icon-wrench"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 搜索内容与操作按钮栏 -->
|
<!-- 搜索内容与操作按钮栏 -->
|
||||||
</form:form>
|
</form:form>
|
||||||
|
|||||||
Reference in New Issue
Block a user