Commit 050420e6 authored by hongguangwu's avatar hongguangwu

MVP1.4导出-最后优化

parent ad06fedd
......@@ -84,12 +84,12 @@ public class TStatisticsCurrentReportController {
@Operation(description = "导出统计-本期申报 hasPermission('salary_tstatisticscurrentreport-export')")
@PostMapping("/export")
@PreAuthorize("@pms.hasPermission('salary_tstatisticscurrentreport-export')")
public void export(HttpServletResponse response, @RequestBody TStatisticsCurrentReportSearchVo searchVo) {
if (Common.isEmpty(searchVo.getDeclareMonth())) {
public void export(HttpServletResponse response, @RequestBody TStatisticsCurrentReportSearchVo tStatisticsCurrentReport) {
if (Common.isEmpty(tStatisticsCurrentReport.getDeclareMonth())) {
String nowMonth = DateUtil.addMonth(0); //本月
searchVo.setDeclareMonth(nowMonth);
tStatisticsCurrentReport.setDeclareMonth(nowMonth);
}
tStatisticsCurrentReportService.listExport(response, searchVo);
tStatisticsCurrentReportService.listExport(response, tStatisticsCurrentReport);
}
/**
......
......@@ -46,7 +46,7 @@ public interface TStatisticsCurrentReportService extends IService<TStatisticsCur
* @Date: 2022/8/19 17:04
* @return: void
**/
void listExport(HttpServletResponse response, TStatisticsCurrentReportSearchVo searchVo);
void listExport(HttpServletResponse response, TStatisticsCurrentReportSearchVo tStatisticsCurrentReport);
/**
* @param yearMonth
......
......@@ -72,11 +72,11 @@ public class TStatisticsCurrentReportServiceImpl extends ServiceImpl<TStatistics
* @return
*/
@Override
public void listExport(HttpServletResponse response, TStatisticsCurrentReportSearchVo searchVo) {
public void listExport(HttpServletResponse response, TStatisticsCurrentReportSearchVo tStatisticsCurrentReport) {
String fileName = "本期申报批量导出" + DateUtil.getThisTime() + CommonConstants.XLSX;
//获取要导出的列表
List<TStatisticsCurrentReport> list = new ArrayList<>();
long count = noPageCountDiy(searchVo);
long count = noPageCountDiy(tStatisticsCurrentReport);
ServletOutputStream out = null;
try {
out = response.getOutputStream();
......@@ -84,15 +84,15 @@ public class TStatisticsCurrentReportServiceImpl extends ServiceImpl<TStatistics
response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, "UTF-8"));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcelFactory.write(out, TStatisticsCurrentReport.class).includeColumnFiledNames(searchVo.getExportFields()).build();
ExcelWriter excelWriter = EasyExcelFactory.write(out, TStatisticsCurrentReport.class).includeColumnFiledNames(tStatisticsCurrentReport.getExportFields()).build();
int index = 0;
WriteSheet writeSheet;
if (count > CommonConstants.ZERO_INT) {
for (int i = 0; i <= count; i = i + CommonConstants.EXCEL_EXPORT_LIMIT_3) {
// 获取实际记录
searchVo.setLimitStart(i);
searchVo.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT_3);
list = noPageDiy(searchVo);
tStatisticsCurrentReport.setLimitStart(i);
tStatisticsCurrentReport.setLimitEnd(CommonConstants.EXCEL_EXPORT_LIMIT_3);
list = noPageDiy(tStatisticsCurrentReport);
if (Common.isNotNull(list)) {
writeSheet = EasyExcelFactory.writerSheet("本期申报" + index).build();
excelWriter.write(list, writeSheet);
......
......@@ -319,9 +319,9 @@
<include refid="tStatisticsCurrentReport_where"/>
</where>
order by a.DECLARE_MONTH desc
<if test="searchVo != null">
<if test="searchVo.limitStart != null">
limit #{searchVo.limitStart},#{searchVo.limitEnd}
<if test="tStatisticsCurrentReport != null">
<if test="tStatisticsCurrentReport.limitStart != null">
limit #{tStatisticsCurrentReport.limitStart},#{tStatisticsCurrentReport.limitEnd}
</if>
</if>
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment