日志检索 协议下的 日志查询和导出功能

This commit is contained in:
lihaochen
2018-12-17 01:56:37 +08:00
parent fade97c28d
commit 6e6a35a28c
37 changed files with 2047 additions and 689 deletions

View File

@@ -1,5 +1,6 @@
package com.nis.web.controller.log.ntc;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -13,6 +14,7 @@ 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;
@@ -20,20 +22,24 @@ 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.NtcAppLog;
import com.nis.domain.log.NtcBGPLog;
import com.nis.domain.log.NtcCollectRadiusLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
@Controller
@RequestMapping("${adminPath}/log/ntc/other/bgpLogs")
public class BgpLogController extends BaseController {
@RequestMapping(value = {"list", ""})
public String list(@ModelAttribute("log") NtcBGPLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
@RequestMapping(value = { "list", "" })
public String list(@ModelAttribute("log") NtcBGPLog log, Model model, HttpServletRequest request,
HttpServletResponse response) {
try {
PageLog<NtcBGPLog> page = new PageLog<NtcBGPLog>(request, response);
Map<String, Object> params = new HashMap<String, Object>();
@@ -43,22 +49,23 @@ public class BgpLogController extends BaseController {
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_BGP_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<NtcBGPLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcBGPLog>>(){}.getType());
LogRecvData<NtcBGPLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcBGPLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcBGPLog> data=fromJson.getData();
Page<NtcBGPLog> data = fromJson.getData();
page.setCount(data.getCount());
page.setLast(data.getLast());
page.setList(data.getList());
List<NtcBGPLog> list = page.getList();
for (NtcBGPLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l,serviceList);
setLogAction(l, serviceList);
}
model.addAttribute("page", page);
}
@@ -67,8 +74,67 @@ public class BgpLogController extends BaseController {
logger.error("查询失败", e);
addMessageLog(model, e.getMessage());
}
return "/log/ntc/bgpList";
}
// radius配置导出
@RequestMapping(value = "exportBgp")
public void exportBgp(@ModelAttribute("log") NtcBGPLog log, Model model, String hColumns, String type,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
System.out.println("进来了bgp");
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<NtcBGPLog> page = new PageLog<NtcBGPLog>(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());
initLogSearchValue(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_BGP_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
List<NtcBGPLog> list = new ArrayList<NtcBGPLog>();
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<NtcBGPLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcBGPLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcBGPLog> data = fromJson.getData();
list = data.getList();
}
}
titleList.add("bgp_control");
classMap.put("bgp_control", NtcBGPLog.class);
SysUser user = UserUtils.getUser();
if (!user.isAdmin()) {
hColumns += ",scene_file,";
} else {
hColumns += ",";
}
String cfgIndexInfoNoExport = "," + hColumns;
noExportMap.put("bgp_control", cfgIndexInfoNoExport);
dataMap.put("bgp_control", list);
/* } */
if ("csv".equals(type)) {
this._exportCsv(model, request, response, redirectAttributes, "bgp_control", titleList, classMap,
dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, "bgp_control", titleList, classMap, dataMap,
noExportMap);
}
} catch (Exception e) {
logger.error("bgp_control export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
}
}
}

View File

