fei
6 天以前 1868fe69485d0d904bba24f2672a52a626ccf9f2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java
@@ -528,24 +528,107 @@
                    }
                }
                //09-备考表.pdf
//                pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), ids[i]);
//                // 2. 压缩PDF到ZIP文件
//                // 添加PDF文件到ZIP
//                ZipEntry zipEntry4 = new ZipEntry(fna + adir +"/"+pdf09Path);
//                zos.putNextEntry(zipEntry4);
//
//                // 读取PDF文件内容并写入ZIP
//                try (FileInputStream fis = new FileInputStream(pdf09Path)) {
//                    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);
                //拿到相关数据
                List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(ids[i]));
                LocalDate currentDate = LocalDate.now();
                String cdt = currentDate.getYear()+"年"+currentDate.getMonthValue()+"月"+currentDate.getDayOfMonth()+"日";
                pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), ids[i]);
                // 2. 压缩PDF到ZIP文件
                // 添加PDF文件到ZIP
                HashMap<String, Object> hs = new HashMap<String, Object>();
                int allPages = 0;
                int texPages = 0;
                int picPages = 0;
                int patPages = 0;
                if(!dmfs.isEmpty())
                {
                    for(DocumentMaterialFileStyle documentMaterialFileStyle:dmfs)
                    {
                        if(documentMaterialFileStyle.getFileStyle().equals("文字材料"))
                            texPages = documentMaterialFileStyle.getCnt();
                        if(documentMaterialFileStyle.getFileStyle().equals("图样材料"))
                            patPages = documentMaterialFileStyle.getCnt();
                        if(documentMaterialFileStyle.getFileStyle().equals("照片材料"))
                            picPages = documentMaterialFileStyle.getCnt();
                    }
                }
                allPages = texPages + picPages + patPages;
                hs.put("pages", allPages);
                hs.put("patPages", patPages);
                hs.put("picPages", picPages);
                hs.put("texPages", texPages);
                hs.put("volumeNumber", aIV.getRecordId());
                hs.put("time", cdt);
                if (!getLicense()) {
                    System.out.println("没有相关证书!");
                }
                try {
                    // 获取 Word 模板所在路径
                    String filepath = "09-备考表.docx";
                    // 通过 XWPFTemplate 编译文件并渲染数据到模板中
                    XWPFTemplate template = XWPFTemplate.compile(filepath).render(hs
                    );
                    String renderedDocPath = "rendered_output.docx";
                    File renderedFile = new File(renderedDocPath);
                    try {
                        // 将完成数据渲染的文档写出
                        template.writeAndClose(new FileOutputStream(renderedFile));
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    com.aspose.words.Document doc = new com.aspose.words.Document("rendered_output.docx");
                    // 创建临时字节输出流
                    ByteArrayOutputStream baobk = new ByteArrayOutputStream();
                    // 将Word文档转换为PDF字节数组
                    doc.save(baobk, com.aspose.words.SaveFormat.PDF);//ȫ��֧��DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF �໥ת��
                ZipEntry zipEntry4 = new ZipEntry(fna + adir +"/"+pdf09Path);
                zos.putNextEntry(zipEntry4);
                    baobk.writeTo(zos);
                // 读取PDF文件内容并写入ZIP
                try (FileInputStream fis = new FileInputStream(pdf09Path)) {
                    byte[] buffer = new byte[1024];
                    int len;
                    while ((len = fis.read(buffer)) > 0) {
                        zos.write(buffer, 0, len);
                } catch (Exception e) {
                    e.printStackTrace();
                    }
                }
             //   com.aspose.words.Document doc = new com.aspose.words.Document("09-备考表.docx");
                //excel 卷内封面导出zip
                ZipEntry entryiv = new ZipEntry(fna + adir +"/"+"案卷封面" + ".xls");
@@ -867,23 +950,30 @@
            String cdt = currentDate.getYear()+"年"+currentDate.getMonthValue()+"月"+currentDate.getDayOfMonth()+"日";
            HashMap<String, Object> hs = new HashMap<String, Object>();
            if(dmfs.isEmpty())
            int allPages = 0;
            int texPages = 0;
            int picPages = 0;
            int patPages = 0;
            if(!dmfs.isEmpty())
            {
                //全部数据值为0
                hs.put("pages", 0);
                for(DocumentMaterialFileStyle documentMaterialFileStyle:dmfs)
                {
                    if(documentMaterialFileStyle.getFileStyle().equals("文字材料"))
                        texPages = documentMaterialFileStyle.getCnt();
                    if(documentMaterialFileStyle.getFileStyle().equals("图样材料"))
                        patPages = documentMaterialFileStyle.getCnt();
                    if(documentMaterialFileStyle.getFileStyle().equals("照片材料"))
                        picPages = documentMaterialFileStyle.getCnt();
                }
            }
            allPages = texPages + picPages + patPages;
            hs.put("pages", allPages);
            hs.put("patPages", patPages);
            hs.put("picPages", picPages);
            hs.put("texPages", texPages);
                hs.put("volumeNumber", aIV.getRecordId());
                hs.put("time", cdt);
            }
            else {
                int pcc = dmfs.size()<=1?0: dmfs.get(1).getCnt();
                int oth = dmfs.size()<=2?0: dmfs.get(2).getCnt();
                int allCnt = dmfs.get(0).getCnt() + pcc + oth;
                hs.put("pages", allCnt);
                hs.put("volumeNumber", aIV.getRecordId());
                hs.put("time", cdt);
            }
            if (!getLicense()) {
                System.out.println("没有相关证书!");
            }
@@ -1169,7 +1259,9 @@
                    res = false;
                }
                //得到文件名frontCompWithZore(4, dc.get)+
                String fname = frontCompWithZore(4, dc.getFileNumber().intValue())+"-"+dc.getTitle()+"-"+frontCompWithZore(4,dc.getPageNumber().intValue())+"."
                String fname = "";
                if(dc.getFileNumber()!=null&&dc.getPageNumber()!=null) {
                    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("01-申请材料/"+fname));
@@ -1179,15 +1271,14 @@
                    zos.putNextEntry(new ZipEntry("03-结论性文件/"+fname));
                else if(dc.getStage().equals("04-其他材料")) {
                    zos.putNextEntry(new ZipEntry("04-其他材料/" + fname));
                }
                else if(dc.getStage().equals("05-档案变更材料"))
                    } else if (dc.getStage().equals("05-档案变更材料"))
                    zos.putNextEntry(new ZipEntry("05-档案变更材料/"+fname));
                else if(dc.getStage().equals("06-业务数据"))
                    zos.putNextEntry(new ZipEntry("06-业务数据/"+fname));
                else
                    zos.putNextEntry(new ZipEntry(fname));
                }
                int len;
                FileInputStream in = new FileInputStream(tempFile);