Commit 329a54a0 authored by 赵啸非's avatar 赵啸非

异常日志前端展示添加

parent 2c5221d2
...@@ -13,6 +13,7 @@ import com.rabbitmq.client.AMQP; ...@@ -13,6 +13,7 @@ import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel; import com.rabbitmq.client.Channel;
import com.rabbitmq.client.impl.AMQImpl; import com.rabbitmq.client.impl.AMQImpl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.annotation.RabbitListener;
...@@ -50,26 +51,30 @@ public class AccessMessageConsumerListener { ...@@ -50,26 +51,30 @@ public class AccessMessageConsumerListener {
// if(messages instanceof ArrayList<String>){ // if(messages instanceof ArrayList<String>){
// //
// } // }
if ( messages.stream().noneMatch((o -> !(o instanceof String)))) {
if (messages instanceof List && ((List) messages).stream() log.info("都匹配");
.noneMatch((o -> !(o instanceof String)))) {
log.info("1111111111");
}else{ }else{
log.info("2222222222222"); log.info("存在类型不匹配");
} }
List<AccessLogEntity> collect = messages.stream().map(message -> { List<AccessLogEntity> collect = messages.stream().map(message -> {
try { try {
AccessLogEntity entity =null;
if(message instanceof String){
log.info("message:{}", message);
entity = JSON.parseObject(message, AccessLogEntity.class);
entity.setId(IdUtil.getSnowflake(0, 1).nextId());
entity.setCreateUserId(1L);
entity.setCreateTime(new Date());
}else{
// entity=(AccessLogEntity)message;
}
//String json = JSONUtil.formatJsonStr(new String(message, StandardCharsets.UTF_8)); //String json = JSONUtil.formatJsonStr(new String(message, StandardCharsets.UTF_8));
log.info("message:{}", message);
AccessLogEntity entity = JSON.parseObject(message, AccessLogEntity.class);
entity.setId(IdUtil.getSnowflake(0, 1).nextId());
entity.setCreateUserId(1L);
entity.setCreateTime(new Date());
return entity; return entity;
} catch (Exception e) { } catch (Exception e) {
log.info("反序列化异常", e); log.info("反序列化异常", e);
...@@ -85,6 +90,20 @@ public class AccessMessageConsumerListener { ...@@ -85,6 +90,20 @@ public class AccessMessageConsumerListener {
public static void main(String[] args) { public static void main(String[] args) {
ArrayList<?> messages = new ArrayList<>();
// messages.add("111");
if ( messages.stream().noneMatch((o -> !(o instanceof String)))) {
log.info("都匹配");
}else{
log.info("存在不匹配");
}
/*
String json = "{\n" + String json = "{\n" +
" \"appName\":\"smart-gateway\",\n" + " \"appName\":\"smart-gateway\",\n" +
" \"deleted\":0,\n" + " \"deleted\":0,\n" +
...@@ -122,7 +141,7 @@ public class AccessMessageConsumerListener { ...@@ -122,7 +141,7 @@ public class AccessMessageConsumerListener {
System.out.println(JSON.toJSONString(jsonObject)); System.out.println(JSON.toJSONString(jsonObject));
System.out.println(JSONUtil.formatJsonStr(JSON.toJSONString(jsonObject))); System.out.println(JSONUtil.formatJsonStr(JSON.toJSONString(jsonObject)));*/
} }
......
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