@@ -1,6 +1,7 @@
package com.nis.web.controller.log.ntc;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
@@ -17,6 +18,7 @@ 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;
@@ -28,7 +30,11 @@ 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.NtcBGPLog;
import com.nis.domain.log.NtcCollectRadiusLog;
import com.nis.domain.log.NtcCollectVoipLog;
import com.nis.domain.log.NtcCollectVoipLog;
import com.nis.domain.log.NtcCollectVoipLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.util.CodeDicUtils;
@@ -38,13 +44,15 @@ import com.nis.util.DictUtils;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.dao.dashboard.codedic.CodeResult;
import com.nis.web.security.UserUtils;
@Controller
@RequestMapping(value = "${adminPath}/log/ntc/ntcCollectVoipLogs")
public class CollectVoipLogController extends BaseController{
public class CollectVoipLogController extends BaseController {
/**
* voip泛收日志
*
* @param model
* @param entry
* @param request
@@ -53,16 +61,17 @@ public class CollectVoipLogController extends BaseController{
* @throws ClientProtocolException
* @throws IOException
*/
@RequestMapping(value={"list",""})
public String list(Model model,@ModelAttribute("log")NtcCollectVoipLog entry,HttpServletRequest request, HttpServletResponse response) throws ClientProtocolException, IOException {
@RequestMapping(value = { "list", "" })
public String list(Model model, @ModelAttribute("log") NtcCollectVoipLog entry, HttpServletRequest request,
HttpServletResponse response) throws ClientProtocolException, IOException {
try {
PageLog<NtcCollectVoipLog> page = new PageLog<NtcCollectVoipLog>(request, response);
Map<String, Object> params=new HashMap<>();
Map<String, Object> params = new HashMap<>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
//查询值判断
// 查询值判断
if (StringUtils.isNotBlank(entry.getSearchFoundStartTime())
&& StringUtils.isNotBlank(entry.getSearchFoundEndTime())) {
params.put("searchFoundStartTime", entry.getSearchFoundStartTime());
@@ -118,19 +127,19 @@ public class CollectVoipLogController extends BaseController{
}
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entry.getFunctionId());
model.addAttribute("serviceList", serviceList);
//获取字典信息
List<CodeResult> protocolList=CodeDicUtils.getCodeList("protocolCode");
List<CodeResult> behaviorList=CodeDicUtils.getCodeList("behaviorCode");
List<CodeResult> appList=CodeDicUtils.getCodeList("appCode");
// 获取字典信息
List<CodeResult> protocolList = CodeDicUtils.getCodeList("protocolCode");
List<CodeResult> behaviorList = CodeDicUtils.getCodeList("behaviorCode");
List<CodeResult> appList = CodeDicUtils.getCodeList("appCode");
model.addAttribute("protocolList", protocolList);
model.addAttribute("behaviorList", behaviorList);
model.addAttribute("appList", appList);
String url = "";
url = Constants.LOG_BASE_URL+Constants.NTC_COLLECT_VOIP_LOG;
String jsonString = HttpClientUtil.getMsg(url,params,request);
url = Constants.LOG_BASE_URL + Constants.NTC_COLLECT_VOIP_LOG;
String jsonString = HttpClientUtil.getMsg(url, params, request);
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
@@ -140,9 +149,11 @@ public class CollectVoipLogController extends BaseController{
}
});
Gson gson = builder.setDateFormat("yyyy-MM-dd HH:mm:ss").create();
//gson泛型支持
LogRecvData<NtcCollectVoipLog> fromJson = gson.fromJson(jsonString, new TypeToken<LogRecvData<NtcCollectVoipLog>>(){}.getType());
// gson泛型支持
LogRecvData<NtcCollectVoipLog> fromJson = gson.fromJson(jsonString,
new TypeToken<LogRecvData<NtcCollectVoipLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcCollectVoipLog> data = fromJson.getData();
page.setCount(data.getCount());
@@ -157,5 +168,151 @@ public class CollectVoipLogController extends BaseController{
}
return "/log/ntc/collectVoipList";
}
// VoipCollect配置导出
@RequestMapping(value = "exportVoipCollect")
public void exportVoipCollect(@ModelAttribute("log") NtcCollectVoipLog entry, Model model, String hColumns,
String type, HttpServletRequest request, HttpServletResponse response,
RedirectAttributes redirectAttributes) {
try {
PageLog<NtcCollectVoipLog> page = new PageLog<NtcCollectVoipLog>(request, response);
Map<String, Object> params = new HashMap<>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
// 查询值判断
List<NtcCollectVoipLog> list = new ArrayList<NtcCollectVoipLog>();
if (StringUtils.isNotBlank(entry.getSearchFoundStartTime())
&& StringUtils.isNotBlank(entry.getSearchFoundEndTime())) {
params.put("searchFoundStartTime", entry.getSearchFoundStartTime());
params.put("searchFoundEndTime", entry.getSearchFoundEndTime());
} else {
// 判断是否是从配置界面过来的日志查询
if (StringUtils.isNotBlank(entry.getIsLogTotalSearch())) {
Calendar time = Calendar.getInstance();
time.add(Calendar.MINUTE, -5);
String searchEndTime = DateUtils.formatDateTime(time.getTime());
params.put("searchFoundEndTime", searchEndTime);
entry.setSearchFoundEndTime(searchEndTime);
time.add(Calendar.MINUTE, -5);
String searchStartTime = DateUtils.formatDateTime(time.getTime());
params.put("searchFoundStartTime", searchStartTime);
entry.setSearchFoundStartTime(searchStartTime);
} else {
// 设置默认查询当前时间及前五分钟
String endTime = DateUtils.getDateTime();
Date dateStart = new Date(new Date().getTime() - Constants.LOG_TIME_INTERVAL);
String startTime = DateUtils.formatDateTime(dateStart);
params.put("searchFoundStartTime", startTime);
params.put("searchFoundEndTime", endTime);
entry.setSearchFoundStartTime(startTime);
entry.setSearchFoundEndTime(endTime);
}
logger.info("searchFoundStartTime" + params.get("searchFoundStartTime"));
logger.info("searchFoundEndTime" + params.get("searchFoundEndTime"));
}
if (StringUtils.isNotBlank(entry.getVoipProtocol())) {
params.put("searchVoipProtocol", entry.getVoipProtocol());
}
if (StringUtils.isNotBlank(entry.getRtpDIp())) {
params.put("searchRtpDIp", entry.getRtpDIp());
}
if (StringUtils.isNotBlank(entry.getCapIp())) {
params.put("searchCapIp", entry.getCapIp());
}
if (StringUtils.isNotBlank(entry.getRtpSIp())) {
params.put("searchRtpSIp", entry.getRtpSIp());
}
if (StringUtils.isNotBlank(entry.getSipDIp())) {
params.put("searchSipDIp", entry.getSipDIp());
}
if (StringUtils.isNotBlank(entry.getSipSIp())) {
params.put("searchSipSIp", entry.getSipSIp());
}
if (StringUtils.isNotBlank(entry.getOrderBy())) {
params.put("orderBy", entry.getOrderBy());
}
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entry.getFunctionId());
model.addAttribute("serviceList", serviceList);
// 获取字典信息
List<CodeResult> protocolList = CodeDicUtils.getCodeList("protocolCode");
List<CodeResult> behaviorList = CodeDicUtils.getCodeList("behaviorCode");
List<CodeResult> appList = CodeDicUtils.getCodeList("appCode");
String url = "";
url = Constants.LOG_BASE_URL + Constants.NTC_COLLECT_VOIP_LOG;
String jsonString = HttpClientUtil.getMsg(url, params, request);
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
public Date deserialize(JsonElement json, java.lang.reflect.Type typeOfT,
JsonDeserializationContext context) throws JsonParseException {
return new Date(json.getAsJsonPrimitive().getAsLong());
}
});
Gson gson = builder.setDateFormat("yyyy-MM-dd HH:mm:ss").create();
// gson泛型支持
LogRecvData<NtcCollectVoipLog> fromJson = gson.fromJson(jsonString,
new TypeToken<LogRecvData<NtcCollectVoipLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcCollectVoipLog> data = fromJson.getData();
list = data.getList();
// list = getList();
}
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>();
titleList.add("collect_voip");
classMap.put("collect_voip", NtcCollectVoipLog.class);
SysUser user = UserUtils.getUser();
if (!user.isAdmin()) {
hColumns += ",scene_file,";
} else {
hColumns += ",";
}
String cfgIndexInfoNoExport = ",cfg_id,action," + hColumns;
noExportMap.put("collect_voip", cfgIndexInfoNoExport);
dataMap.put("collect_voip", list);
/* } */
if ("csv".equals(type)) {
this._exportCsv(model, request, response, redirectAttributes, "collect_voip", titleList, classMap,
dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, "collect_voip", titleList, classMap, dataMap,
noExportMap);
}
} catch (Exception e) {
logger.error("collect_voip export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
}
}
public List<NtcCollectVoipLog> getList() {
List<NtcCollectVoipLog> list = new ArrayList<NtcCollectVoipLog>();
for (int i = 0; i < 100; i++) {
NtcCollectVoipLog ntcCollectVoipLog = new NtcCollectVoipLog();
ntcCollectVoipLog.setAction(i);
ntcCollectVoipLog.setCalledAccount("-" + i);
ntcCollectVoipLog.setCallId("11" + i);
ntcCollectVoipLog.setDate(new Date().toString());
ntcCollectVoipLog.setId(1L);
ntcCollectVoipLog.setSearchRtpDIp("123");
ntcCollectVoipLog.setCallId("199199");
ntcCollectVoipLog.setAction(1);
ntcCollectVoipLog.setCapIp("11");
ntcCollectVoipLog.setContacts("aa");
ntcCollectVoipLog.setFromToStoreUrl("tocal");
list.add(ntcCollectVoipLog);
}
return list;
}
}

View File

