Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
log-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
log-platform
Commits
329a54a0
Commit
329a54a0
authored
Aug 26, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异常日志前端展示添加
parent
2c5221d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
11 deletions
+30
-11
log-manager/src/main/java/com/mortals/xhx/base/framework/listener/AccessMessageConsumerListener.java
...ase/framework/listener/AccessMessageConsumerListener.java
+30
-11
No files found.
log-manager/src/main/java/com/mortals/xhx/base/framework/listener/AccessMessageConsumerListener.java
View file @
329a54a0
...
...
@@ -13,6 +13,7 @@ import com.rabbitmq.client.AMQP;
import
com.rabbitmq.client.Channel
;
import
com.rabbitmq.client.impl.AMQImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.poi.ss.formula.functions.T
;
import
org.springframework.amqp.core.Message
;
import
org.springframework.amqp.rabbit.annotation.RabbitHandler
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
...
...
@@ -50,26 +51,30 @@ public class AccessMessageConsumerListener {
// if(messages instanceof ArrayList<String>){
//
// }
if
(
messages
instanceof
List
&&
((
List
)
messages
).
stream
()
.
noneMatch
((
o
->
!(
o
instanceof
String
))))
{
log
.
info
(
"1111111111"
);
if
(
messages
.
stream
().
noneMatch
((
o
->
!(
o
instanceof
String
))))
{
log
.
info
(
"都匹配"
);
}
else
{
log
.
info
(
"
2222222222222
"
);
log
.
info
(
"
存在类型不匹配
"
);
}
List
<
AccessLogEntity
>
collect
=
messages
.
stream
().
map
(
message
->
{
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));
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
;
}
catch
(
Exception
e
)
{
log
.
info
(
"反序列化异常"
,
e
);
...
...
@@ -85,6 +90,20 @@ public class AccessMessageConsumerListener {
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" +
" \"appName\":\"smart-gateway\",\n" +
" \"deleted\":0,\n" +
...
...
@@ -122,7 +141,7 @@ public class AccessMessageConsumerListener {
System.out.println(JSON.toJSONString(jsonObject));
System
.
out
.
println
(
JSONUtil
.
formatJsonStr
(
JSON
.
toJSONString
(
jsonObject
)));
System.out.println(JSONUtil.formatJsonStr(JSON.toJSONString(jsonObject)));
*/
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment