From 48e488cb68a3ea43dc47bbc34b288eb607aa4651 Mon Sep 17 00:00:00 2001 From: leijun Date: Sat, 15 Dec 2018 20:34:10 +0800 Subject: [PATCH] =?UTF-8?q?radius=E6=97=A5=E5=BF=97=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=20action=E5=92=8Ccfgid=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/nis/domain/log/BaseLogEntity.java | 22 ++++++ .../nis/domain/log/NtcCollectRadiusLog.java | 6 ++ src/main/java/com/nis/util/Reflections.java | 12 +++- .../java/com/nis/util/excel/ExportExcel.java | 2 +- .../ntc/NtcCollectRadiusLogController.java | 68 +++++++++++++++++-- .../WEB-INF/views/log/ntc/radiusLogList.jsp | 48 ++++++++++--- 6 files changed, 141 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/nis/domain/log/BaseLogEntity.java b/src/main/java/com/nis/domain/log/BaseLogEntity.java index e1c53ff14..a62f5c0ea 100644 --- a/src/main/java/com/nis/domain/log/BaseLogEntity.java +++ b/src/main/java/com/nis/domain/log/BaseLogEntity.java @@ -1,34 +1,53 @@ package com.nis.domain.log; +import com.google.gson.annotations.Expose; import com.nis.domain.BaseEntity; +import com.nis.util.excel.ExcelField; public class BaseLogEntity extends BaseEntity { private static final long serialVersionUID = 8321337584518281424L; protected Integer cfgId; + @ExcelField(title="found_time",sort=5) protected String foundTime; //发现时间,timestamp protected String recvTime; //接收时间,timestamp + @ExcelField(title="transport_layer_protocol",dictType="LOG_PROTOCOL",sort=30) protected String transProto; //协议类型,从字典LOG_PROTOCOL取值 + @ExcelField(title="addr_type",dictType="IP_TYPE",sort=35) protected Integer addrType; //ip地址类型,从字典IP_TYPE取值 + @Expose + @ExcelField(title="server_ip",sort=40) protected String dIp; //服务端ip地址 + @Expose + @ExcelField(title="client_ip",sort=41) protected String sIp; //客户端ip地址 + @Expose + @ExcelField(title="server_port",sort=42) protected String dPort; //服务端ip端口 + @Expose + @ExcelField(title="client_port",sort=43) protected String sPort; //客户端ip端口 protected Integer service; //配置表的serviceId protected Integer entranceId; //出入口编号 protected Integer deviceId; //串联设备编号 + @ExcelField(title="direction",dictType="LOG_DIRECTION",sort=55) protected Integer direction; //传输方向 0:域内->域外,1:域外->域内,从字典LOG_DIRECTION取值 + @ExcelField(title="stream_type",dictType="LOG_STREAM_TYPE",sort=65) protected Integer streamDir; //流类型 0:c2s;1:s2c;2:double,从字典LOG_STREAMTYPE取值 protected String capIp; //处理机IP + @ExcelField(title="nest_addr_list",sort=66) protected String addrList; //嵌套地址列表 + @ExcelField(title="server_locate",sort=67) protected String serverLocate;// 服务端地址定位信息 + @ExcelField(title="client_locate",sort=68) protected String clientLocate;// 客户端地址定位信息 protected String userRegion; //用户自定义 protected String sAsn;//客户端ASN protected String dAsn;//服务端ASN protected String sSubscribeId;//客户端用户名 protected String dSubscribeId;//服务端用户名 + @ExcelField(title="scene_file",sort=70) protected String sceneFile;//现场日志文件地址 protected Integer functionId; @@ -44,9 +63,12 @@ public class BaseLogEntity extends BaseEntity { protected String orderBy;//排序参数 //新增字段 + @ExcelField(title="encap_type",dictType="ENCAP_TYPE",sort=50) protected Integer encapType;//原始二层封装格式 protected Integer linkId;//串联设备链路号 + @ExcelField(title="inner_smac",sort=58) protected String innerSmac;//MAC_IN_MAC的内层源MAC + @ExcelField(title="inner_dmac",sort=59) protected String innerDmac;//MAC_IN_MAC的内层目标MAC diff --git a/src/main/java/com/nis/domain/log/NtcCollectRadiusLog.java b/src/main/java/com/nis/domain/log/NtcCollectRadiusLog.java index 3f932f91b..52924f008 100644 --- a/src/main/java/com/nis/domain/log/NtcCollectRadiusLog.java +++ b/src/main/java/com/nis/domain/log/NtcCollectRadiusLog.java @@ -1,12 +1,18 @@ package com.nis.domain.log; +import com.nis.util.excel.ExcelField; + public class NtcCollectRadiusLog extends BaseLogEntity { private static final long serialVersionUID = -4947912502754359817L; + @ExcelField(title="message_type",dictType="MESSAGE_TYPE",sort=10) protected Integer code; + @ExcelField(title="nas_ip",sort=15) protected String nasIp; + @ExcelField(title="framed_ip",sort=20) protected String framedIp; + @ExcelField(title="log_user_name",sort=25) protected String account; public Integer getCode() { return code; diff --git a/src/main/java/com/nis/util/Reflections.java b/src/main/java/com/nis/util/Reflections.java index c811cb301..61aa08b68 100644 --- a/src/main/java/com/nis/util/Reflections.java +++ b/src/main/java/com/nis/util/Reflections.java @@ -40,7 +40,17 @@ public class Reflections { public static Object invokeGetter(Object obj, String propertyName) { Object object = obj; for (String name : StringUtils.split(propertyName, ".")){ - String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name); + String getName=StringUtils.capitalize(name); + if(getName.equals("SIp")){ + getName="sIp"; + }else if(getName.equals("DIp")){ + getName="dIp"; + }else if(getName.equals("DPort")){ + getName="dPort"; + }else if(getName.equals("SPort")){ + getName="sPort"; + } + String getterMethodName = GETTER_PREFIX + getName; object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); } return object; diff --git a/src/main/java/com/nis/util/excel/ExportExcel.java b/src/main/java/com/nis/util/excel/ExportExcel.java index c74b8e1db..33194c26b 100644 --- a/src/main/java/com/nis/util/excel/ExportExcel.java +++ b/src/main/java/com/nis/util/excel/ExportExcel.java @@ -1997,7 +1997,7 @@ public class ExportExcel { val = getBasicInfo(ef.dictType(),map,valStr); }else{ //字典数据已做国际化处理 - String dict=DictUtils.getDictLabel(ef.dictType(), valStr, ""); + String dict=DictUtils.getDictLabel(ef.dictType(), valStr, valStr); //如果找不到字典国际化值,把字典本身作为默认值放进去,不然导出就是空了 val = msgProp.getProperty(dict,dict); } diff --git a/src/main/java/com/nis/web/controller/log/ntc/NtcCollectRadiusLogController.java b/src/main/java/com/nis/web/controller/log/ntc/NtcCollectRadiusLogController.java index 77506b14c..adb78c1f2 100644 --- a/src/main/java/com/nis/web/controller/log/ntc/NtcCollectRadiusLogController.java +++ b/src/main/java/com/nis/web/controller/log/ntc/NtcCollectRadiusLogController.java @@ -1,26 +1,24 @@ 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.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.log.IrDnatLog; -import com.nis.domain.log.IrSnatLog; import com.nis.domain.log.NtcCollectRadiusLog; import com.nis.domain.maat.LogRecvData; import com.nis.util.Constants; @@ -33,14 +31,21 @@ import com.nis.web.controller.BaseController; public class NtcCollectRadiusLogController extends BaseController { @RequestMapping(value = {"list", ""}) - public String list(@ModelAttribute("log") IrSnatLog log, Model model, HttpServletRequest request, HttpServletResponse response) { + public String list(@ModelAttribute("log") NtcCollectRadiusLog log, Model model, HttpServletRequest request, HttpServletResponse response) { try { PageLog page = new PageLog(request, response); Map params = new HashMap(); params.put("pageSize", page.getPageSize()); params.put("pageNo", page.getPageNo()); initLogSearchValue(log, params); - + // 请求参数判断 + if(StringUtils.isNotBlank(log.getNasIp())) { + params.put("searchNasIp", log.getNasIp()); + }else if(StringUtils.isNotBlank(log.getFramedIp())) { + params.put("searchFramedIp", log.getFramedIp()); + }else if(StringUtils.isNotBlank(log.getAccount())) { + params.put("searchAccount", log.getAccount()); + } List serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId()); model.addAttribute("serviceList", serviceList); @@ -71,4 +76,53 @@ public class NtcCollectRadiusLogController extends BaseController { return "/log/ntc/radiusLogList"; } + //bgp配置导出 + @RequestMapping(value = "exportRadius") + public void exportbgp(@ModelAttribute("log") NtcCollectRadiusLog log, Model model, HttpServletRequest request, HttpServletResponse response,RedirectAttributes redirectAttributes){ + try { + //export data info + List titleList=new ArrayList(); + Map> classMap=new HashMap>(); + Map dataMap=new HashMap(); + Map noExportMap=new HashMap(); + //--------------------------- + PageLog page = new PageLog(request, response); + page.setPageNo(1); + page.setPageSize(Constants.MAX_EXPORT_SIZE); + Map params = new HashMap(); + params.put("pageSize", page.getPageSize()); + params.put("pageNo", page.getPageNo()); + initLogSearchValue(log, params); + // 请求参数判断 + if(StringUtils.isNotBlank(log.getNasIp())) { + params.put("searchNasIp", log.getNasIp()); + }else if(StringUtils.isNotBlank(log.getFramedIp())) { + params.put("searchFramedIp", log.getFramedIp()); + }else if(StringUtils.isNotBlank(log.getAccount())) { + params.put("searchAccount", log.getAccount()); + } + List list=new ArrayList(); + String url =Constants.LOG_BASE_URL + Constants.NTC_COLLECT_RADIUS_LOG; + String recv = HttpClientUtil.getMsg(url, params, request); + if (StringUtils.isNotBlank(recv)) { + Gson gson = new GsonBuilder().create(); + LogRecvData fromJson = gson.fromJson(recv, new TypeToken>(){}.getType()); + if (fromJson.getStatus().intValue() == 200) { + Page data = fromJson.getData(); + list= data.getList(); + } + } + titleList.add("radius_log"); + classMap.put("radius_log", NtcCollectRadiusLog.class); + String cfgIndexInfoNoExport=""; + noExportMap.put("radius_log",cfgIndexInfoNoExport); + dataMap.put("radius_log",list); + /*}*/ + this._export(model, request, response, redirectAttributes,"radius_log",titleList,classMap,dataMap,noExportMap); + } catch (Exception e) { + logger.error("radius export failed",e); + addMessage(redirectAttributes,"error","export_failed"); + } + } + } diff --git a/src/main/webapp/WEB-INF/views/log/ntc/radiusLogList.jsp b/src/main/webapp/WEB-INF/views/log/ntc/radiusLogList.jsp index 3108c5480..00ae2f4cd 100644 --- a/src/main/webapp/WEB-INF/views/log/ntc/radiusLogList.jsp +++ b/src/main/webapp/WEB-INF/views/log/ntc/radiusLogList.jsp @@ -7,6 +7,9 @@