提交一版日志的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();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,12 @@
|
||||
<%@ include file="/WEB-INF/include/taglib.jsp"%>
|
||||
<html>
|
||||
<head>
|
||||
<title>IP<spring:message code="log"></spring:message></title>
|
||||
<title>
|
||||
<c:if test="${log.functionId eq 5 }">IP</c:if>
|
||||
<c:if test="${log.functionId eq 7 }">DNS</c:if>
|
||||
<c:if test="${log.functionId eq 8 }">HTTP</c:if>
|
||||
<spring:message code="log"></spring:message>
|
||||
</title>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
//reset
|
||||
@@ -26,7 +31,10 @@
|
||||
<div class="theme-panel hidden-xs hidden-sm">
|
||||
</div>
|
||||
<h3 class="page-title">
|
||||
IP<spring:message code="log"></spring:message>
|
||||
<c:if test="${log.functionId eq 5 }">IP</c:if>
|
||||
<c:if test="${log.functionId eq 7 }">DNS</c:if>
|
||||
<c:if test="${log.functionId eq 8 }">HTTP</c:if>
|
||||
<spring:message code="log"></spring:message>
|
||||
<small><spring:message code="date_list"/></small>
|
||||
</h3>
|
||||
<h5 class="page-header"></h5>
|
||||
@@ -35,7 +43,16 @@
|
||||
<div class="portlet">
|
||||
<div class="portlet-body">
|
||||
<div class="row" >
|
||||
<form:form id="searchForm" modelAttribute="log" action="${ctx}/log/ntc/ip/list" method="post" class="form-search">
|
||||
<c:if test="${log.functionId eq 5 }">
|
||||
<c:set var="function" value="ip"/>
|
||||
</c:if>
|
||||
<c:if test="${log.functionId eq 7 }">
|
||||
<c:set var="function" value="dns"/>
|
||||
</c:if>
|
||||
<c:if test="${log.functionId eq 8 }">
|
||||
<c:set var="function" value="http"/>
|
||||
</c:if>
|
||||
<form:form id="searchForm" modelAttribute="log" action="${ctx}/log/ntc/${function}/list" method="post" class="form-search">
|
||||
<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
|
||||
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
|
||||
<input id="functionId" name="functionId" type="hidden" value="${log.functionId}"/>
|
||||
@@ -54,9 +71,8 @@
|
||||
<div class="pull-left">
|
||||
<form:select path="serviceType" class="selectpicker select2 input-small">
|
||||
<form:option value=""><spring:message code="action"/></form:option>
|
||||
<c:forEach items="${serviceList}" var="service">
|
||||
<form:option value="${service.serviceId}" ><spring:message code="${service.actionCode}"/></form:option>
|
||||
</c:forEach>
|
||||
<form:option value="16"><spring:message code="action_reject"/></form:option>
|
||||
<form:option value="1"><spring:message code="action_monit"/></form:option>
|
||||
</form:select>
|
||||
</div>
|
||||
<div class="pull-left">
|
||||
@@ -94,8 +110,8 @@
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<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>
|
||||
data-container="body" data-placement="top" data-original-title=<spring:message code="custom_columns"/> href="javascript:;">
|
||||
<i class="icon-wrench"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -126,12 +142,22 @@
|
||||
<input name="clientIp" type="text" class="form-control" value="${log.clientIp }"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label><spring:message code="serverip"></spring:message>:</label>
|
||||
<input name="serverIp" type="text" class="form-control" value="${log.serverIp }"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<c:if test="${log.functionId eq 8 }">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label>URL:</label>
|
||||
<input name="url" type="text" class="form-control" value="${log.url }"/>
|
||||
</div>
|
||||
</div>
|
||||
</c:if>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /筛选搜索内容栏 结束-->
|
||||
@@ -142,9 +168,11 @@
|
||||
<table id="contentTable" class="table table-striped table-bordered table-condensed text-nowrap">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<!--<th><input type="checkbox" class="i-checks" id="checkAll"></th>-->
|
||||
<th><spring:message code='cfg_id'/></th>
|
||||
<th>ip<spring:message code="type"/></th>
|
||||
<th><spring:message code="action"/></th>
|
||||
<th><spring:message code="client_ip"/></th>
|
||||
<th><spring:message code="client_port"/></th>
|
||||
<th><spring:message code="server_ip"/></th>
|
||||
@@ -152,6 +180,9 @@
|
||||
<th><spring:message code="protocol"/></th>
|
||||
<th><spring:message code="entrance_id"/></th>
|
||||
<th><spring:message code="direction"/></th>
|
||||
<c:if test="${log.functionId eq 8 }">
|
||||
<th>URL</th>
|
||||
</c:if>
|
||||
<th><spring:message code="found_time"/></th>
|
||||
<th><spring:message code="recv_time"/></th>
|
||||
<th><spring:message code="device_id"/></th>
|
||||
@@ -160,40 +191,48 @@
|
||||
<th><spring:message code="nest_addr_list"/></th>
|
||||
<th><spring:message code="user_region"/></th>
|
||||
</tr>
|
||||
<c:forEach var="log" items="${page.list }">
|
||||
<c:forEach var="_log" items="${page.list }">
|
||||
<tr>
|
||||
<td>${log.cfgId }</td>
|
||||
<td></td>
|
||||
<td>${_log.cfgId }</td>
|
||||
<td>
|
||||
<c:forEach items="${fns:getDictList('IP_TYPE')}" var="ipType">
|
||||
<c:if test="${ipType.itemCode==log.addrType}">${ipType.itemValue}</c:if>
|
||||
<c:if test="${ipType.itemCode eq _log.addrType}">${ipType.itemValue}</c:if>
|
||||
</c:forEach>
|
||||
</td>
|
||||
<td>${log.clientIp }</td>
|
||||
<td>${log.clientPort }</td>
|
||||
<td>${log.serverIp }</td>
|
||||
<td>${log.serverPort }</td>
|
||||
<td>
|
||||
<c:if test="${_log.action eq 16 }"><spring:message code="action_reject"/></c:if>
|
||||
<c:if test="${_log.action eq 1 }"><spring:message code="action_monit"/></c:if>
|
||||
</td>
|
||||
<td>${_log.clientIp }</td>
|
||||
<td>${_log.clientPort }</td>
|
||||
<td>${_log.serverIp }</td>
|
||||
<td>${_log.serverPort }</td>
|
||||
<td>
|
||||
<c:forEach items="${fns:getDictList('LOG_PROTOCOL')}" var="logProtocol">
|
||||
<c:if test="${logProtocol.itemCode == log.protocol}">${logProtocol.itemValue}</c:if>
|
||||
<c:if test="${logProtocol.itemCode eq _log.protocol}">${logProtocol.itemValue}</c:if>
|
||||
</c:forEach>
|
||||
</td>
|
||||
<td>${log.entranceId }</td>
|
||||
<td>${_log.entranceId }</td>
|
||||
<td>
|
||||
<c:forEach items="${fns:getDictList('DIRECTION')}" var="direction">
|
||||
<c:if test="${direction.itemCode == log.direction}"><spring:message code="${direction.itemValue}"/></c:if>
|
||||
<c:if test="${direction.itemCode eq _log.direction}"><spring:message code="${direction.itemValue}"/></c:if>
|
||||
</c:forEach>
|
||||
</td>
|
||||
<td>${log.foundTime }</td>
|
||||
<td>${log.recvTime }</td>
|
||||
<td>${log.deviceId }</td>
|
||||
<c:if test="${log.functionId eq 8 }">
|
||||
<td title="${_log.url }">${fns:abbr(_log.url, 20)}</td>
|
||||
</c:if>
|
||||
<td>${_log.foundTime }</td>
|
||||
<td>${_log.recvTime }</td>
|
||||
<td>${_log.deviceId }</td>
|
||||
<td>
|
||||
<c:forEach items="${fns:getDictList('LOG_STREAM_TYPE')}" var="streamType">
|
||||
<c:if test="${streamType.itemCode == log.streamType}">${streamType.itemValue}</c:if>
|
||||
<c:if test="${streamType.itemCode eq _log.streamType}">${streamType.itemValue}</c:if>
|
||||
</c:forEach>
|
||||
</td>
|
||||
<td>${log.cljIp }</td>
|
||||
<td>${log.nestAddrList }</td>
|
||||
<td>${log.userRegion }</td>
|
||||
<td>${_log.cljIp }</td>
|
||||
<td>${_log.nestAddrList }</td>
|
||||
<td>${_log.userRegion }</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</thead>
|
||||
|
||||
Reference in New Issue
Block a user