Forráskód Böngészése

feature: 下载数量过大优化

wuyongyi 2 éve
szülő
commit
02ed10f08a

+ 2 - 2
src/main/java/com/ywt/mg/services/CheckUpOrderService.java

@@ -192,7 +192,7 @@ public class CheckUpOrderService {
             }
             int size = list.size();
             List<ExcelCollectPojo> itemList = getStatisticsData(size, payTotal, refundTotal);
-            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, size);
 
         } catch (Exception e) {
             logger.error("/checkUp/downloadCheckUpOrderList(): {}", e.getMessage(), e);
@@ -300,7 +300,7 @@ public class CheckUpOrderService {
             }
             int size = checkUpOrderList.size();
             List<ExcelCollectPojo> itemList = new ArrayList<>();
-            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, size);
         } catch (Exception e) {
             logger.error("/checkUp/downloadCheckUpOrderBillList(): {}", e.getMessage(), e);
             e.printStackTrace();

+ 4 - 2
src/main/java/com/ywt/mg/services/DepositService.java

@@ -239,8 +239,9 @@ public class DepositService {
                 }
 
             }
+            int total = list.getTotal();
             List<ExcelCollectPojo> itemList = new ArrayList<>();
-            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, total);
         } catch (Exception e) {
             logger.error("/deposit/downloadDepositList(): {}", e.getMessage(), e);
             e.printStackTrace();
@@ -364,8 +365,9 @@ public class DepositService {
                 }
 
             }
+            int total = depositPageList.getTotal();
             List<ExcelCollectPojo> itemList = new ArrayList<>();