@@ -1,5 +1,6 @@
package com.nis.web.controller.log.ntc;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -13,6 +14,7 @@ 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;
@@ -21,20 +23,23 @@ 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.log.NtcDdosLog;
import com.nis.domain.SysUser;
import com.nis.domain.log.NtcCollectRadiusLog;
import com.nis.domain.log.NtcDnsLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
@Controller
@RequestMapping("${adminPath}/log/ntc/dns")
public class DnsLogController extends BaseController {
@RequestMapping("list")
public String list(@ModelAttribute("log") NtcDnsLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
public String list(@ModelAttribute("log") NtcDnsLog log, Model model, HttpServletRequest request,
HttpServletResponse response) {
try {
PageLog<NtcDnsLog> page = new PageLog<NtcDnsLog>(request, response);
Map<String, Object> params = new HashMap<String, Object>();
@@ -44,16 +49,17 @@ public class DnsLogController extends BaseController {
params.put("searchQname", log.getQname());
}
initLogSearchValue(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_DNS_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
Gson gson = new GsonBuilder().create();
LogRecvData<NtcDnsLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcDnsLog>>(){}.getType());
LogRecvData<NtcDnsLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcDnsLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcDnsLog> data = fromJson.getData();
page.setCount(data.getCount());
@@ -62,7 +68,7 @@ public class DnsLogController extends BaseController {
List<NtcDnsLog> list = page.getList();
for (NtcDnsLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l,serviceList);
setLogAction(l, serviceList);
}
model.addAttribute("page", page);
}
@@ -70,7 +76,71 @@ public class DnsLogController extends BaseController {
logger.error("查询失败", e);
addMessageLog(model, e.getMessage());
}
return "/log/ntc/dnsList";
}
// Dns配置导出
@RequestMapping(value = "exportDns")
public void exportDns(@ModelAttribute("log") NtcDnsLog log, Model model, String hColumns, String type,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
System.out.println("进来了dns");
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<NtcDnsLog> page = new PageLog<NtcDnsLog>(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());
initLogSearchValue(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_DNS_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
List<NtcDnsLog> list = new ArrayList<NtcDnsLog>();
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<NtcDnsLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcDnsLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcDnsLog> data = fromJson.getData();
list = data.getList();
}
}
for (NtcDnsLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l, serviceList);
}
titleList.add("DNS");
classMap.put("DNS", NtcDnsLog.class);
SysUser user = UserUtils.getUser();
if (!user.isAdmin()) {
hColumns += ",scene_file,";
} else {
hColumns += ",";
}
String cfgIndexInfoNoExport = "," + hColumns;
noExportMap.put("DNS", cfgIndexInfoNoExport);
dataMap.put("DNS", list);
/* } */
if ("csv".equals(type)) {
this._exportCsv(model, request, response, redirectAttributes, "DNS", titleList, classMap,
dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, "DNS", titleList, classMap, dataMap,
noExportMap);
}
} catch (Exception e) {
logger.error("DNS export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
}
}
}

View File

