| 
						
						
						
					 | 
					@ -1,5 +1,6 @@ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					package com.epmet.commons.tools.aspect; | 
					 | 
					 | 
					package com.epmet.commons.tools.aspect; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.alibaba.fastjson.JSON; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.constant.AppClientConstant; | 
					 | 
					 | 
					import com.epmet.commons.tools.constant.AppClientConstant; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.constant.ThreadLocalConstant; | 
					 | 
					 | 
					import com.epmet.commons.tools.constant.ThreadLocalConstant; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.exception.*; | 
					 | 
					 | 
					import com.epmet.commons.tools.exception.*; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -14,6 +15,9 @@ import javax.servlet.http.HttpServletRequest; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.time.Duration; | 
					 | 
					 | 
					import java.time.Duration; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.time.LocalDateTime; | 
					 | 
					 | 
					import java.time.LocalDateTime; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.Arrays; | 
					 | 
					 | 
					import java.util.Arrays; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import java.util.Enumeration; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import java.util.HashMap; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import java.util.Map; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					/** | 
					 | 
					 | 
					/** | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 * 日志切面 | 
					 | 
					 | 
					 * 日志切面 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -54,6 +58,8 @@ public abstract class BaseRequestLogAspect { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        //    transactionSerial = UUID.randomUUID().toString();
 | 
					 | 
					 | 
					        //    transactionSerial = UUID.randomUUID().toString();
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        //}
 | 
					 | 
					 | 
					        //}
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        Map<String, String> requestHeaders = getRequestHeaders(request); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        // 将当前线程名称设置为事务流水号
 | 
					 | 
					 | 
					        // 将当前线程名称设置为事务流水号
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (!StringUtils.isEmpty(transactionSerial)) { | 
					 | 
					 | 
					        if (!StringUtils.isEmpty(transactionSerial)) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            Thread.currentThread().setName(transactionSerial); | 
					 | 
					 | 
					            Thread.currentThread().setName(transactionSerial); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -64,7 +70,8 @@ public abstract class BaseRequestLogAspect { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        try { | 
					 | 
					 | 
					        try { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            Object[] args = point.getArgs(); | 
					 | 
					 | 
					            Object[] args = point.getArgs(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            ThreadLocalConstant.requestParam.set(Arrays.toString(point.getArgs())); | 
					 | 
					 | 
					            ThreadLocalConstant.requestParam.set(Arrays.toString(point.getArgs())); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            log.info(">>>>>>>>请求信息>>>>>>>>:事务流水号:{},url:{} ,method:{},请求参数:{}", transactionSerial, requestURI, method, objectsToString(args)); | 
					 | 
					 | 
					            log.info(">>>>>>>>请求信息>>>>>>>>:事务流水号:{},url:{} ,method:{},请求参数:{},请求头:{}", | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    transactionSerial, requestURI, method, objectsToString(args), requestHeaders); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            result = point.proceed(); | 
					 | 
					 | 
					            result = point.proceed(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            resultInfoLog(transactionSerial, getExecPeriod(startTime), result); | 
					 | 
					 | 
					            resultInfoLog(transactionSerial, getExecPeriod(startTime), result); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } catch (RenException e) { | 
					 | 
					 | 
					        } catch (RenException e) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -91,6 +98,23 @@ public abstract class BaseRequestLogAspect { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        return result; | 
					 | 
					 | 
					        return result; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @Description 获取请求头信息 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @return | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @author wxz | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @date 2021.03.31 13:59 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    */ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    private Map<String, String> getRequestHeaders(HttpServletRequest request) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        Enumeration<String> headerNames = request.getHeaderNames(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        HashMap<String, String> headerMap = new HashMap<>(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        while (headerNames.hasMoreElements()) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            String headerName = headerNames.nextElement(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            String headerValue = request.getHeader(headerName); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            headerMap.put(headerName, headerValue); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        return headerMap; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    /** | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * info日志 | 
					 | 
					 | 
					     * info日志 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * @param transactionSerial | 
					 | 
					 | 
					     * @param transactionSerial | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -225,7 +249,13 @@ public abstract class BaseRequestLogAspect { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            StringBuilder builder = new StringBuilder("["); | 
					 | 
					 | 
					            StringBuilder builder = new StringBuilder("["); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            for (Object object : args) { | 
					 | 
					 | 
					            for (Object object : args) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                if (object != null) { | 
					 | 
					 | 
					                if (object != null) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    try { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        // 尝试作为json解析
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        String objectString = JSON.toJSONString(object); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                        builder.append(objectString); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    } catch (Exception e) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                        builder.append(object.toString()); | 
					 | 
					 | 
					                        builder.append(object.toString()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    builder.append(","); | 
					 | 
					 | 
					                    builder.append(","); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                } | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            } | 
					 | 
					 | 
					            } | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |