|
|
|
@ -8,6 +8,9 @@ |
|
|
|
|
|
|
|
package com.elink.esua.epdc.log; |
|
|
|
|
|
|
|
import com.elink.esua.epdc.commons.tools.log.SysLogError; |
|
|
|
import com.elink.esua.epdc.commons.tools.log.SysLogLogin; |
|
|
|
import com.elink.esua.epdc.commons.tools.log.SysLogOperation; |
|
|
|
import com.elink.esua.epdc.entity.SysLogLoginEntity; |
|
|
|
import com.elink.esua.epdc.entity.SysLogOperationEntity; |
|
|
|
import com.elink.esua.epdc.service.SysLogErrorService; |
|
|
|
@ -61,36 +64,38 @@ public class LogConsumer implements CommandLineRunner { |
|
|
|
} |
|
|
|
|
|
|
|
private void receiveQueue() { |
|
|
|
log.info("日志存储开始-------------"); |
|
|
|
String key = RedisKeys.getSysLogKey(); |
|
|
|
//每次插入100条
|
|
|
|
int count = 100; |
|
|
|
for (int i = 0; i < count; i++) { |
|
|
|
log.info("1日志存储开始-------------"); |
|
|
|
BaseLog baseLog = (BaseLog) redisUtils.rightPop(key); |
|
|
|
if (baseLog == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
log.info("日志存储开始-------------"+baseLog.toString()); |
|
|
|
//登录日志
|
|
|
|
if (baseLog.getType() == LogTypeEnum.LOGIN.value()) { |
|
|
|
SysLogLoginEntity entity = ConvertUtils.sourceToTarget(log, SysLogLoginEntity.class); |
|
|
|
log.info("登录日志开始-------------"+entity.toString()); |
|
|
|
SysLogLogin sysLogLogin = (SysLogLogin) baseLog; |
|
|
|
SysLogLoginEntity entity = ConvertUtils.sourceToTarget(sysLogLogin, SysLogLoginEntity.class); |
|
|
|
log.info("1登录日志开始-------------"+entity.toString()); |
|
|
|
sysLogLoginService.save(entity); |
|
|
|
} |
|
|
|
|
|
|
|
//操作日志
|
|
|
|
if (baseLog.getType() == LogTypeEnum.OPERATION.value()) { |
|
|
|
SysLogOperationEntity entity = ConvertUtils.sourceToTarget(log, SysLogOperationEntity.class); |
|
|
|
SysLogOperation sysLogOperation = (SysLogOperation) baseLog; |
|
|
|
SysLogOperationEntity entity = ConvertUtils.sourceToTarget(sysLogOperation, SysLogOperationEntity.class); |
|
|
|
log.info("操作日志开始-------------"+entity.toString()); |
|
|
|
sysLogOperationService.save(entity); |
|
|
|
} |
|
|
|
|
|
|
|
//异常日志
|
|
|
|
if (baseLog.getType() == LogTypeEnum.ERROR.value()) { |
|
|
|
SysLogErrorEntity entity = ConvertUtils.sourceToTarget(log, SysLogErrorEntity.class); |
|
|
|
log.info("异常日志开始-------------"+entity.toString()); |
|
|
|
sysLogErrorService.save(entity); |
|
|
|
} |
|
|
|
// //异常日志
|
|
|
|
// if (baseLog.getType() == LogTypeEnum.ERROR.value()) {
|
|
|
|
// SysLogError logError = (SysLogError) baseLog;
|
|
|
|
// SysLogErrorEntity entity = ConvertUtils.sourceToTarget(logError, SysLogErrorEntity.class);
|
|
|
|
// log.info("异常日志开始-------------"+entity.toString());
|
|
|
|
// sysLogErrorService.save(entity);
|
|
|
|
// }
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|