From e8f25dbd8e774360a3ce2172de6a8415a5afb498 Mon Sep 17 00:00:00 2001 From: whb <17803890193@163.com> Date: Tue, 16 Apr 2024 15:24:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=B4=A2=E5=8A=A1=E6=8C=87?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StuExportToExcelController.java | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/main/java/com/sztzjy/digital_credit/controller/StuExportToExcelController.java diff --git a/src/main/java/com/sztzjy/digital_credit/controller/StuExportToExcelController.java b/src/main/java/com/sztzjy/digital_credit/controller/StuExportToExcelController.java new file mode 100644 index 0000000..45cc617 --- /dev/null +++ b/src/main/java/com/sztzjy/digital_credit/controller/StuExportToExcelController.java @@ -0,0 +1,78 @@ +package com.sztzjy.digital_credit.controller; + +import cn.hutool.core.util.IdUtil; +import com.sztzjy.digital_credit.annotation.AnonymousAccess; +import com.sztzjy.digital_credit.entity.StuFinancialStatements; +import com.sztzjy.digital_credit.entity.StuFinancialStatementsExample; +import com.sztzjy.digital_credit.mapper.StuFinancialStatementsMapper; +import com.sztzjy.digital_credit.util.excel.FilePortUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import javax.validation.constraints.NotBlank; +import java.util.Arrays; +import java.util.List; + +/** + * @author 17803 + * @date 2024-04-16 9:47 + */ + +@Api(tags = "导出Excel") +@RestController +@RequestMapping("api/stu/enterprise/export") +public class StuExportToExcelController { + + @Autowired + private StuFinancialStatementsMapper financialStatementsMapper; + + + + //TODO + // 财务指标Excel 未导出 + + + @AnonymousAccess + @GetMapping("/generalViewExport") + @ApiOperation("资产负债表") + public void balanceSheet(HttpServletResponse response,@NotBlank @RequestParam @ApiParam("资产负债表/现金流量表/利润表") String module) { +// //导出的表名 +// String title = IdUtil.simpleUUID(); + //表中第一行表头字段 + String[] headers = {"序号", "指标名称", "2023/12/31","2022/12/31","2021/12/31"}; + + StuFinancialStatementsExample financialStatementsExample = new StuFinancialStatementsExample(); + financialStatementsExample.createCriteria().andModuleEqualTo(module); + //实际数据结果集 + List financialStatementsList = financialStatementsMapper.selectByExample(financialStatementsExample); + + + //List tchGeneralViewDTOS = userService.selectAllGeneralViewList(schoolId); + + //具体需要写入excel需要哪些字段,这些字段取自UserReward类,也就是上面的实际数据结果集的泛型 + List listColumn = Arrays.asList("serialNumber", "indicatorName", "dateOne", "dateTwo","dateThree"); + try { + FilePortUtil.exportExcel(response, module, headers, financialStatementsList, listColumn); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + + + + + + + + + +}