This commit is contained in:
wucongxing8150 2025-07-07 17:34:12 +08:00
parent c53320b516
commit e82ee7e019

View File

@ -98,11 +98,15 @@ public class CaseplatformCaseExcelController {
// 结算导出 // 结算导出
@ApiOperation("结算导出") @ApiOperation("结算导出")
@GetMapping("/caseplatformCase/settlementExcel") @GetMapping("/caseplatformCase/settlementExcel")
public void exportExpertCaseExcel(HttpServletResponse response, @Valid CaseplatformCaseQueryForm queryForm) { public void exportExpertCaseExceli(HttpServletResponse response, @Valid CaseplatformCaseQueryForm queryForm) {
try { try {
List<ExportExpertCaseExcelVo> list = caseplatformCaseService.exportExpertCaseExcel(queryForm); List<ExportExpertCaseExcelVo> list = caseplatformCaseService.exportExpertCaseExcel(queryForm);
List<ExportExpertCaseExcelVo> processedList = caseplatformCaseService.exportExpertCaseExcelProcess(list); List<ExportExpertCaseExcelVo> processedList = caseplatformCaseService.exportExpertCaseExcelProcess(list);
// 设置本地文件路径
String filePath = "./病例数据.xlsx";
FileOutputStream outputStream = new FileOutputStream(filePath);
// 字段标题 // 字段标题
List<List<String>> head = Arrays.asList( List<List<String>> head = Arrays.asList(
Collections.singletonList("序号"), Collections.singletonList("序号"),
@ -132,7 +136,7 @@ public class CaseplatformCaseExcelController {
contentStyle.setVerticalAlignment(VerticalAlignment.CENTER); contentStyle.setVerticalAlignment(VerticalAlignment.CENTER);
// 1. 创建ExcelWriter // 1. 创建ExcelWriter
ExcelWriter writer = EasyExcel.write(response.getOutputStream(), ExportExpertCaseExcelVo.class) ExcelWriter writer = EasyExcel.write(outputStream, ExportExpertCaseExcelVo.class)
.head(head) .head(head)
.excelType(ExcelTypeEnum.XLSX) .excelType(ExcelTypeEnum.XLSX)
.registerWriteHandler(new HorizontalCellStyleStrategy(headStyle, contentStyle)) .registerWriteHandler(new HorizontalCellStyleStrategy(headStyle, contentStyle))
@ -168,6 +172,65 @@ public class CaseplatformCaseExcelController {
} }
} }
// 结算导出
@ApiOperation("结算导出")
@GetMapping("/caseplatformCase/settlementExcel")
public void exportExpertCaseExcel(HttpServletResponse response, @Valid CaseplatformCaseQueryForm queryForm) {
try {
List<ExportExpertCaseExcelVo> list = caseplatformCaseService.exportExpertCaseExcel(queryForm);
List<ExportExpertCaseExcelVo> processedList = caseplatformCaseService.exportExpertCaseExcelProcess(list);
// 字段标题
List<List<String>> head = Arrays.asList(
Collections.singletonList("序号"),
Collections.singletonList("银行"),
Collections.singletonList("账号所在省份"),
Collections.singletonList("账户所在地市"),
Collections.singletonList("卡号"),
Collections.singletonList("姓名"),
Collections.singletonList("实发"),
Collections.singletonList("备注"),
Collections.singletonList("个税"),
Collections.singletonList("应发"),
Collections.singletonList("单位"),
Collections.singletonList("电话"),
Collections.singletonList("身份证号"),
Collections.singletonList("关联病例")
);
// 1设置表头样式
WriteCellStyle headStyle = new WriteCellStyle();
// 1.1设置表头数据居中
headStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
// 2设置表格内容样式
WriteCellStyle bodyStyle = new WriteCellStyle();
// 2.1设置表格内容水平居中
bodyStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
// 2.2设置表格内容垂直居中
bodyStyle.setVerticalAlignment(VerticalAlignment.CENTER);
// 3设置表格sheet样式
WriteSheet sheet = EasyExcel.writerSheet().head(head).sheetNo(1).build();
// 4拿到表格处理对象
ExcelWriter writer = EasyExcel.write(response.getOutputStream()).needHead(true).excelType(ExcelTypeEnum.XLSX)
// 设置单元格的风格样式
.registerWriteHandler(new HorizontalCellStyleStrategy(headStyle, bodyStyle))
.build();
// 5写入excel数据
writer.write(processedList, sheet);
// 6通知浏览器以附件的形式下载处理设置返回头要注意文件名有中文
String fileName = URLEncoder.encode("结算导出", "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
response.setContentType("multipart/form-data");
response.setCharacterEncoding("utf-8");
writer.finish();
} catch (Exception e) {
e.printStackTrace();
}
}
@ApiOperation("结算导入") @ApiOperation("结算导入")