Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
Details
Activity
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
fangxinjiang
yifu-mvp
Commits
97f873a3
Commit
97f873a3
authored
Dec 23, 2025
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化-fxj
parent
a787f0c5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
TDispatchInfoServiceImpl.java
...v1/yifu/social/service/impl/TDispatchInfoServiceImpl.java
+18
-9
No files found.
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/service/impl/TDispatchInfoServiceImpl.java
View file @
97f873a3
...
...
@@ -234,9 +234,12 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
if
(
redisLabelMap
!=
null
)
{
redisLabelMap
.
putAll
(
userMap
);
}
// 使用 try-with-resources 确保输出流正确关闭
try
(
ServletOutputStream
out
=
response
.
getOutputStream
())
{
ExcelWriter
excelWriter
=
EasyExcel
.
write
(
out
,
TDispatchInfoExportVo
.
class
)
// 获取输出流
OutputStream
out
=
null
;
ExcelWriter
excelWriter
=
null
;
try
{
out
=
response
.
getOutputStream
();
excelWriter
=
EasyExcel
.
write
(
out
,
TDispatchInfoExportVo
.
class
)
.
registerConverter
(
new
DictConverter
(
nameAndDicTypeMap
,
redisLabelMap
))
.
includeColumnFieldNames
(
searchVo
.
getExportFields
())
.
build
();
...
...
@@ -263,13 +266,19 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
excelWriter
.
write
(
list
,
writeSheet
);
}
excelWriter
.
finish
();
out
.
flush
();
}
catch
(
IOException
e
)
{
log
.
error
(
"导出文件时发生IO异常"
,
e
);
throw
new
RuntimeException
(
"导出文件失败"
,
e
);
// 可以根据需要转换为业务异常
}
finally
{
if
(
excelWriter
!=
null
)
{
try
{
excelWriter
.
finish
();
}
catch
(
Exception
e
)
{
log
.
error
(
"关闭ExcelWriter时发生异常"
,
e
);
}
}
}
}
catch
(
IOException
e
)
{
log
.
error
(
"导出文件时发生IO异常"
,
e
);
throw
new
RuntimeException
(
"导出文件失败"
,
e
);
// 可以根据需要转换为业务异常
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"执行导出时发生未知异常"
,
e
);
throw
new
RuntimeException
(
"导出过程中发生错误"
,
e
);
}
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