From 4001e7479d33cd3fa5a8e00d07ae191ee95c5793 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期三, 03 四月 2024 19:02:07 +0800
Subject: [PATCH] git ch

---
 server/service/src/main/java/com/doumee/core/annotation/excel/ExcelExporter.java |  332 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 312 insertions(+), 20 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 79aef73..a371437 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
@@ -263,7 +263,7 @@
         style.setAlignment(HorizontalAlignment.CENTER);
         style.setVerticalAlignment(VerticalAlignment.CENTER);
         // 璁剧疆鑳屾櫙
-        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+//        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
 //        style.setFillForegroundColor(columnConfig.dataBackgroundColor().getIndex());
         // 瀛椾綋
         Font font = workbook.createFont();
@@ -1280,6 +1280,8 @@
             throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e);
         }
     }
+
+
     public void exportUnionApplyDetailDo (UnionApply data, String sheetName, OutputStream os) {
         SXSSFWorkbook sxssfWorkbook;
         try {
@@ -1387,17 +1389,17 @@
         try {
             sxssfWorkbook = new SXSSFWorkbook();
             Sheet sheet = sxssfWorkbook.createSheet(sheetName);
-            for (int i = 0; i < 8; i++) {
-                sheet.setColumnWidth(i, ((i==3|| i== 4|| i== 5 ||i== 6 || i==7)?16:8) * 2 * 256);
+            for (int i = 0; i < 9; i++) {
+                sheet.setColumnWidth(i, ((i==3|| i== 4|| i== 5 ||i== 6 || i==7|| i==8 || i==9)?16:8) * 2 * 256);
             }
             sheet.createFreezePane(0, 1);
-            sheet.addMergedRegion(new CellRangeAddress(0   ,0,0,7));
+            sheet.addMergedRegion(new CellRangeAddress(0   ,0,0,8));
             Row title = sheet.createRow(0);
             title.setHeight((short) 2000);
             Cell c = title.createCell(0);
             c.setCellValue(sheetName);
             configFirstCell(sxssfWorkbook,c);
-            for (int i = 0; i < 8; i++) {
+            for (int i = 0; i < 9; i++) {
                 if(i>0){
                     title.createCell(i).setCellValue("");
                 }
@@ -1433,7 +1435,6 @@
                 configDataCell(sxssfWorkbook,header2.getCell(i));
             }
 
-
             Row header3 = sheet.createRow(3);
             header3.createCell(0).setCellValue("琚繚闄╀汉");
             header3.createCell(1).setCellValue(data.getCompanyNames());
@@ -1450,23 +1451,10 @@
             sheet.addMergedRegion(new CellRangeAddress(3  ,3,1,8));
 
 
-            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("鍘熸淳閬e崟浣�");
-            header4.createCell(6).setCellValue("鍘熸墍鎵�灞炲伐绉�");
-            header4.createCell(7).setCellValue("鏇存敼鍚庢淳閬e崟浣�");
-            header4.createCell(8).setCellValue("鏇存敼鍚庢墍灞炲伐绉�");
-            for (int i = 0; i < 9; i++) {
-                configFirstCell(sxssfWorkbook,header4.getCell(i));
-            }
 
             List<ApplyChagneDetail> otherChangeDetailList = data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.TWO)).collect(Collectors.toList());
 
-            Integer row = 4;
+            Integer row = 3;
 
             if(CollectionUtils.isNotEmpty(otherChangeDetailList)){
                 row = row + 1;
@@ -1747,4 +1735,308 @@
         }
         return null;
     }
+
+
+
+
+    public void exportUnionChangeDetail(UnionChange model, HttpServletResponse response) {
+        try {
+            String fileName = "鍔犲噺淇濊鎯呭崟";
+            if(model.getType().equals(Constants.ONE)){
+                fileName = "鏇存崲娲鹃仯鍗曚綅璇︽儏鍗�";
+            }
+            String encodeFileName = URLEncoder.encode(fileName +"_"+model.getShopName(), 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);
+            if(model.getType().equals(Constants.ZERO)){
+                this.exportUnionChangeAddDetailDo(model,"鍔犲噺淇濈敵璇疯〃", response.getOutputStream());
+            }else{
+                this.exportUnionChangeDuDetailDo(model,"鏇存崲娲鹃仯鍗曚綅鐢宠琛�", response.getOutputStream());
+            }
+
+        } catch (IOException e) {
+            throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e);
+        }
+    }
+
+    public void exportUnionChangeAddDetailDo (UnionChange data, String sheetName, OutputStream os) {
+        SXSSFWorkbook sxssfWorkbook;
+        try {
+            sxssfWorkbook = new SXSSFWorkbook();
+            Sheet sheet = sxssfWorkbook.createSheet(sheetName);
+            for (int i = 0; i < 8; i++) {
+                sheet.setColumnWidth(i, ((i==3|| i==4|| i== 5 )?16:8) * 2 * 256);
+            }
+            sheet.createFreezePane(0, 1);
+            sheet.addMergedRegion(new CellRangeAddress(0   ,0,0,7));
+            Row title = sheet.createRow(0);
+            title.setHeight((short) 2000);
+            for (int i = 0; i < 8; i++) {
+                title.createCell(i).setCellValue(i==0?sheetName:"");
+                configTitleCell(sxssfWorkbook,title.getCell(i));
+            }
+            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("鍔犱繚浜烘暟");
+            header1.createCell(6).setCellValue("鍑忎繚浜烘暟");
+            header1.createCell(7).setCellValue("鏈熸湜鎵瑰崟鐢熸晥鏈�");
+            for (int i = 0; i < 8; i++) {
+                configFirstCell(sxssfWorkbook,header1.getCell(i));
+            }
+
+            Row header2 = sheet.createRow(2);
+            header2.createCell(0).setCellValue(data.getShopName());
+            header2.createCell(1).setCellValue(data.getSolutionsName());
+            header2.createCell(2).setCellValue(data.getApplyCode());
+            header2.createCell(3).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getStartTime()));
+            header2.createCell(4).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getEndTime()));
+            header2.createCell(5).setCellValue(data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.ZERO)).collect(Collectors.toList()).size());
+            header2.createCell(6).setCellValue(data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.ONE)).collect(Collectors.toList()).size());
+            header2.createCell(7).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getValidTime()));
+            for (int i = 0; i < 8; i++) {
+                configDataCell(sxssfWorkbook,   header2.getCell(i));
+            }
+
+            Row header3 = sheet.createRow(3);
+            header3.createCell(0).setCellValue("琚繚闄╀汉");
+            header3.createCell(1).setCellValue(data.getCompanyNames());
+            header3.createCell(2).setCellValue("");
+            header3.createCell(3).setCellValue("");
+            header3.createCell(4).setCellValue("");
+            header3.createCell(5).setCellValue("");
+            header3.createCell(6).setCellValue("");
+            header3.createCell(7).setCellValue("");
+            for (int i = 0; i < 8; i++) {
+                configFirstCell(sxssfWorkbook,header3.getCell(i));
+            }
+            sheet.addMergedRegion(new CellRangeAddress(3  ,3,1,7));
+
+            Integer row = 4;
+            List<ApplyChagneDetail> addChangeDetailList = data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.ZERO)).collect(Collectors.toList());
+            if(CollectionUtils.isNotEmpty(addChangeDetailList)){
+                Row header4 = sheet.createRow(row);
+                header4.createCell(0).setCellValue("鍔犱繚浜哄憳");
+                for (int i = 0; i < 8; i++) {
+                    configFirstCell(sxssfWorkbook,   header4.getCell(i));
+                }
+                sheet.addMergedRegion(new CellRangeAddress(row  ,row,0,7));
+                row = row + 1;
+                Row header5 = sheet.createRow(row);
+                header5.createCell(0).setCellValue("搴忓彿");
+                header5.createCell(1).setCellValue("鍛樺伐濮撳悕");
+                header5.createCell(2).setCellValue("鎬у埆");
+                header5.createCell(3).setCellValue("韬唤璇佸彿");
+                header5.createCell(4).setCellValue("琚繚闄╀汉");
+                header5.createCell(5).setCellValue("娲鹃仯鍗曚綅");
+                header5.createCell(6).setCellValue("");
+                header5.createCell(7).setCellValue("鎵�灞炲伐绉�");
+                for (int i = 0; i < 8; i++) {
+                    configFirstCell(sxssfWorkbook,header5.getCell(i));
+                }
+                sheet.addMergedRegion(new CellRangeAddress(row  ,row,5,6));
+                for (int rowIndex = 0; rowIndex < addChangeDetailList.size(); rowIndex++) {
+                    row = row + 1 ;
+                    Row header6 = sheet.createRow(row);
+                    ApplyChagneDetail applyChagneDetail = addChangeDetailList.get(rowIndex);
+                    header6.createCell(0).setCellValue(rowIndex + 1);
+                    header6.createCell(1).setCellValue(applyChagneDetail.getMemberName());
+                    header6.createCell(2).setCellValue(Constants.equalsInteger(applyChagneDetail.getSex(),0)?"鐢�":(Constants.equalsInteger(applyChagneDetail.getSex(),1)?"濂�":"-"));
+                    header6.createCell(3).setCellValue(applyChagneDetail.getIdcardNo());
+                    header6.createCell(4).setCellValue(applyChagneDetail.getCompanyName());
+                    header6.createCell(5).setCellValue(applyChagneDetail.getDuName());
+                    header6.createCell(6).setCellValue("");
+                    header6.createCell(7).setCellValue(applyChagneDetail.getWorkTypeName());
+                    for (int i = 0; i < 8; i++) {
+                        configFirstCell(sxssfWorkbook,header6.getCell(i));
+                    }
+                    sheet.addMergedRegion(new CellRangeAddress(row  ,row,5,6));
+                }
+            }
+
+            List<ApplyChagneDetail> reduceChangeDetailList = data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.ONE)).collect(Collectors.toList());
+            row = row + 1;
+            if(CollectionUtils.isNotEmpty(reduceChangeDetailList)){
+                Row header4 = sheet.createRow(row);
+                header4.createCell(0).setCellValue("鍑忎繚浜哄憳");
+                for (int i = 0; i < 8; i++) {
+                    configFirstCell(sxssfWorkbook,   header4.getCell(i));
+                }
+                sheet.addMergedRegion(new CellRangeAddress(row  ,row,0,7));
+
+                row = row + 1;
+                Row header5 = sheet.createRow(row);
+                header5.createCell(0).setCellValue("搴忓彿");
+                header5.createCell(1).setCellValue("鍛樺伐濮撳悕");
+                header5.createCell(2).setCellValue("鎬у埆");
+                header5.createCell(3).setCellValue("韬唤璇佸彿");
+                header5.createCell(4).setCellValue("琚繚闄╀汉");
+                header5.createCell(5).setCellValue("娲鹃仯鍗曚綅");
+                header5.createCell(6).setCellValue("");
+                header5.createCell(7).setCellValue("鎵�灞炲伐绉�");
+                for (int i = 0; i < 8; i++) {
+                    configFirstCell(sxssfWorkbook,header5.getCell(i));
+                }
+                sheet.addMergedRegion(new CellRangeAddress(row  ,row,5,6));
+
+                row = row + 1 ;
+                for (int rowIndex = 0; rowIndex < reduceChangeDetailList.size(); rowIndex++) {
+                    row = row + rowIndex;
+                    Row header6 = sheet.createRow(row);
+                    ApplyChagneDetail applyChagneDetail = reduceChangeDetailList.get(rowIndex);
+                    header6.createCell(0).setCellValue(rowIndex + 1);
+                    header6.createCell(1).setCellValue(applyChagneDetail.getMemberName());
+                    header6.createCell(2).setCellValue(Constants.equalsInteger(applyChagneDetail.getSex(),0)?"鐢�":(Constants.equalsInteger(applyChagneDetail.getSex(),1)?"濂�":"-"));
+                    header6.createCell(3).setCellValue(applyChagneDetail.getIdcardNo());
+                    header6.createCell(4).setCellValue(applyChagneDetail.getCompanyName());
+                    header6.createCell(5).setCellValue(applyChagneDetail.getDuName());
+                    header6.createCell(6).setCellValue("");
+                    header6.createCell(7).setCellValue(applyChagneDetail.getWorkTypeName());
+                    for (int i = 0; i < 8; i++) {
+                        configFirstCell(sxssfWorkbook,header6.getCell(i));
+                    }
+                    sheet.addMergedRegion(new CellRangeAddress(row  ,row,5,6));
+                }
+            }
+            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();
+                }
+            }
+        }
+    }
+
+
+    public void exportUnionChangeDuDetailDo (UnionChange data, String sheetName, OutputStream os) {
+        SXSSFWorkbook sxssfWorkbook;
+        try {
+            sxssfWorkbook = new SXSSFWorkbook();
+            Sheet sheet = sxssfWorkbook.createSheet(sheetName);
+            for (int i = 0; i < 9; i++) {
+                sheet.setColumnWidth(i, ((i==3|| i== 4|| i== 5 ||i== 6 || i==7|| i==8 || i==9)?16:8) * 2 * 256);
+            }
+            sheet.createFreezePane(0, 1);
+            sheet.addMergedRegion(new CellRangeAddress(0   ,0,0,8));
+            Row title = sheet.createRow(0);
+            title.setHeight((short) 2000);
+            Cell c = title.createCell(0);
+            c.setCellValue(sheetName);
+            configFirstCell(sxssfWorkbook,c);
+            for (int i = 0; i < 9; i++) {
+                if(i>0){
+                    title.createCell(i).setCellValue("");
+                }
+                configTitleCell(sxssfWorkbook,title.getCell(i));
+            }
+            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("淇濋櫓鐢熸晥璧锋湡");
+            header1.createCell(6).setCellValue("淇濋櫓鐢熸晥姝㈡湡");
+            header1.createCell(7).setCellValue("鎹㈠巶浜烘暟");
+            header1.createCell(8).setCellValue("鏈熸湜鎵瑰崟鐢熸晥鏈�");
+            for (int i = 0; i < 9; i++) {
+                configFirstCell(sxssfWorkbook,header1.getCell(i));
+            }
+            sheet.addMergedRegion(new CellRangeAddress(1  ,1,1,3));
+
+            Row header2 = sheet.createRow(2);
+            header2.createCell(0).setCellValue(data.getShopName());
+            header2.createCell(1).setCellValue(data.getSolutionsName());
+            header2.createCell(2).setCellValue("");
+            header2.createCell(3).setCellValue("");
+            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(7).setCellValue(data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.TWO)).collect(Collectors.toList()).size());
+            header2.createCell(8).setCellValue(com.doumee.core.utils.DateUtil.getPlusTime2(data.getApplyStartTime()));
+            sheet.addMergedRegion(new CellRangeAddress(2  ,2,1,3));
+            for (int i = 0; i < 9; i++) {
+                configDataCell(sxssfWorkbook,header2.getCell(i));
+            }
+
+            Row header3 = sheet.createRow(3);
+            header3.createCell(0).setCellValue("琚繚闄╀汉");
+            header3.createCell(1).setCellValue(data.getCompanyNames());
+            header3.createCell(2).setCellValue("");
+            header3.createCell(3).setCellValue("");
+            header3.createCell(4).setCellValue("");
+            header3.createCell(5).setCellValue("");
+            header3.createCell(6).setCellValue("");
+            header3.createCell(7).setCellValue("");
+            header3.createCell(8).setCellValue("");
+            for (int i = 0; i < 9; i++) {
+                configFirstCell(sxssfWorkbook,header3.getCell(i));
+            }
+            sheet.addMergedRegion(new CellRangeAddress(3  ,3,1,8));
+
+
+
+            List<ApplyChagneDetail> otherChangeDetailList = data.getApplyChagneDetailList().stream().filter(i->i.getType().equals(Constants.TWO)).collect(Collectors.toList());
+
+            Integer row = 3;
+
+            if(CollectionUtils.isNotEmpty(otherChangeDetailList)){
+                row = row + 1;
+                Row header5 = sheet.createRow(row);
+                header5.createCell(0).setCellValue("搴忓彿");
+                header5.createCell(1).setCellValue("鍛樺伐濮撳悕");
+                header5.createCell(2).setCellValue("鎬у埆");
+                header5.createCell(3).setCellValue("韬唤璇佸彿");
+                header5.createCell(4).setCellValue("琚繚闄╀汉");
+                header5.createCell(5).setCellValue("鍘熸淳閬e崟浣�");
+                header5.createCell(6).setCellValue("鍘熸墍灞炲伐绉�");
+                header5.createCell(7).setCellValue("鏇存敼鍚庢淳閬e崟浣�");
+                header5.createCell(8).setCellValue("鏇存敼鍚庢墍灞炲伐绉�");
+                for (int i = 0; i < 9; i++) {
+                    configFirstCell(sxssfWorkbook,header5.getCell(i));
+                }
+                for (int rowIndex = 0; rowIndex < otherChangeDetailList.size(); rowIndex++) {
+                    row = row + 1;
+                    Row header6 = sheet.createRow(row);
+                    ApplyChagneDetail applyChagneDetail = otherChangeDetailList.get(rowIndex);
+                    header6.createCell(0).setCellValue(rowIndex + 1);
+                    header6.createCell(1).setCellValue(applyChagneDetail.getMemberName());
+                    header6.createCell(2).setCellValue(Constants.equalsInteger(applyChagneDetail.getSex(),0)?"鐢�":(Constants.equalsInteger(applyChagneDetail.getSex(),1)?"濂�":"-"));
+                    header6.createCell(3).setCellValue(applyChagneDetail.getIdcardNo());
+                    header6.createCell(4).setCellValue(applyChagneDetail.getCompanyName());
+                    header6.createCell(5).setCellValue(applyChagneDetail.getOldDuName());
+                    header6.createCell(6).setCellValue(applyChagneDetail.getOldWorkTypeName());
+                    header6.createCell(7).setCellValue(applyChagneDetail.getDuName());
+                    header6.createCell(8).setCellValue(applyChagneDetail.getWorkTypeName());
+                    for (int i = 0; i < 9; i++) {
+                        configFirstCell(sxssfWorkbook,header6.getCell(i));
+                    }
+                }
+            }
+
+            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();
+                }
+            }
+        }
+    }
 }

--
Gitblit v1.9.3