From fcc5194c1b671e76cb9054c9a14360139fe3be72 Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期二, 16 九月 2025 22:23:50 +0800
Subject: [PATCH] 新增了代码

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java |  667 ++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 439 insertions(+), 228 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 40d7f56..7b7f477 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,13 @@
 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.domain.ArchiveRecords;
 import com.ruoyi.domain.DocumentMaterials;
-import com.ruoyi.domain.vo.ArchiveInfoVo;
-import com.ruoyi.domain.vo.DocumentMaterialsVo;
+import com.ruoyi.domain.vo.*;
 import com.ruoyi.framework.web.domain.server.Sys;
 import com.ruoyi.service.IArchiveRecordsService;
 import com.ruoyi.service.IDocumentMaterialsService;
@@ -25,6 +28,7 @@
 import org.apache.poi.xssf.usermodel.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -36,9 +40,13 @@
 import java.net.URLEncoder;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.List;
+import java.util.stream.Collectors;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 import java.util.zip.ZipInputStream;
@@ -59,18 +67,355 @@
 
     @Autowired
     private IArchiveRecordsService iArchiveRecordsService;
+
+
+
+
+
+    @PostMapping("/importTemplate")
+    public void importTemplate(HttpServletResponse response) throws IOException
+    {
+        //瀵煎嚭鍗烽潰灏侀潰浠g爜
+
+        ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(55L);
+        List<ArchiveInfoVo> arsi = new ArrayList<>();
+        arsi.add(aIV);
+
+        String recordId = aIV.getRecordId();
+        byte[] imgr = barcodeService.generateBarcodeImage(recordId);
+        byte[] sedcode = pdfGenerateService.createQrCodeN(recordId, 30, 30);
+        ExcelExp e1 = new ExcelExp("妗堝嵎灏侀潰鏁版嵁",arsi, ArchiveInfoVo.class);
+        ExcelExp e2 = new ExcelExp("妗堝嵎灏侀潰",  arsi, recordId, imgr,sedcode, ArchiveInfoVo.class);
+        List<ExcelExp> mysheet = new ArrayList<ExcelExp>();
+        mysheet.add(e1);
+        mysheet.add(e2);
+        ByteOutputStream bos1 = new ByteOutputStream();
+        ExcelUtilManySheetSecond<List<ExcelExp>> util2 = new ExcelUtilManySheetSecond<List<ExcelExp>>(mysheet);
+
+      //  util2.exportExcelManySheet(response, mysheet);
+
+
+
+        //瀵煎嚭鍗烽潰鐩綍浠g爜
+//        DocumentMaterials documentMaterials = new DocumentMaterials();
+//        documentMaterials.setRecordId(55L);
+//      //  List<DocumentMaterials> docs = documentMaterialsService.selectDocumentMaterialsList(documentMaterials);
+//        List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo("55");
+//      //  dsvs.get(0).setUrl("/profile/upload/2025/08/14/30_20250814212128A031.jpg");
+//
+//
+//      //  dsvs.stream().map()
+//        List<DocumentMaterialsVoSmall> list2 = dsvs.stream().map(res -> new DocumentMaterialsVoSmall(res.getNum(), res.getDocumentNumber(),res.getCreator(),
+//                res.getTitle(), res.getDate(), res.getPageNumber(), res.getRemarks())).collect(Collectors.toList());
+//
+//        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);
+       // util2.exportExcelManySheet(response, mysheet);
+
+    }
+
+
+
+    @PostMapping("/exportChooseArchive/{ids}")
+    public void exportChooseArchive(HttpServletResponse response,  @PathVariable Long[] ids)throws Exception
+    {
+        System.out.println("092939932");
+        String zipFileName ="test" +".zip";
+        //鐢熸垚鍘嬬缉鍖呭瓨鍌ㄥ湴鍧�锛堟渶鍚庝細鍒犳帀锛�
+        String fileZip = RuoYiConfig.getProfile() + "/download/" + zipFileName;
+        OutputStream os=null;
+        ZipOutputStream zos = null ;
+        System.out.println("==============_______________");
+        System.out.println(ids.length);
+        File file = new File(fileZip);
+        try {
+            if (!file.getParentFile().exists()) {
+                file.getParentFile().mkdirs();
+            }
+            os = new FileOutputStream(file);
+            //鍘嬬缉鏂囦欢
+            zos = new ZipOutputStream(os);
+            //鎷垮埌褰撳墠鐨勬椂闂�
+            LocalDate date = LocalDate.now();
+            System.out.println("褰撳墠鏃ユ湡: " + date);
+
+
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
+            String formattedDate = date.format(formatter);
+            System.out.println(formattedDate);
+            String fna = "GH"+20250908+"/";
+            zos.putNextEntry(new ZipEntry(fna));
+
+
+            //娣诲姞ids鐨勫叏閮ㄦ暟鎹埌excel
+            ArchiveRecords archiveRecords = new ArchiveRecords();
+            archiveRecords.setIds(ids);
+            List<ArchiveRecords> lis = iArchiveRecordsService.selectArchiveRecordsList(archiveRecords);
+            //妗堝嵎鐩綍瀵煎嚭
+            ZipEntry entry = new ZipEntry("妗堝嵎鐩綍" + ".xls");
+            ExcelUtil<ArchiveRecords> util = new ExcelUtil<ArchiveRecords>(ArchiveRecords.class);
+
+            zos.putNextEntry(entry);
+            ByteOutputStream bos = new ByteOutputStream();
+            util.byteOutputStreamExcel(bos, lis,"妗堝嵎鐩綍", "");
+            bos.writeTo(zos);
+
+            //绉讳氦娓呭崟
+            List<ArchiveRecordSmall> lrs = iArchiveRecordsService.findByIds(archiveRecords);
+            System.out.println(lrs);
+            ZipEntry entry1 = new ZipEntry("绉讳氦娓呭崟" + ".xls");
+            ExcelUtil<ArchiveRecordSmall> util1 = new ExcelUtil<ArchiveRecordSmall>(ArchiveRecordSmall.class);
+
+            zos.putNextEntry(entry1);
+            ByteOutputStream bos1 = new ByteOutputStream();
+            util1.byteOutputStreamExcel(bos1, lrs,"绉讳氦娓呭崟", "");
+            bos1.writeTo(zos);
+            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");
+
+
+                //.selectDocumentMaterialsList(documentMaterials);
+                List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(ids[i].toString());
+                ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(ids[i]);
+
+                String adir = aIV.getInquiryNumber() + " " + aIV.getRecordId();
+                System.out.println(fna+adir);
+                zos.putNextEntry(new ZipEntry(fna + adir + "/"));
+
+                //鍦ㄩ噷闈㈡坊鍔犳枃浠�
+                boolean res = true;
+                if(res) {
+                    zos.putNextEntry(new ZipEntry(fna + adir + "/01-鐢宠鏉愭枡/"));
+                    zos.putNextEntry(new ZipEntry(fna + adir + "/02-鍔炴杩囩▼鏉愭枡/"));
+                    zos.putNextEntry(new ZipEntry(fna + adir + "/03-缁撹鎬ф枃浠�/"));
+                    zos.putNextEntry(new ZipEntry(fna + adir + "/04-鍏朵粬鏉愭枡/"));
+                    zos.putNextEntry(new ZipEntry(fna + adir + "/05-妗f鍙樻洿鏉愭枡/"));
+                    zos.putNextEntry(new ZipEntry(fna + adir + "/06-涓氬姟鏁版嵁/"));
+                    res = false;
+                }
+                //娣诲姞07  鐨刾df
+                //pdf鐩綍灏侀潰
+                String pdfPathF = "07-鍗烽潰灏侀潰.pdf";
+                pdfGenerateService.generatePdf(pdfPathF, ids[i]);
+                // 2. 鍘嬬缉PDF鍒癦IP鏂囦欢
+                // 娣诲姞PDF鏂囦欢鍒癦IP
+                ZipEntry zipEntry2 = new ZipEntry(fna + adir +"/"+pdfPathF);
+                zos.putNextEntry(zipEntry2);
+
+                // 璇诲彇PDF鏂囦欢鍐呭骞跺啓鍏IP
+                try (FileInputStream fis = new FileInputStream(pdfPathF)) {
+                    byte[] buffer = new byte[1024];
+                    int len;
+                    while ((len = fis.read(buffer)) > 0) {
+                        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,"鐢靛瓙鏂囦欢鐩綍", "");
+                bos.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 bos6 = new ByteOutputStream();
+
+                    util2.exportExcelManySheet(bos6, mysheet);
+
+                    //   util1.byteOutputStreamExcel(bos1, dsvs,"Date List", "");
+                    bos6.writeTo(zos);
+                }
+                //鎶奺xcel杞负pdf
+
+
+
+                byte[] buf = new byte[1024];
+                for (DocumentMaterialsVoLarge dc : docs) {
+                    String filePath = dc.getUrl();
+                    if(filePath==null)
+                        continue;
+                    filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/");
+
+                    System.out.println(filePath);
+                    File tempFile = new File(filePath);
+
+                    //鍦ㄥ帇缂╁寘涓坊鍔犳枃浠跺す
+
+                    //寰楀埌鏂囦欢鍚峟rontCompWithZore(4, dc.get)+
+                    String fname = frontCompWithZore(4, dc.getFileNumber().intValue())+"-"+dc.getTitle()+"-"+frontCompWithZore(4,dc.getPageNumber().intValue())+"."
+                            +dc.getUrl().split("\\.")[1];
+                    if(dc.getStage().equals("01-鐢宠鏉愭枡"))
+                        zos.putNextEntry(new ZipEntry(fna + adir + "/01-鐢宠鏉愭枡/"+fname));
+                    else if(dc.getStage().equals("02-鍔炴杩囩▼鏉愭枡"))
+                        zos.putNextEntry(new ZipEntry(fna + adir + "/02-鍔炴杩囩▼鏉愭枡/"+fname));
+                    else if(dc.getStage().equals("03-缁撹鎬ф枃浠�"))
+                        zos.putNextEntry(new ZipEntry(fna + adir + "/03-缁撹鎬ф枃浠�/"+fname));
+                    else if(dc.getStage().equals("04-鍏朵粬鏉愭枡")) {
+                        zos.putNextEntry(new ZipEntry(fna + adir + "/04-鍏朵粬鏉愭枡/" + fname));
+                    }
+                    else if(dc.getStage().equals("05-妗f鍙樻洿鏉愭枡"))
+                        zos.putNextEntry(new ZipEntry(fna + adir + "/05-妗f鍙樻洿鏉愭枡/"+fname));
+                    else if(dc.getStage().equals("06-涓氬姟鏁版嵁"))
+                        zos.putNextEntry(new ZipEntry(fna + adir + "/06-涓氬姟鏁版嵁/"+fname));
+                    else
+                        zos.putNextEntry(new ZipEntry(fna + adir + "/"+fname));
+
+
+
+                    int len;
+                    FileInputStream in = new FileInputStream(tempFile);
+                    while ((len = in.read(buf)) != -1){
+                        zos.write(buf, 0, len);
+                    }
+                    //  zos.putNextEntry(new ZipEntry("04-鍏朵粬鏉愭枡"));
+                    zos.closeEntry();
+                    in.close();
+                }
+            }
+            System.out.println(file.getName());
+            writeFileToRes(response, file.getName(), file);
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }finally {
+            //鍏抽棴娴�
+            if(zos != null){
+                try {
+                    zos.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            //鍏抽棴娴�
+            if(os!= null){
+                try {
+                    os.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+
+    }
+
+
+
+
+
+
     /**
      * 鎵撳寘涓嬭浇
      * @param response
      * @param
      */
-    @PostMapping("/export")
+    @PostMapping("/export/{id}")
 
-    public void packDownload(HttpServletResponse response, Long id) throws Exception {
+    public void packDownload(HttpServletResponse response,  @PathVariable Long id) throws Exception {
         // 鑾峰彇鏂囦欢鐨勪繚瀛樹綅缃�,璇诲彇鏁版嵁搴�,
         DocumentMaterials documentMaterials = new DocumentMaterials();
         documentMaterials.setRecordId(id);
-        List<DocumentMaterials> docs = documentMaterialsService.selectDocumentMaterialsList(documentMaterials);
+        List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(id);
+       System.out.println(docs.size()+"----009");
+
+
+                //.selectDocumentMaterialsList(documentMaterials);
         List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString());
         ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(id);
 
@@ -93,8 +438,11 @@
             String datumName = "user";
             //鍘嬬缉鏂囦欢
             List<String> filePathList = paths;
-            File file = compressedFileToZip(docs, dsvs, aIV);
+            File file = compressedFileToZip(docs, dsvs, aIV, id);
             System.out.println(file.getName());
+
+            String fileName =aIV.getRecordId()+".zip";
+
             //杈撳嚭鏂囦欢娴�
             writeFileToRes(response, file.getName(), file);
             //鍒犻櫎鍘嬬缉鍖�
@@ -114,26 +462,7 @@
         response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
         FileUtils.setAttachmentResponseHeader(response, realFileName);
         FileUtils.writeBytes(filePath, response.getOutputStream());
-        //        FileInputStream inputStream = new FileInputStream(file);
-//        //1.璁剧疆鏂囦欢ContentType绫诲瀷锛岃繖鏍疯缃紝浼氳嚜鍔ㄥ垽鏂笅杞芥枃浠剁被鍨�.
-//        response.setContentType("application/octet-stream");
-//        //2.璁剧疆鏂囦欢澶达細鏈�鍚庝竴涓弬鏁版槸璁剧疆涓嬭浇鏂囦欢鍚�
-//        response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
-//        response.addHeader("Content-Length", "" + file.length());
-//
-//        //3.閫氳繃response鑾峰彇ServletOutputStream瀵硅薄(out)
-//        ServletOutputStream out = response.getOutputStream();
-//
-//        int b = 0;
-//        byte[] buffer = new byte[1024];
-//        while (b != -1) {
-//            b = inputStream.read(buffer);
-//            //4.鍐欏埌杈撳嚭娴�(out)涓�
-//            out.write(buffer, 0, b);
-//        }
-//        out.flush();
-//        out.close();
-//        inputStream.close();
+
     }
     public String frontCompWithZore(int formatLength,int formatNumber){
         /**
@@ -146,82 +475,7 @@
         return newString;
     }
 
-    private void handleXSSFImages(XSSFSheet sheet, Document pdfDoc) throws Exception {
-        XSSFDrawing drawing = sheet.getDrawingPatriarch();
-        if (drawing == null) return;
 
-        for (XSSFShape shape : drawing.getShapes()) {
-            if (shape instanceof XSSFPicture) {
-                XSSFPicture pic = (XSSFPicture)shape;
-                XSSFClientAnchor anchor = pic.getPreferredSize();
-
-                // 鑾峰彇鍥剧墖鏁版嵁
-                byte[] bytes = pic.getPictureData().getData();
-                Image pdfImage = Image.getInstance(bytes);
-
-                // 璁剧疆鍥剧墖浣嶇疆鍜屽ぇ灏�
-                float imageWidth = pdfImage.getWidth();
-                float imageHeight = pdfImage.getHeight();
-                float scale = Math.min(
-                        (PageSize.A4.getWidth() - 100) / imageWidth,
-                        (PageSize.A4.getHeight() - 100) / imageHeight
-                );
-                pdfImage.scaleAbsolute(imageWidth * scale, imageHeight * scale);
-
-                // 娣诲姞鍥剧墖鍒癙DF
-                pdfDoc.add(pdfImage);
-                pdfDoc.add(Chunk.NEWLINE);
-            }
-        }
-    }
-
-
-
-
-    private static String getCellValue(Cell cell,FormulaEvaluator evaluator) {
-      //  System.out.println(cell);
-        if (cell == null) return "";
-        CellValue cellValue = evaluator.evaluate(cell);
-        if(cellValue==null)
-            return "";
-      //  System.out.println(cellValue.getCellType());
-        switch (cellValue.getCellType()) {
-            case STRING:
-                return cell.getStringCellValue();
-            case NUMERIC:
-                // 鑾峰彇鏁板�煎苟杞负鏁村瀷
-                double numericValue = cell.getNumericCellValue();
-                // 鍒ゆ柇鏄惁涓烘暣鏁�
-                if (numericValue == (int)numericValue) {
-                    if((int)numericValue==0)
-                        return "";
-                    else
-                        return String.valueOf((int)numericValue);
-                } else {
-                    return String.valueOf(numericValue); // 鎴栬�呮牴鎹渶瑕佽繑鍥炲洓鑸嶄簲鍏ョ殑鏁村瀷
-                }
-
-            case BOOLEAN:
-                return String.valueOf(cell.getBooleanCellValue());
-            case FORMULA:
-
-                return cell.getCellFormula()+"";
-            case BLANK:
-                return "";
-            default:
-                return "";
-        }
-    }
-    private int getRealLastCellNum(Row row) {
-        int lastCellNum = 0;
-        for (int i = 0; i < row.getLastCellNum(); i++) {
-            Cell cell = row.getCell(i);
-            if (cell != null && cell.getCellType() != CellType.BLANK) {
-                lastCellNum = i + 1;
-            }
-        }
-        return lastCellNum;
-    }
 
 
 
@@ -252,10 +506,10 @@
 
 
     // 鍘嬬缉鏂囦欢
-    private File compressedFileToZip(List<DocumentMaterials> docs, List<DocumentMaterialsVo> dsvs,   ArchiveInfoVo aIV) throws Exception {
+    private File compressedFileToZip(List<DocumentMaterialsVoLarge> docs, List<DocumentMaterialsVo> dsvs,   ArchiveInfoVo aIV, Long id) throws Exception {
         //鍘嬬缉鍖呭叿浣撳悕绉帮紙鎷兼帴鏃堕棿鎴抽槻姝㈤噸鍚嶏級
         String datumName = "";
-        String zipFileName = datumName + "-" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".zip";
+        String zipFileName =dsvs.get(0).getDocumentNumber()+aIV.getRecordId()+ ".zip";
         //鐢熸垚鍘嬬缉鍖呭瓨鍌ㄥ湴鍧�锛堟渶鍚庝細鍒犳帀锛�
         String fileZip = RuoYiConfig.getProfile() + "/download/" + zipFileName;
         OutputStream os=null;
@@ -272,7 +526,7 @@
 
             //pdf鐩綍灏侀潰
             String pdfPathF = "07-鍗烽潰灏侀潰.pdf";
-            pdfGenerateService.generatePdf(pdfPathF);
+            pdfGenerateService.generatePdf(pdfPathF, 55L);
             // 2. 鍘嬬缉PDF鍒癦IP鏂囦欢
                 // 娣诲姞PDF鏂囦欢鍒癦IP
                 ZipEntry zipEntry = new ZipEntry(pdfPathF);
@@ -286,158 +540,115 @@
                         zos.write(buffer, 0, len);
                     }
                 }
+            //08-鍗峰唴鍗峰唴鐩綍鐨刾df
+            String pdf08Path= "08-鍗峰唴鐩綍.pdf";
+            List<DocumentMaterialsVo> list3 = dsvs;
+            pdfGenerateService.generateFileDirectoryPdf(pdf08Path, list3);
+            ZipEntry zipEntry2 = new ZipEntry(pdf08Path);
+            zos.putNextEntry(zipEntry2);
+
+            // 璇诲彇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(), id);
+            // 2. 鍘嬬缉PDF鍒癦IP鏂囦欢
+            // 娣诲姞PDF鏂囦欢鍒癦IP
+            ZipEntry zipEntry1 = new ZipEntry(pdf09Path);
+            zos.putNextEntry(zipEntry1);
+
+            // 璇诲彇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("鍗峰唴灏侀潰" + ".xls");
-            ExcelUtil<ArchiveInfoVo> utilsv = new ExcelUtil<ArchiveInfoVo>(ArchiveInfoVo.class);
 
+            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);
-            ByteOutputStream boss = new ByteOutputStream();
-            List<ArchiveInfoVo> aivs = new ArrayList<>();
-            aivs.add(aIV);
-            utilsv.byteOutputStreamExcel(boss, aivs,"Date List", "");
-            boss.writeTo(zos);
+
+//            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 entry = new ZipEntry("鐢靛瓙鏂囦欢鐩綍" + ".xls");
-            ExcelUtil<DocumentMaterials> util = new ExcelUtil<DocumentMaterials>(DocumentMaterials.class);
+            ExcelUtil<DocumentMaterialsVoLarge> util = new ExcelUtil<DocumentMaterialsVoLarge>(DocumentMaterialsVoLarge.class);
 
             zos.putNextEntry(entry);
             ByteOutputStream bos = new ByteOutputStream();
-            util.byteOutputStreamExcel(bos, docs,"Date List", "");
+            util.byteOutputStreamExcel(bos, docs,"鐢靛瓙鏂囦欢鐩綍", "");
             bos.writeTo(zos);
 
             //鎷垮埌鍗峰唴鐩綍鐨別xcel
+            List<DocumentMaterialsVoSmall> list2 = dsvs.stream().map(res -> new DocumentMaterialsVoSmall(res.getNum(), res.getDocumentNumber(),res.getCreator(),
+                    res.getTitle(), res.getDate(), res.getPageNumber(), res.getRemarks())).collect(Collectors.toList());
+
+            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("鍗峰唴鐩綍" + ".xls");
             ExcelUtil<DocumentMaterialsVo> util1 = new ExcelUtil<DocumentMaterialsVo>(DocumentMaterialsVo.class);
             System.out.println(dsvs);
             zos.putNextEntry(entr);
             ByteOutputStream bos1 = new ByteOutputStream();
-            util1.byteOutputStreamExcel(bos1, dsvs,"Date List", "");
+
+            util2.exportExcelManySheet(bos1, mysheet);
+
+         //   util1.byteOutputStreamExcel(bos1, dsvs,"Date List", "");
             bos1.writeTo(zos);
             //鎶奺xcel杞负pdf
 
 
-            try {
-                // 1. 璇诲彇Excel鏂囦欢
-                String excelPath = RuoYiConfig.getProfile() + "/download/"+"鍗峰収鐩綍.xls";
-                String pdfPath = RuoYiConfig.getProfile() + "/download/"+"1.pdf";
-
-                Workbook workbook = WorkbookFactory.create(new File(excelPath));
-                FileOutputStream fos = new FileOutputStream(pdfPath);
-                FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
 
 
-                // 鑾峰彇绗竴涓伐浣滆〃
-                    Sheet sheet = workbook.getSheetAt(1);
-
-                    // 鍒涘缓PDF鏂囨。瀵硅薄
-                    Document document = new Document(PageSize.A2, 50, 50, 50, 50);
-
-                    // 鍒涘缓PDF杈撳嚭娴�
-                    PdfWriter writer = PdfWriter.getInstance(document, fos);
-                // 4. 澶勭悊宸ヤ綔琛ㄤ腑鐨勫浘鐗�
-                if (workbook instanceof XSSFWorkbook) {
-                    handleXSSFImages((XSSFSheet)sheet, document);
-                }
-                    // 鎵撳紑PDF鏂囨。
-                    document.open();
-
-                    // 鍒涘缓PDF琛ㄦ牸瀵硅薄
-                System.out.println(sheet.getRow(0).getLastCellNum()+"--00");
-                    PdfPTable table = new PdfPTable(sheet.getRow(0).getLastCellNum());
-                    table.setHeaderRows(1);
-
-                    // 璁剧疆琛ㄦ牸瀹藉害
-                    table.setWidthPercentage(100);
-
-                    // 璁剧疆琛ㄦ牸鏍囬
-                    Paragraph title = new Paragraph(sheet.getSheetName(), new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 16, Font.BOLD));
-                    title.setAlignment(Element.ALIGN_CENTER);
-                    document.add(title);
-                   // System.out.println(sheet.)
-                    // 娣诲姞琛ㄦ牸鍐呭
-                    for (Row row : sheet) {
-                        {
-                            if (row == null) continue;
-                            System.out.println(getRealLastCellNum(row)+"---987");
-//                            if(row.getRowNum()==0)
-//                                continue;
-                            if(row.getRowNum()==2)
-                            {
-                                PdfPCell pdfCell = ImageSet(100);
-                                pdfCell.setColspan(7);
-                                pdfCell.setRowspan(3);
-                                pdfCell.setBorderWidth(1f);
-                                pdfCell.setBorderColor(BaseColor.BLACK);
-                                pdfCell.setPadding(5f);
-                                pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
-                                pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
-                                table.addCell(pdfCell);
-                                System.out.println("{{{{{{{{{{{{{");
-                                continue;
-                            }
-                            for (int i = 0; i < 7; i++)
-                            {
-
-                                Cell cell = row.getCell(i);
-                                if(row.getRowNum()==3)
-                                {
-                                    PdfPCell pdfCell = new PdfPCell(new Paragraph("鍗峰唴鐩綍", new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 12)));
-                                    pdfCell.setColspan(7);
-                                    pdfCell.setBorderWidth(1f);
-                                    pdfCell.setBorderColor(BaseColor.BLACK);
-                                    pdfCell.setPadding(5f);
-                                    pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
-                                    pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
-                                    table.addCell(pdfCell);
-                                    System.out.println("{{{{{{{{{{{{{");
-                                    break;
-                                }
-                                if(cell==null) {
-
-                                    table.addCell("");
-                                    continue;
-                                }
-                                PdfPCell pdfCell = new PdfPCell(new Paragraph(getCellValue(cell, evaluator), new Font(BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED), 12)));
-
-                                if(row.getRowNum()!=1) {
-                                    pdfCell.setBorderWidth(1f);
-                                    pdfCell.setBorderColor(BaseColor.BLACK);
-                                    pdfCell.setPadding(5f);
-                                    pdfCell.setHorizontalAlignment(Element.ALIGN_CENTER);
-                                    pdfCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
-                                }
-                                if (cell.getRowIndex() == 5) {
-                                    pdfCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
-                                }
-
-                                table.addCell(pdfCell);
-
-                            }
-                        }
-                    }
-
-                    // 娣诲姞琛ㄦ牸鍒癙DF鏂囨。
-                    table.setSpacingBefore(20f);
-                    table.setSpacingAfter(20f);
-                    table.setKeepTogether(true);
-                    document.add(table);
-
-                    // 鍏抽棴PDF鏂囨。
-                    document.close();
-
-
-
-
-
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
             boolean res = true;
 
             byte[] buf = new byte[1024];
-            for (DocumentMaterials dc : docs) {
+            for (DocumentMaterialsVoLarge dc : docs) {
                 String filePath = dc.getUrl();
+                if(filePath==null)
+                    continue;
                 filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/");
 
                 System.out.println(filePath);

--
Gitblit v1.9.1