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(); + } + } + + + + + + + + + + + +}