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
e8f81291
Commit
e8f81291
authored
Mar 10, 2025
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复异常提醒,从而正确的跟踪异常信息
parent
77fb7cbb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
19 deletions
+21
-19
DbExecuteImpl.java
.../src/main/java/com/yanzuoguang/db/impl/DbExecuteImpl.java
+21
-19
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/db/impl/DbExecuteImpl.java
View file @
e8f81291
...
...
@@ -2,8 +2,9 @@ package com.yanzuoguang.db.impl;
import
com.yanzuoguang.db.ConfigDb
;
import
com.yanzuoguang.db.DbExecute
;
import
com.yanzuoguang.log.LogCountTime
;
import
com.yanzuoguang.util.helper.YzgTimeout
;
import
com.yanzuoguang.log.AspectLogResult
;
import
com.yanzuoguang.log.AspectLogStart
;
import
com.yanzuoguang.log.LogInfoVo
;
import
com.yanzuoguang.util.vo.MapRow
;
import
com.yanzuoguang.util.vo.Ref
;
import
org.springframework.jdbc.core.JdbcTemplate
;
...
...
@@ -24,13 +25,19 @@ public class DbExecuteImpl implements DbExecute {
private
final
JdbcTemplate
jdbcTemplate
;
private
final
DbExecutePrintSql
printSql
;
private
final
ConfigDb
configDb
;
private
final
LogCountTime
logCountTime
;
private
final
AspectLogStart
aspectLogStart
;
private
final
AspectLogResult
aspectLogResult
;
public
DbExecuteImpl
(
JdbcTemplate
jdbcTemplate
,
DbExecutePrintSql
printSql
,
ConfigDb
configDb
,
LogCountTime
logCountTime
)
{
public
DbExecuteImpl
(
JdbcTemplate
jdbcTemplate
,
DbExecutePrintSql
printSql
,
ConfigDb
configDb
,
AspectLogStart
aspectLogStart
,
AspectLogResult
aspectLogResult
)
{
this
.
jdbcTemplate
=
jdbcTemplate
;
this
.
printSql
=
printSql
;
this
.
configDb
=
configDb
;
this
.
logCountTime
=
logCountTime
;
this
.
aspectLogStart
=
aspectLogStart
;
this
.
aspectLogResult
=
aspectLogResult
;
}
public
JdbcTemplate
getJdbc
()
{
...
...
@@ -148,29 +155,24 @@ public class DbExecuteImpl implements DbExecute {
*/
private
void
executeSql
(
SqlInfo
sqlInfo
,
DbSqlFunction
<
Ref
<
Integer
>,
Long
>
sqlFunction
)
{
// 开始记录日志
String
fullUrl
=
String
.
format
(
"Sql:%s:%s"
,
sqlInfo
.
getTargetClass
().
getSimpleName
(),
sqlInfo
.
getSqlName
());
logCountTime
.
start
(
fullUrl
);
LogInfoVo
log
=
aspectLogStart
.
requestLog
(
sqlInfo
.
getTargetClass
(),
"Sql"
,
String
.
format
(
"%s:%s"
,
sqlInfo
.
getTargetClass
().
getSimpleName
(),
sqlInfo
.
getSqlName
()),
sqlInfo
,
true
);
// 开始时间
long
start
=
System
.
currentTimeMillis
();
Ref
<
Integer
>
row
=
new
Ref
<>(
0
);
sqlInfo
.
setSql
(
this
.
handleParas
(
sqlInfo
.
getSql
()));
boolean
isError
=
false
;
try
{
YzgTimeout
.
timeOut
(
sqlInfo
.
getTargetClass
(),
sqlInfo
.
getSqlName
()
,
()
->
sqlFunction
.
accept
(
row
,
start
)
// 打印超时的SQL语句
,
(
time
)
->
printSql
.
print
(
sqlInfo
,
time
,
row
.
value
)
);
// 执行得函数
sqlFunction
.
accept
(
row
,
start
);
// 写入日志
aspectLogResult
.
responseLog
(
log
,
row
,
null
);
}
catch
(
Exception
ex
)
{
isError
=
true
;
// 写入日志
aspectLogResult
.
responseLog
(
log
,
row
,
ex
);
throw
ex
;
}
finally
{
// 写入日志
long
time
=
System
.
currentTimeMillis
()
-
start
;
logCountTime
.
finish
(
fullUrl
,
time
,
isError
);
// 打印sql语句
printSql
.
print
(
sqlInfo
,
time
,
row
.
value
);
printSql
.
print
(
sqlInfo
,
log
.
getUseTime
()
,
row
.
value
);
}
}
...
...
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