From 131cd265f4711691fe22ff50c44f523c65cd7022 Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期一, 17 十一月 2025 11:49:52 +0800
Subject: [PATCH] 修改了对应代码

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java |  173 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 159 insertions(+), 14 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java
index 3978688..3f7963e 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java
@@ -8,10 +8,7 @@
 import com.itextpdf.text.pdf.PdfWriter;
 import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.utils.file.FileUtils;
-import com.ruoyi.common.utils.poi.ExcelExp;
-import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.common.utils.poi.ExcelUtilManySheet;
-import com.ruoyi.common.utils.poi.ExcelUtilManySheetSecond;
+import com.ruoyi.common.utils.poi.*;
 import com.ruoyi.domain.ArchiveRecords;
 import com.ruoyi.domain.DocumentMaterials;
 import com.ruoyi.domain.vo.*;
@@ -125,6 +122,22 @@
     @PostMapping("/exportChooseArchive/{ids}")
     public void exportChooseArchive(HttpServletResponse response,  @PathVariable Long[] ids)throws Exception
     {
+        //璁$畻鏂囦欢鐨勫ぇ灏�
+        Double siz = 0.0;
+        for(int i = 0; i < ids.length; i++) {
+
+            // 鑾峰彇鏂囦欢鐨勪繚瀛樹綅缃�,璇诲彇鏁版嵁搴�,
+            DocumentMaterials documentMaterials = new DocumentMaterials();
+            documentMaterials.setRecordId(ids[i]);
+            List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(ids[i]);
+            System.out.println(docs.size()+"----009");
+            for (DocumentMaterialsVoLarge dc : docs) {
+                if(dc!=null)
+                    siz += dc.getFileSize()!=null?dc.getFileSize():0;
+            }
+        }
+        System.out.println(siz/1000);
+        //鍒ゆ柇鏄惁澶т簬4G锛屾槸鐨勮瘽锛岀洿鎺ユ姏鍑哄紓甯�
         System.out.println("092939932");
         String zipFileName ="test" +".zip";
         //鐢熸垚鍘嬬缉鍖呭瓨鍌ㄥ湴鍧�锛堟渶鍚庝細鍒犳帀锛�
@@ -169,13 +182,31 @@
             //绉讳氦娓呭崟
             List<ArchiveRecordSmall> lrs = iArchiveRecordsService.findByIds(archiveRecords);
             System.out.println(lrs);
+            System.out.println("99999999990000");
             ZipEntry entry1 = new ZipEntry("绉讳氦娓呭崟" + ".xls");
             ExcelUtil<ArchiveRecordSmall> util1 = new ExcelUtil<ArchiveRecordSmall>(ArchiveRecordSmall.class);
 
+
+
+            ExcelExp e6 = new ExcelExp("绉讳氦娓呭崟",lrs, ArchiveRecordSmall.class);
+          //  ExcelExp e4 = new ExcelExp("妗堝嵎灏侀潰",  arsi, recordId1, imgr1,sedcode, ArchiveInfoVo.class);
+            List<ExcelExp> mysheet6 = new ArrayList<ExcelExp>();
+            mysheet6.add(e6);
+         //   mysheet1.add(e4);
+            ByteOutputStream bos6 = new ByteOutputStream();
+            ExcelUtilManySheetThird<List<ExcelExp>> util6 = new ExcelUtilManySheetThird<List<ExcelExp>>(mysheet6);
+
+            util6.exportExcelManySheet(bos6, mysheet6);
+
+            //  System.out.println(bos2);
             zos.putNextEntry(entry1);
-            ByteOutputStream bos1 = new ByteOutputStream();
-            util1.byteOutputStreamExcel(bos1, lrs,"绉讳氦娓呭崟", "");
-            bos1.writeTo(zos);
+          //  ByteOutputStream bos1 = new ByteOutputStream();
+           // util6.byteOutputStreamExcel(bos1, lrs,"绉讳氦娓呭崟", "");
+            bos6.writeTo(zos);
+
+
+
+
             for(int i = 0; i < ids.length; i++) {
 
                 // 鑾峰彇鏂囦欢鐨勪繚瀛樹綅缃�,璇诲彇鏁版嵁搴�,
@@ -206,7 +237,7 @@
                 }
                 //娣诲姞07  鐨刾df
                 //pdf鐩綍灏侀潰
-                String pdfPathF = "07-鍗烽潰灏侀潰.pdf";
+                String pdfPathF = "07-妗堝嵎灏侀潰.pdf";
                 pdfGenerateService.generatePdf(pdfPathF, ids[i]);
                 // 2. 鍘嬬缉PDF鍒癦IP鏂囦欢
                 // 娣诲姞PDF鏂囦欢鍒癦IP
@@ -221,6 +252,111 @@
                         zos.write(buffer, 0, len);
                     }
                 }
