流量统计-解决traffic详情时折线图最后时间点数据为0问题。解决用户行为统计中用户名跟ip可能为空无用户名登录时报错问题。app,协议,traffic详情时间查询条件格式化,默认时间显示为最近一小时,列表数据保留两位小数。

This commit is contained in:
zhanghongqing
2018-12-13 20:37:13 +08:00
parent d623414376
commit 4c18346d87
7 changed files with 218 additions and 86 deletions

View File

@@ -115,9 +115,9 @@ public class TrafficStatisticsInfoController extends BaseController {
public String bandwidthList(Model model){
Calendar cal = Calendar. getInstance ();
cal.setTime(new Date());
String now = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(cal.getTime());//获取到完整的时间
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:ss" ).format(cal.getTime());
String oneHoursAgo = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());
model.addAttribute("beginDate", oneHoursAgo);
model.addAttribute("endDate", now);
return "/dashboard/trafficBandwidthList";
@@ -126,7 +126,14 @@ public class TrafficStatisticsInfoController extends BaseController {
* 流量统计滚动动作查看详情页面
*/
@RequestMapping(value={"trafficBlockList","trafficMonitorList"})
public String serviceBlockList(@RequestParam("searchAction")String searchAction,HttpServletRequest request, HttpServletResponse response, Model model){
public String serviceBlockList(@RequestParam("searchAction")String searchAction,Model model){
Calendar cal = Calendar. getInstance ();
cal.setTime(new Date());
String now = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());//获取到完整的时间
cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1);
String oneHoursAgo = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());
model.addAttribute("beginDate", oneHoursAgo);
model.addAttribute("endDate", now);
model.addAttribute("searchAction", searchAction);
return "/dashboard/trafficActionTransList";
}
@@ -135,12 +142,13 @@ public class TrafficStatisticsInfoController extends BaseController {
*/
@RequestMapping(value="actionEntranceTrans")
@ResponseBody
public List actionTrans(@RequestParam("searchAction")String searchAction){
public List actionTrans(String beginDate,String endDate,@RequestParam("searchAction")String searchAction){
Map<String, Object> fromJsonList = new HashMap<String, Object>();
List resultList = new ArrayList();
String url = Constants.DASHBOARD_URL+Constants.NTC_ACTION_ENTRANCE_REPORT;
url=url+"?searchAction="+searchAction;
try {
url = urlAddDate(url,beginDate,endDate);
String string = HttpClientUtil.get(url);
Gson gson = new GsonBuilder().create();
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
@@ -153,13 +161,23 @@ public class TrafficStatisticsInfoController extends BaseController {
}
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:ss" ).format(cal.getTime());//获取到完整的时间
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:ss" ).format(cal.getTime());
beginDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());
}
URIBuilder uriBuilder = new URIBuilder(url);
uriBuilder.addParameter("beginDate",beginDate);
@@ -239,11 +257,11 @@ public class TrafficStatisticsInfoController extends BaseController {
public String protocolTypeList(Model model){
Calendar cal = Calendar. getInstance ();
cal.setTime(new Date());
String now = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(cal.getTime());//获取到完整的时间
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:ss" ).format(cal.getTime());
model.addAttribute("searchFoundStartTime", oneHoursAgo);
model.addAttribute("searchFoundEndTime", now);
String oneHoursAgo = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());
model.addAttribute("beginDate", oneHoursAgo);
model.addAttribute("endDate", now);
return "/dashboard/trafficProtocolTypeList";
}
/**
@@ -251,16 +269,12 @@ public class TrafficStatisticsInfoController extends BaseController {
*/
@RequestMapping(value="protocolList")
@ResponseBody
public List protocolList(Model model,@RequestParam(required=false)String searchFoundStartTime,@RequestParam(required=false)String searchFoundEndTime){
public List protocolList(Model model,@RequestParam(required=false)String beginDate,@RequestParam(required=false)String endDate){
Map<String, Object> fromJsonList = new HashMap<String, Object>();
List list = new ArrayList();
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_PROTOCOL_LIST;
try {
if(!StringUtil.isBlank(searchFoundStartTime)&&!StringUtil.isBlank(searchFoundEndTime)){
searchFoundStartTime=URLEncoder.encode(searchFoundStartTime, "UTF-8");
searchFoundEndTime=URLEncoder.encode(searchFoundEndTime, "UTF-8");
url+="?searchFoundStartTime="+searchFoundStartTime+"&searchFoundEndTime="+searchFoundEndTime;
}
url=urlAddDate(url,beginDate,endDate);
String string = HttpClientUtil.get(url);
Gson gson = new GsonBuilder().create();
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());
@@ -311,7 +325,14 @@ public class TrafficStatisticsInfoController extends BaseController {
* App类型详细列表
*/
@RequestMapping(value="appTypeList")
public String appTypeList(){
public String appTypeList(Model model){
Calendar cal = Calendar. getInstance ();
cal.setTime(new Date());
String now = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());//获取到完整的时间
cal.set(Calendar.HOUR_OF_DAY, cal.get(Calendar.HOUR_OF_DAY) - 1);
String oneHoursAgo = new SimpleDateFormat( "yyyy-MM-dd HH:mm:00" ).format(cal.getTime());
model.addAttribute("beginDate", oneHoursAgo);
model.addAttribute("endDate", now);
return "/dashboard/trafficAppTypeList";
}
/**
@@ -319,16 +340,12 @@ public class TrafficStatisticsInfoController extends BaseController {
*/
@RequestMapping(value="appList")
@ResponseBody
public List appList(@RequestParam(value="searchFoundStartTime",required=false)String searchFoundStartTime,@RequestParam(value="searchFoundEndTime",required=false)String searchFoundEndTime){
public List appList(@RequestParam(value="beginDate",required=false)String beginDate,@RequestParam(value="endDate",required=false)String endDate){
Map<String, Object> fromJsonList = new HashMap<String, Object>();
List list = new ArrayList();
String url = Constants.DASHBOARD_URL+Constants.TRAFFIC_APP_LIST;
try {
if(!StringUtil.isBlank(searchFoundStartTime)&&!StringUtil.isBlank(searchFoundEndTime)){
searchFoundStartTime=URLEncoder.encode(searchFoundStartTime, "UTF-8");
searchFoundEndTime=URLEncoder.encode(searchFoundEndTime, "UTF-8");
url+="?searchFoundStartTime="+searchFoundStartTime+"&searchFoundEndTime="+searchFoundEndTime;
}
url=urlAddDate(url,beginDate,endDate);
String string = HttpClientUtil.get(url);
Gson gson = new GsonBuilder().create();
fromJsonList = gson.fromJson(string, new TypeToken<Map>(){}.getType());