-            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, total);
         } catch (Exception e) {
             logger.error("/deposit/downloadDepositBillList(): {}", e.getMessage(), e);
             e.printStackTrace();

+ 4 - 4
src/main/java/com/ywt/mg/services/DownloadRecordService.java

@@ -327,7 +327,7 @@ public class DownloadRecordService {
      * @param itemList         统计map
      * @throws Exception
      */
-    public void createFileAndUploadOssAndSaveToDataBase(String fileName, int downloadRecordId, ExcelDataMap map, List<ExcelCollectPojo> itemList) throws Exception {
+    public void createFileAndUploadOssAndSaveToDataBase(String fileName, int downloadRecordId, ExcelDataMap map, List<ExcelCollectPojo> itemList, int size) throws Exception {
         // 前缀(路径)
         String preLocalPath = ConstantDef.LOCAL_DOWNLOAD_FILE_PATH;
         // 后缀(下载时间和格式)
@@ -337,7 +337,7 @@ public class DownloadRecordService {
 
         // 生成本地文件
         ExcelStyleMap excelStyleMap = new ExcelStyleMap(new String[]{});
-        OutputStream ba = excelDownloadSrv.generateAndReturnExcelFileWithNoStyleAndCollectLocal(fileName, localPath, map, excelStyleMap, itemList);
+        OutputStream ba = excelDownloadSrv.generateAndReturnExcelFileWithNoStyleAndCollectLocal(fileName, localPath, map, excelStyleMap, itemList, size);
 
         // 本地文件上传到oss,文件名带后缀
         String ossPath = String.format(ConstantDef.BIG_DATA_EXCEL_FILE_PATH, FormatUtil.formatDate(new Date(), "yyyy-MM"));
@@ -364,7 +364,7 @@ public class DownloadRecordService {
      * @param itemList         统计map
      * @throws Exception
      */
-    public void createMealFileAndUploadOssAndSaveToDataBase(String fileName, int downloadRecordId, ExcelDataMap map, List<CustomExcelItem> itemList) throws Exception {
+    public void createMealFileAndUploadOssAndSaveToDataBase(String fileName, int downloadRecordId, ExcelDataMap map, List<CustomExcelItem> itemList, int size) throws Exception {
         // 前缀(路径)
         String preLocalPath = ConstantDef.LOCAL_DOWNLOAD_FILE_PATH;
         // 后缀(下载时间和格式)
@@ -374,7 +374,7 @@ public class DownloadRecordService {
 
         // 生成本地文件
         ExcelStyleMap excelStyleMap = new ExcelStyleMap(new String[]{});
-        OutputStream ba = excelDownloadSrv.generateAndReturnMealExcelFileWithNoStyleAndCollectLocal(fileName, localPath, map, excelStyleMap, itemList);
+        OutputStream ba = excelDownloadSrv.generateAndReturnMealExcelFileWithNoStyleAndCollectLocal(fileName, localPath, map, excelStyleMap, itemList, size);
 
         // 本地文件上传到oss,文件名带后缀
         String ossPath = String.format(ConstantDef.BIG_DATA_EXCEL_FILE_PATH, FormatUtil.formatDate(new Date(), "yyyy-MM"));

+ 2 - 2
src/main/java/com/ywt/mg/services/MealOrderService.java

@@ -396,7 +396,7 @@ public class MealOrderService {
 //         downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
             List<CustomExcelItem> itemList = getStatisticsData(userMealOrderViews, shopList);
             downloadRecordService.createMealFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map,
-                    needStat ? itemList : null);
+                    needStat ? itemList : null, size);
 
         } catch (Exception e) {
             logger.error("/mealOrder/downloadMealOrderList(): {}", e.getMessage(), e);
@@ -796,7 +796,7 @@ public class MealOrderService {
             }
             int size = list.size();
             List<ExcelCollectPojo> itemList = new ArrayList<>();
-            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, size);
 
         } catch (Exception e) {
             logger.error("/mealOrder/downloadMealOrderBillsList(): {}", e.getMessage(), e);

+ 1 - 1
src/main/java/com/ywt/mg/services/NatOrderService.java

@@ -215,7 +215,7 @@ public class NatOrderService {
             }
             int size = list.size();
             List<ExcelCollectPojo> itemList = getStatisticsData(size, payTotal, refundTotal);
-            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, size);
 
         } catch (Exception e) {
             logger.error("/natOrder/downloadNatOrderList: {}", e.getMessage(), e);

+ 1 - 1
src/main/java/com/ywt/mg/services/OfflineNewService.java

@@ -337,7 +337,7 @@ public class OfflineNewService {
             int size = offlineList.size();
             List<ExcelCollectPojo> itemList = getStatisticsData(size, payTotal, refundTotal);
             // 创建文件 并且上传到 OSS,最后保存到本地数据库
-            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, size);
         } catch (Exception e) {
             logger.error("/offline/downloadOfflineList(): {}", e.getMessage(), e);
             e.printStackTrace();

+ 2 - 2
src/main/java/com/ywt/mg/services/OutpatientOrderService.java

@@ -364,7 +364,7 @@ public class OutpatientOrderService {
             }
             int size = list.size();
             List<ExcelCollectPojo> itemList = getStatisticsData(size, payTotal);
-            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, size);
         } catch (Exception e) {
             logger.error("/outPatient/downloadOutPatientOrderList(): {}", e.getMessage(), e);
             e.printStackTrace();
@@ -515,7 +515,7 @@ public class OutpatientOrderService {
             }
             int size = outpatientOrderList.size();
             List<ExcelCollectPojo> itemList = new ArrayList<>();
-            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, size);
         } catch (Exception e) {
             logger.error("/registeredOrder/downloadRegisteredOrderList: {}", e.getMessage(), e);
             e.printStackTrace();

+ 1 - 1
src/main/java/com/ywt/mg/services/PharmacyService.java

@@ -474,7 +474,7 @@ public class PharmacyService {
                     posPay, posRefundTotal,
                     medicalInsurancePay, medicalInsuranceRefundTotal,
                     icbcPay, icbcRefundTotal);
-            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, size);
 
         } catch (Exception e) {
             logger.error("/pharmacy/downloadPrescriptionlist(): {}", e.getMessage(), e);

+ 2 - 2
src/main/java/com/ywt/mg/services/PrescriptionServices.java

@@ -455,7 +455,7 @@ public class PrescriptionServices {
                     posPay, posRefundTotal,
                     medicalInsurancePay, medicalInsuranceRefundTotal,
                     icbcPay, icbcRefundTotal);
-            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, size);
 
 
         } catch (Exception e) {
@@ -859,7 +859,7 @@ public class PrescriptionServices {
             }
             int size = list.size();
             List<ExcelCollectPojo> itemList = new ArrayList<>();
-            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, size);
         } catch (Exception e) {
             logger.error("/prescription/downloadPrescriptionDrugList(): {}", e.getMessage(), e);
             e.printStackTrace();

+ 3 - 2
src/main/java/com/ywt/mg/services/RegisteredOrderService.java

@@ -431,7 +431,7 @@ public class RegisteredOrderService {
             }
             int size = registeredOrderList.size();
             List<ExcelCollectPojo> itemList = getStatisticsData(size, payTotal, refundTotal);
-            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, size);
 
         } catch (Exception e) {
             logger.error("/registeredOrder/downloadRegisteredOrderList: {}", e.getMessage(), e);
@@ -608,8 +608,9 @@ public class RegisteredOrderService {
                     }
                 }
             }
