三种日志查询方案提交
This commit is contained in:
@@ -436,6 +436,7 @@ public final class Constants {
|
||||
public static final Integer BUSINESSTYPE_REPORT=Configurations.getIntProperty("businesstype_report", 2);
|
||||
//默认日志查询时长(ms)
|
||||
public static final String LOG_TIME_START = Configurations.getStringProperty("log_time_start",null);
|
||||
public static final String LOG_TIME_END = Configurations.getStringProperty("log_time_end",null);
|
||||
//默认日志查询时长(ms)
|
||||
public static final Integer LOG_TIME_RANGE = Configurations.getIntProperty("log_time_range", 300000);
|
||||
//日志检索菜单ID
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
*/
|
||||
package com.nis.web.controller.report;
|
||||
|
||||
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;
|
||||
@@ -18,6 +20,7 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
@@ -53,9 +56,43 @@ public class NtcPzReportController extends BaseController{
|
||||
public List<Map<String, Object>> ajaxGetLogTotal(Model model,long endTime,String actions,Integer functionId,String compileIds){
|
||||
List<Map<String, Object>> dataList=new ArrayList<>();
|
||||
SimpleDateFormat sdf=new SimpleDateFormat(Constants.SEARCH_DATEFORMAT);
|
||||
int interval=Constants.LOG_TIME_RANGE;
|
||||
Date endDate=new Date(endTime);
|
||||
Date startDate=new Date(endTime-interval);
|
||||
Date endDate=null;
|
||||
Date startDate=null;
|
||||
if(StringUtils.isNotBlank(Constants.LOG_TIME_START)) {
|
||||
try {
|
||||
startDate=sdf.parse(Constants.LOG_TIME_START);
|
||||
if(StringUtils.isNotBlank(Constants.LOG_TIME_END)) {
|
||||
endDate=sdf.parse(Constants.LOG_TIME_END);
|
||||
}else {
|
||||
endDate=new Date(endTime);
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}else {
|
||||
Calendar cal=Calendar.getInstance();
|
||||
//分钟间隔
|
||||
int interval=Constants.LOG_TIME_RANGE/1000/60;
|
||||
cal.setTimeInMillis(endTime);
|
||||
if(interval<60) {//5分钟
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
int minute=cal.get(Calendar.MINUTE);
|
||||
cal.set(Calendar.MINUTE,minute/interval*interval);
|
||||
}else {//1小时
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MINUTE, 0);
|
||||
}
|
||||
Calendar endTimeCal=Calendar.getInstance();
|
||||
endTimeCal.setTimeInMillis(cal.getTimeInMillis());
|
||||
endTimeCal.add(Calendar.SECOND, -1);
|
||||
endDate=endTimeCal.getTime();
|
||||
cal.add(Calendar.MINUTE, -interval);
|
||||
startDate=cal.getTime();
|
||||
}
|
||||
logger.info("log search end time:"+sdf.format(endDate));
|
||||
logger.info("log search start time:"+sdf.format(startDate));
|
||||
String serviceIdsStr="";
|
||||
StringBuffer serviceIds=new StringBuffer();
|
||||
List<FunctionServiceDict> serviceList=DictUtils.getFunctionServiceDictList(functionId.intValue());
|
||||
|
||||
@@ -467,4 +467,5 @@ app_id_region=APP_ID
|
||||
app_spec_service_code_max_val=310000
|
||||
app_spec_service_code_min_val=300001
|
||||
groupReuseSources=groupReuseSources
|
||||
log_time_start=2018-07-01 00:00:00
|
||||
log_time_start=2018-07-01 00:00:00
|
||||
log_time_end=2018-08-01 00:00:00
|
||||
Reference in New Issue
Block a user