接口上加注解EpcLog 并加备注 可存储操作日志
This commit is contained in:
@@ -19,7 +19,7 @@ public class ActDefineStartMap {
|
|||||||
map.put("3","StandAskForOpinion");
|
map.put("3","StandAskForOpinion");
|
||||||
map.put("4","standardregulatoryinventory");
|
map.put("4","standardregulatoryinventory");
|
||||||
map.put("5","projectEvaluationNewProcess");
|
map.put("5","projectEvaluationNewProcess");
|
||||||
map.put("6","Projectcomplianceassessment");
|
map.put("6","xmhgpgXM");
|
||||||
|
|
||||||
|
|
||||||
map.put("8","nonConformanceRectificationKey");
|
map.put("8","nonConformanceRectificationKey");
|
||||||
|
|||||||
+1
-1
@@ -473,7 +473,7 @@ public class WorkFlowController {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "特殊完成任务节点 会更改草稿")
|
@ApiOperation(value = "特殊完成任务节点 会更·改草稿")
|
||||||
@PostMapping("/completeTaskNew")
|
@PostMapping("/completeTaskNew")
|
||||||
public Wrapper<String> completeTaskByUserIdNew( BusMesSpecial busMes){
|
public Wrapper<String> completeTaskByUserIdNew( BusMesSpecial busMes){
|
||||||
Wrapper<String> str = workFlowFeignClient.completeTaskByUserIdNew(busMes);
|
Wrapper<String> str = workFlowFeignClient.completeTaskByUserIdNew(busMes);
|
||||||
|
|||||||
+6
-1
@@ -78,7 +78,12 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 解析客户端操作系统、浏览器等 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>eu.bitwalker</groupId>
|
||||||
|
<artifactId>UserAgentUtils</artifactId>
|
||||||
|
<version>1.21</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
<!-- <groupId>com.adc</groupId>-->
|
<!-- <groupId>com.adc</groupId>-->
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.adc.da.Log;
|
||||||
|
|
||||||
|
public enum BusinessType {
|
||||||
|
/**
|
||||||
|
* 其他
|
||||||
|
*/
|
||||||
|
OTHER,
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*/
|
||||||
|
INSERT,
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*/
|
||||||
|
UPDATE,
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
DELETE,
|
||||||
|
/**
|
||||||
|
* 查询
|
||||||
|
*/
|
||||||
|
SEARCH,
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.adc.da.Log;
|
||||||
|
|
||||||
|
import org.apache.poi.ss.usermodel.DataValidationConstraint;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface EpcLog {
|
||||||
|
|
||||||
|
String value() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模块
|
||||||
|
*/
|
||||||
|
public String title() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能
|
||||||
|
*/
|
||||||
|
public BusinessType businessType() default BusinessType.OTHER;
|
||||||
|
|
||||||
|
|
||||||
|
String description();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
package com.adc.da.Log;
|
||||||
|
|
||||||
|
import com.adc.da.slrs.sysLog.entity.SysLog;
|
||||||
|
import com.adc.da.slrs.sysLog.service.ISysLogService;
|
||||||
|
import com.adc.da.util.LoginUserUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.aspectj.lang.JoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.AfterReturning;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class logs {
|
||||||
|
//日志 注解方式存储日志
|
||||||
|
|
||||||
|
long beginTime;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ISysLogService sysLogService;
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private HttpServletRequest request;
|
||||||
|
|
||||||
|
// 配置织入点
|
||||||
|
@Pointcut("@annotation(EpcLog)")
|
||||||
|
public void logPointCut() {
|
||||||
|
log.info("=================已进入监听==========");
|
||||||
|
beginTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后置通知(在方法执行之后并返回数据) 用于拦截Controller层无异常的操作
|
||||||
|
* @param joinPoint 切点
|
||||||
|
*/
|
||||||
|
@AfterReturning("logPointCut()")
|
||||||
|
public void after(JoinPoint joinPoint){
|
||||||
|
Executor executor = Executors.newCachedThreadPool();
|
||||||
|
try {
|
||||||
|
String description = getControllerMethodInfo(joinPoint).get("description").toString();
|
||||||
|
Map<String, String[]> logParams = request.getParameterMap();
|
||||||
|
// String principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||||
|
|
||||||
|
SysLog log = new SysLog();
|
||||||
|
// ##请求用户
|
||||||
|
log.setUserId(LoginUserUtil.getUserId());
|
||||||
|
// ##日志标题
|
||||||
|
log.setOperLocation(description);
|
||||||
|
// ##日志类型
|
||||||
|
log.setOper(String.valueOf(getControllerMethodInfo(joinPoint).get("type")));
|
||||||
|
// ##日志请求url
|
||||||
|
// log.setRequestUrl(request.getRequestURI());…
|
||||||
|
// ##请求方式
|
||||||
|
// log.setRequestType(request.getMethod());
|
||||||
|
// ##请求参数
|
||||||
|
log.setJson(logParams.toString());
|
||||||
|
// ##请求开始时间
|
||||||
|
long endTime = System.currentTimeMillis();
|
||||||
|
// ##请求耗时
|
||||||
|
Long logElapsedTime = endTime - beginTime;
|
||||||
|
log.setRunTime(logElapsedTime.intValue());
|
||||||
|
|
||||||
|
// ##调用线程保存至log表
|
||||||
|
executor.execute(new SaveSystemLogThread(log, sysLogService));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("AOP后置通知异常", e);
|
||||||
|
}
|
||||||
|
((ExecutorService) executor).shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存日志至数据库
|
||||||
|
*/
|
||||||
|
protected static class SaveSystemLogThread implements Runnable {
|
||||||
|
|
||||||
|
private SysLog log;
|
||||||
|
private ISysLogService logService;
|
||||||
|
|
||||||
|
public SaveSystemLogThread(SysLog esLog, ISysLogService logService) {
|
||||||
|
this.log = esLog;
|
||||||
|
this.logService = logService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
log.setId(String.valueOf(UUID.randomUUID()));
|
||||||
|
logService.save(log);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取注解中对方法的描述信息 用于Controller层注解
|
||||||
|
* @param joinPoint 切点
|
||||||
|
* @return 方法描述
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static Map<String, Object> getControllerMethodInfo(JoinPoint joinPoint) throws Exception{
|
||||||
|
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>(16);
|
||||||
|
// ## 获取目标类名
|
||||||
|
String targetName = joinPoint.getTarget().getClass().getName();
|
||||||
|
// ## 获取方法名
|
||||||
|
String methodName = joinPoint.getSignature().getName();
|
||||||
|
// ## 获取相关参数
|
||||||
|
Object[] arguments = joinPoint.getArgs();
|
||||||
|
// ## 生成类对象
|
||||||
|
Class targetClass = Class.forName(targetName);
|
||||||
|
// ## 获取该类中的方法
|
||||||
|
Method[] methods = targetClass.getMethods();
|
||||||
|
|
||||||
|
String description = "";
|
||||||
|
Integer type = null;
|
||||||
|
|
||||||
|
for(Method method : methods) {
|
||||||
|
if(!method.getName().equals(methodName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Class[] clazzs = method.getParameterTypes();
|
||||||
|
if(clazzs.length != arguments.length) {
|
||||||
|
// ## 比较方法中参数个数与从切点中获取的参数个数是否相同,原因是方法可以重载
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
description = method.getAnnotation(EpcLog.class).description();
|
||||||
|
type = method.getAnnotation(EpcLog.class).businessType().ordinal();
|
||||||
|
map.put("description", description);
|
||||||
|
map.put("type", type);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+3
-6
@@ -1,10 +1,9 @@
|
|||||||
package com.adc.da.slrs.sarStandardsInfo.controller;
|
package com.adc.da.slrs.sarStandardsInfo.controller;
|
||||||
|
|
||||||
|
|
||||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
||||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
||||||
import cn.hutool.core.util.ZipUtil;
|
import cn.hutool.core.util.ZipUtil;
|
||||||
import com.adc.da.att.entity.AttFileEO;
|
import com.adc.da.Log.BusinessType;
|
||||||
|
import com.adc.da.Log.EpcLog;
|
||||||
import com.adc.da.common.FileUnZip;
|
import com.adc.da.common.FileUnZip;
|
||||||
import com.adc.da.common.ReadExcel;
|
import com.adc.da.common.ReadExcel;
|
||||||
import com.adc.da.exception.AdcDaBaseException;
|
import com.adc.da.exception.AdcDaBaseException;
|
||||||
@@ -22,7 +21,6 @@ import com.adc.da.util.LoginUserUtil;
|
|||||||
import com.adc.da.util.UUIDUtils;
|
import com.adc.da.util.UUIDUtils;
|
||||||
import com.adc.da.utils.util.*;
|
import com.adc.da.utils.util.*;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -44,11 +42,9 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -93,6 +89,7 @@ public class SarStandardsInfoController extends BaseController<SarStandardsInfo>
|
|||||||
|
|
||||||
@ApiOperation(value = "|SarStandardsInfoEO|自定义分页查询")
|
@ApiOperation(value = "|SarStandardsInfoEO|自定义分页查询")
|
||||||
@GetMapping("/getSarStandardsInfoPage")
|
@GetMapping("/getSarStandardsInfoPage")
|
||||||
|
@EpcLog(description = "国内库或国外库查询",businessType = BusinessType.SEARCH)
|
||||||
//@RequiresPermissions("lawss:sarStandardsInfo:getSarStandardsInfoPage")
|
//@RequiresPermissions("lawss:sarStandardsInfo:getSarStandardsInfoPage")
|
||||||
public ResponseMessage<PageInfo<SarStandardsInfo>> getSarStandardsInfoPage(SarStandardsInfoEOPage page,@RequestParam(defaultValue = "0") String mark) throws Exception {
|
public ResponseMessage<PageInfo<SarStandardsInfo>> getSarStandardsInfoPage(SarStandardsInfoEOPage page,@RequestParam(defaultValue = "0") String mark) throws Exception {
|
||||||
if (null != page.getNowOrderBy()) {
|
if (null != page.getNowOrderBy()) {
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.adc.da.slrs.sysLog.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import com.adc.da.slrs.sysLog.entity.SysLog;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.adc.da.base.web.BaseController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author yzh
|
||||||
|
* @since 2022-02-15
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Api(description = "|SysLog|")
|
||||||
|
@RequestMapping("/sysLog/sys-log")
|
||||||
|
public class SysLogController extends BaseController<SysLog> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.adc.da.slrs.sysLog.dao;
|
||||||
|
|
||||||
|
import com.adc.da.slrs.sysLog.entity.SysLog;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author yzh
|
||||||
|
* @since 2022-02-15
|
||||||
|
*/
|
||||||
|
public interface SysLogDao extends BaseMapper<SysLog> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.adc.da.slrs.sysLog.entity;
|
||||||
|
|
||||||
|
import com.adc.da.base.entity.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author yzh
|
||||||
|
* @since 2022-02-15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value="SysLog对象", description="")
|
||||||
|
public class SysLog extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "用户id")
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "操作时间")
|
||||||
|
private String operTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "操作类型")
|
||||||
|
private String oper;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "操作ip")
|
||||||
|
private String operIp;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "操作系统类型")
|
||||||
|
private String operSystem;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "使用的浏览器")
|
||||||
|
private String operBrowser;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "日志等级")
|
||||||
|
private String operLevel;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "操作模块")
|
||||||
|
private String operLocation;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "传参")
|
||||||
|
private String json;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "接口耗时")
|
||||||
|
private int runTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.adc.da.slrs.sysLog.service;
|
||||||
|
|
||||||
|
import com.adc.da.slrs.sysLog.entity.SysLog;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author yzh
|
||||||
|
* @since 2022-02-15
|
||||||
|
*/
|
||||||
|
public interface ISysLogService extends IService<SysLog> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.adc.da.slrs.sysLog.service.impl;
|
||||||
|
|
||||||
|
import com.adc.da.slrs.sysLog.entity.SysLog;
|
||||||
|
import com.adc.da.slrs.sysLog.dao.SysLogDao;
|
||||||
|
import com.adc.da.slrs.sysLog.service.ISysLogService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author yzh
|
||||||
|
* @since 2022-02-15
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysLogServiceImpl extends ServiceImpl<SysLogDao, SysLog> implements ISysLogService {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
LEFT JOIN ts_resource ON SAR_STAND_MENU.MENU_ID = ts_resource.ID
|
LEFT JOIN ts_resource ON SAR_STAND_MENU.MENU_ID = ts_resource.ID
|
||||||
<where>
|
<where>
|
||||||
SAR_STAND_MENU.VALID_FLAG = 0
|
SAR_STAND_MENU.VALID_FLAG = 0
|
||||||
<if test="standId !=null and stand != ''">
|
<if test="standId !=null and standId != ''">
|
||||||
AND stand_id = #{standId}
|
AND stand_id = #{standId}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -58,7 +58,7 @@
|
|||||||
<sql id="Group_Column_List_show" >
|
<sql id="Group_Column_List_show" >
|
||||||
stand_status, replaced_stand_num, replace_stand_num,put_time,
|
stand_status, replaced_stand_num, replace_stand_num,put_time,
|
||||||
issue_time, stand_en_name, stand_name, stand_code,stand_status,
|
issue_time, stand_en_name, stand_name, stand_code,stand_status,
|
||||||
SAR_BUSSIONESS_STAND.id
|
SAR_BUSSIONESS_STAND.id, SAR_BUSS_STAND_ATTR_INFO.DTQBBHBUSS
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?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.adc.da.slrs.sysLog.dao.SysLogDao">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user