提交一版日志的action查询和展示
This commit is contained in:
@@ -30,13 +30,19 @@ public class BaseLogEntity<T> extends BaseEntity<T> {
|
||||
protected String userRegion; //用户自定义
|
||||
|
||||
protected Integer functionId;
|
||||
protected Integer action;
|
||||
|
||||
//自定义字段
|
||||
protected String seltype;//选中类型,页面搜索用
|
||||
protected String searchFoundStartTime;//开始时间,格式为yyyy-mm-dd hh24:mi:ss
|
||||
protected String searchFoundEndTime;//结束时间,格式同上
|
||||
|
||||
|
||||
public Integer getAction() {
|
||||
return action;
|
||||
}
|
||||
public void setAction(Integer action) {
|
||||
this.action = action;
|
||||
}
|
||||
public Integer getFunctionId() {
|
||||
return functionId;
|
||||
}
|
||||
|
||||
@@ -473,21 +473,31 @@ public class BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
public void initLogServiceType(Model model, BaseLogEntity log) {
|
||||
public void setLogAction(BaseLogEntity log) {
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
|
||||
model.addAttribute("serviceList", serviceList);
|
||||
for (FunctionServiceDict dict : serviceList) {
|
||||
if (dict.getServiceId().intValue() == log.getServiceType().intValue()) {
|
||||
log.setAction(dict.getAction());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//初始化查询值判断
|
||||
public void initLogSearchValue(BaseLogEntity entry,Map<String, Object> params){
|
||||
|
||||
params.put("operator", entry.getCurrentUser().getName());
|
||||
params.put("opTime", DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
params.put("opAction", 4);
|
||||
|
||||
if (StringUtils.isNotBlank(entry.getSearchFoundStartTime())&&StringUtils.isNotBlank(entry.getSearchFoundEndTime())) {
|
||||
params.put("searchFoundStartTime", entry.getSearchFoundStartTime());
|
||||
params.put("searchFoundEndTime", entry.getSearchFoundEndTime());
|
||||
}else{
|
||||
//设置默认查询当前时间及前五分钟
|
||||
String startTime = DateUtils.getDateTime();
|
||||
Date dateEnd = new Date(new Date().getTime()-Constants.LOG_TIME_RANGE);
|
||||
String endTime = DateUtils.formatDateTime(dateEnd);
|
||||
String endTime = DateUtils.getDateTime();
|
||||
Date dateStart = new Date(new Date().getTime() - Constants.LOG_TIME_RANGE);
|
||||
String startTime = DateUtils.formatDateTime(dateStart);
|
||||
params.put("searchFoundStartTime", startTime);
|
||||
params.put("searchFoundEndTime",endTime );
|
||||
entry.setSearchFoundStartTime(startTime);
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.nis.web.controller.log.ntc;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -20,41 +23,47 @@ import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.log.NtcIpLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/log/ntc/ip")
|
||||
public class NtcIpLogController extends BaseController {
|
||||
public class IpLogController extends BaseController {
|
||||
|
||||
@RequestMapping("list")
|
||||
public String list(@ModelAttribute("log") NtcIpLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
|
||||
//初始化action
|
||||
initLogServiceType(model, log);
|
||||
|
||||
Page<NtcIpLog> page = new Page<NtcIpLog>(request, response);
|
||||
int pageNo = page.getPageNo();
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
initLogSearchValue(log, params);
|
||||
|
||||
String url = Constants.LOG_BASE_URL + Constants.NTC_IP_LOG;
|
||||
String recv = HttpClientUtil.getMsg(url, params);
|
||||
|
||||
String recv = null;
|
||||
|
||||
try {
|
||||
String path = request.getClass().getClassLoader().getResource("").getPath();
|
||||
recv = FileUtil.readAsString(new File(path + "com/nis/web/test/logTest.txt"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
logger.info("NTC-IP查询结果:" + recv);
|
||||
// try {
|
||||
// String path = request.getClass().getClassLoader().getResource("").getPath();
|
||||
// recv = FileUtil.readAsString(new File(path + "com/nis/web/test/logTest.txt"));
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
Gson gson = new GsonBuilder().create();
|
||||
|
||||
try {
|
||||
LogRecvData<NtcIpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcIpLog>>(){}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
logger.info("查询状态:成功");
|
||||
BeanUtils.copyProperties(fromJson.getData(), page);
|
||||
List<NtcIpLog> list = page.getList();
|
||||
for (NtcIpLog l : list) {
|
||||
l.setFunctionId(log.getFunctionId());
|
||||
setLogAction(l);
|
||||
}
|
||||
model.addAttribute("page", page);
|
||||
}
|
||||
} catch (JsonSyntaxException e) {
|
||||
logger.info("查询失败");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user