+
+                //08-鍗峰唴鍗峰唴鐩綍鐨刾df
+                String pdf08Path= "08-鍗峰唴鐩綍.pdf";
+                List<DocumentMaterialsVo> list3 = dsvs;
+                if(list3.size()>0) {
+                    pdfGenerateService.generateFileDirectoryPdf(pdf08Path, list3);
+                    ZipEntry zipEntry3 = new ZipEntry(fna + adir +"/"+pdf08Path);
+                    zos.putNextEntry(zipEntry3);
+
+                    // 璇诲彇PDF鏂囦欢鍐呭骞跺啓鍏IP
+                    try (FileInputStream fis = new FileInputStream(pdf08Path)) {
+                        byte[] buffer = new byte[1024];
+                        int len;
+                        while ((len = fis.read(buffer)) > 0) {
+                            zos.write(buffer, 0, len);
+                        }
+                    }
+                }
+                //09-澶囪�冭〃.pdf
+                String pdf09Path = "09-澶囪�冭〃.pdf";
+                pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), ids[i]);
+                // 2. 鍘嬬缉PDF鍒癦IP鏂囦欢
+                // 娣诲姞PDF鏂囦欢鍒癦IP
+                ZipEntry zipEntry4 = new ZipEntry(fna + adir +"/"+pdf09Path);
+                zos.putNextEntry(zipEntry4);
+
+                // 璇诲彇PDF鏂囦欢鍐呭骞跺啓鍏IP
+                try (FileInputStream fis = new FileInputStream(pdf09Path)) {
+                    byte[] buffer = new byte[1024];
+                    int len;
+                    while ((len = fis.read(buffer)) > 0) {
+                        zos.write(buffer, 0, len);
+                    }
+                }
+
+                //excel 鍗峰唴灏侀潰瀵煎嚭zip
+                ZipEntry entryiv = new ZipEntry(fna + adir +"/"+"妗堝嵎灏侀潰" + ".xls");
+
+                List<ArchiveInfoVo> arsi = new ArrayList<>();
+                arsi.add(aIV);
+
+                String recordId1 = aIV.getRecordId();
+                byte[] imgr1 = barcodeService.generateBarcodeImage(recordId1);
+                byte[] sedcode = pdfGenerateService.createQrCodeN(recordId1, 30, 30);
+                ExcelExp e3 = new ExcelExp("妗堝嵎灏侀潰鏁版嵁",arsi, ArchiveInfoVo.class);
+                ExcelExp e4 = new ExcelExp("妗堝嵎灏侀潰",  arsi, recordId1, imgr1,sedcode, ArchiveInfoVo.class);
+                List<ExcelExp> mysheet1 = new ArrayList<ExcelExp>();
+                mysheet1.add(e3);
+                mysheet1.add(e4);
+                ByteOutputStream bos2 = new ByteOutputStream();
+                ExcelUtilManySheetSecond<List<ExcelExp>> util3 = new ExcelUtilManySheetSecond<List<ExcelExp>>(mysheet1);
+
+                util3.exportExcelManySheet(bos2, mysheet1);
+
+                //  System.out.println(bos2);
+                zos.putNextEntry(entryiv);
+
+//            ExcelUtil<ArchiveInfoVo> utilsv = new ExcelUtil<ArchiveInfoVo>(ArchiveInfoVo.class);
+//
+//
+//            ByteOutputStream boss = new ByteOutputStream();
+//            List<ArchiveInfoVo> aivs = new ArrayList<>();
+//            aivs.add(aIV);
+//            utilsv.byteOutputStreamExcel(boss, aivs,"Date List", "");
+                bos2.writeTo(zos);
+
+
+
+                //鍐欏叆鐢靛瓙鐩綍  xsxl
+
+                ZipEntry entry5 = new ZipEntry(fna + adir +"/"+"鐢靛瓙鏂囦欢鐩綍" + ".xls");
+                ExcelUtil<DocumentMaterialsVoLarge> util5 = new ExcelUtil<DocumentMaterialsVoLarge>(DocumentMaterialsVoLarge.class);
+
+                zos.putNextEntry(entry5);
+                ByteOutputStream bos5 = new ByteOutputStream();
+                util5.byteOutputStreamExcel(bos5, docs,"鐢靛瓙鏂囦欢鐩綍", "");
+                bos5.writeTo(zos);
+
+                //鎷垮埌鍗峰唴鐩綍鐨別xcel
+                List<DocumentMaterialsVoSmall> list2 = dsvs.stream().map(res1 -> new DocumentMaterialsVoSmall(res1.getNum(), res1.getDocumentNumber(),res1.getCreator(),
+                        res1.getTitle(), res1.getDate(), res1.getPageNumber(), res1.getRemarks())).collect(Collectors.toList());
+                if(!dsvs.isEmpty()) {
+                    String recordId = dsvs.get(0).getRecordId();
+                    byte[] imgr = barcodeService.generateBarcodeImage(recordId);
+                    ExcelExp e1 = new ExcelExp("鍗峰唴鐩綍鏁版嵁", dsvs, DocumentMaterialsVo.class);
+                    ExcelExp e2 = new ExcelExp("鍗峰唴鏁版嵁", list2, recordId, imgr, DocumentMaterialsVoSmall.class);
+                    List<ExcelExp> mysheet = new ArrayList<ExcelExp>();
+                    mysheet.add(e1);
+                    mysheet.add(e2);
+                    ExcelUtilManySheet<List<ExcelExp>> util2 = new ExcelUtilManySheet<List<ExcelExp>>(mysheet);
+                    ZipEntry entr = new ZipEntry(fna + adir + "/" + "鍗峰唴鐩綍" + ".xls");
+                    // ExcelUtil<DocumentMaterialsVo> util1 = new ExcelUtil<DocumentMaterialsVo>(DocumentMaterialsVo.class);
+                    System.out.println(dsvs);
+                    zos.putNextEntry(entr);
+                    ByteOutputStream bos8 = new ByteOutputStream();
+
+                    util2.exportExcelManySheet(bos6, mysheet);
+
+                    //   util1.byteOutputStreamExcel(bos1, dsvs,"Date List", "");
+                    bos8.writeTo(zos);
+                }
+                //鎶奺xcel杞负pdf
+
+
+
                 byte[] buf = new byte[1024];
                 for (DocumentMaterialsVoLarge dc : docs) {
                     String filePath = dc.getUrl();
@@ -264,8 +400,11 @@
                     in.close();
                 }
             }
