流量日志菜单下新增 文件扫描菜单
This commit is contained in:
@@ -0,0 +1,175 @@
|
||||
package com.nis.web.controller.log.ntc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.PageLog;
|
||||
import com.nis.domain.SysUser;
|
||||
import com.nis.domain.log.NtcHttpObjScanResultLog;
|
||||
import com.nis.domain.maat.LogRecvData;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/log/ntc/httpObjScanResult")
|
||||
public class HttpObjScanResultLogController extends BaseController {
|
||||
|
||||
@RequestMapping(value = { "list", "" })
|
||||
public String list(@ModelAttribute("log") NtcHttpObjScanResultLog log, Model model, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
try {
|
||||
PageLog<NtcHttpObjScanResultLog> page = new PageLog<NtcHttpObjScanResultLog>(request, response);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
if (StringUtils.isNotBlank(log.getUrl())) {
|
||||
String httpurl = StringEscapeUtils.unescapeHtml(log.getUrl());
|
||||
params.put("searchUrl", httpurl);
|
||||
}
|
||||
initLogSearchValue(log, params);
|
||||
|
||||
if (StringUtils.isNotBlank(log.getdPort())) {
|
||||
params.put("searchDPort", log.getdPort());
|
||||
}
|
||||
if (StringUtils.isNotBlank(log.getsPort())) {
|
||||
params.put("searchSPort", log.getsPort());
|
||||
}
|
||||
if (null != log.getDeviceId()) {
|
||||
params.put("searchDeviceId", log.getDeviceId());
|
||||
}
|
||||
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
|
||||
model.addAttribute("serviceList", serviceList);
|
||||
|
||||
String url = Constants.LOG_BASE_URL + Constants.NTC_HTTP_OBJSCAN_RESULT_LOGS;
|
||||
String recv = HttpClientUtil.getMsg(url, params, request);
|
||||
|
||||
Gson gson = new GsonBuilder().create();
|
||||
|
||||
LogRecvData<NtcHttpObjScanResultLog> fromJson = gson.fromJson(recv,
|
||||
new TypeToken<LogRecvData<NtcHttpObjScanResultLog>>() {
|
||||
}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
Page<NtcHttpObjScanResultLog> data = fromJson.getData();
|
||||
page.setCount(data.getCount());
|
||||
page.setLast(data.getLast());
|
||||
page.setList(data.getList());
|
||||
List<NtcHttpObjScanResultLog> list = page.getList();
|
||||
for (NtcHttpObjScanResultLog l : list) {
|
||||
l.setFunctionId(log.getFunctionId());
|
||||
setLogAction(l, serviceList);
|
||||
}
|
||||
model.addAttribute("page", page);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("查询失败", e);
|
||||
addMessageLog(model, e.getMessage());
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
|
||||
return "/log/ntc/httpObjScanResultList";
|
||||
}
|
||||
|
||||
// 文件离线扫描结果 导出
|
||||
@RequestMapping(value = "exportHttpObjScanResult")
|
||||
public void exportHttpObjScanResult(@ModelAttribute("log") NtcHttpObjScanResultLog log, Model model, String hColumns, String type,
|
||||
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
|
||||
try {
|
||||
// export data info
|
||||
List<String> titleList = new ArrayList<String>();
|
||||
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
|
||||
Map<String, List> dataMap = new HashMap<String, List>();
|
||||
Map<String, String> noExportMap = new HashMap<String, String>();
|
||||
// ---------------------------
|
||||
PageLog<NtcHttpObjScanResultLog> page = new PageLog<NtcHttpObjScanResultLog>(request, response);
|
||||
page.setPageNo(1);
|
||||
page.setPageSize(Constants.MAX_LOG_EXPORT_SIZE);
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("pageSize", page.getPageSize());
|
||||
params.put("pageNo", page.getPageNo());
|
||||
if (StringUtils.isNotBlank(log.getUrl())) {
|
||||
String httpurl = StringEscapeUtils.unescapeHtml(log.getUrl());
|
||||
params.put("searchUrl", httpurl);
|
||||
}
|
||||
initLogSearchValue(log, params);
|
||||
|
||||
if (StringUtils.isNotBlank(log.getdPort())) {
|
||||
params.put("searchDport", log.getdPort());
|
||||
}
|
||||
if (StringUtils.isNotBlank(log.getsPort())) {
|
||||
params.put("searchSport", log.getsPort());
|
||||
}
|
||||
if (null != log.getDeviceId()) {
|
||||
params.put("searchDeviceId", log.getDeviceId());
|
||||
}
|
||||
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
|
||||
model.addAttribute("serviceList", serviceList);
|
||||
|
||||
String url = Constants.LOG_BASE_URL + Constants.NTC_HTTP_OBJSCAN_RESULT_LOGS;
|
||||
String recv = HttpClientUtil.getMsg(url, params, request);
|
||||
List<NtcHttpObjScanResultLog> list = new ArrayList<NtcHttpObjScanResultLog>();
|
||||
if (StringUtils.isNotBlank(recv)) {
|
||||
Gson gson = new GsonBuilder().create();
|
||||
LogRecvData<NtcHttpObjScanResultLog> fromJson = gson.fromJson(recv,
|
||||
new TypeToken<LogRecvData<NtcHttpObjScanResultLog>>() {
|
||||
}.getType());
|
||||
if (fromJson.getStatus().intValue() == 200) {
|
||||
Page<NtcHttpObjScanResultLog> data = fromJson.getData();
|
||||
list = data.getList();
|
||||
}
|
||||
}
|
||||
for (NtcHttpObjScanResultLog l : list) {
|
||||
l.setFunctionId(log.getFunctionId());
|
||||
setLogAction(l, serviceList);
|
||||
}
|
||||
titleList.add("http_obj_scan_result");
|
||||
classMap.put("http_obj_scan_result", NtcHttpObjScanResultLog.class);
|
||||
SysUser user = UserUtils.getUser();
|
||||
if (!user.isAdmin()) {
|
||||
hColumns += ",scene_file,";
|
||||
} else {
|
||||
hColumns += ",";
|
||||
}
|
||||
String cfgIndexInfoNoExport = ",action,cfg_id,"
|
||||
+ hColumns;
|
||||
noExportMap.put("http_obj_scan_result", cfgIndexInfoNoExport);
|
||||
dataMap.put("http_obj_scan_result", list);
|
||||
String timeRange = initLogMap(log, "http_obj_scan_result");
|
||||
noExportMap.put("timeRange", timeRange);
|
||||
if ("csv".equals(type)) {
|
||||
this._exportCsv(model, request, response, redirectAttributes, "http_obj_scan_result", titleList, classMap,
|
||||
dataMap, noExportMap);
|
||||
} else {
|
||||
this._export(model, request, response, redirectAttributes, "http_obj_scan_result", titleList, classMap, dataMap,
|
||||
noExportMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("http_obj_scan_result export failed", e);
|
||||
addMessage(redirectAttributes, "error", "export_failed");
|
||||
LogUtils.saveLog(request, null, e, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user