This commit is contained in:
wwb 2026-01-06 09:51:29 +08:00
parent 670456654b
commit d3b8a38f99
1 changed files with 9 additions and 3 deletions

View File

@ -38,6 +38,7 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ResourceLoader;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -76,6 +77,10 @@ public class StatementAccountController {
@Resource
private CustomerService customerService;
@Resource
private ResourceLoader resourceLoader;
@PostMapping("/create")
@Operation(summary = "创建对账单")
@PreAuthorize("@ss.hasPermission('oms:statement-account:create')")
@ -217,12 +222,13 @@ public class StatementAccountController {
// 填充list 的时候还要注意 模板中{.} 多了个点 表示list
// 如果填充list的对象是map,必须包涵所有list的key,哪怕数据为null必须使用map.put(key,null)
//docker生成路径
URL templateFileUrl = ResourceUtil.getResource("templates/dzd_excel_templates.xlsx");
//URL templateFileUrl = ResourceUtil.getResource("templates/dzd_excel_templates.xlsx");
org.springframework.core.io.Resource resource = resourceLoader.getResource("classpath:templates/dzd_excel_templates.xlsx"); // 例如获取index.html
String templateFileUrl = resource.getURI().toString();
String pathUrl = System.getProperty("user.dir") + "/pdffile";
String fileName = pathUrl+"/对账单-"+customer.getName()+"-"+DateUtil.date(statementAccount.getDate().toLocalDate()).toString("YYYYMM")+".xlsx";
try (ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(templateFileUrl.getPath()).build()) {
try (ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(templateFileUrl).build()) {
WriteSheet writeSheet = EasyExcel.writerSheet().build();
// 直接写入数据
excelWriter.fill(models, writeSheet);