-            System.out.println(file.getName());
-            writeFileToRes(response, file.getName(), file);
+
+            //鍒犻櫎鍘嬬缉鍖�
+//            if(file.exists()){
+//                file.delete();
+//            }
 
         } catch (Exception e) {
             throw new RuntimeException(e);
@@ -287,6 +426,11 @@
                 }
             }
         }
+
+        System.out.println(file.getName());
+        System.out.println(file.getTotalSpace());
+        //    file.
+        writeFileToRes(response, file.getName(), file);
 
     }
 
@@ -352,8 +496,9 @@
 
         String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
         String filePath = RuoYiConfig.getDownloadPath() + fileName;
-
-
+        if(file.exists())
+            System.out.println("322329323232323");
+        System.out.println(filePath+"0009999999999");
         response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
         FileUtils.setAttachmentResponseHeader(response, realFileName);
         FileUtils.writeBytes(filePath, response.getOutputStream());
@@ -420,7 +565,7 @@
             zos = new ZipOutputStream(os);
 
             //pdf鐩綍灏侀潰
-            String pdfPathF = "07-鍗烽潰灏侀潰.pdf";
+            String pdfPathF = "07-妗堝嵎灏侀潰.pdf";
             pdfGenerateService.generatePdf(pdfPathF, 55L);
             // 2. 鍘嬬缉PDF鍒癦IP鏂囦欢
                 // 娣诲姞PDF鏂囦欢鍒癦IP
@@ -471,7 +616,7 @@
 
 
                 //excel 鍗峰唴灏侀潰瀵煎嚭zip
-            ZipEntry entryiv = new ZipEntry("鍗峰唴灏侀潰" + ".xls");
+            ZipEntry entryiv = new ZipEntry("妗堝嵎灏侀潰" + ".xls");
 
             List<ArchiveInfoVo> arsi = new ArrayList<>();
             arsi.add(aIV);

--
Gitblit v1.9.1