From bd2d3096021fc03aecea16fccd2463ea424066a4 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期三, 24 一月 2024 18:12:48 +0800
Subject: [PATCH] 111
---
server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java | 301 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 301 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..2eb2d10 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,11 @@
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
+import com.doumee.core.utils.Constants;
+import com.doumee.dao.business.model.ApplyChagneDetail;
+import com.doumee.dao.business.model.ApplyChange;
+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 +402,302 @@
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();
+ }
+ }
+ }
+ }
+
+ /**
+ * 鎹㈠巶鐢宠琛ㄥ鍑�
+ * @param model
+ * @param response
+ */
+
+ public void exportChangeUnitExcel(ApplyChange 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.exportChangeUnitExcelDo(model,"鎹㈠巶鐢宠琛�", response.getOutputStream());
+ } catch (IOException e) {
+ throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e);
+ }
+ }
+
+ /**
+ * 鍔犲噺鐢宠琛ㄥ鍑�
+ * @param model
+ * @param response
+ */
+ public void exportJiajianBaoExcel(ApplyChange 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.exportJiajianBaoExcelDo(model,"鍔犲噺淇濈敵璇疯〃_", response.getOutputStream());
+ } catch (IOException e) {
+ throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e);
+ }
+ }
+
+ /**
+ * 瀵煎嚭鍔犲噺淇濈敵璇疯鍗�
+ * @param data 鏁版嵁
+ * @param sheetName Sheet鍚嶇О
+ * @param os 杈撳嚭娴�
+ */
+ public void exportJiajianBaoExcelDo (ApplyChange 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,8));
+ 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(3).setCellValue("淇濋櫓鏂规");
+ header1.createCell(4).setCellValue("淇濆崟鍙�");
+ header1.createCell(5).setCellValue("淇濋櫓鐢熸晥璧锋湡");
+ header1.createCell(6).setCellValue("淇濋櫓鐢熸晥姝㈡湡");
+ header1.createCell(9).setCellValue("鍔犱繚浜烘暟");
+ header1.createCell(10).setCellValue("鍑忎繚浜烘暟");
+ header1.createCell(11).setCellValue("鏈熸湜鎵瑰崟鐢熸晥鏈�");
+ sheet.addMergedRegion(new CellRangeAddress(1 ,1,0,2));
+ sheet.addMergedRegion(new CellRangeAddress(1 ,1,6,8));
+
+
+ Row header2 = sheet.createRow(2);
+ header2.createCell(0).setCellValue(data.getCompanyName());
+ header2.createCell(3).setCellValue(data.getSolutionsName());
+ header2.createCell(4).setCellValue(data.getApplyCode());
+ header2.createCell(5).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getStartTime()));
+ header2.createCell(6).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getEndTime()));
+ header2.createCell(9).setCellValue(data.getAddNum());
+ header2.createCell(10).setCellValue(data.getDelNum());
+ header2.createCell(11).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getValidTime()));
+ sheet.addMergedRegion(new CellRangeAddress(2 ,2,0,2));
+ sheet.addMergedRegion(new CellRangeAddress(2 ,2,6,8));
+ //绌虹櫧琛�
+ Row header3 = sheet.createRow(3);
+ header2.createCell(0).setCellValue("鍔犱繚浜哄憳");
+ header2.createCell(6).setCellValue("鍑忎繚浜哄憳");
+ sheet.addMergedRegion(new CellRangeAddress(3 ,3,0,5));
+ sheet.addMergedRegion(new CellRangeAddress(3 ,3,6,11));
+
+ 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("鎵�灞炲伐绉�");
+ header4.createCell(6).setCellValue("搴忓彿");
+ header4.createCell(7).setCellValue("鍛樺伐濮撳悕");
+ header4.createCell(8).setCellValue("鎬у埆");
+ header4.createCell(9).setCellValue("韬唤璇佸彿");
+ header4.createCell(10).setCellValue("娲鹃仯鍗曚綅");
+ header4.createCell(11).setCellValue("鎵�灞炲伐绉�");
+ int maxNum = data.getAddNum()>data.getDelNum()?data.getAddNum():data.getDelNum();
+ // 鍒涘缓鏁版嵁璁板綍
+ for (int rowIndex = 0; rowIndex <maxNum; rowIndex++) {
+ ApplyChagneDetail addModel = data.getAddDetailList().size()> rowIndex?data.getAddDetailList().get(rowIndex):null;
+ ApplyChagneDetail delModel = data.getDelDetailList().size()> rowIndex?data.getDelDetailList().get(rowIndex):null;
+ Row header5 = sheet.createRow(rowIndex + 5);
+ if(addModel!=null){
+ header5.createCell(0).setCellValue(rowIndex+1);
+ header5.createCell(1).setCellValue(StringUtils.defaultString(addModel.getMemberName(),""));
+ header5.createCell(2).setCellValue(Constants.equalsInteger(addModel.getSex(),0)?"鐢�":(Constants.equalsInteger(addModel.getSex(),1)?"濂�":"-"));
+ header5.createCell(3).setCellValue(StringUtils.defaultString(addModel.getIdcardNo(),""));
+ header5.createCell(4).setCellValue(StringUtils.defaultString(addModel.getDuName(),""));
+ header5.createCell(5).setCellValue(StringUtils.defaultString(addModel.getWorkTypeName(),""));
+ }
+ if(delModel!=null){
+ header5.createCell(6).setCellValue(rowIndex+1);
+ header5.createCell(7).setCellValue(StringUtils.defaultString(delModel.getMemberName(),""));
+ header5.createCell(8).setCellValue(Constants.equalsInteger(delModel.getSex(),0)?"鐢�":(Constants.equalsInteger(delModel.getSex(),1)?"濂�":"-"));
+ header5.createCell(9).setCellValue(StringUtils.defaultString(delModel.getIdcardNo(),""));
+ header5.createCell(10).setCellValue(StringUtils.defaultString(delModel.getDuName(),""));
+ header5.createCell(11).setCellValue(StringUtils.defaultString(delModel.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();
+ }
+ }
+ }
+ }
+ /**
+ * 瀵煎嚭鍔犲噺淇濈敵璇疯鍗�
+ * @param data 鏁版嵁
+ * @param sheetName Sheet鍚嶇О
+ * @param os 杈撳嚭娴�
+ */
+ public void exportChangeUnitExcelDo (ApplyChange 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,8));
+ 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(3).setCellValue("淇濆崟鍙�");
+ header1.createCell(4).setCellValue("淇濋櫓鐢熸晥璧锋湡");
+ header1.createCell(5).setCellValue("淇濋櫓鐢熸晥姝㈡湡");
+ header1.createCell(6).setCellValue("鎹㈠巶浜烘暟");
+ header1.createCell(7).setCellValue("鏈熸湜鎵瑰崟鐢熸晥鏈�");
+ sheet.addMergedRegion(new CellRangeAddress(1 ,1,1,2));
+
+ Row header2 = sheet.createRow(2);
+ header2.createCell(0).setCellValue(data.getCompanyName());
+ header2.createCell(1).setCellValue(data.getSolutionsName());
+ header2.createCell(3).setCellValue(data.getApplyCode());
+ header2.createCell(4).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getStartTime()));
+ header2.createCell(5).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getEndTime()));
+ header2.createCell(6).setCellValue(data.getChangeNum());
+ header2.createCell(7).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getValidTime()));
+ sheet.addMergedRegion(new CellRangeAddress(2 ,2,1,2));
+
+ Row header4 = sheet.createRow(3);
+ header4.createCell(0).setCellValue("搴忓彿");
+ header4.createCell(1).setCellValue("鍛樺伐濮撳悕");
+ header4.createCell(2).setCellValue("鎬у埆");
+ header4.createCell(3).setCellValue("韬唤璇佸彿");
+ header4.createCell(4).setCellValue("鍘熸淳閬e崟浣�");
+ header4.createCell(5).setCellValue("鍘熸墍鎵�灞炲伐绉�");
+ header4.createCell(6).setCellValue("鏇存敼鍚庢淳閬e崟浣�");
+ header4.createCell(7).setCellValue("鏇存敼鍚庢墍灞炲伐绉�");
+ // 鍒涘缓鏁版嵁璁板綍
+ for (int rowIndex = 0; rowIndex <data.getChangeDetailList().size(); rowIndex++) {
+ ApplyChagneDetail addModel = data.getChangeDetailList().get(rowIndex);
+ Row header5 = sheet.createRow(rowIndex + 4);
+ header5.createCell(0).setCellValue(rowIndex+1);
+ header5.createCell(1).setCellValue(StringUtils.defaultString(addModel.getMemberName(),""));
+ header5.createCell(2).setCellValue(Constants.equalsInteger(addModel.getSex(),0)?"鐢�":(Constants.equalsInteger(addModel.getSex(),1)?"濂�":"-"));
+ header5.createCell(3).setCellValue(StringUtils.defaultString(addModel.getIdcardNo(),""));
+ header5.createCell(4).setCellValue(StringUtils.defaultString(addModel.getOldDuName(),""));
+ header5.createCell(5).setCellValue(StringUtils.defaultString(addModel.getOldWorkTypeName(),""));
+ header5.createCell(6).setCellValue(StringUtils.defaultString(addModel.getDuName(),""));
+ header5.createCell(7).setCellValue(StringUtils.defaultString(addModel.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