用户行为统计修改默认时间为当前一小时
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package com.nis.web.controller.dashboard;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
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;
|
||||
@@ -15,6 +18,7 @@ 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.ResponseBody;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@@ -40,7 +44,7 @@ public class TrafficStatisticsReportController extends BaseController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("userBehavior")
|
||||
public String list(@ModelAttribute("log") NtcRadiusReport bean,Model model, HttpServletRequest request, HttpServletResponse response) {
|
||||
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> userJsonList = new HashMap<String, Object>();
|
||||
Map<String, Object> ipJsonList = new HashMap<String, Object>();
|
||||
@@ -64,8 +68,15 @@ public class TrafficStatisticsReportController extends BaseController {
|
||||
List ipList = new ArrayList();
|
||||
try {
|
||||
if(StringUtil.isBlank(statTime)&&StringUtil.isBlank(endTime)) {
|
||||
statTime=DateUtils.getDate()+" 00:00:00"; // 默认今天
|
||||
endTime=DateUtils.getDateTime();
|
||||
// 设置默认时间为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");
|
||||
@@ -82,6 +93,7 @@ public class TrafficStatisticsReportController extends BaseController {
|
||||
userUrl=userUrl+paramUrl;
|
||||
ipUrl=ipUrl+paramUrl;
|
||||
}
|
||||
model.addAttribute("nowTime", DateUtils.getDateTime());
|
||||
// 用户及IP数据
|
||||
String string = HttpClientUtil.get(destUrl);
|
||||
Gson gson = new GsonBuilder().create();
|
||||
@@ -142,28 +154,8 @@ public class TrafficStatisticsReportController extends BaseController {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes,"error","request_service_failed");
|
||||
}
|
||||
return "/dashboard/trafficUserBehavior";
|
||||
}
|
||||
/* public static void main(String[] args) {
|
||||
Map<String, Object> fromJsonList = new HashMap<String, Object>();
|
||||
HashMap<String, Object> m = new HashMap<String, Object>();
|
||||
List list = new ArrayList();
|
||||
String string;
|
||||
try {
|
||||
string = HttpClientUtil.get("http://localhost:8082/galaxy-service/service/log/v1/ntcRadiusReport?"
|
||||
+ "searchBusinessType=1&searchReportStartTime=2018-06-01+15%3A41%3A21&searchReportEndTime=2018-10-30+15%3A46%3A21");
|
||||
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");
|
||||
System.err.println(map.get("nasIpList"));
|
||||
System.err.println(map.get("accountList"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -175,51 +175,6 @@
|
||||
<div class="portlet">
|
||||
<div class="portlet-body">
|
||||
<sys:message content="${message}" type="${messageType }"/>
|
||||
<!-- top -->
|
||||
<%-- <div class="row">
|
||||
<div class="col-md-6">
|
||||
<h4 class="ng-binding"><spring:message code="user_behavior_data"/></h4>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<c:if test="${empty accountList}">
|
||||
<div class="none-data"><i class="fa fa-warning font-red-flamingo"></i> <spring:message code="noneData"/></div>
|
||||
</c:if>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<h4 class="ng-binding"><spring:message code="ip_behavior_data"/></h4>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<table id="contentTable" class="table table-striped table-bordered table-condensed text-nowrap">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><spring:message code="ip"/></th>
|
||||
<th><spring:message code="visits"/></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<c:forEach items="${nasIpList}" var="data">
|
||||
<tr>
|
||||
<td>${data.nasIp}</td>
|
||||
<td><fmt:formatNumber type="number" value="${data.num}" minFractionDigits="0"></fmt:formatNumber></td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<c:if test="${empty nasIpList}">
|
||||
<div class="none-data"><i class="fa fa-warning font-red-flamingo"></i> <spring:message code="noneData"/></div>
|
||||
</c:if>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> --%>
|
||||
<!-- top end -->
|
||||
|
||||
<div class="row">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="userBtn active configType">
|
||||
@@ -242,7 +197,7 @@
|
||||
<span class="selectpicker form-control" ><spring:message code="begin_date"/></span>
|
||||
</div>
|
||||
<input id="searchFoundStartTime" name="searchFoundStartTime" type="text" readonly="readonly" class="form-control Wdate "
|
||||
value="${log.searchFoundStartTime}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
|
||||
value="${log.searchFoundStartTime}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true,maxDate:'${nowTime}'});"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pull-left">
|
||||
@@ -251,7 +206,7 @@
|
||||
<span class="selectpicker form-control" ><spring:message code="end_date"/></span>
|
||||
</div>
|
||||
<input id="searchFoundEndTime" name="searchFoundEndTime" type="text" readonly="readonly" class="form-control Wdate "
|
||||
value="${log.searchFoundEndTime}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
|
||||
value="${log.searchFoundEndTime}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true,maxDate:'${nowTime}'});"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pull-left accountSearch">
|
||||
|
||||
Reference in New Issue
Block a user