+            int size =  registeredOrderList.size();
             List<ExcelCollectPojo> itemList = new ArrayList<>();
-            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, size);
 
         } catch (Exception e) {
             logger.error("/registeredOrder/downloadRegisteredOrderBillsList: {}", e.getMessage(), e);

+ 281 - 113
src/main/java/com/ywt/mg/web/common/ExcelDownloadSrv.java

@@ -8,23 +8,19 @@ import com.ywt.mg.domain.models.ExcelStyleMap;
 import com.ywt.mg.domain.models.pojo.CustomExcelItem;
 import com.ywt.mg.domain.models.pojo.ExcelCollectPojo;
 import jxl.Workbook;
-import jxl.format.*;
 import jxl.format.Alignment;
 import jxl.format.Border;
 import jxl.format.BorderLineStyle;
 import jxl.format.Colour;
 import jxl.format.VerticalAlignment;
+import jxl.format.*;
 import jxl.write.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
 
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.ByteArrayOutputStream;
-import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
@@ -288,7 +284,7 @@ public class ExcelDownloadSrv {
      * @author Walker, added on 06/27/2019.
      */
     public OutputStream  generateAndReturnExcelFileWithNoStyleAndCollectLocal(String fileName, String path, ExcelDataMap data, ExcelStyleMap excelStyleMap,
-                                                                       List<ExcelCollectPojo> collectList) throws AppMessageException {
+                                                                       List<ExcelCollectPojo> collectList, int size) throws AppMessageException {
 
         OutputStream ba = null;
         ba = new ByteArrayOutputStream();
@@ -301,72 +297,180 @@ public class ExcelDownloadSrv {
             // 创建写工作簿对象
 //            WritableWorkbook workbook = Workbook.createWorkbook(file);
             workbook = Workbook.createWorkbook(ba);
-            // 工作表
-            WritableSheet sheet = workbook.createSheet(fileName, 0);
 
-            //表头格式
-            WritableCellFormat cellFormat = ExcelDownloadSrv.getWritableCellFormat();
-            //数据行格式
-            // 设置背景、字体颜色、对齐方式等等;
-            WritableFont font2 = new WritableFont(WritableFont.ARIAL, 14, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
-            WritableCellFormat cellFormat2 = new WritableCellFormat(font2);
-            //设置文字居中对齐方式;
-            cellFormat2.setAlignment(Alignment.CENTRE);
-            //设置垂直居中;
-            cellFormat2.setVerticalAlignment(VerticalAlignment.CENTRE);
-            cellFormat2.setBackground(Colour.WHITE);
-            cellFormat2.setBorder(Border.ALL, BorderLineStyle.THIN);
-            cellFormat2.setWrap(true);
-            //给sheet电子版中所有的列设置默认的列的宽度;
-            sheet.getSettings().setDefaultColumnWidth(20);
-            sheet.getSettings().setDefaultRowHeight(30 * 20);
+            int list = size;
+            int a = 0;
+            if(list < 60000){
+                a = 1;
+            } else {
+                if (list % 60000 == 0) {
+                    a = list / 60000;
+                } else {
+                    a = list / 60000 + 1;
+                }
+            }
 
-            //单独应用样式
-            if (excelStyleMap != null) {
-                for (String column : excelStyleMap.keySet()) {
-                    // 指定列宽
-                    int styleColumnWidth = excelStyleMap.getIntValueSafely(column, ExcelStyleMap.STYLE_COLUMN_WIDTH, 0);
-                    List<String> columns = new ArrayList<>(data.keySet());
-                    for (int i = 0; i < columns.size(); i++) {
-                        if (columns.get(i).equals(column)) {
-                            sheet.setColumnView(i, styleColumnWidth);
+            // 工作表
+            for (int i = 0; i < a; i++) {
+                int page = i + 1;
+                WritableSheet sheet = workbook.createSheet(fileName + page, 0);
+                WritableCellFormat cellFormat = ExcelDownloadSrv.getWritableCellFormat();
+                //数据行格式
+                // 设置背景、字体颜色、对齐方式等等;
+                WritableFont font2 = new WritableFont(WritableFont.ARIAL, 14, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
+                WritableCellFormat cellFormat2 = new WritableCellFormat(font2);
+                //设置文字居中对齐方式;
+                cellFormat2.setAlignment(Alignment.CENTRE);
+                //设置垂直居中;
+                cellFormat2.setVerticalAlignment(VerticalAlignment.CENTRE);
+                cellFormat2.setBackground(Colour.WHITE);
+                cellFormat2.setBorder(Border.ALL, BorderLineStyle.THIN);
+                cellFormat2.setWrap(true);
+                //给sheet电子版中所有的列设置默认的列的宽度;
+                sheet.getSettings().setDefaultColumnWidth(20);
+                sheet.getSettings().setDefaultRowHeight(30 * 20);
+                int firstRow = 0;
+                //填充表头
+                int headerColumn = 0;
+//                int headerColumn2 = 0;
+//                int headerColumn3 = 0;
+                for (String key : data.keySet()) {
+                    Label label = new Label(headerColumn, firstRow, key, cellFormat);
+                    sheet.addCell(label);
+//                    Label label2 = new Label(headerColumn2, firstRow, key, cellFormat);
+//                sheet2.addCell(label2);
+//                Label label3 = new Label(headerColumn3, firstRow, key, cellFormat);
+//                sheet3.addCell(label3);
+                    List<String> colData = data.get(key);
+                    for (int q = 0; q < 60000; q++) {
+                        int e = 60000 * i;
+                        Label lb = new Label(headerColumn, q + 1, Checker.getStringValue(colData.get(e + q)), cellFormat);
+                        sheet.addCell(lb);
+//                    sheet2.addCell(lb);
+                    }
+//                for (int q = 0; q < 2; q++) {
+//                    Label lb = new Label(headerColumn2, q + 1, Checker.getStringValue(colData.get(2 + q)), cellFormat);
+//                    sheet2.addCell(lb);
+//                }
+//                for (int q = 0; q < 2; q++) {
+//                    Label lb = new Label(headerColumn3, q + 1, Checker.getStringValue(colData.get(4 + q)), cellFormat);
+//                    sheet3.addCell(lb);
+//                }
+                    headerColumn++;
+//                headerColumn2++;
+//                headerColumn3++;
+                }
+                if (i == a - 1) {
+                    if (!Checker.isNone(collectList)) {
+                        for (ExcelCollectPojo pojo : collectList) {
+                            String[] dataArr = pojo.getDataArr();
+                            for (int r = 0, j = dataArr.length; r < j; r++) {
+//                        Label lb = new Label(pojo.getCol() + i, pojo.getRow(), dataArr[i], cellFormat);
+//                        sheet.addCell(lb);
+                                Label lb2 = new Label(pojo.getCol() + r, pojo.getRow(), dataArr[r], cellFormat);
+                                sheet.addCell(lb2);
+                            }
                         }
                     }
                 }
-            }
+
+
+//            WritableSheet sheet = workbook.createSheet(fileName, 0);
+//            WritableSheet sheet2 = workbook.createSheet(fileName + "2", 1);
+//            WritableSheet sheet3 = workbook.createSheet(fileName + "3", 2);
+//
+//            //表头格式
+//            WritableCellFormat cellFormat = ExcelDownloadSrv.getWritableCellFormat();
+//            //数据行格式
+//            // 设置背景、字体颜色、对齐方式等等;
+//            WritableFont font2 = new WritableFont(WritableFont.ARIAL, 14, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
+//            WritableCellFormat cellFormat2 = new WritableCellFormat(font2);
+//            //设置文字居中对齐方式;
+//            cellFormat2.setAlignment(Alignment.CENTRE);
+//            //设置垂直居中;
+//            cellFormat2.setVerticalAlignment(VerticalAlignment.CENTRE);
+//            cellFormat2.setBackground(Colour.WHITE);
+//            cellFormat2.setBorder(Border.ALL, BorderLineStyle.THIN);
+//            cellFormat2.setWrap(true);
+//            //给sheet电子版中所有的列设置默认的列的宽度;
+//            sheet.getSettings().setDefaultColumnWidth(20);
+//            sheet.getSettings().setDefaultRowHeight(30 * 20);
+//            sheet2.getSettings().setDefaultColumnWidth(20);
+//            sheet2.getSettings().setDefaultRowHeight(30 * 20);
+//            sheet3.getSettings().setDefaultColumnWidth(20);
+//            sheet3.getSettings().setDefaultRowHeight(30 * 20);
+
+//            //单独应用样式
+//            if (excelStyleMap != null) {
+//                for (String column : excelStyleMap.keySet()) {
+//                    // 指定列宽
+//                    int styleColumnWidth = excelStyleMap.getIntValueSafely(column, ExcelStyleMap.STYLE_COLUMN_WIDTH, 0);
+//                    List<String> columns = new ArrayList<>(data.keySet());
+//                    for (int i = 0; i <1; i++) {
+//                        if (columns.get(i).equals(column)) {
+//                            sheet.setColumnView(i, styleColumnWidth);
+//                        }
+//                    }
+//
+//                }
+//            }
 //            // 设置格式(实线)
 //            WritableCellFormat cellFormat = new WritableCellFormat();
 //            //给sheet电子版中所有的列设置默认的列的宽度;
 //            sheet.getSettings().setDefaultColumnWidth(20);
 //            sheet.getSettings().setDefaultRowHeight(35 * 20);
-            //行号
-            int firstRow = 0;
-            //填充表头
-            int headerColumn = 0;
-            for (String key : data.keySet()) {
-                Label label = new Label(headerColumn, firstRow, key, cellFormat);
-                sheet.addCell(label);
-                List<String> colData = data.get(key);
-                for (int i = 0; i < colData.size(); i++) {
-                    Label lb = new Label(headerColumn, i + 1, Checker.getStringValue(colData.get(i)), cellFormat);
-                    sheet.addCell(lb);
-                }
-                headerColumn++;
-            }
-            // 添加汇总
-            if (!Checker.isNone(collectList)) {
-                for (ExcelCollectPojo pojo : collectList) {
-                    String[] dataArr = pojo.getDataArr();
-                    for (int i = 0, j = dataArr.length; i < j; i++) {
-                        Label lb = new Label(pojo.getCol() + i, pojo.getRow(), dataArr[i], cellFormat);
-                        sheet.addCell(lb);
-                    }
+                //行号
+//            int firstRow = 0;
+//            //填充表头
+//            int headerColumn = 0;
+//            int headerColumn2 = 0;
+//            int headerColumn3 = 0;
+//            for (String key : data.keySet()) {
+//                Label label = new Label(headerColumn, firstRow, key, cellFormat);
+//                sheet.addCell(label);
+//                Label label2 = new Label(headerColumn2, firstRow, key, cellFormat);
+//                sheet2.addCell(label2);
+//                Label label3 = new Label(headerColumn3, firstRow, key, cellFormat);
+//                sheet2.addCell(label3);
+//                List<String> colData = data.get(key);
+//                for (int i = 0; i < 2; i++) {
+//                    Label lb = new Label(headerColumn, i + 1, Checker.getStringValue(colData.get(i)), cellFormat);
+//                    sheet.addCell(lb);
+////                    sheet2.addCell(lb);
+//                }
+//                for (int q = 0; q < 2; q++) {
+//                    Label lb = new Label(headerColumn2, q + 1, Checker.getStringValue(colData.get(2 + q)), cellFormat);
+//                    sheet2.addCell(lb);
+//                }
+//                for (int q = 0; q < 2; q++) {
+//                    Label lb = new Label(headerColumn3, q + 1, Checker.getStringValue(colData.get(4 + q)), cellFormat);
+//                    sheet3.addCell(lb);
+//                }
+//                headerColumn++;
+//                headerColumn2++;
+//                headerColumn3++;
+//            }
+                // 添加汇总
+//            if (!Checker.isNone(collectList)) {
+//                for (ExcelCollectPojo pojo : collectList) {
+//                    String[] dataArr = pojo.getDataArr();
+//                    for (int i = 0, j = dataArr.length; i < j; i++) {
+////                        Label lb = new Label(pojo.getCol() + i, pojo.getRow(), dataArr[i], cellFormat);
+////                        sheet.addCell(lb);
+//                        Label lb2 = new Label(pojo.getCol() + i, pojo.getRow(), dataArr[i], cellFormat);
+//                        sheet2.addCell(lb2);
+//                    }
+//                }
+//            }
+                //开始执行写入操作
+                if (i == a - 1) {
+                    workbook.write();
+                    //关闭流
+                    workbook.close();
                 }
+
             }
-            //开始执行写入操作
-            workbook.write();
-            //关闭流
-            workbook.close();
+
             if (ba != null) {
                 try {
                     ba.close();
@@ -417,7 +521,7 @@ public class ExcelDownloadSrv {
      * @author Walker, added on 06/27/2019.
      */
     public OutputStream generateAndReturnMealExcelFileWithNoStyleAndCollectLocal(String fileName, String path, ExcelDataMap data, ExcelStyleMap excelStyleMap,
-                                                                     List<CustomExcelItem> collectList) throws AppMessageException {
+                                                                     List<CustomExcelItem> collectList, int size) throws AppMessageException {
         if (data == null || data.isEmpty()) {
             throw new AppMessageException("数据为空");
         }
@@ -426,66 +530,130 @@ public class ExcelDownloadSrv {
         WritableWorkbook workbook = null;
         try {
 //            File file = new File(path);
-            // 创建写工作簿对象
-             workbook = Workbook.createWorkbook(ba);
-            // 工作表
-            WritableSheet sheet = workbook.createSheet(fileName, 0);
-            //表头格式
-            WritableCellFormat cellFormat = ExcelDownloadSrv.getWritableCellFormat();
-            //数据行格式
-            // 设置背景、字体颜色、对齐方式等等;
-            WritableFont font2 = new WritableFont(WritableFont.ARIAL, 14, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
-            WritableCellFormat cellFormat2 = new WritableCellFormat(font2);
-            //设置文字居中对齐方式;
-            cellFormat2.setAlignment(Alignment.CENTRE);
-            //设置垂直居中;
-            cellFormat2.setVerticalAlignment(VerticalAlignment.CENTRE);
-            cellFormat2.setBackground(Colour.WHITE);
-            cellFormat2.setBorder(Border.ALL, BorderLineStyle.THIN);
-            cellFormat2.setWrap(true);
-            //给sheet电子版中所有的列设置默认的列的宽度;
-            sheet.getSettings().setDefaultColumnWidth(20);
-            sheet.getSettings().setDefaultRowHeight(30 * 20);
-            //单独应用样式
-            if (excelStyleMap != null) {
-                for (String column : excelStyleMap.keySet()) {
-                    // 指定列宽
-                    int styleColumnWidth = excelStyleMap.getIntValueSafely(column, ExcelStyleMap.STYLE_COLUMN_WIDTH, 0);
-                    List<String> columns = new ArrayList<>(data.keySet());
-                    for (int i = 0; i < columns.size(); i++) {
-                        if (columns.get(i).equals(column)) {
-                            sheet.setColumnView(i, styleColumnWidth);
-                        }
-                    }
+            workbook = Workbook.createWorkbook(ba);
+
+            int list = size;
+            int a = 0;
+            if(list < 60000){
+                a = 1;
+            } else {
+                if (list % 60000 == 0) {
+                    a = list / 60000;
+                } else {
+                    a = list / 60000 + 1;
                 }
             }
 
-            //行号
-            int firstRow = 0;
-            //填充表头
-            int headerColumn = 0;
-            for (String key : data.keySet()) {
-                Label label = new Label(headerColumn, firstRow, key, cellFormat);
-                sheet.addCell(label);
-                List<String> colData = data.get(key);
-                for (int i = 0; i < colData.size(); i++) {
-                    Label lb = new Label(headerColumn, i + 1, Checker.getStringValue(colData.get(i)), cellFormat2);
-                    sheet.addCell(lb);
+            for (int i = 0; i < a; i++) {
+                int page = i + 1;
+
+                WritableSheet sheet = workbook.createSheet(fileName + page, 0);
+                WritableCellFormat cellFormat = ExcelDownloadSrv.getWritableCellFormat();
+                //数据行格式
+                // 设置背景、字体颜色、对齐方式等等;
+                WritableFont font2 = new WritableFont(WritableFont.ARIAL, 14, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
+                WritableCellFormat cellFormat2 = new WritableCellFormat(font2);
+                //设置文字居中对齐方式;
+                cellFormat2.setAlignment(Alignment.CENTRE);
+                //设置垂直居中;
+                cellFormat2.setVerticalAlignment(VerticalAlignment.CENTRE);
+                cellFormat2.setBackground(Colour.WHITE);
+                cellFormat2.setBorder(Border.ALL, BorderLineStyle.THIN);
+                cellFormat2.setWrap(true);
+                //给sheet电子版中所有的列设置默认的列的宽度;
+                sheet.getSettings().setDefaultColumnWidth(20);
+                sheet.getSettings().setDefaultRowHeight(30 * 20);
+                int firstRow = 0;
+                //填充表头
+                int headerColumn = 0;
+
+
+                for (String key : data.keySet()) {
+                    Label label = new Label(headerColumn, firstRow, key, cellFormat);
+                    sheet.addCell(label);
+                    List<String> colData = data.get(key);
+                    for (int q = 0; q < 60000; q++) {
+                        int e = 60000 * i;
+                        Label lb = new Label(headerColumn, q + 1, Checker.getStringValue(colData.get(e + q)), cellFormat);
+                        sheet.addCell(lb);
+                    }
+                    headerColumn++;
                 }
-                headerColumn++;
-            }
-            // 添加汇总
-            if (!Checker.isNone(collectList)) {
-                for (CustomExcelItem item : collectList) {
-                        sheet.addCell(new Label(item.getColumn(), item.getRow(), item.getContent(),
-                                item.getCellFormat() == null ? cellFormat2 : item.getCellFormat()));
+                // 添加汇总
+                if (i == a - 1) {
+                    if (!Checker.isNone(collectList)) {
+                        for (CustomExcelItem item : collectList) {
+                            sheet.addCell(new Label(item.getColumn(), item.getRow(), item.getContent(),
+                                    item.getCellFormat() == null ? cellFormat2 : item.getCellFormat()));
+
 
+                        }
+                    }
+                }
+
+                if (i == a - 1){
+                    workbook.write();
+                    //关闭流
+                    workbook.close();
                 }
             }
+//            // 工作表
+//            WritableSheet sheet = workbook.createSheet(fileName, 0);
+//            //表头格式
+//            WritableCellFormat cellFormat = ExcelDownloadSrv.getWritableCellFormat();
+//            //数据行格式
+//            // 设置背景、字体颜色、对齐方式等等;
+//            WritableFont font2 = new WritableFont(WritableFont.ARIAL, 14, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
+//            WritableCellFormat cellFormat2 = new WritableCellFormat(font2);
+//            //设置文字居中对齐方式;
+//            cellFormat2.setAlignment(Alignment.CENTRE);
+//            //设置垂直居中;
+//            cellFormat2.setVerticalAlignment(VerticalAlignment.CENTRE);
+//            cellFormat2.setBackground(Colour.WHITE);
+//            cellFormat2.setBorder(Border.ALL, BorderLineStyle.THIN);
+//            cellFormat2.setWrap(true);
+//            //给sheet电子版中所有的列设置默认的列的宽度;
+//            sheet.getSettings().setDefaultColumnWidth(20);
+//            sheet.getSettings().setDefaultRowHeight(30 * 20);
+            //单独应用样式
+//            if (excelStyleMap != null) {
+//                for (String column : excelStyleMap.keySet()) {
+//                    // 指定列宽
+//                    int styleColumnWidth = excelStyleMap.getIntValueSafely(column, ExcelStyleMap.STYLE_COLUMN_WIDTH, 0);
+//                    List<String> columns = new ArrayList<>(data.keySet());
+//                    for (int i = 0; i < columns.size(); i++) {
+//                        if (columns.get(i).equals(column)) {
+//                            sheet.setColumnView(i, styleColumnWidth);
+//                        }
+//                    }
+//                }
+//            }
+
+            //行号
+//            int firstRow = 0;
+//            //填充表头
+//            int headerColumn = 0;
+//            for (String key : data.keySet()) {
+//                Label label = new Label(headerColumn, firstRow, key, cellFormat);
+//                sheet.addCell(label);
+//                List<String> colData = data.get(key);
+//                for (int i = 0; i < colData.size(); i++) {
+//                    Label lb = new Label(headerColumn, i + 1, Checker.getStringValue(colData.get(i)), cellFormat2);
+//                    sheet.addCell(lb);
+//                }
+//                headerColumn++;
+//            }
+//            // 添加汇总
+//            if (!Checker.isNone(collectList)) {
+//                for (CustomExcelItem item : collectList) {
+//                        sheet.addCell(new Label(item.getColumn(), item.getRow(), item.getContent(),
+//                                item.getCellFormat() == null ? cellFormat2 : item.getCellFormat()));
+//
+//                }
+//            }
             //开始执行写入操作
-            workbook.write();
-            //关闭流
-            workbook.close();
+
+
             if (ba != null) {
                 try {
                     ba.close();