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
4a7314cb
Commit
4a7314cb
authored
Jan 16, 2025
by
huyuchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
huych-含风险项目商险不购买申请提交
parent
91c7aa8d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
33 deletions
+108
-33
CommonConstants.java
...ud/plus/v1/yifu/common/core/constant/CommonConstants.java
+2
-0
TInsuranceUnpurchaseApplyServiceImpl.java
...ry/service/impl/TInsuranceUnpurchaseApplyServiceImpl.java
+53
-15
TInsuranceUnpurchasePersonServiceImpl.java
...y/service/impl/TInsuranceUnpurchasePersonServiceImpl.java
+53
-18
No files found.
yifu-common/yifu-common-core/src/main/java/com/yifu/cloud/plus/v1/yifu/common/core/constant/CommonConstants.java
View file @
4a7314cb
...
...
@@ -370,6 +370,8 @@ public interface CommonConstants {
String
ID
=
"ID"
;
String
PARAM_IS_NOT_ERROR
=
"传参异常,请检查参数"
;
int
EXCEL_EXPORT_LIMIT
=
60000
;
int
EXCEL_EXPORT_LIMIT_NEW
=
20000
;
// 给量大的表导出使用
int
EXCEL_EXPORT_LIMIT_3
=
30000
;
...
...
yifu-salary/yifu-salary-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/service/impl/TInsuranceUnpurchaseApplyServiceImpl.java
View file @
4a7314cb
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
salary
.
service
.
impl
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.EasyExcelFactory
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.write.metadata.WriteSheet
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
...
...
@@ -39,6 +40,7 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.time.LocalDateTime
;
...
...
@@ -114,22 +116,24 @@ public class TInsuranceUnpurchaseApplyServiceImpl extends ServiceImpl<TInsurance
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter
excelWriter
=
EasyExcel
.
write
(
out
,
TInsuranceUnpurchaseApplyVo
.
class
).
build
();
int
index
=
0
;
// if (count > CommonConstants.EXCEL_EXPORT_LIMIT_NEW) {
// list.add(new ExportErrorVo("导出条数最大为20000条"));
// }
if
(
count
>
CommonConstants
.
ZERO_INT
)
{
for
(
int
i
=
0
;
i
<=
count
;
i
=
i
+
CommonConstants
.
EXCEL_EXPORT_LIMIT_NEW
)
{
// 获取实际记录
searchVo
.
setLimitStart
(
i
);
searchVo
.
setLimitEnd
(
CommonConstants
.
EXCEL_EXPORT_LIMIT_NEW
);
list
=
baseMapper
.
getTInsuranceUnpurchaseApplyExportList
(
searchVo
);
if
(
Common
.
isNotNull
(
list
))
{
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(
"含风险项目不购买申请表"
+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
index
++;
}
if
(
Common
.
isNotNull
(
list
))
{
list
.
clear
();
if
(
count
>
CommonConstants
.
EXCEL_EXPORT_LIMIT_NEW
)
{
exportError
(
response
,
"数据超过2万条,请联系管理员后端导出"
);
}
else
{
for
(
int
i
=
0
;
i
<=
count
;
i
=
i
+
CommonConstants
.
EXCEL_EXPORT_LIMIT_NEW
)
{
// 获取实际记录
searchVo
.
setLimitStart
(
i
);
searchVo
.
setLimitEnd
(
CommonConstants
.
EXCEL_EXPORT_LIMIT_NEW
);
list
=
baseMapper
.
getTInsuranceUnpurchaseApplyExportList
(
searchVo
);
if
(
Common
.
isNotNull
(
list
))
{
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(
"含风险项目不购买申请表"
+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
index
++;
}
if
(
Common
.
isNotNull
(
list
))
{
list
.
clear
();
}
}
}
}
else
{
...
...
@@ -559,4 +563,38 @@ public class TInsuranceUnpurchaseApplyServiceImpl extends ServiceImpl<TInsurance
insuranceUnpurchaseApply
,
insuranceUnpurchaseApply
.
getCreateUserDeptId
());
}
private
void
exportError
(
HttpServletResponse
response
,
String
errorMessage
)
{
String
fileName
=
"导出异常"
+
DateUtil
.
getThisTime
()
+
CommonConstants
.
XLSX
;
//获取要导出的列表
List
<
ExportErrorVo
>
list
=
new
ArrayList
<>();
list
.
add
(
new
ExportErrorVo
(
errorMessage
));
ServletOutputStream
out
=
null
;
try
{
out
=
response
.
getOutputStream
();
response
.
setContentType
(
CommonConstants
.
MULTIPART_FORM_DATA
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setHeader
(
CommonConstants
.
CONTENT_DISPOSITION
,
CommonConstants
.
ATTACHMENT_FILENAME
+
URLEncoder
.
encode
(
fileName
,
"UTF-8"
));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter
excelWriter
=
EasyExcelFactory
.
write
(
out
,
ExportErrorVo
.
class
).
build
();
int
index
=
0
;
WriteSheet
writeSheet
=
EasyExcelFactory
.
writerSheet
(
"异常信息"
+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
if
(
Common
.
isNotNull
(
list
))
{
list
.
clear
();
}
out
.
flush
();
excelWriter
.
finish
();
}
catch
(
Exception
e
)
{
log
.
error
(
"执行异常"
,
e
);
}
finally
{
try
{
if
(
null
!=
out
)
{
out
.
close
();
}
}
catch
(
IOException
e
)
{
log
.
error
(
"执行异常"
,
e
);
}
}
}
}
yifu-salary/yifu-salary-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/service/impl/TInsuranceUnpurchasePersonServiceImpl.java
View file @
4a7314cb
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
salary
.
service
.
impl
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.EasyExcelFactory
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.write.metadata.WriteSheet
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
...
...
@@ -28,6 +29,7 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
...
...
@@ -83,25 +85,25 @@ public class TInsuranceUnpurchasePersonServiceImpl extends ServiceImpl<TInsuranc
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter
excelWriter
=
EasyExcel
.
write
(
out
,
TInsuranceUnpurchasePersonVo
.
class
).
build
();
int
index
=
0
;
if
(
count
>
CommonConstants
.
EXCEL_EXPORT_LIMIT_NEW
){
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(
"含风险项目不购买申请明细表"
+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
}
if
(
count
>
CommonConstants
.
ZERO_INT
){
for
(
int
i
=
0
;
i
<=
count
;
i
=
i
+
CommonConstants
.
EXCEL_EXPORT_LIMIT_NEW
)
{
// 获取实际记录
searchVo
.
setLimitStart
(
i
);
searchVo
.
setLimitEnd
(
CommonConstants
.
EXCEL_EXPORT_LIMIT_NEW
);
list
=
baseMapper
.
getTInsuranceUnpurchaseInfoExportList
(
searchVo
);
if
(
Common
.
isNotNull
(
list
)){
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(
"含风险项目不购买申请明细表"
+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
index
++;
}
if
(
Common
.
isNotNull
(
list
)){
list
.
clear
();
}
}
if
(
count
>
CommonConstants
.
EXCEL_EXPORT_LIMIT_NEW
)
{
exportError
(
response
,
"数据超过2万条,请联系管理员后端导出"
);
}
else
{
for
(
int
i
=
0
;
i
<=
count
;
i
=
i
+
CommonConstants
.
EXCEL_EXPORT_LIMIT_NEW
)
{
// 获取实际记录
searchVo
.
setLimitStart
(
i
);
searchVo
.
setLimitEnd
(
CommonConstants
.
EXCEL_EXPORT_LIMIT_NEW
);
list
=
baseMapper
.
getTInsuranceUnpurchaseInfoExportList
(
searchVo
);
if
(
Common
.
isNotNull
(
list
))
{
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(
"含风险项目不购买申请明细表"
+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
index
++;
}
if
(
Common
.
isNotNull
(
list
))
{
list
.
clear
();
}
}
}
}
else
{
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(
"含风险项目不购买申请明细表"
+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
...
...
@@ -221,5 +223,38 @@ public class TInsuranceUnpurchasePersonServiceImpl extends ServiceImpl<TInsuranc
}
}
private
void
exportError
(
HttpServletResponse
response
,
String
errorMessage
)
{
String
fileName
=
"导出异常"
+
DateUtil
.
getThisTime
()
+
CommonConstants
.
XLSX
;
//获取要导出的列表
List
<
ExportErrorVo
>
list
=
new
ArrayList
<>();
list
.
add
(
new
ExportErrorVo
(
errorMessage
));
ServletOutputStream
out
=
null
;
try
{
out
=
response
.
getOutputStream
();
response
.
setContentType
(
CommonConstants
.
MULTIPART_FORM_DATA
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setHeader
(
CommonConstants
.
CONTENT_DISPOSITION
,
CommonConstants
.
ATTACHMENT_FILENAME
+
URLEncoder
.
encode
(
fileName
,
"UTF-8"
));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter
excelWriter
=
EasyExcelFactory
.
write
(
out
,
ExportErrorVo
.
class
).
build
();
int
index
=
0
;
WriteSheet
writeSheet
=
EasyExcelFactory
.
writerSheet
(
"异常信息"
+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
if
(
Common
.
isNotNull
(
list
))
{
list
.
clear
();
}
out
.
flush
();
excelWriter
.
finish
();
}
catch
(
Exception
e
)
{
log
.
error
(
"执行异常"
,
e
);
}
finally
{
try
{
if
(
null
!=
out
)
{
out
.
close
();
}
}
catch
(
IOException
e
)
{
log
.
error
(
"执行异常"
,
e
);
}
}
}
}
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