1.新增ClickHouse数据源 切换到DATA_SOURCE_C即可

2.新增策略事件日志查询接口
This commit is contained in:
李皓宸
2019-05-31 14:04:04 +08:00
parent ba00559f06
commit ca23d01243
9 changed files with 1291 additions and 2 deletions

View File

@@ -0,0 +1,950 @@
package com.nis.domain.restful;
import java.io.Serializable;
import java.util.Date;
import javax.xml.bind.annotation.XmlTransient;
import org.apache.poi.ss.formula.functions.T;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.nis.domain.LogEntity;
import com.nis.domain.Page;
import com.wordnik.swagger.annotations.ApiModelProperty;
/**
*
* @ClassName: PolicyEventLog
* @Description:策略事件日志
* @author A.Chen
* @date: 2019/05/29
*/
public class PolicyEventLog implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "策略ID", required = true, notes = "库中字段为policyId,返回compileId")
private int compileId;
@ApiModelProperty(value = "动作", required = true)
private int action;
@ApiModelProperty(value = "服务端IP地址", required = true)
private String serverIp;
@ApiModelProperty(value = "客户端IP地址", required = true)
private String clientIp;
@ApiModelProperty(value = "服务端端口", required = true)
private String serverPort;
@ApiModelProperty(value = "客户端端口", required = true)
private String clientPort;
@ApiModelProperty(value = "运营商", required = true)
private String isp;
@ApiModelProperty(value = "服务端ASN", required = true)
private String serverAsn;
@ApiModelProperty(value = "客户端ASN", required = true)
private String clientAsn;
@ApiModelProperty(value = "通信时长", required = true)
private Integer conDurationMs;
@ApiModelProperty(value = "访问URL", required = true)
private String url;
@ApiModelProperty(value = "主机地址", required = true)
private String host;
@ApiModelProperty(value = "域名", required = true)
private String domain;
@ApiModelProperty(value = "分类", required = true)
private String category;
@ApiModelProperty(value = "请求行", required = true)
private String reqLine;
@ApiModelProperty(value = "应答行", required = true)
private String resLine;
@ApiModelProperty(value = "Cookie值", required = true)
private String cookie;
@ApiModelProperty(value = "Referer值", required = true)
private String referer;
@ApiModelProperty(value = "UA值", required = true)
private String userAgent;
@ApiModelProperty(value = "Content-Length值", required = true)
private String contentLen;
@ApiModelProperty(value = "Content-Type值", required = true)
private String contentType;
@ApiModelProperty(value = "set-Cookie值", required = true)
private String setCookie;
@ApiModelProperty(value = "原始请求头", required = true)
private String reqHeader;
@ApiModelProperty(value = "原始应答头", required = true)
private String respHeader;
@ApiModelProperty(value = "请求体转储文件KEY", required = true)
private String reqBodyKey;
@ApiModelProperty(value = "原始请求体", required = true)
private String reqBody;
@ApiModelProperty(value = "应答体转储文件KEY", required = true)
private String resBodyKey;
@ApiModelProperty(value = "原始应答体", required = true)
private String respBody;
@ApiModelProperty(value = "版本", required = true)
private String version;
@ApiModelProperty(value = "sni", required = true)
private String sni;
@ApiModelProperty(value = "san", required = true)
private String san;
@ApiModelProperty(value = "cn", required = true)
private String cn;
@ApiModelProperty(value = "app", required = true)
private Integer appId;
@ApiModelProperty(value = "Protocol", required = true)
private Integer protocolId;
@ApiModelProperty(value = "握手延迟", required = true)
private Integer conLatencyMs;
@ApiModelProperty(value = "pinning状态", required = true)
private Integer pinningst;
@ApiModelProperty(value = "c2s包数", required = true)
private Integer c2sPktNum;
@ApiModelProperty(value = "s2c包数", required = true)
private Integer s2cPktNum;
@ApiModelProperty(value = "c2s字节数", required = true)
private Integer c2sByteNum;
@ApiModelProperty(value = "s2c字节数", required = true)
private Integer s2cByteNum;
@ApiModelProperty(value = "ISN接入的IP", required = true)
private String nasIp;
@ApiModelProperty(value = "用户IP地址", required = true)
private String framedIp;
@ApiModelProperty(value = "用户名", required = true)
private String account;
@ApiModelProperty(value = "报文类型", required = true, notes = "1- Access-Request 2- Access-Accept 3- Access-Reject 4- Accounting-Request(账户授权) 5- Accounting-Response 11-Access-Challenge")
private Integer packetType;
@ApiModelProperty(value = "应用协议类型", required = true, notes = "http1/http2")
private String appProto;
@ApiModelProperty(value = "会话创建时间", required = true)
private long startTime;
@ApiModelProperty(value = "会话结束时间", required = true)
private long endTime;
@ApiModelProperty(value = "客户端用户名", required = true)
private String subscribeId;
@ApiModelProperty(value = "接收时间", required = true)
private long recvTime;
@ApiModelProperty(value = "协议类型", required = true)
private String transProto;
@ApiModelProperty(value = "IP地址类型", required = true)
private Integer addrType;
@ApiModelProperty(value = "业务类型", required = true)
private Integer service;
@ApiModelProperty(value = "出入口编号", required = true)
private Long entranceId;
@ApiModelProperty(value = "串联设备编号", required = true)
private Integer deviceId;
@ApiModelProperty(value = "传输方向", required = true, notes = "0域内->域外1域外->域内描述的是CLIENT_IP信息")
private Integer direction;
@ApiModelProperty(value = "流类型", required = true, notes = "0c2s1s2c2double")
private Integer streamDir;
@ApiModelProperty(value = "处理机IP", required = true)
private String capIp;
@ApiModelProperty(value = "嵌套地址列表", required = true)
private String addrList;
@ApiModelProperty(value = "服务端地址定位信息", required = true)
private String serverLocation;
@ApiModelProperty(value = "串联设备链路号", required = true)
private Long linkId;
@ApiModelProperty(value = "原始二层封装格式", required = true)
private Integer encapType;
@ApiModelProperty(value = "客户端地址定位信息", required = true)
private String clientLocation;
private Page<T> page;
// 请求参数属性(不返回 )
private String searchFields;// 指定查询某些字段
private Integer searchCompileId;// 策略ID
private Integer searchAction;// 动作
private Integer searchStartRecvTime;// 开始时间 时间戳
private Integer searchEndRecvTime;// 结束时间 时间戳
private String searchTransProto;// 协议类型
private Integer searchAddrType;// 地址类型
private String searchServerIp;// 服务端IP地址
private String searchClientIp;// 客户端IP地址
private String searchIsp;// 运营商
private Integer searchDirection;// 方向
private String searchCapIp;// 处理机IP
private String searchServerLocation;// 服务端地址定位信息
private String searchClientLocation;// 客户端地址定位信息
private String searchHost;// 主机地址
private String searchDomain;// 域名
private String searchSni;// sni
private String searchSan;// san
private String searchCn;// cn
private Integer searchAppId;// app
private Integer searchProtocolId;// Protocol
private String searchUrl;// url
private Integer searchEntranceId;
@JsonIgnore
@XmlTransient
public Page<T> getPage() {
if (page == null) {
page = new Page<T>();
}
return page;
}
public Page<T> setPage(Page<T> page) {
this.page = page;
return page;
}
public int getCompileId() {
return compileId;
}
public void setCompileId(int compileId) {
this.compileId = compileId;
}
public int getAction() {
return action;
}
public void setAction(int action) {
this.action = action;
}
public String getServerIp() {
return serverIp;
}
public void setServerIp(String serverIp) {
this.serverIp = serverIp;
}
public String getClientIp() {
return clientIp;
}
public void setClientIp(String clientIp) {
this.clientIp = clientIp;
}
public String getServerPort() {
return serverPort;
}
public void setServerPort(String serverPort) {
this.serverPort = serverPort;
}
public String getClientPort() {
return clientPort;
}
public void setClientPort(String clientPort) {
this.clientPort = clientPort;
}
public String getIsp() {
return isp;
}
public void setIsp(String isp) {
this.isp = isp;
}
public String getServerAsn() {
return serverAsn;
}
public void setServerAsn(String serverAsn) {
this.serverAsn = serverAsn;
}
public String getClientAsn() {
return clientAsn;
}
public void setClientAsn(String clientAsn) {
this.clientAsn = clientAsn;
}
public Integer getConDurationMs() {
return conDurationMs;
}
public void setConDurationMs(Integer conDurationMs) {
this.conDurationMs = conDurationMs;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getReqLine() {
return reqLine;
}
public void setReqLine(String reqLine) {
this.reqLine = reqLine;
}
public String getResLine() {
return resLine;
}
public void setResLine(String resLine) {
this.resLine = resLine;
}
public String getCookie() {
return cookie;
}
public void setCookie(String cookie) {
this.cookie = cookie;
}
public String getReferer() {
return referer;
}
public void setReferer(String referer) {
this.referer = referer;
}
public String getUserAgent() {
return userAgent;
}
public void setUserAgent(String userAgent) {
this.userAgent = userAgent;
}
public String getContentLen() {
return contentLen;
}
public void setContentLen(String contentLen) {
this.contentLen = contentLen;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getSetCookie() {
return setCookie;
}
public void setSetCookie(String setCookie) {
this.setCookie = setCookie;
}
public String getReqHeader() {
return reqHeader;
}
public void setReqHeader(String reqHeader) {
this.reqHeader = reqHeader;
}
public String getRespHeader() {
return respHeader;
}
public void setRespHeader(String respHeader) {
this.respHeader = respHeader;
}
public String getReqBodyKey() {
return reqBodyKey;
}
public void setReqBodyKey(String reqBodyKey) {
this.reqBodyKey = reqBodyKey;
}
public String getReqBody() {
return reqBody;
}
public void setReqBody(String reqBody) {
this.reqBody = reqBody;
}
public String getResBodyKey() {
return resBodyKey;
}
public void setResBodyKey(String resBodyKey) {
this.resBodyKey = resBodyKey;
}
public String getRespBody() {
return respBody;
}
public void setRespBody(String respBody) {
this.respBody = respBody;
}
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 getCn() {
return cn;
}
public void setCn(String cn) {
this.cn = cn;
}
public Integer getAppId() {
return appId;
}
public void setAppId(Integer appId) {
this.appId = appId;
}
public Integer getProtocolId() {
return protocolId;
}
public void setProtocolId(Integer protocolId) {
this.protocolId = protocolId;
}
public Integer getConLatencyMs() {
return conLatencyMs;
}
public void setConLatencyMs(Integer conLatencyMs) {
this.conLatencyMs = conLatencyMs;
}
public Integer getPinningst() {
return pinningst;
}
public void setPinningst(Integer pinningst) {
this.pinningst = pinningst;
}
public Integer getC2sPktNum() {
return c2sPktNum;
}
public void setC2sPktNum(Integer c2sPktNum) {
this.c2sPktNum = c2sPktNum;
}
public Integer getS2cPktNum() {
return s2cPktNum;
}
public void setS2cPktNum(Integer s2cPktNum) {
this.s2cPktNum = s2cPktNum;
}
public Integer getC2sByteNum() {
return c2sByteNum;
}
public void setC2sByteNum(Integer c2sByteNum) {
this.c2sByteNum = c2sByteNum;
}
public Integer getS2cByteNum() {
return s2cByteNum;
}
public void setS2cByteNum(Integer s2cByteNum) {
this.s2cByteNum = s2cByteNum;
}
public String getNasIp() {
return nasIp;
}
public void setNasIp(String nasIp) {
this.nasIp = nasIp;
}
public String getFramedIp() {
return framedIp;
}
public void setFramedIp(String framedIp) {
this.framedIp = framedIp;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public Integer getPacketType() {
return packetType;
}
public void setPacketType(Integer packetType) {
this.packetType = packetType;
}
public String getAppProto() {
return appProto;
}
public void setAppProto(String appProto) {
this.appProto = appProto;
}
public long getStartTime() {
return startTime;
}
public void setStartTime(long startTime) {
this.startTime = startTime;
}
public long getEndTime() {
return endTime;
}
public void setEndTime(long endTime) {
this.endTime = endTime;
}
public String getSubscribeId() {
return subscribeId;
}
public void setSubscribeId(String subscribeId) {
this.subscribeId = subscribeId;
}
@JsonIgnore
public String getSearchFields() {
return searchFields;
}
public void setSearchFields(String searchFields) {
this.searchFields = searchFields;
}
@JsonIgnore
public Integer getSearchCompileId() {
return searchCompileId;
}
public void setSearchCompileId(Integer searchCompileId) {
this.searchCompileId = searchCompileId;
}
@JsonIgnore
public Integer getSearchAction() {
return searchAction;
}
public void setSearchAction(Integer searchAction) {
this.searchAction = searchAction;
}
@JsonIgnore
public Integer getSearchStartRecvTime() {
return searchStartRecvTime;
}
public void setSearchStartRecvTime(Integer searchStartRecvTime) {
this.searchStartRecvTime = searchStartRecvTime;
}
@JsonIgnore
public Integer getSearchEndRecvTime() {
return searchEndRecvTime;
}
public void setSearchEndRecvTime(Integer searchEndRecvTime) {
this.searchEndRecvTime = searchEndRecvTime;
}
@JsonIgnore
public Integer getSearchAddrType() {
return searchAddrType;
}
public void setSearchAddrType(Integer searchAddrType) {
this.searchAddrType = searchAddrType;
}
@JsonIgnore
public String getSearchServerIp() {
return searchServerIp;
}
public void setSearchServerIp(String searchServerIp) {
this.searchServerIp = searchServerIp;
}
@JsonIgnore
public String getSearchClientIp() {
return searchClientIp;
}
public void setSearchClientIp(String searchClientIp) {
this.searchClientIp = searchClientIp;
}
@JsonIgnore
public String getSearchHost() {
return searchHost;
}
public void setSearchHost(String searchHost) {
this.searchHost = searchHost;
}
@JsonIgnore
public String getSearchDomain() {
return searchDomain;
}
public void setSearchDomain(String searchDomain) {
this.searchDomain = searchDomain;
}
@JsonIgnore
public String getSearchSni() {
return searchSni;
}
public void setSearchSni(String searchSni) {
this.searchSni = searchSni;
}
@JsonIgnore
public String getSearchSan() {
return searchSan;
}
public void setSearchSan(String searchSan) {
this.searchSan = searchSan;
}
@JsonIgnore
public String getSearchCn() {
return searchCn;
}
public void setSearchCn(String searchCn) {
this.searchCn = searchCn;
}
@JsonIgnore
public Integer getSearchAppId() {
return searchAppId;
}
public void setSearchAppId(Integer searchAppId) {
this.searchAppId = searchAppId;
}
@JsonIgnore
public Integer getSearchProtocolId() {
return searchProtocolId;
}
public void setSearchProtocolId(Integer searchProtocolId) {
this.searchProtocolId = searchProtocolId;
}
@JsonIgnore
public String getSearchUrl() {
return searchUrl;
}
public void setSearchUrl(String searchUrl) {
this.searchUrl = searchUrl;
}
public long getRecvTime() {
return recvTime;
}
public void setRecvTime(long recvTime) {
this.recvTime = recvTime;
}
public String getTransProto() {
return transProto;
}
public void setTransProto(String transProto) {
this.transProto = transProto;
}
public Integer getAddrType() {
return addrType;
}
public void setAddrType(Integer addrType) {
this.addrType = addrType;
}
public Integer getService() {
return service;
}
public void setService(Integer service) {
this.service = service;
}
public Long getEntranceId() {
return entranceId;
}
public void setEntranceId(Long entranceId) {
this.entranceId = entranceId;
}
public Integer getDeviceId() {
return deviceId;
}
public void setDeviceId(Integer deviceId) {
this.deviceId = deviceId;
}
public Integer getDirection() {
return direction;
}
public void setDirection(Integer direction) {
this.direction = direction;
}
public Integer getStreamDir() {
return streamDir;
}
public void setStreamDir(Integer streamDir) {
this.streamDir = streamDir;
}
public String getCapIp() {
return capIp;
}
public void setCapIp(String capIp) {
this.capIp = capIp;
}
public String getAddrList() {
return addrList;
}
public void setAddrList(String addrList) {
this.addrList = addrList;
}
public Long getLinkId() {
return linkId;
}
public void setLinkId(Long linkId) {
this.linkId = linkId;
}
public Integer getEncapType() {
return encapType;
}
public void setEncapType(Integer encapType) {
this.encapType = encapType;
}
public String getServerLocation() {
return serverLocation;
}
public void setServerLocation(String serverLocation) {
this.serverLocation = serverLocation;
}
public String getClientLocation() {
return clientLocation;
}
public void setClientLocation(String clientLocation) {
this.clientLocation = clientLocation;
}
@JsonIgnore
public String getSearchTransProto() {
return searchTransProto;
}
public void setSearchTransProto(String searchTransProto) {
this.searchTransProto = searchTransProto;
}
@JsonIgnore
public String getSearchIsp() {
return searchIsp;
}
public void setSearchIsp(String searchIsp) {
this.searchIsp = searchIsp;
}
@JsonIgnore
public Integer getSearchDirection() {
return searchDirection;
}
public void setSearchDirection(Integer searchDirection) {
this.searchDirection = searchDirection;
}
@JsonIgnore
public String getSearchCapIp() {
return searchCapIp;
}
public void setSearchCapIp(String searchCapIp) {
this.searchCapIp = searchCapIp;
}
@JsonIgnore
public String getSearchServerLocation() {
return searchServerLocation;
}
public void setSearchServerLocation(String searchServerLocation) {
this.searchServerLocation = searchServerLocation;
}
@JsonIgnore
public String getSearchClientLocation() {
return searchClientLocation;
}
public void setSearchClientLocation(String searchClientLocation) {
this.searchClientLocation = searchClientLocation;
}
@JsonIgnore
public Integer getSearchEntranceId() {
return searchEntranceId;
}
public void setSearchEntranceId(Integer searchEntranceId) {
this.searchEntranceId = searchEntranceId;
}
}

View File

@@ -44,6 +44,15 @@ public class PropertyPlaceholderConfigurerCrypt extends PropertyPlaceholderConfi
String ckLocalNewPassword = props.getProperty("jdbc.ckLocalNew.password");
String ckLocalNewScretKey = props.getProperty("jdbc.ckLocalNew.key");
if (null != ckLocalPassword) {
props.setProperty("jdbc.ckLocalNew.password",
new String(AESUtil.decrypt(Base64.decodeBase64(ckLocalNewPassword), ckLocalNewScretKey)));
}
// hive
String hivePassword = props.getProperty("jdbc.hive.password");
String hiveScretKey = props.getProperty("jdbc.hive.key");

View File

@@ -11,8 +11,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.datasource.CustomerContextHolder;
import com.nis.domain.Page;
import com.nis.domain.restful.DkBehaviorLog;
import com.nis.domain.restful.PolicyEventLog;
import com.nis.domain.restful.PxyHttpLog;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
@@ -22,6 +24,7 @@ import com.nis.util.ExceptionUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.AuditLogThread;
import com.nis.web.service.LogDataService;
import com.nis.web.service.NtcLogServiceNew;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.NtcLogService;
import com.wordnik.swagger.annotations.Api;
@@ -54,6 +57,8 @@ public class LogController extends BaseRestController {
protected NtcLogService ntcLogService;
@Autowired
private LogDataService logDataService;
@Autowired
private NtcLogServiceNew ntcLogServiceNew;
@RequestMapping(value = "/dkBehaviorLogs", method = RequestMethod.GET)
@ApiOperation(value = "行为识别日志查询", httpMethod = "GET", notes = "对日志功能“行为识别”提供数据基础查询服务")
@@ -112,5 +117,38 @@ public class LogController extends BaseRestController {
return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "PXY HTTP日志检索成功", page,
0);
}
@RequestMapping(value = "/policyevent", method = RequestMethod.GET)
@ApiOperation(value = "策略事件日志查询", httpMethod = "GET", notes = "对日志功能“国家代理”-“HTTP(s)操控”提供数据基础查询服务")
public Map<String, ?> policyEvent(Page page, PolicyEventLog policyEventLog, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
try {
//切换数据源为C
CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_C);
// resetTime(policyEventLog);
ntcLogService.policyEventConditionCheck(auditLogThread, start, policyEventLog, PxyHttpLog.class, page);
ntcLogServiceNew.getPolicyEventLog(policyEventLog, page);
} catch (Exception e) {
auditLogThread.setExceptionInfo("PXY HTTP日志检索失败:"+e.getMessage());
logger.error("策略事件日志检索失败:"+ExceptionUtil.getExceptionMsg(e));
if (e instanceof RestServiceException) {
throw new RestServiceException(auditLogThread, System.currentTimeMillis() - start,
"策略事件日志检索失败:" + e.getMessage(), ((RestServiceException) e).getErrorCode());
} else if (e instanceof ServiceRuntimeException) {
throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
"策略事件日志检索失败:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode());
} else {
throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start,
"策略事件日志检索失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue());
}
}
return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "策略事件日志检索成功", page,
0);
}
}