@@ -1,6 +1,7 @@
package com.nis.web.controller.log.ntc;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -8,12 +9,14 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.ClientProtocolException;
import org.springframework.beans.BeanUtils;
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;
@@ -21,18 +24,21 @@ 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.NtcDnsLog;
import com.nis.domain.log.NtcFtpLog;
import com.nis.domain.log.NtcFtpLog;
import com.nis.domain.log.NtcOpenVpnLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
@Controller
@RequestMapping(value = "${adminPath}/log/ntc/NtcFtpLogs")
public class FtpLogController extends BaseController{
public class FtpLogController extends BaseController {
/**
* @param model
@@ -43,29 +49,31 @@ public class FtpLogController extends BaseController{
* @throws ClientProtocolException
* @throws IOException
*/
@RequestMapping(value={"list",""})
public String list(Model model,@ModelAttribute("log")NtcFtpLog entry,HttpServletRequest request, HttpServletResponse response) throws ClientProtocolException, IOException {
@RequestMapping(value = { "list", "" })
public String list(Model model, @ModelAttribute("log") NtcFtpLog entry, HttpServletRequest request,
HttpServletResponse response) throws ClientProtocolException, IOException {
try {
PageLog<NtcFtpLog> page = new PageLog<NtcFtpLog>(request, response);
Map<String, Object> params=new HashMap<>();
Map<String, Object> params = new HashMap<>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
//查询值判断
initLogSearchValue(entry,params);
// 查询值判断
initLogSearchValue(entry, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entry.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = "";
url = Constants.LOG_BASE_URL+Constants.NTC_FTP_LOG;
String jsonString = HttpClientUtil.getMsg(url,params,request);
url = Constants.LOG_BASE_URL + Constants.NTC_FTP_LOG;
String jsonString = HttpClientUtil.getMsg(url, params, request);
Gson gson = new GsonBuilder().create();
//gson泛型支持
LogRecvData<NtcFtpLog> fromJson = gson.fromJson(jsonString, new TypeToken<LogRecvData<NtcFtpLog>>(){}.getType());
// gson泛型支持
LogRecvData<NtcFtpLog> fromJson = gson.fromJson(jsonString, new TypeToken<LogRecvData<NtcFtpLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcFtpLog> data = fromJson.getData();
page.setCount(data.getCount());
@@ -74,7 +82,7 @@ public class FtpLogController extends BaseController{
List<NtcFtpLog> list = page.getList();
for (NtcFtpLog l : list) {
l.setFunctionId(entry.getFunctionId());
setLogAction(l,serviceList);
setLogAction(l, serviceList);
}
model.addAttribute("page", page);
logger.info("查询Ftp日志成功");
@@ -85,5 +93,68 @@ public class FtpLogController extends BaseController{
}
return "/log/ntc/ftpList";
}
// ftp配置导出
@RequestMapping(value = "exportFtp")
public void exportFtp(@ModelAttribute("log") NtcFtpLog log, Model model, String hColumns, String type,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
System.out.println("进来了Ftp");
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<NtcFtpLog> page = new PageLog<NtcFtpLog>(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());
initLogSearchValue(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_FTP_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
List<NtcFtpLog> list = new ArrayList<NtcFtpLog>();
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<NtcFtpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcFtpLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcFtpLog> data = fromJson.getData();
list = data.getList();
}
}
for (NtcFtpLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l, serviceList);
}
titleList.add("ftp_control");
classMap.put("ftp_control", NtcFtpLog.class);
SysUser user = UserUtils.getUser();
if (!user.isAdmin()) {
hColumns += ",scene_file,";
} else {
hColumns += ",";
}
String cfgIndexInfoNoExport = "," + hColumns;
noExportMap.put("ftp_control", cfgIndexInfoNoExport);
dataMap.put("ftp_control", list);
/* } */
if ("csv".equals(type)) {
this._exportCsv(model, request, response, redirectAttributes, "ftp_control", titleList, classMap,
dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, "ftp_control", titleList, classMap, dataMap,
noExportMap);
}
} catch (Exception e) {
logger.error("ftp_control export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
}
}
}

View File

@@ -1,5 +1,6 @@
package com.nis.web.controller.log.ntc;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -13,6 +14,7 @@ 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;
@@ -20,21 +22,24 @@ 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.NtcFtpLog;
import com.nis.domain.log.NtcHttpLog;
import com.nis.domain.log.NtcKeywordsUrlLog;
import com.nis.domain.log.NtcKeywordsUrlLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
@Controller
@RequestMapping("${adminPath}/log/ntc/httpkey")
public class HttpKeyLogController extends BaseController {
@RequestMapping("list")
public String list(@ModelAttribute("log") NtcKeywordsUrlLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
public String list(@ModelAttribute("log") NtcKeywordsUrlLog log, Model model, HttpServletRequest request,
HttpServletResponse response) {
try {
PageLog<NtcKeywordsUrlLog> page = new PageLog<NtcKeywordsUrlLog>(request, response);
Map<String, Object> params = new HashMap<String, Object>();
@@ -44,16 +49,18 @@ public class HttpKeyLogController extends BaseController {
params.put("searchUrl", log.getUrl());
}
initLogSearchValue(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_KEYWORDS_URL_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
Gson gson = new GsonBuilder().create();
LogRecvData<NtcKeywordsUrlLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcKeywordsUrlLog>>(){}.getType());
LogRecvData<NtcKeywordsUrlLog> fromJson = gson.fromJson(recv,
new TypeToken<LogRecvData<NtcKeywordsUrlLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcKeywordsUrlLog> data = fromJson.getData();
page.setCount(data.getCount());
@@ -62,7 +69,7 @@ public class HttpKeyLogController extends BaseController {
List<NtcKeywordsUrlLog> list = page.getList();
for (NtcKeywordsUrlLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l,serviceList);
setLogAction(l, serviceList);
}
model.addAttribute("page", page);
}
@@ -70,7 +77,72 @@ public class HttpKeyLogController extends BaseController {
logger.error("查询失败", e);
addMessageLog(model, e.getMessage());
}
return "/log/ntc/httpKeyList";
}
// httpKey配置导出
@RequestMapping(value = "exportHttpKey")
public void exportHttpKey(@ModelAttribute("log") NtcKeywordsUrlLog log, Model model, String hColumns, String type,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
System.out.println("进来了httpKey");
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<NtcKeywordsUrlLog> page = new PageLog<NtcKeywordsUrlLog>(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());
initLogSearchValue(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_KEYWORDS_URL_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
List<NtcKeywordsUrlLog> list = new ArrayList<NtcKeywordsUrlLog>();
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<NtcKeywordsUrlLog> fromJson = gson.fromJson(recv,
new TypeToken<LogRecvData<NtcKeywordsUrlLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcKeywordsUrlLog> data = fromJson.getData();
list = data.getList();
}
}
for (NtcKeywordsUrlLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l, serviceList);
}
titleList.add("http_keyword");
classMap.put("http_keyword", NtcKeywordsUrlLog.class);
SysUser user = UserUtils.getUser();
if (!user.isAdmin()) {
hColumns += ",scene_file,";
} else {
hColumns += ",";
}
String cfgIndexInfoNoExport = "," + hColumns;
noExportMap.put("http_keyword", cfgIndexInfoNoExport);
dataMap.put("http_keyword", list);
/* } */
if ("csv".equals(type)) {
this._exportCsv(model, request, response, redirectAttributes, "http_keyword", titleList, classMap,
dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, "http_keyword", titleList, classMap, dataMap,
noExportMap);
}
} catch (Exception e) {
logger.error("http_keyword export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
}
}
}

View File

@@ -1,5 +1,6 @@
package com.nis.web.controller.log.ntc;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -12,6 +13,7 @@ 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;
@@ -19,19 +21,23 @@ 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.NtcHttpLog;
import com.nis.domain.log.NtcHttpLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
@Controller
@RequestMapping("${adminPath}/log/ntc/http")
public class HttpLogController extends BaseController {
@RequestMapping("list")
public String list(@ModelAttribute("log") NtcHttpLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
public String list(@ModelAttribute("log") NtcHttpLog log, Model model, HttpServletRequest request,
HttpServletResponse response) {
try {
PageLog<NtcHttpLog> page = new PageLog<NtcHttpLog>(request, response);
Map<String, Object> params = new HashMap<String, Object>();
@@ -41,32 +47,33 @@ public class HttpLogController extends BaseController {
params.put("searchUrl", log.getUrl());
}
initLogSearchValue(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
serviceList.addAll(DictUtils.getFunctionServiceDictList(635));
for (FunctionServiceDict serviceDict : serviceList) {
if(serviceDict.getFunctionId() == log.getFunctionId()){
if(serviceDict.getAction() == Constants.MONIT_ACTION){
if (serviceDict.getFunctionId() == log.getFunctionId()) {
if (serviceDict.getAction() == Constants.MONIT_ACTION) {
serviceDict.setActionCode("log_search_http_monit");
}else if(serviceDict.getAction() == Constants.REJECT_ACTION){
} else if (serviceDict.getAction() == Constants.REJECT_ACTION) {
serviceDict.setActionCode("log_search_http_reject");
}
}else{
if(serviceDict.getAction() == Constants.MONIT_ACTION){
} else {
if (serviceDict.getAction() == Constants.MONIT_ACTION) {
serviceDict.setActionCode("log_search_keyword_monit");
}else if(serviceDict.getAction() == Constants.REJECT_ACTION){
} else if (serviceDict.getAction() == Constants.REJECT_ACTION) {
serviceDict.setActionCode("log_search_keyword_reject");
}
}
}
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_HTTP_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
Gson gson = new GsonBuilder().create();
LogRecvData<NtcHttpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcHttpLog>>(){}.getType());
LogRecvData<NtcHttpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcHttpLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcHttpLog> data = fromJson.getData();
page.setCount(data.getCount());
@@ -75,7 +82,7 @@ public class HttpLogController extends BaseController {
List<NtcHttpLog> list = page.getList();
for (NtcHttpLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l,serviceList);
setLogAction(l, serviceList);
}
model.addAttribute("page", page);
}
@@ -83,7 +90,71 @@ public class HttpLogController extends BaseController {
logger.error("查询失败", e);
addMessageLog(model, e.getMessage());
}
return "/log/ntc/httpList";
}
// http配置导出
@RequestMapping(value = "exportHttp")
public void exportHttp(@ModelAttribute("log") NtcHttpLog log, Model model, String hColumns, String type,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
System.out.println("进来了http");
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<NtcHttpLog> page = new PageLog<NtcHttpLog>(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());
initLogSearchValue(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_HTTP_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
List<NtcHttpLog> list = new ArrayList<NtcHttpLog>();
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<NtcHttpLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcHttpLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcHttpLog> data = fromJson.getData();
list = data.getList();
}
}
for (NtcHttpLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l, serviceList);
}
titleList.add("HTTP");
classMap.put("HTTP", NtcHttpLog.class);
SysUser user = UserUtils.getUser();
if (!user.isAdmin()) {
hColumns += ",scene_file,";
} else {
hColumns += ",";
}
String cfgIndexInfoNoExport = "," + hColumns;
noExportMap.put("HTTP", cfgIndexInfoNoExport);
dataMap.put("HTTP", list);
/* } */
if ("csv".equals(type)) {
this._exportCsv(model, request, response, redirectAttributes, "HTTP", titleList, classMap,
dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, "HTTP", titleList, classMap, dataMap,
noExportMap);
}
} catch (Exception e) {
logger.error("HTTP export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
}
}
}

View File

@@ -1,5 +1,6 @@
package com.nis.web.controller.log.ntc;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -14,6 +15,7 @@ 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;
@@ -21,27 +23,31 @@ 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.NtcIpLog;
import com.nis.domain.log.NtcMailLog;
import com.nis.domain.log.NtcMailLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
@Controller
@RequestMapping("${adminPath}/log/ntc/mail")
public class MailLogController extends BaseController {
@RequestMapping("list")
public String list(@ModelAttribute("log") NtcMailLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
public String list(@ModelAttribute("log") NtcMailLog log, Model model, HttpServletRequest request,
HttpServletResponse response) {
try {
PageLog<NtcMailLog> page = new PageLog<NtcMailLog>(request, response);
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
initLogSearchValue(log, params);
// 增加收/发件人、邮件主题查询
if (StringUtils.isNotBlank(log.getMailTo())) {
params.put("searchMailTo", StringEscapeUtils.unescapeHtml(log.getMailTo()));
@@ -52,16 +58,17 @@ public class MailLogController extends BaseController {
if (StringUtils.isNotBlank(log.getSubject())) {
params.put("searchSubject", StringEscapeUtils.unescapeHtml(log.getSubject()));
}
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_MAIL_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<NtcMailLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcMailLog>>(){}.getType());
LogRecvData<NtcMailLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcMailLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcMailLog> data = fromJson.getData();
page.setCount(data.getCount());
@@ -70,7 +77,7 @@ public class MailLogController extends BaseController {
List<NtcMailLog> list = page.getList();
for (NtcMailLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l,serviceList);
setLogAction(l, serviceList);
}
model.addAttribute("page", page);
}
@@ -79,7 +86,71 @@ public class MailLogController extends BaseController {
logger.error("查询失败", e);
addMessageLog(model, e.getMessage());
}
return "/log/ntc/mailList";
}
// Mail配置导出
@RequestMapping(value = "exportMail")
public void exportMail(@ModelAttribute("log") NtcMailLog log, Model model, String hColumns, String type,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
System.out.println("进来了Mail");
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<NtcMailLog> page = new PageLog<NtcMailLog>(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());
initLogSearchValue(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_MAIL_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
List<NtcMailLog> list = new ArrayList<NtcMailLog>();
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<NtcMailLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcMailLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcMailLog> data = fromJson.getData();
list = data.getList();
}
}
for (NtcMailLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l, serviceList);
}
titleList.add("mail_control");
classMap.put("mail_control", NtcMailLog.class);
SysUser user = UserUtils.getUser();
if (!user.isAdmin()) {
hColumns += ",scene_file,";
} else {
hColumns += ",";
}
String cfgIndexInfoNoExport = "," + hColumns;
noExportMap.put("mail_control", cfgIndexInfoNoExport);
dataMap.put("mail_control", list);
/* } */
if ("csv".equals(type)) {
this._exportCsv(model, request, response, redirectAttributes, "mail_control", titleList, classMap,
dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, "mail_control", titleList, classMap, dataMap,
noExportMap);
}
} catch (Exception e) {
logger.error("mail_control export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
}
}
}

View File

@@ -1,6 +1,7 @@
package com.nis.web.controller.log.ntc;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -8,12 +9,14 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.ClientProtocolException;
import org.springframework.beans.BeanUtils;
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;
@@ -21,20 +24,24 @@ 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.MmAvIpLog;
import com.nis.domain.log.NtcStreamMediaLog;
import com.nis.domain.log.NtcStreamMediaLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
@Controller
@RequestMapping(value = "${adminPath}/log/ntc/mmAvUrlLogs")
public class MmAvUrlLogController extends BaseController{
public class MmAvUrlLogController extends BaseController {
/**
* 音视频url日志
*
* @param model
* @param entry
* @param request
@@ -43,29 +50,32 @@ public class MmAvUrlLogController extends BaseController{
* @throws ClientProtocolException
* @throws IOException
*/
@RequestMapping(value={"list",""})
public String list(Model model,@ModelAttribute("log")NtcStreamMediaLog entry,HttpServletRequest request, HttpServletResponse response) throws ClientProtocolException, IOException {
@RequestMapping(value = { "list", "" })
public String list(Model model, @ModelAttribute("log") NtcStreamMediaLog entry, HttpServletRequest request,
HttpServletResponse response) throws ClientProtocolException, IOException {
try {
PageLog<NtcStreamMediaLog> page = new PageLog<NtcStreamMediaLog>(request, response);
Map<String, Object> params=new HashMap<>();
Map<String, Object> params = new HashMap<>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
//查询值判断
initLogSearchValue(entry,params);
// 查询值判断
initLogSearchValue(entry, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entry.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = "";
url = Constants.LOG_BASE_URL+Constants.NTC_STREAMMEDIA_LOG;
String jsonString = HttpClientUtil.getMsg(url,params,request);
url = Constants.LOG_BASE_URL + Constants.NTC_STREAMMEDIA_LOG;
String jsonString = HttpClientUtil.getMsg(url, params, request);
Gson gson = new GsonBuilder().create();
//gson泛型支持
LogRecvData<NtcStreamMediaLog> fromJson = gson.fromJson(jsonString, new TypeToken<LogRecvData<NtcStreamMediaLog>>(){}.getType());
// gson泛型支持
LogRecvData<NtcStreamMediaLog> fromJson = gson.fromJson(jsonString,
new TypeToken<LogRecvData<NtcStreamMediaLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcStreamMediaLog> data = fromJson.getData();
page.setCount(data.getCount());
@@ -74,7 +84,7 @@ public class MmAvUrlLogController extends BaseController{
List<NtcStreamMediaLog> list = page.getList();
for (NtcStreamMediaLog l : list) {
l.setFunctionId(entry.getFunctionId());
setLogAction(l,serviceList);
setLogAction(l, serviceList);
}
model.addAttribute("page", page);
logger.info("查询音视频url日志成功");
@@ -85,5 +95,70 @@ public class MmAvUrlLogController extends BaseController{
}
return "/log/ntc/ntcStreamMedia";
}
// AvUrl配置导出
@RequestMapping(value = "exportAvUrl")
public void exportAvUrl(@ModelAttribute("log") NtcStreamMediaLog log, Model model, String hColumns, String type,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
System.out.println("进来了AvUrl");
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<NtcStreamMediaLog> page = new PageLog<NtcStreamMediaLog>(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());
initLogSearchValue(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_STREAMMEDIA_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
List<NtcStreamMediaLog> list = new ArrayList<NtcStreamMediaLog>();
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<NtcStreamMediaLog> fromJson = gson.fromJson(recv,
new TypeToken<LogRecvData<NtcStreamMediaLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcStreamMediaLog> data = fromJson.getData();
list = data.getList();
}
}
for (NtcStreamMediaLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l, serviceList);
}
titleList.add("streaming_media");
classMap.put("streaming_media", NtcStreamMediaLog.class);
SysUser user = UserUtils.getUser();
if (!user.isAdmin()) {
hColumns += ",scene_file,";
} else {
hColumns += ",";
}
String cfgIndexInfoNoExport = "," + hColumns;
noExportMap.put("streaming_media", cfgIndexInfoNoExport);
dataMap.put("streaming_media", list);
/* } */
if ("csv".equals(type)) {
this._exportCsv(model, request, response, redirectAttributes, "streaming_media", titleList, classMap,
dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, "streaming_media", titleList, classMap, dataMap,
noExportMap);
}
} catch (Exception e) {
logger.error("streaming_media export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
}
}
}

View File

@@ -1,6 +1,7 @@
package com.nis.web.controller.log.ntc;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -8,12 +9,14 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.ClientProtocolException;
import org.springframework.beans.BeanUtils;
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;
@@ -21,16 +24,19 @@ 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.MmVoipLog;
import com.nis.domain.log.MmVoipLog;
import com.nis.domain.maat.LogRecvData;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
@Controller
@RequestMapping(value = "${adminPath}/log/ntc/mmVoipIpLogs")
public class MmVoipIpLogController extends BaseController{
public class MmVoipIpLogController extends BaseController {
/**
* @param model
@@ -41,29 +47,31 @@ public class MmVoipIpLogController extends BaseController{
* @throws ClientProtocolException
* @throws IOException
*/
@RequestMapping(value={"list",""})
public String list(Model model,@ModelAttribute("log")MmVoipLog entry,HttpServletRequest request, HttpServletResponse response) throws ClientProtocolException, IOException {
@RequestMapping(value = { "list", "" })
public String list(Model model, @ModelAttribute("log") MmVoipLog entry, HttpServletRequest request,
HttpServletResponse response) throws ClientProtocolException, IOException {
try {
PageLog<MmVoipLog> page = new PageLog<MmVoipLog>(request, response);
Map<String, Object> params=new HashMap<>();
Map<String, Object> params = new HashMap<>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
//查询值判断
initLogSearchValue(entry,params);
// 查询值判断
initLogSearchValue(entry, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entry.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = "";
url = Constants.LOG_BASE_URL+Constants.NTC_MMVOIP_LOG;
String jsonString = HttpClientUtil.getMsg(url,params,request);
url = Constants.LOG_BASE_URL + Constants.NTC_MMVOIP_LOG;
String jsonString = HttpClientUtil.getMsg(url, params, request);
Gson gson = new GsonBuilder().create();
//gson泛型支持
LogRecvData<MmVoipLog> fromJson = gson.fromJson(jsonString, new TypeToken<LogRecvData<MmVoipLog>>(){}.getType());
// gson泛型支持
LogRecvData<MmVoipLog> fromJson = gson.fromJson(jsonString, new TypeToken<LogRecvData<MmVoipLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<MmVoipLog> data = fromJson.getData();
page.setCount(data.getCount());
@@ -72,7 +80,7 @@ public class MmVoipIpLogController extends BaseController{
List<MmVoipLog> list = page.getList();
for (MmVoipLog l : list) {
l.setFunctionId(entry.getFunctionId());
setLogAction(l,serviceList);
setLogAction(l, serviceList);
}
model.addAttribute("page", page);
logger.info("查询Voip日志成功");
@@ -83,5 +91,69 @@ public class MmVoipIpLogController extends BaseController{
}
return "/log/ntc/mmVoipIpList";
}
// Voip配置导出
@RequestMapping(value = "exportVoip")
public void exportVoip(@ModelAttribute("log") MmVoipLog log, Model model, String hColumns, String type,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
System.out.println("进来了Voip");
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<MmVoipLog> page = new PageLog<MmVoipLog>(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());
initLogSearchValue(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_MMVOIP_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
List<MmVoipLog> list = new ArrayList<MmVoipLog>();
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<MmVoipLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<MmVoipLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<MmVoipLog> data = fromJson.getData();
list = data.getList();
}
}
for (MmVoipLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l, serviceList);
}
titleList.add("av_voip_control");
classMap.put("av_voip_control", MmVoipLog.class);
SysUser user = UserUtils.getUser();
if (!user.isAdmin()) {
hColumns += ",duation,from_to_store_ip,from_to_store_url,to_from_store_ip,to_from_store_url,log_uri,direction,scene_file,";
} else {
hColumns += ",";
}
String cfgIndexInfoNoExport = "," + hColumns;
noExportMap.put("av_voip_control", cfgIndexInfoNoExport);
dataMap.put("av_voip_control", list);
/* } */
if ("csv".equals(type)) {
this._exportCsv(model, request, response, redirectAttributes, "av_voip_control", titleList, classMap,
dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, "av_voip_control", titleList, classMap,
dataMap, noExportMap);
}
} catch (Exception e) {
logger.error("av_voip_control export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
}
}
}

View File

@@ -18,6 +18,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -26,10 +27,12 @@ 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.IrDnatLog;
import com.nis.domain.log.IrSnatLog;
import com.nis.domain.log.NtcCollectRadiusLog;
import com.nis.domain.log.NtcConnRecordLog;
import com.nis.domain.log.NtcConnRecordLog;
import com.nis.domain.log.SearchReport;
import com.nis.domain.maat.LogRecvData;
import com.nis.domain.report.NtcServiceReport;
@@ -42,43 +45,48 @@ import com.nis.util.StringUtil;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.dao.dashboard.codedic.CodeResult;
import com.nis.web.security.UserUtils;
import net.sf.json.JSONObject;
@Controller
@RequestMapping("${adminPath}/log/ntc/connRecordLogs")
public class NtcConnRecordLogController extends BaseController {
@RequestMapping(value = {"/list", ""})
public String connRecordLogs(@ModelAttribute("log") NtcConnRecordLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
@RequestMapping(value = { "/list", "" })
public String connRecordLogs(@ModelAttribute("log") NtcConnRecordLog log, Model model, HttpServletRequest request,
HttpServletResponse response) {
try {
PageLog<NtcConnRecordLog> page = new PageLog<NtcConnRecordLog>(request, response);
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
initLogSearchValue(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
List<CodeResult> appList=CodeDicUtils.getCodeList("appCode");
List<CodeResult> appList = CodeDicUtils.getCodeList("appCode");
model.addAttribute("appList", appList);
String url =Constants.LOG_BASE_URL + Constants.NTC_CONN_RECORD_LOG;
String url = Constants.LOG_BASE_URL + Constants.NTC_CONN_RECORD_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<NtcConnRecordLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcConnRecordLog>>(){}.getType());
LogRecvData<NtcConnRecordLog> fromJson = gson.fromJson(recv,
new TypeToken<LogRecvData<NtcConnRecordLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcConnRecordLog> data = fromJson.getData();
page.setCount(data.getCount());
page.setLast(data.getLast());
page.setList(data.getList());
/*List<NtcCollectRadiusLog> list = page.getList();
for (NtcConnRecordLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l,serviceList);
}*/
/*
* List<NtcCollectRadiusLog> list = page.getList(); for
* (NtcConnRecordLog l : list) {
* l.setFunctionId(log.getFunctionId());
* setLogAction(l,serviceList); }
*/
model.addAttribute("page", page);
}
}
@@ -86,41 +94,102 @@ public class NtcConnRecordLogController extends BaseController {
logger.error("查询失败", e);
addMessageLog(model, e.getMessage());
}
return "/log/ntc/connRecordLogList";
}
@RequestMapping("/ajaxConnRecordPercent")
@ResponseBody
public JSONObject ajaxConnRecordPercent(String searchFoundStartTime,
String searchFoundEndTime,
String searchStreamDir,
HttpServletRequest request,
HttpServletResponse response) {
JSONObject resultAllJson=new JSONObject();
JSONObject result=new JSONObject();
Map<String, Object> params=new HashMap<>();
public JSONObject ajaxConnRecordPercent(String searchFoundStartTime, String searchFoundEndTime,
String searchStreamDir, HttpServletRequest request, HttpServletResponse response) {
JSONObject resultAllJson = new JSONObject();
JSONObject result = new JSONObject();
Map<String, Object> params = new HashMap<>();
try {
params.put("searchFoundStartTime", searchFoundStartTime);
params.put("searchFoundEndTime", searchFoundEndTime);
StringBuffer url=new StringBuffer(Constants.LOG_BASE_URL+Constants.NTC_CONN_RECORD_PERCENT);
String json=HttpClientUtil.getMsg(url.toString(), params,request);
if(!StringUtil.isEmpty(json)) {
resultAllJson=JSONObject.fromObject(json);
if(!StringUtil.isEmpty(resultAllJson)) {
result=(JSONObject) resultAllJson.get("data");
StringBuffer url = new StringBuffer(Constants.LOG_BASE_URL + Constants.NTC_CONN_RECORD_PERCENT);
String json = HttpClientUtil.getMsg(url.toString(), params, request);
if (!StringUtil.isEmpty(json)) {
resultAllJson = JSONObject.fromObject(json);
if (!StringUtil.isEmpty(resultAllJson)) {
result = (JSONObject) resultAllJson.get("data");
}
}
result.put("success","success");
result.put("success", "success");
} catch (MaatConvertException e) {
logger.error("ajaxConnRecordPercent检索失败",e);
result.put("error",getMsgProp().get("request_service_failed"));
}catch (Exception e) {
logger.error("ajaxConnRecordPercent检索失败",e);
result.put("error",getMsgProp().get("search_error"));
}
logger.error("ajaxConnRecordPercent检索失败", e);
result.put("error", getMsgProp().get("request_service_failed"));
} catch (Exception e) {
logger.error("ajaxConnRecordPercent检索失败", e);
result.put("error", getMsgProp().get("search_error"));
}
return result;
}
// ConnRecord配置导出
@RequestMapping(value = "exportConnRecord")
public void exportConnRecord(@ModelAttribute("log") NtcConnRecordLog log, Model model, String hColumns, String type,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
System.out.println("进来了ConnRecord");
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<NtcConnRecordLog> page = new PageLog<NtcConnRecordLog>(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());
initLogSearchValue(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_CONN_RECORD_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
List<NtcConnRecordLog> list = new ArrayList<NtcConnRecordLog>();
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<NtcConnRecordLog> fromJson = gson.fromJson(recv,
new TypeToken<LogRecvData<NtcConnRecordLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcConnRecordLog> data = fromJson.getData();
list = data.getList();
}
}
for (NtcConnRecordLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l, serviceList);
}
titleList.add("conn_record");
classMap.put("conn_record", NtcConnRecordLog.class);
SysUser user = UserUtils.getUser();
if (!user.isAdmin()) {
hColumns += ",scene_file,";
} else {
hColumns += ",";
}
String cfgIndexInfoNoExport = "," + hColumns;
noExportMap.put("conn_record", cfgIndexInfoNoExport);
dataMap.put("conn_record", list);
/* } */
if ("csv".equals(type)) {
this._exportCsv(model, request, response, redirectAttributes, "conn_record", titleList, classMap,
dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, "conn_record", titleList, classMap, dataMap,
noExportMap);
}
} catch (Exception e) {
logger.error("conn_record export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
}
}
}

View File

@@ -1,5 +1,6 @@
package com.nis.web.controller.log.ntc;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -13,6 +14,7 @@ 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;
@@ -20,6 +22,8 @@ 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.NtcP2pLog;
import com.nis.domain.log.NtcOpenVpnLog;
import com.nis.domain.log.NtcP2pLog;
import com.nis.domain.maat.LogRecvData;
@@ -27,13 +31,15 @@ import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
@Controller
@RequestMapping("${adminPath}/log/ntc/p2pLogs")
public class P2pLogController extends BaseController {
@RequestMapping(value = {"list", ""})
public String list(@ModelAttribute("log") NtcP2pLog log, Model model, HttpServletRequest request, HttpServletResponse response) {
@RequestMapping(value = { "list", "" })
public String list(@ModelAttribute("log") NtcP2pLog log, Model model, HttpServletRequest request,
HttpServletResponse response) {
try {
PageLog<NtcP2pLog> page = new PageLog<NtcP2pLog>(request, response);
Map<String, Object> params = new HashMap<String, Object>();
@@ -43,13 +49,14 @@ public class P2pLogController extends BaseController {
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_P2P_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
String recv = HttpClientUtil.getMsg(url, params, request);
logger.error("查询结果:" + recv);
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<NtcP2pLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcP2pLog>>(){}.getType());
LogRecvData<NtcP2pLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcP2pLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcP2pLog> data = fromJson.getData();
page.setCount(data.getCount());
@@ -58,7 +65,7 @@ public class P2pLogController extends BaseController {
List<NtcP2pLog> list = page.getList();
for (NtcP2pLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l,serviceList);
setLogAction(l, serviceList);
}
model.addAttribute("page", page);
}
@@ -67,8 +74,72 @@ public class P2pLogController extends BaseController {
logger.error("查询失败", e);
addMessageLog(model, e.getMessage());
}
return "/log/ntc/p2pList";
}
// p2p配置导出
@RequestMapping(value = "exportP2p")
public void exportP2p(@ModelAttribute("log") NtcP2pLog log, Model model, String hColumns, String type,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
System.out.println("进来了P2p");
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<NtcP2pLog> page = new PageLog<NtcP2pLog>(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());
initLogSearchValue(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_P2P_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
List<NtcP2pLog> list = new ArrayList<NtcP2pLog>();
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<NtcP2pLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcP2pLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcP2pLog> data = fromJson.getData();
list = data.getList();
}
}
for (NtcP2pLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l, serviceList);
}
titleList.add("p2p_control");
classMap.put("p2p_control", NtcP2pLog.class);
SysUser user = UserUtils.getUser();
if (!user.isAdmin()) {
hColumns += ",scene_file,";
} else {
hColumns += ",";
}
String cfgIndexInfoNoExport = "," + hColumns;
noExportMap.put("p2p_control", cfgIndexInfoNoExport);
dataMap.put("p2p_control", list);
/* } */
if ("csv".equals(type)) {
this._exportCsv(model, request, response, redirectAttributes, "p2p_control", titleList, classMap,
dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, "p2p_control", titleList, classMap, dataMap,
noExportMap);
}
} catch (Exception e) {
logger.error("p2p_control export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
}
}
}

View File

@@ -1,5 +1,6 @@
package com.nis.web.controller.log.ntc;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -12,6 +13,7 @@ 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;
@@ -20,6 +22,8 @@ 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.NtcSslLog;
import com.nis.domain.log.NtcSshLog;
import com.nis.domain.log.NtcSslLog;
import com.nis.domain.maat.LogRecvData;
@@ -28,35 +32,39 @@ import com.nis.util.DictUtils;
import com.nis.util.StringUtils;
import com.nis.util.httpclient.HttpClientUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
@Controller
@RequestMapping("${adminPath}/log/ntc/sslLogs")
@SuppressWarnings("all")
public class SslLogController extends BaseController {
@RequestMapping(value = {"/list"})
public String list(HttpServletRequest request, HttpServletResponse response, Model model, @ModelAttribute("log")NtcSslLog ntcSslLog) {
PageLog<NtcSslLog> page = new PageLog<NtcSslLog>(request,response);
Map<String, Object> params = new HashMap<String,Object>();
@RequestMapping(value = { "/list" })
public String list(HttpServletRequest request, HttpServletResponse response, Model model,
@ModelAttribute("log") NtcSslLog ntcSslLog) {
PageLog<NtcSslLog> page = new PageLog<NtcSslLog>(request, response);
Map<String, Object> params = new HashMap<String, Object>();
params.put("pageSize", page.getPageSize());
params.put("pageNo", page.getPageNo());
// 请求参数判断
initLogSearchValue(ntcSslLog, params);
if(StringUtils.isNotBlank(ntcSslLog.getSni())) {
if (StringUtils.isNotBlank(ntcSslLog.getSni())) {
params.put("SearchSni", ntcSslLog.getSni());
}
}
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(ntcSslLog.getFunctionId());
model.addAttribute("serviceList", serviceList);
try {
// 请求接口
String url = Constants.LOG_BASE_URL + Constants.NTC_SSL_LOG;
String resJson = HttpClientUtil.getMsg(url, params, request);
Gson gson = new GsonBuilder().create();
LogRecvData<NtcSslLog> fromJson = gson.fromJson(resJson, new TypeToken<LogRecvData<NtcSslLog>>() {}.getType());
if(fromJson.getStatus().intValue() == 200) {
LogRecvData<NtcSslLog> fromJson = gson.fromJson(resJson, new TypeToken<LogRecvData<NtcSslLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcSslLog> data = fromJson.getData();
page.setCount(data.getCount());
page.setLast(data.getLast());
@@ -64,7 +72,7 @@ public class SslLogController extends BaseController {
List<NtcSslLog> list = page.getList();
for (NtcSslLog log : list) {
log.setFunctionId(ntcSslLog.getFunctionId());
setLogAction(log,serviceList);
setLogAction(log, serviceList);
}
model.addAttribute("page", page);
}
@@ -72,7 +80,71 @@ public class SslLogController extends BaseController {
logger.error("SSL日志查询失败", e);
addMessageLog(model, e.getMessage());
}
return "/log/ntc/sslLogList";
}
// Ssl配置导出
@RequestMapping(value = "exportSsl")
public void exportSsl(@ModelAttribute("log") NtcSslLog log, Model model, String hColumns, String type,
HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
System.out.println("进来了ssl");
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<NtcSslLog> page = new PageLog<NtcSslLog>(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());
initLogSearchValue(log, params);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId());
model.addAttribute("serviceList", serviceList);
String url = Constants.LOG_BASE_URL + Constants.NTC_SSL_LOG;
String recv = HttpClientUtil.getMsg(url, params, request);
List<NtcSslLog> list = new ArrayList<NtcSslLog>();
if (StringUtils.isNotBlank(recv)) {
Gson gson = new GsonBuilder().create();
LogRecvData<NtcSslLog> fromJson = gson.fromJson(recv, new TypeToken<LogRecvData<NtcSslLog>>() {
}.getType());
if (fromJson.getStatus().intValue() == 200) {
Page<NtcSslLog> data = fromJson.getData();
list = data.getList();
}
}
for (NtcSslLog l : list) {
l.setFunctionId(log.getFunctionId());
setLogAction(l, serviceList);
}
titleList.add("ssl_control");
classMap.put("ssl_control", NtcSslLog.class);
SysUser user = UserUtils.getUser();
if (!user.isAdmin()) {
hColumns += ",scene_file,";
} else {
hColumns += ",";
}
String cfgIndexInfoNoExport = "," + hColumns;
noExportMap.put("ssl_control", cfgIndexInfoNoExport);
dataMap.put("ssl_control", list);
/* } */
if ("csv".equals(type)) {
this._exportCsv(model, request, response, redirectAttributes, "ssl_control", titleList, classMap, dataMap,
noExportMap);
} else {
this._export(model, request, response, redirectAttributes, "ssl_control", titleList, classMap, dataMap,
noExportMap);
}
} catch (Exception e) {
logger.error("ssl_control export failed", e);
addMessage(redirectAttributes, "error", "export_failed");
}
}
}