From 3f44e29a7e2620bcc498f9d4bf7c454b00225ee2 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 23 一月 2024 10:20:51 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java | 86 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 86 insertions(+), 0 deletions(-)
diff --git a/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java b/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java
index b236b07..b186485 100644
--- a/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java
+++ b/server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java
@@ -2,6 +2,9 @@
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
+import com.doumee.core.utils.Constants;
+import com.doumee.dao.business.model.ApplyDetail;
+import com.doumee.dao.business.model.InsuranceApply;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
@@ -397,6 +400,89 @@
return stringValue;
}
+ public void exportApplyDetail(InsuranceApply model, HttpServletResponse response) {
+ try {
+ String encodeFileName = URLEncoder.encode("鎶曚繚璇︽儏鍗昣"+model.getCompanyName()+"_"+model.getSolutionsName(), Charset.forName("UTF-8").toString()) + ".xlsx";
+ response.setHeader("Content-Disposition","attachment;filename=" + encodeFileName);
+ response.setContentType("application/octet-stream");
+ response.setHeader("eva-opera-type", "download");
+ response.setHeader("eva-download-filename", encodeFileName);
+ this.exportApplyDetailDo(model,"鎶曚繚鐢宠琛�", response.getOutputStream());
+ } catch (IOException e) {
+ throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e);
+ }
+ }
+
+ /**
+ * 瀵煎嚭鍒版寚瀹氳緭鍑烘祦
+ * @param data 鏁版嵁
+ * @param sheetName Sheet鍚嶇О
+ * @param os 杈撳嚭娴�
+ */
+ public void exportApplyDetailDo (InsuranceApply data, String sheetName, OutputStream os) {
+ SXSSFWorkbook sxssfWorkbook;
+ try {
+ sxssfWorkbook = new SXSSFWorkbook();
+ Sheet sheet = sxssfWorkbook.createSheet(sheetName);
+ sheet.createFreezePane(0, 1);
+ sheet.addMergedRegion(new CellRangeAddress(0 ,0,0,6));
+ Row title = sheet.createRow(0);
+ title.setHeight((short) 1000);
+ Cell c = title.createCell(0);
+ c.setCellValue(sheetName);
+ configFirstCell(sxssfWorkbook,c);
+ Row header1 = sheet.createRow(1);
+ header1.createCell(0).setCellValue("鎶曚繚浼佷笟");
+ header1.createCell(1).setCellValue("淇濋櫓鏂规");
+ header1.createCell(2).setCellValue("淇濋櫓鐢熸晥璧锋湡");
+ header1.createCell(3).setCellValue("淇濋櫓鐢熸晥姝㈡湡");
+ header1.createCell(4).setCellValue("鎶曚繚浜烘暟");
+ header1.createCell(5).setCellValue("鎬昏垂鐢紙鍏冿級");
+ Row header2 = sheet.createRow(2);
+ header2.createCell(0).setCellValue(data.getCompanyName());
+ header2.createCell(1).setCellValue(data.getSolutionsName());
+ header2.createCell(2).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getStartTime()));
+ header2.createCell(3).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getEndTime()));
+ header2.createCell(4).setCellValue(data.getInsureNum());
+ header2.createCell(5).setCellValue(Constants.formatBigdecimal2Float(data.getFee()).toString());
+ //绌虹櫧琛�
+ Row header3 = sheet.createRow(3);
+ sheet.addMergedRegion(new CellRangeAddress(3 ,3,0,6));
+
+ Row header4 = sheet.createRow(4);
+ header4.createCell(0).setCellValue("搴忓彿");
+ header4.createCell(1).setCellValue("鍛樺伐濮撳悕");
+ header4.createCell(2).setCellValue("鎬у埆");
+ header4.createCell(3).setCellValue("韬唤璇佸彿");
+ header4.createCell(4).setCellValue("娲鹃仯鍗曚綅");
+ header4.createCell(5).setCellValue("鎵�灞炲伐绉�");
+ if(data.getApplyDetailList()!=null)
+ // 鍒涘缓鏁版嵁璁板綍
+ for (int rowIndex = 0; rowIndex < data.getApplyDetailList().size(); rowIndex++) {
+ ApplyDetail d = data.getApplyDetailList().get(rowIndex);
+ Row header5 = sheet.createRow(rowIndex + 4);
+ header5.createCell(0).setCellValue(rowIndex+1);
+ header5.createCell(1).setCellValue(StringUtils.defaultString(d.getMemberName(),""));
+ header5.createCell(2).setCellValue(Constants.equalsInteger(d.getSex(),0)?"鐢�":(Constants.equalsInteger(d.getSex(),1)?"濂�":"-"));
+ header5.createCell(3).setCellValue(StringUtils.defaultString(d.getIdcardNo(),""));
+ header5.createCell(4).setCellValue(StringUtils.defaultString(d.getDuName(),""));
+ header5.createCell(5).setCellValue(StringUtils.defaultString(d.getWorkTypeName(),""));
+ }
+ sxssfWorkbook.write(os);
+ os.close();
+ } catch (Exception e) {
+ throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e);
+ } finally {
+ if (os != null) {
+ try {
+ os.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
@Data
@AllArgsConstructor
private static class ColumnInfo {
--
Gitblit v1.9.3