View File

@@ -0,0 +1,12 @@
package com.nis.web.dao;
import java.util.List;
import com.nis.domain.restful.PolicyEventLog;
@MyBatisDao
public interface NtcLogDaoNew {
List<PolicyEventLog> getPolicyEventLog(PolicyEventLog policyEventLog);
}

View File

@@ -0,0 +1,178 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nis.web.dao.NtcLogDaoNew">
<resultMap id="NtcPolicyEventLogMap" type="com.nis.domain.restful.PolicyEventLog">
<result column="policy_id" jdbcType="INTEGER" property="compileId" />
<result column="action" jdbcType="INTEGER" property="action" />
<result column="start_time" jdbcType="INTEGER" property="startTime" />
<result column="end_time" jdbcType="INTEGER" property="endTime" />
<result column="recv_time" jdbcType="INTEGER" property="recvTime" />
<result column="trans_proto" jdbcType="VARCHAR" property="transProto" />
<result column="app_proto" jdbcType="VARCHAR" property="appProto" />
<result column="addr_type" jdbcType="INTEGER" property="addrType" />
<result column="server_ip" jdbcType="VARCHAR" property="serverIp" />
<result column="client_ip" jdbcType="VARCHAR" property="clientIp" />
<result column="server_port" jdbcType="INTEGER" property="serverPort" />
<result column="client_port" jdbcType="INTEGER" property="clientPort" />
<result column="service" jdbcType="INTEGER" property="service" />
<result column="entrance_id" jdbcType="INTEGER" property="entranceId" />
<result column="device_id" jdbcType="INTEGER" property="deviceId" />
<result column="link_id" jdbcType="BIGINT" property="linkId" />
<result column="isp" jdbcType="VARCHAR" property="isp" />
<result column="encap_type" jdbcType="INTEGER" property="encapType" />
<result column="direction" jdbcType="INTEGER" property="direction" />
<result column="stream_dir" jdbcType="INTEGER" property="streamDir" />
<result column="cap_ip" jdbcType="VARCHAR" property="capIp" />
<result column="addr_list" jdbcType="VARCHAR" property="addrList" />
<result column="server_location" jdbcType="VARCHAR" property="serverLocation" />
<result column="client_location" jdbcType="VARCHAR" property="clientLocation" />
<result column="client_asn" jdbcType="VARCHAR" property="clientAsn" />
<result column="server_asn" jdbcType="VARCHAR" property="serverAsn" />
<result column="subscribe_id" jdbcType="VARCHAR" property="subscribeId" />
<result column="con_duration_ms" jdbcType="INTEGER" property="conDurationMs" />
<result column="url" jdbcType="VARCHAR" property="url" />
<result column="host" jdbcType="VARCHAR" property="host" />
<result column="domain" jdbcType="VARCHAR" property="domain" />
<result column="category" jdbcType="VARCHAR" property="category" />
<result column="req_line" jdbcType="VARCHAR" property="reqLine" />
<result column="res_line" jdbcType="VARCHAR" property="resLine" />
<result column="cookie" jdbcType="VARCHAR" property="cookie" />
<result column="referer" jdbcType="VARCHAR" property="referer" />
<result column="user_agent" jdbcType="VARCHAR" property="userAgent" />
<result column="content_len" jdbcType="VARCHAR" property="contentLen" />
<result column="content_type" jdbcType="VARCHAR" property="contentType" />
<result column="set_cookie" jdbcType="VARCHAR" property="setCookie" />
<result column="req_header" jdbcType="VARCHAR" property="reqHeader" />
<result column="resp_header" jdbcType="VARCHAR" property="respHeader" />
<result column="req_body_key" jdbcType="VARCHAR" property="reqBodyKey" />
<result column="req_body" jdbcType="VARCHAR" property="reqBody" />
<result column="res_body_key" jdbcType="VARCHAR" property="resBodyKey" />
<result column="resp_body" jdbcType="VARCHAR" property="respBody" />
<result column="version" jdbcType="VARCHAR" property="version" />
<result column="sni" jdbcType="VARCHAR" property="sni" />
<result column="san" jdbcType="VARCHAR" property="san" />
<result column="cn" jdbcType="VARCHAR" property="cn" />
<result column="app_id" jdbcType="INTEGER" property="appId" />
<result column="protocol_id" jdbcType="INTEGER" property="protocolId" />
<result column="con_latency_ms" jdbcType="INTEGER" property="conLatencyMs" />
<result column="pinningst" jdbcType="INTEGER" property="pinningst" />
<result column="c2s_pkt_num" jdbcType="INTEGER" property="c2sPktNum" />
<result column="s2c_pkt_num" jdbcType="INTEGER" property="s2cPktNum" />
<result column="c2s_byte_num" jdbcType="INTEGER" property="c2sByteNum" />
<result column="s2c_byte_num" jdbcType="INTEGER" property="s2cByteNum" />
<result column="nas_ip" jdbcType="VARCHAR" property="nasIp" />
<result column="framed_ip" jdbcType="VARCHAR" property="framedIp" />
<result column="account" jdbcType="VARCHAR" property="account" />
<result column="packet_type" jdbcType="INTEGER" property="packetType" />
</resultMap>
<sql id="getPolicyEventLogColumn">
policy_id,action,start_time,end_time,recv_time,trans_proto,
app_proto,addr_type,server_ip,client_ip,server_port,client_port,
service,entrance_id,device_id,link_id,isp,encap_type,direction,stream_dir,
cap_ip,addr_list,server_location,client_location,client_asn,server_asn,
subscribe_id,con_duration_ms,url,host,domain,category,req_line,
res_line,cookie,referer,user_agent,content_len,content_type,set_cookie,
req_header,resp_header,req_body_key,req_body,res_body_key,resp_body,version,
sni,san,cn,app_id,protocol_id,con_latency_ms,pinningst,c2s_pkt_num,s2c_pkt_num,
c2s_byte_num,s2c_byte_num,nas_ip,framed_ip,account,packet_type
</sql>
<select id="getPolicyEventLog" parameterType="com.nis.domain.restful.PolicyEventLog" resultMap="NtcPolicyEventLogMap">
select
<choose>
<when test="searchFields !=null and searchFields !=''">
#{searchFields}
</when>
<otherwise>
<include refid="getPolicyEventLogColumn"/>
</otherwise>
</choose>
from policy_event_log_local
<where>
<if test="searchCompileId !=null">
and policy_id = #{searchCompileId}
</if>
<if test="searchAction !=null">
and action = #{searchAction}
</if>
<if test="searchStartRecvTime !=null">
and start_time &gt;= #{searchStartRecvTime}
</if>
<if test="searchEndRecvTime !=null">
and end_time &lt; #{searchEndRecvTime}
</if>
<if test="searchTransProto !=null and searchTransProto !=''">
and trans_proto = #{searchTransProto}
</if>
<if test="searchAddrType !=null">
and addr_type = #{searchAddrType}
</if>
<if test="searchServerIp !=null and searchServerIp !=''">
and server_ip = #{searchServerIp}
</if>
<if test="searchClientIp !=null and searchClientIp !=''">
and client_ip = #{searchClientIp}
</if>
<if test="searchIsp !=null and searchIsp !=''">
and isp = #{searchIsp}
</if>
<if test="searchDirection !=null and searchDirection !=''">
and direction = #{searchDirection}
</if>
<if test="searchCapIp !=null and searchCapIp !=''">
and cap_ip = #{searchCapIp}
</if>
<if test="searchServerLocation !=null and searchServerLocation !=''">
and server_location = #{searchServerLocation}
</if>
<if test="searchClientLocation !=null and searchClientLocation !=''">
and client_location = #{searchClientLocation}
</if>
<if test="searchHost !=null and searchHost !=''">
and host = #{searchHost}
</if>
<if test="searchDomain !=null and searchDomain !=''">
and domain LIKE concat(concat('%',#{searchDomain}),'%')
</if>
<if test="searchSni !=null and searchSni !=''">
and sni = #{searchSni}
</if>
<if test="searchSan !=null and searchSan !=''">
and san = #{searchSan}
</if>
<if test="searchCn !=null and searchCn !=''">
and cn = #{searchCn}
</if>
<if test="searchAppId !=null and searchAppId !=''">
and app_id = #{searchAppId}
</if>
<if test="searchProtocolId !=null and searchProtocolId !=''">
and protocol_id = #{searchProtocolId}
</if>
<if test="searchEntranceId !=null">
and entrance_id = #{searchEntranceId}
</if>
<if test="searchUrl !=null and searchUrl !=''">
and url LIKE concat(concat('%',#{searchUrl}),'%')
</if>
</where>
<choose>
<when test="page !=null and page.orderBy !=null and page.orderBy !=''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY recv_time DESC
</otherwise>
</choose>
</select>
</mapper>

View File

@@ -21,6 +21,7 @@ import com.nis.domain.Page;
import com.nis.domain.restful.NtcCollectVoipLog;
import com.nis.domain.restful.NtcRadiusReport;
import com.nis.domain.restful.NtcReportEntity;
import com.nis.domain.restful.PolicyEventLog;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.restful.ServiceRuntimeException;
@@ -257,6 +258,29 @@ public abstract class BaseLogService {
logger.info("请求参数校验结束----" + System.currentTimeMillis());
}
public void policyEventConditionCheck(AuditLogThread thread, long start, PolicyEventLog entity, Class clazz,
Page page) {
logger.info("请求参数校验开始----" + System.currentTimeMillis());
try {
if (null!=entity.getSearchCompileId()) {
Integer.valueOf(entity.getSearchCompileId());
}
} catch (Exception e) {
throw new RestServiceException("SearchCfgId参数错误", RestBusinessCode.param_formate_error.getValue());
}
try {
checkCloumnIsExist(thread, start, clazz, page);
} catch (RestServiceException e) {
throw e;
} catch (Exception e) {
throw new ServiceRuntimeException(ExceptionUtil.getExceptionMsg(e),
RestBusinessCode.service_runtime_error.getValue());
}
logger.info("请求参数校验结束----" + System.currentTimeMillis());
}
/**
*

View File

@@ -0,0 +1,33 @@
package com.nis.web.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nis.domain.Page;
import com.nis.domain.restful.PolicyEventLog;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.web.dao.NtcLogDaoNew;
import com.zdjizhi.utils.DateUtils;
import com.zdjizhi.utils.StringUtil;
import com.zdjizhi.utils.TimeConstants;
@Service
public class NtcLogServiceNew {
@Autowired
NtcLogDaoNew ntcLogDaoNew;
public Page<?> getPolicyEventLog(PolicyEventLog policyEventLog,Page page){
policyEventLog.setPage(page);
List<PolicyEventLog> list = ntcLogDaoNew.getPolicyEventLog(policyEventLog);
page.setList(list);
if (page.getLast() > 100) {
page.setLast(100);
}
return page;
}
}

View File

@@ -243,12 +243,50 @@
</bean>
<bean id="LocalNewClickHouseDataSourceByDruid" class="com.alibaba.druid.pool.DruidDataSource"
init-method="init" destroy-method="close">
<property name="driverClassName" value="${jdbc.clickhouse.driver}" />
<property name="url" value="${jdbc.ckLocalNew.url}" />
<property name="username" value="${jdbc.ckLocalNew.username}" />
<property name="password" value="${jdbc.ckLocalNew.password}" />
<!-- 配置初始化连接池数量 -->
<property name="initialSize" value="${druid.log.initialSize}" />
<!-- 配置最小连接池数量 -->
<property name="minIdle" value="${druid.log.minIdle}" />
<!-- 配置最大连接池数量 -->
<property name="maxActive" value="${druid.log.maxActive}" />
<!-- 配置获取连接等待超时的时间 单位毫秒 -->
<property name="maxWait" value="${druid.log.maxWait}" />
<!--使用非公平锁 -->
<property name="useUnfairLock" value="${druid.log.useUnfairLock}" />
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="${druid.log.timeBetweenEvictionRunsMillis}" />
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="${druid.log.minEvictableIdleTimeMillis}" />
<!--用来检测连接是否有效的sql要求是一个查询语句。 -->
<property name="validationQuery" value="${druid.log.clickHouse.validationQuery}" />
<!--申请连接的时候检测如果空闲时间大于timeBetweenEvictionRunsMillis执行validationQuery检测连接是否有效。 -->
<property name="testWhileIdle" value="${druid.log.testWhileIdle}" />
<!--申请连接时执行validationQuery检测连接是否有效 -->
<property name="testOnBorrow" value="${druid.log.testOnBorrow}" />
<!--归还连接时执行validationQuery检测连接是否有效 -->
<property name="testOnReturn" value="${druid.log.testOnReturn}" />
<!-- 打开PSCache并且指定每个连接上PSCache的大小 -->
<property name="poolPreparedStatements" value="${druid.log.poolPreparedStatements}" />
<!--要启用PSCache必须配置大于0当大于0时poolPreparedStatements自动触发修改为true。在Druid中不会存在Oracle下PSCache占用内存过多的问题可以把这个数值配置大一些比如说100 -->
<property name="maxOpenPreparedStatements" value="${druid.log.maxOpenPreparedStatements}" />
<!-- 配置监控统计拦截的filters去掉后监控界面sql无法统计 -->
<property name="filters" value="${druid.log.filters}" />
</bean>
<bean id="dynamicDataSource" class="com.nis.datasource.DynamicDataSource">
<property name="targetDataSources">
<map key-type="java.lang.String">
<entry value-ref="ProductDataSource" key="dataSourceA"></entry>
<entry value-ref="LocalClickHouseDataSourceByDruid" key="dataSourceB"></entry>
<entry value-ref="LocalNewClickHouseDataSourceByDruid" key="dataSourceC"></entry>
</map>
</property>
<property name="defaultTargetDataSource" ref="ProductDataSource"></property>

View File

@@ -98,19 +98,26 @@ jdbc.clickhouse.driver=ru.yandex.clickhouse.ClickHouseDriver
#华严账号密码同元辰鑫
#jdbc.clickhouse.url=jdbc:clickhouse://192.168.10.77:8123/k18_ods?socket_timeout=90000
#元辰鑫账号密码同华严
jdbc.clickhouse.url=jdbc:clickhouse://192.168.10.192:8123/k18_ods?socket_timeout=90000
jdbc.clickhouse.url=jdbc:clickhouse://192.168.10.193:8123/k18_ods?socket_timeout=90000
jdbc.clickhouse.username=default
jdbc.clickhouse.key=aUkjs+fcwf6p4rDqHiC+ng==
jdbc.clickhouse.password=jOA3tbfJiJlPci6XUHIbVg==
#本地的clickhouse地址,新增的TBS_ODS_NTC_CONN_RECORD_LOG_LOCAL在本地
jdbc.ckLocal.url=jdbc:clickhouse://192.168.10.192:8123/k18_ods?socket_timeout=90000
jdbc.ckLocal.url=jdbc:clickhouse://192.168.10.193:8123/k18_galaxy_service?socket_timeout=90000
jdbc.ckLocal.username=default
#实际密码ceiec2018
jdbc.ckLocal.key=aUkjs+fcwf6p4rDqHiC+ng==
jdbc.ckLocal.password=jOA3tbfJiJlPci6XUHIbVg==
#本地的clickhouse新地址,
jdbc.ckLocalNew.url=jdbc:clickhouse://192.168.10.193:8123/tsg_galaxy?socket_timeout=90000
jdbc.ckLocalNew.username=default
#实际密码ceiec2018
jdbc.ckLocalNew.key=aUkjs+fcwf6p4rDqHiC+ng==
jdbc.ckLocalNew.password=jOA3tbfJiJlPci6XUHIbVg==
#########################配置日志查询使用druid连接池#########################################