From a18ddf2d468705b88fdae11000475ad4b2c025db Mon Sep 17 00:00:00 2001 From: chenjinsong Date: Wed, 13 Jun 2018 14:36:58 +0800 Subject: [PATCH] =?UTF-8?q?ntc-ip=E6=97=A5=E5=BF=97=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=EF=BC=88=E9=83=A8=E5=88=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/nis/domain/log/BaseLogEntity.java | 42 ++-- .../java/com/nis/domain/log/NtcIpLog.java | 30 --- .../nis/web/controller/BaseController.java | 6 + .../log/ntc/NtcIpLogController.java | 68 ++++++ src/main/java/com/nis/web/test/logTest.txt | 53 +++++ .../webapp/WEB-INF/views/log/ntc/ipList.jsp | 211 ++++++++++++++++++ 6 files changed, 363 insertions(+), 47 deletions(-) create mode 100644 src/main/java/com/nis/web/controller/log/ntc/NtcIpLogController.java create mode 100644 src/main/java/com/nis/web/test/logTest.txt create mode 100644 src/main/webapp/WEB-INF/views/log/ntc/ipList.jsp diff --git a/src/main/java/com/nis/domain/log/BaseLogEntity.java b/src/main/java/com/nis/domain/log/BaseLogEntity.java index 3967c8933..513313d43 100644 --- a/src/main/java/com/nis/domain/log/BaseLogEntity.java +++ b/src/main/java/com/nis/domain/log/BaseLogEntity.java @@ -11,23 +11,25 @@ public class BaseLogEntity extends BaseEntity { private static final long serialVersionUID = 8321337584518281424L; - private Integer cfgId; - private String foundTime; //发现时间,timestamp - private String recvTime; //接收时间,timestamp - private String protocol; //协议类型,从字典LOG_PROTOCOL取值 - private Integer addrType; //ip地址类型,从字典IP_TYPE取值 - private String serverIp; //服务端ip地址 - private String clientIp; //客户端ip地址 - private String serverPort; //服务端ip端口 - private String clientPort; //客户端ip端口 - private Integer serviceType; //配置表的serviceId - private Integer entranceId; //出入口编号 - private Integer deviceId; //串联设备编号 - private Integer direction; //传输方向 0:域内->域外,1:域外->域内,从字典LOG_DIRECTION取值 - private Integer streamType; //流类型 0:c2s;1:s2c;2:double,从字典LOG_STREAMTYPE取值 - private String cljIp; //处理机IP - private String nestAddrList; //嵌套地址列表 - private String userRegion; //用户自定义 + protected Integer cfgId; + protected String foundTime; //发现时间,timestamp + protected String recvTime; //接收时间,timestamp + protected String protocol; //协议类型,从字典LOG_PROTOCOL取值 + protected Integer addrType; //ip地址类型,从字典IP_TYPE取值 + protected String serverIp; //服务端ip地址 + protected String clientIp; //客户端ip地址 + protected String serverPort; //服务端ip端口 + protected String clientPort; //客户端ip端口 + protected Integer serviceType; //配置表的serviceId + protected Integer entranceId; //出入口编号 + protected Integer deviceId; //串联设备编号 + protected Integer direction; //传输方向 0:域内->域外,1:域外->域内,从字典LOG_DIRECTION取值 + protected Integer streamType; //流类型 0:c2s;1:s2c;2:double,从字典LOG_STREAMTYPE取值 + protected String cljIp; //处理机IP + protected String nestAddrList; //嵌套地址列表 + protected String userRegion; //用户自定义 + + protected Integer functionId; //自定义字段 protected String seltype;//选中类型,页面搜索用 @@ -35,6 +37,12 @@ public class BaseLogEntity extends BaseEntity { protected String searchFoundEndTime;//结束时间,格式同上 + public Integer getFunctionId() { + return functionId; + } + public void setFunctionId(Integer functionId) { + this.functionId = functionId; + } public String getFoundTime() { return foundTime; } diff --git a/src/main/java/com/nis/domain/log/NtcIpLog.java b/src/main/java/com/nis/domain/log/NtcIpLog.java index 4a7361909..a3eb3bfde 100644 --- a/src/main/java/com/nis/domain/log/NtcIpLog.java +++ b/src/main/java/com/nis/domain/log/NtcIpLog.java @@ -4,34 +4,4 @@ public class NtcIpLog extends BaseLogEntity { private static final long serialVersionUID = 4597407682545926823L; - private String version; - private String sni; - private String san; - private String ca; - - public String getVersion() { - return version; - } - public void setVersion(String version) { - this.version = version; - } - public String getSni() { - return sni; - } - public void setSni(String sni) { - this.sni = sni; - } - public String getSan() { - return san; - } - public void setSan(String san) { - this.san = san; - } - public String getCa() { - return ca; - } - public void setCa(String ca) { - this.ca = ca; - } - } diff --git a/src/main/java/com/nis/web/controller/BaseController.java b/src/main/java/com/nis/web/controller/BaseController.java index 1bc26dd04..3e1905e78 100644 --- a/src/main/java/com/nis/web/controller/BaseController.java +++ b/src/main/java/com/nis/web/controller/BaseController.java @@ -44,6 +44,7 @@ import com.nis.domain.configuration.IpCfgTemplate; import com.nis.domain.configuration.NumBoundaryCfg; import com.nis.domain.configuration.RequestInfo; import com.nis.domain.configuration.StringCfgTemplate; +import com.nis.domain.log.BaseLogEntity; import com.nis.util.Configurations; //import com.nis.main.ConvertTool; import com.nis.util.Constants; @@ -470,4 +471,9 @@ public class BaseController { e.printStackTrace(); } } + + public void initLogServiceType(Model model, BaseLogEntity log) { + List serviceList = DictUtils.getFunctionServiceDictList(log.getFunctionId()); + model.addAttribute("serviceList", serviceList); + } } diff --git a/src/main/java/com/nis/web/controller/log/ntc/NtcIpLogController.java b/src/main/java/com/nis/web/controller/log/ntc/NtcIpLogController.java new file mode 100644 index 000000000..2cb8ca51a --- /dev/null +++ b/src/main/java/com/nis/web/controller/log/ntc/NtcIpLogController.java @@ -0,0 +1,68 @@ +package com.nis.web.controller.log.ntc; + +import java.io.File; +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.aspectj.util.FileUtil; +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 com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonSyntaxException; +import com.google.gson.reflect.TypeToken; +import com.nis.domain.Page; +import com.nis.domain.log.NtcIpLog; +import com.nis.domain.maat.LogRecvData; +import com.nis.web.controller.BaseController; + +@Controller +@RequestMapping("${adminPath}/log/ntc/ip") +public class NtcIpLogController extends BaseController { + + @RequestMapping("list") + public String list(@ModelAttribute("log") NtcIpLog log, Model model, HttpServletRequest request, HttpServletResponse response) { + //初始化action + initLogServiceType(model, log); + + Page page = new Page(request, response); + int pageNo = page.getPageNo(); + + + String recv = null; + + try { + String path = request.getClass().getClassLoader().getResource("").getPath(); + recv = FileUtil.readAsString(new File(path + "com/nis/web/test/logTest.txt")); + } catch (IOException e) { + e.printStackTrace(); + } + logger.info("NTC-IP查询结果:" + recv); + + Gson gson = new GsonBuilder().create(); + + try { + LogRecvData fromJson = gson.fromJson(recv, new TypeToken>(){}.getType()); + if (fromJson.getStatus().intValue() == 200) { + logger.info("查询状态:成功"); + BeanUtils.copyProperties(fromJson.getData(), page); + model.addAttribute("page", page); + } + } catch (JsonSyntaxException e) { + e.printStackTrace(); + } + + return "/log/ntc/ipList"; + } + + @RequestMapping("form") + public String form() { + return ""; + } +} diff --git a/src/main/java/com/nis/web/test/logTest.txt b/src/main/java/com/nis/web/test/logTest.txt new file mode 100644 index 000000000..63e6403f2 --- /dev/null +++ b/src/main/java/com/nis/web/test/logTest.txt @@ -0,0 +1,53 @@ +{ + "status":200, + "businessCode":2000, + "reason":"Success", + "msg":"success", + "fromuri":"abc", + "logSource":0, + "data":{ + "pageNo":2, + "pageSize":20, + "count":41, + "last":3, + "list":[ + { + "cfgId":21, + "foundTime":"2018-06-10 10:10:10", + "recvTime":"2018-06-11 11:11:11", + "protocol":"L2TP", + "addrType":4, + "serverIp":"10.0.6.121", + "clientIp":"10.0.6.122", + "serverPort":"8080", + "clientPort":"8080", + "serviceType":10, + "entranceId":112, + "deviceId":2, + "direction":1, + "streamType":0, + "cljIp":"10.1.1.2", + "nestAddrList":"11111", + "userRegion":"aaa" + },{ + "cfgId":22, + "foundTime":"2018-06-10 10:10:10", + "recvTime":"2018-06-11 11:11:11", + "protocol":"L2TP", + "addrType":4, + "serverIp":"10.0.6.121", + "clientIp":"10.0.6.122", + "serverPort":"8080", + "clientPort":"8080", + "serviceType":10, + "entranceId":112, + "deviceId":2, + "direction":2, + "streamType":1, + "cljIp":"10.1.1.2", + "nestAddrList":"11111", + "userRegion":"aaa" + } + ] + } +} \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/log/ntc/ipList.jsp b/src/main/webapp/WEB-INF/views/log/ntc/ipList.jsp new file mode 100644 index 000000000..f04612c0e --- /dev/null +++ b/src/main/webapp/WEB-INF/views/log/ntc/ipList.jsp @@ -0,0 +1,211 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + +IP<spring:message code="log"></spring:message> + + + + +
+ +

+ IP + +

+ +
+
+
+
+
+ + + + + + + +
+
+ + + + + + +
+
+ + + + + + +
+
+
+
+ + + + + + +
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+ + + +
+ +
+ + + +
+
+
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ip
${log.cfgId } + + ${ipType.itemValue} + + ${log.clientIp }${log.clientPort }${log.serverIp }${log.serverPort } + + ${logProtocol.itemValue} + + ${log.entranceId } + + + + ${log.foundTime }${log.recvTime }${log.deviceId } + + ${streamType.itemValue} + + ${log.cljIp }${log.nestAddrList }${log.userRegion }
+
${page}
+
+ +
+
+
+ + + \ No newline at end of file