|
@@ -0,0 +1,76 @@
|
|
|
+package com.diagbot.aop;
|
|
|
+
|
|
|
+import com.diagbot.annotation.BiLogger;
|
|
|
+import com.diagbot.enums.ProductTypeEnum;
|
|
|
+import com.diagbot.rabbit.MySender;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.GsonUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
+import com.diagbot.vo.BaseBiVO;
|
|
|
+import com.diagbot.vo.BiRecord;
|
|
|
+import org.aspectj.lang.JoinPoint;
|
|
|
+import org.aspectj.lang.annotation.AfterReturning;
|
|
|
+import org.aspectj.lang.annotation.Aspect;
|
|
|
+import org.aspectj.lang.reflect.MethodSignature;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.lang.reflect.Method;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description: 日志拦截切面
|
|
|
+ * @author: gaodm
|
|
|
+ * @time: 2018/8/2 13:36
|
|
|
+ */
|
|
|
+@Aspect
|
|
|
+@Component
|
|
|
+public class BiLoggerAspect {
|
|
|
+ @Autowired
|
|
|
+ private MySender mySender;
|
|
|
+
|
|
|
+ @AfterReturning(value = "@annotation(com.diagbot.annotation.BiLogger)", returning = "keys")
|
|
|
+ public void saveBiRecord(JoinPoint joinPoint, Object keys) {
|
|
|
+ MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
|
|
+ Method method = signature.getMethod();
|
|
|
+
|
|
|
+ BiRecord biRecord = new BiRecord();
|
|
|
+ //请求的参数
|
|
|
+ Object[] args = joinPoint.getArgs();
|
|
|
+ String params = "";
|
|
|
+ for (Object o : args) {
|
|
|
+ if (o instanceof BaseBiVO) {
|
|
|
+ BaseBiVO baseBiVO = (BaseBiVO) o;
|
|
|
+ if (StringUtil.isBlank(baseBiVO.getHospitalCode())) {
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ BeanUtil.copyProperties(baseBiVO, biRecord);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ params += GsonUtil.toJson(o);
|
|
|
+ }
|
|
|
+ if (!StringUtil.isEmpty(params)) {
|
|
|
+ biRecord.setParams(params);
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置功能编码
|
|
|
+ BiLogger biLogger = method.getAnnotation(BiLogger.class);
|
|
|
+ if (biLogger != null) {
|
|
|
+ //注解上的描述
|
|
|
+ biRecord.setCode(biLogger.value());
|
|
|
+ }
|
|
|
+
|
|
|
+ //出参设置
|
|
|
+ String result = "";
|
|
|
+ result = GsonUtil.toJson(keys);
|
|
|
+ if (!StringUtil.isEmpty(result)) {
|
|
|
+ biRecord.setResult(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ biRecord.setGmtCreate(new Date());
|
|
|
+ biRecord.setProductType(ProductTypeEnum.ICSS.getKey());
|
|
|
+ //保存BI日志
|
|
|
+ mySender.outputBiLogSend(biRecord);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|