Merge branch 'Release-1.1' into develop

This commit is contained in:
doufenghu
2018-08-08 19:41:43 +08:00
8 changed files with 98 additions and 27 deletions

View File

@@ -42,6 +42,7 @@ public class ServicesRequestLog implements Serializable {
private String exceptionInfo;
private String serverIp;
private String traceCode;
private String requestURI;
/**
* serverIp
@@ -224,4 +225,17 @@ public class ServicesRequestLog implements Serializable {
this.traceCode = traceCode;
}
/**
* @param requestURI the requestURI to set
*/
public void setRequestURI(String requestURI) {
this.requestURI = requestURI;
}
/**
* @return the requestURI
*/
public String getRequestURI() {
return requestURI;
}
}

View File

@@ -3,7 +3,7 @@ package com.nis.domain;
import java.util.Date;
public class SwaggerLog extends BaseEntity<SwaggerLog> {
private static final long serialVersionUID = 5351369774420087482L;
private static final long serialVersionUID = 1L;
private String operator;
private String version;
private Integer opAction;
@@ -16,13 +16,13 @@ public class SwaggerLog extends BaseEntity<SwaggerLog> {
private String exceptionInfo;
private String serverIp;
private String traceCode;
private String requestUri;
private String exception;// 界面的异常信息框
private Date beginDate; // 开始日期
private Date endDate; // 结束日期
public String getOperator() {
return operator;
}
@@ -143,4 +143,12 @@ public class SwaggerLog extends BaseEntity<SwaggerLog> {
this.endDate = endDate;
}
public String getRequestUri() {
return requestUri;
}
public void setRequestUri(String requestUri) {
this.requestUri = requestUri;
}
}

View File

@@ -88,8 +88,8 @@ public class LogInterceptor extends BaseService implements HandlerInterceptor {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
String requestURI = request.getRequestURI();
// logger.info("请求路径是:" + requestURI);
// logger.info("请求参数是:" + getBodyString(request));
// logger.info("请求路径是:" + requestURI);
// logger.info("请求参数是:" + getBodyString(request));
long beginTime = System.currentTimeMillis();// 1、开始时间
timeThreadLocal.set(beginTime); // 线程绑定变量(该数据只有当前请求的线程可见)
if (logger.isDebugEnabled()) {
@@ -128,9 +128,13 @@ public class LogInterceptor extends BaseService implements HandlerInterceptor {
}
// 保存日志
LogUtils.saveLog(request, handler, ex, null, consumerTime);
String requestURI = request.getRequestURI();
// swagger日志请求和行为日志请求不记录请求日志
if (!requestURI.equals("/galaxy/nis/sys/log/swaggerLogList")
&& !requestURI.equals("/galaxy/nis/sys/log/list")) {
// 保存日志
LogUtils.saveLog(request, handler, ex, null, consumerTime);
}
}
}

View File

@@ -15,11 +15,12 @@
<result column="EXCEPTION_INFO" jdbcType="BLOB" property="exceptionInfo" typeHandler="com.nis.util.BlobTypeHandler"/>
<result column="SERVER_IP" jdbcType="VARCHAR" property="serverIp" />
<result column="TRACE_CODE" jdbcType="VARCHAR" property="traceCode" />
<result column="REQUEST_URI" jdbcType="VARCHAR" property="requestURI" />
</resultMap>
<sql id="Base_Column_List">
ID, OPERATOR, VERSION, OPACTION,OPTIME, REQUEST_CONTENT,
REQUEST_TIME,REQUEST_IP,
CONSUMER_TIME,BUSINESS_CODE,EXCEPTION_INFO,SERVER_IP,TRACE_CODE
CONSUMER_TIME,BUSINESS_CODE,EXCEPTION_INFO,SERVER_IP,TRACE_CODE,REQUEST_URI
</sql>
<select id="getAllLog" parameterType="com.nis.domain.restful.ServicesRequestLogBean"
resultMap="ServicesRequestLogMap">
@@ -127,6 +128,10 @@
<if test="traceCode != null">
TRACE_CODE,
</if>
<if test="requestURI != null">
REQUEST_URI,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -166,6 +171,9 @@
<if test="traceCode != null">
#{traceCode,jdbcType=VARCHAR},
</if>
<if test="requestURI != null">
#{requestURI,jdbcType=VARCHAR},
</if>
</trim>
</insert>
</mapper>

View File

@@ -10,7 +10,7 @@
#{beginDate} AND #{endDate}
<if test="requestContent != null and requestContent != ''">
AND a.request_Content LIKE
AND a.request_Content LIKE
<if test="dbName == 'oracle'">'%'||#{requestContent}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{requestContent}+'%'</if>
<if test="dbName == 'mysql'">CONCAT('%', #{requestContent}, '%')</if>
@@ -18,22 +18,31 @@
<if test="traceCode != null and traceCode != ''">
AND a.trace_Code=#{traceCode}
</if>
<if test="businessCode != null and businessCode != ''">
AND a.business_Code=#{businessCode}
</if>
<if test="requestUri != null and requestUri != ''">
AND a.REQUEST_URI LIKE
<if test="dbName == 'oracle'">'%'||#{requestUri}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{requestUri}+'%'</if>
<if test="dbName == 'mysql'">CONCAT('%', #{requestUri}, '%')</if>
</if>
<if test="exceptionInfo != null and exceptionInfo != ''">
AND a.exception_Info LIKE
AND a.exception_Info LIKE
<if test="dbName == 'oracle'">'%'||#{exceptionInfo}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{exceptionInfo}+'%'</if>
<if test="dbName == 'mysql'">CONCAT('%', #{exceptionInfo}, '%')</if>
</if>
<if test="requestIp != null and requestIp != ''">
AND a.request_ip like
AND a.request_ip like
<if test="dbName == 'oracle'">'%'||#{requestIp}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{requestIp}+'%'</if>
<if test="dbName == 'mysql'">CONCAT('%', #{requestIp}, '%')</if>
</if>
<if test="serverIp != null and serverIp != ''">
AND a.server_Ip like
AND a.server_Ip like
<if test="dbName == 'oracle'">'%'||#{serverIp}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{serverIp}+'%'</if>
<if test="dbName == 'mysql'">CONCAT('%', #{serverIp}, '%')</if>
@@ -41,6 +50,11 @@
<if test="exception != null and exception != ''">
AND a.exception_Info!=''
</if>
<!-- 默认不显示查询类日志,日志量太大,如果显示在界面选择操作行为即可 -->
<if test="opAction == null or opAction == ''">
AND a.opAction!=4
</if>
<if test="opAction != null and opAction != ''">
AND a.opAction=#{opAction}
</if>

View File

@@ -186,6 +186,7 @@ public abstract class BaseLogService {
try {
if (!StringUtil.isBlank(entity.getSearchFoundEndTime())) {
sdf.setLenient(false);
sdf.parse(entity.getSearchFoundEndTime());
}
} catch (ParseException e) {
@@ -201,6 +202,7 @@ public abstract class BaseLogService {
try {
if (!StringUtil.isBlank(entity.getSearchFoundStartTime())) {
sdf.setLenient(false);
sdf.parse(entity.getSearchFoundStartTime());
}
} catch (ParseException e) {

View File

@@ -105,6 +105,7 @@ public class ServicesRequestLogService {
log.setBusinessCode(businessCode);
log.setExceptionInfo(exceptionInfo);
log.setTraceCode(traceCode);
log.setRequestURI(requestURI);
try {
if(Constants.SERVCER_HOST!=null){
log.setServerIp(Constants.SERVCER_HOST);