Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
0ed3022a
Commit
0ed3022a
authored
May 13, 2022
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复等待时间
parent
2617307d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
25 deletions
+25
-25
CollectionString.java
...main/java/com/yanzuoguang/util/base/CollectionString.java
+2
-2
AspectLogResult.java
.../main/java/com/yanzuoguang/cloud/aop/AspectLogResult.java
+23
-23
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/base/CollectionString.java
View file @
0ed3022a
...
@@ -3,7 +3,7 @@ package com.yanzuoguang.util.base;
...
@@ -3,7 +3,7 @@ package com.yanzuoguang.util.base;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.
Linked
HashMap
;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
...
@@ -26,7 +26,7 @@ public class CollectionString {
...
@@ -26,7 +26,7 @@ public class CollectionString {
*/
*/
public
static
<
T
>
String
getCollectionString
(
String
tag
,
Collection
<
T
>
rowList
)
{
public
static
<
T
>
String
getCollectionString
(
String
tag
,
Collection
<
T
>
rowList
)
{
// 每个字段的长度
// 每个字段的长度
Map
<
String
,
Integer
>
mapFieldCount
=
new
HashMap
<>(
15
);
Map
<
String
,
Integer
>
mapFieldCount
=
new
Linked
HashMap
<>(
15
);
// 每个值的长度
// 每个值的长度
rowList
.
forEach
(
k
->
ObjectEach
.
each
(
k
,
(
name
,
value
,
field
)
->
{
rowList
.
forEach
(
k
->
ObjectEach
.
each
(
k
,
(
name
,
value
,
field
)
->
{
// 获取字符串
// 获取字符串
...
...
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/aop/AspectLogResult.java
View file @
0ed3022a
...
@@ -18,15 +18,13 @@ import org.springframework.stereotype.Component;
...
@@ -18,15 +18,13 @@ import org.springframework.stereotype.Component;
@Component
@Component
public
class
AspectLogResult
{
public
class
AspectLogResult
{
public
static
final
int
WAIT_MAX
=
30
;
public
static
final
int
WAIT_ITEM
=
10
;
private
final
CloudConfig
cloudConfig
;
private
final
CloudConfig
cloudConfig
;
private
final
LogLocal
logLocal
;
private
final
LogLocal
logLocal
;
private
final
AspectLogBody
aspectLogBody
;
private
final
AspectLogBody
aspectLogBody
;
private
final
AspectLogTime
aspectLogTime
;
private
final
AspectLogTime
aspectLogTime
;
private
final
ResponseResult
<
Object
>
responseDefault
=
new
ResponseResult
(
);
private
final
ResponseResult
<
String
>
responseDefault
=
ResponseResult
.
result
(
"操作成功"
);
public
AspectLogResult
(
CloudConfig
cloudConfig
,
LogLocal
logLocal
,
AspectLogBody
aspectLogBody
,
AspectLogTime
aspectLogTime
)
{
public
AspectLogResult
(
CloudConfig
cloudConfig
,
LogLocal
logLocal
,
AspectLogBody
aspectLogBody
,
AspectLogTime
aspectLogTime
)
{
this
.
cloudConfig
=
cloudConfig
;
this
.
cloudConfig
=
cloudConfig
;
...
@@ -52,39 +50,41 @@ public class AspectLogResult {
...
@@ -52,39 +50,41 @@ public class AspectLogResult {
public
void
responseLog
(
Class
<?>
cls
,
String
tag
,
String
url
,
boolean
logFlag
,
long
start
,
public
void
responseLog
(
Class
<?>
cls
,
String
tag
,
String
url
,
boolean
logFlag
,
long
start
,
Object
requestBody
,
Object
result
,
Exception
resultEx
,
LogVo
log
)
{
Object
requestBody
,
Object
result
,
Exception
resultEx
,
LogVo
log
)
{
try
{
try
{
// 执行时间
long
time
=
System
.
currentTimeMillis
()
-
start
;
// 全路径
String
fullUrl
=
String
.
format
(
"%s:%s"
,
tag
,
url
);
String
fullUrl
=
String
.
format
(
"%s:%s"
,
tag
,
url
);
// 输出日志标记
// ThreadHelper.waitRun(WAIT_MAX, WAIT_ITEM, k -> StringHelper.isEmpty(log.getLogId()));
boolean
isLogCommon
=
logFlag
&&
this
.
cloudConfig
.
isLogCommon
();
if
(
StringHelper
.
isEmpty
(
log
.
getLogId
()))
{
boolean
isLogDatabase
=
resultEx
!=
null
;
boolean
isLogDisplay
=
isLogCommon
||
isLogDatabase
;
// 记录请求时间
aspectLogTime
.
finish
(
fullUrl
,
time
,
isLogDatabase
);
// ThreadHelper.waitRun(WAIT_MAX, WAIT_ITEM, k -> StringHelper.isEmpty(log.getLogId()))
if
(
StringHelper
.
isEmpty
(
log
.
getLogId
())
||
!
isLogDisplay
)
{
return
;
return
;
}
}
String
body
=
aspectLogBody
.
getBodyString
(
requestBody
);
String
body
=
aspectLogBody
.
getBodyString
(
requestBody
);
if
(!
StringHelper
.
compare
(
log
.
getContent
(),
body
))
{
if
(!
StringHelper
.
compare
(
log
.
getContent
(),
body
))
{
log
.
setContentTo
(
body
);
log
.
setContentTo
(
body
);
}
}
long
time
=
System
.
currentTimeMillis
()
-
start
;
boolean
isLogCommon
=
logFlag
&&
this
.
cloudConfig
.
isLogCommon
();
boolean
isLogDatabase
=
resultEx
!=
null
;
boolean
isLogDisplay
=
isLogCommon
||
isLogDatabase
;
// 处理结果
// 处理结果
ResponseResult
responseResult
=
responseDefa
ult
;
ResponseResult
<?>
responseRes
ult
;
if
(
result
instanceof
ResponseResult
)
{
if
(
result
instanceof
ResponseResult
)
{
responseResult
=
(
ResponseResult
)
result
;
responseResult
=
(
ResponseResult
<?>
)
result
;
}
else
if
(
result
!=
null
)
{
}
else
if
(
result
!=
null
)
{
responseResult
=
ResponseResult
.
result
(
result
);
responseResult
=
ResponseResult
.
result
(
result
);
}
else
if
(
resultEx
!=
null
)
{
responseResult
=
ExceptionHelper
.
getError
(
resultEx
);
}
else
{
responseResult
=
responseDefault
;
}
}
if
(
isLogDisplay
)
{
// 执行时间
String
json
=
JsonHelper
.
serialize
(
responseResult
);
if
(
resultEx
!=
null
)
{
Log
.
error
(
cls
,
resultEx
,
"%s [ %s ] time %d ms, result: %s"
,
tag
,
url
,
time
,
aspectLogBody
.
getMaxString
(
json
));
responseResult
=
ExceptionHelper
.
getError
(
resultEx
);
if
(
isLogDatabase
)
{
}
logLocal
.
result
(
log
,
responseResult
.
getCode
(),
json
);
String
json
=
JsonHelper
.
serialize
(
responseResult
);
Log
.
error
(
cls
,
resultEx
,
"%s [ %s ] time %d ms, result: %s"
,
tag
,
url
,
time
,
aspectLogBody
.
getMaxString
(
json
));
if
(
isLogDatabase
)
{
logLocal
.
result
(
log
,
responseResult
.
getCode
(),
json
);
}
}
}
aspectLogTime
.
finish
(
fullUrl
,
time
,
isLogDatabase
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
}
finally
{
...
...
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