Commit da4cf5a4 authored by 赵啸非's avatar 赵啸非

业务日志添加

parent 58e135d0
...@@ -56,7 +56,7 @@ public class AccessMessageConsumerListener { ...@@ -56,7 +56,7 @@ public class AccessMessageConsumerListener {
} }
@RabbitHandler @RabbitHandler
public void onMessage(@Payload List<String> messages) throws Exception { public void onMessage(List<String> messages) throws Exception {
log.info("[Access onMessage][线程编号:{} 消息数量:{}]", Thread.currentThread().getName() + Thread.currentThread().getId(), messages.size()); log.info("[Access onMessage][线程编号:{} 消息数量:{}]", Thread.currentThread().getName() + Thread.currentThread().getId(), messages.size());
List<AccessLogEntity> collect = messages.stream().map(message -> { List<AccessLogEntity> collect = messages.stream().map(message -> {
......
...@@ -42,12 +42,10 @@ public class ErrorMessageConsumerListener { ...@@ -42,12 +42,10 @@ public class ErrorMessageConsumerListener {
@RabbitHandler @RabbitHandler
public void onMessage(List<String> messages) throws Exception { public void onMessage(List<String> messages) throws Exception {
log.info("[Error onMessage][线程编号:{} 消息数量:{}]", Thread.currentThread().getName()+Thread.currentThread().getId(), messages.size()); log.info("[Error onMessage][线程编号:{} 消息数量:{}]", Thread.currentThread().getName()+Thread.currentThread().getId(), messages.size());
messages.stream().peek(str -> { messages.stream().peek(str -> {
ErrorLogEntity entity = JSON.parseObject(str, ErrorLogEntity.class); ErrorLogEntity entity = JSON.parseObject(str, ErrorLogEntity.class);
entity.setCreateUserId(1L); entity.setCreateUserId(1L);
entity.setCreateTime(new Date()); entity.setCreateTime(new Date());
if (!ObjectUtils.isEmpty(entity.getFingerprint())) { if (!ObjectUtils.isEmpty(entity.getFingerprint())) {
//// TODO: 2022/8/24 指纹匹配 //// TODO: 2022/8/24 指纹匹配
} else { } else {
...@@ -56,7 +54,6 @@ public class ErrorMessageConsumerListener { ...@@ -56,7 +54,6 @@ public class ErrorMessageConsumerListener {
errorLogQuery.setAppName(entity.getAppName()); errorLogQuery.setAppName(entity.getAppName());
errorLogQuery.setPlatform(entity.getPlatform()); errorLogQuery.setPlatform(entity.getPlatform());
errorLogQuery.setMessage(entity.getMessage()); errorLogQuery.setMessage(entity.getMessage());
ErrorLogEntity errorLogEntity = errorLogService.selectOne(errorLogQuery, null); ErrorLogEntity errorLogEntity = errorLogService.selectOne(errorLogQuery, null);
if (!ObjectUtils.isEmpty(errorLogEntity)) { if (!ObjectUtils.isEmpty(errorLogEntity)) {
errorLogEntity.setCheckNum(errorLogEntity.getCheckNum()+1); errorLogEntity.setCheckNum(errorLogEntity.getCheckNum()+1);
......
...@@ -3,6 +3,7 @@ package com.mortals.xhx.base.framework.listener; ...@@ -3,6 +3,7 @@ package com.mortals.xhx.base.framework.listener;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.xhx.common.key.QueueKey; import com.mortals.xhx.common.key.QueueKey;
import com.mortals.xhx.module.access.model.AccessLogEntity;
import com.mortals.xhx.module.error.model.ErrorLogEntity; import com.mortals.xhx.module.error.model.ErrorLogEntity;
import com.mortals.xhx.module.error.service.ErrorLogService; import com.mortals.xhx.module.error.service.ErrorLogService;
import com.mortals.xhx.module.operate.model.OperateLogEntity; import com.mortals.xhx.module.operate.model.OperateLogEntity;
...@@ -38,9 +39,9 @@ public class OperateMessageConsumerListener { ...@@ -38,9 +39,9 @@ public class OperateMessageConsumerListener {
@Autowired @Autowired
private OperateLogService operateLogService; private OperateLogService operateLogService;
@RabbitHandler /* @RabbitHandler
public void onMessage(@Payload List<String> messages, Channel channel) throws Exception { public void onMessage(@Payload List<String> messages, Channel channel) throws Exception {
log.info("[Oper onMessage][线程编号:{} 消息数量:{}]", Thread.currentThread().getName()+Thread.currentThread().getId(), messages.size()); log.info("[Oper onMessage][线程编号:{} 消息数量:{}]", Thread.currentThread().getName() + Thread.currentThread().getId(), messages.size());
List<OperateLogEntity> collect = messages.stream().map(str -> { List<OperateLogEntity> collect = messages.stream().map(str -> {
OperateLogEntity entity = JSON.parseObject(str, OperateLogEntity.class); OperateLogEntity entity = JSON.parseObject(str, OperateLogEntity.class);
...@@ -50,5 +51,24 @@ public class OperateMessageConsumerListener { ...@@ -50,5 +51,24 @@ public class OperateMessageConsumerListener {
return entity; return entity;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
operateLogService.save(collect); operateLogService.save(collect);
}*/
@RabbitHandler
public void onMessage(List<String> messages){
log.info("[operate onMessage][线程编号:{} 消息数量:{}]", Thread.currentThread().getName() + Thread.currentThread().getId(), messages.size());
List<OperateLogEntity> collect = messages.stream().map(message -> {
try {
OperateLogEntity entity = null;
entity = JSON.parseObject(message, OperateLogEntity.class);
entity.setId(IdUtil.getSnowflake(0, 1).nextId());
entity.setCreateUserId(1L);
entity.setCreateTime(new Date());
return entity;
} catch (Exception e) {
log.info("反序列化异常", e);
return null;
}
}).filter(f -> f != null).collect(Collectors.toList());
operateLogService.save(collect);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment