| | |
| | | |
| | | |
| | | |
| | | ExcelExp e6 = new ExcelExp("移交清单",lrs, ArchiveRecordSmall.class); |
| | | ExcelExp e6 = new ExcelExp("移交清单","GH" + formattedDate + sequence, lrs, ArchiveRecordSmall.class); |
| | | // ExcelExp e4 = new ExcelExp("案卷封面", arsi, recordId1, imgr1,sedcode, ArchiveInfoVo.class); |
| | | List<ExcelExp> mysheet6 = new ArrayList<ExcelExp>(); |
| | | mysheet6.add(e6); |
| | |
| | | |
| | | |
| | | |
| | | System.out.println(ids.length); |
| | | System.out.println("------------------"); |
| | | |
| | | for(int i = 0; i < ids.length; i++) { |
| | | System.out.println(ids[i]); |
| | | |
| | | // 获取文件的保存位置,读取数据库, |
| | | DocumentMaterials documentMaterials = new DocumentMaterials(); |
| | | documentMaterials.setRecordId(ids[i]); |
| | | List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(ids[i]); |
| | | System.out.println(docs.size()+"----009"); |
| | | System.out.println(docs.size()+"----7777"); |
| | | |
| | | |
| | | //.selectDocumentMaterialsList(documentMaterials); |
| | | List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(ids[i].toString()); |
| | | ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(ids[i]); |
| | | |
| | | System.out.println(aIV.getInquiryNumber()); |
| | | System.out.println(aIV.getRecordId()); |
| | | String adir = aIV.getInquiryNumber() + " " + aIV.getRecordId(); |
| | | System.out.println(adir); |
| | | System.out.println(fna+adir); |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/")); |
| | | |
| | |
| | | } |
| | | //添加07 的pdf |
| | | //pdf目录封面 |
| | | String pdfPathF = "07-案卷封面.pdf"; |
| | | pdfGenerateService.generatePdf(pdfPathF, ids[i]); |
| | | // 2. 压缩PDF到ZIP文件 |
| | | // 添加PDF文件到ZIP |
| | | ZipEntry zipEntry2 = new ZipEntry(fna + adir +"/"+pdfPathF); |
| | | zos.putNextEntry(zipEntry2); |
| | | // String pdfPathF = "07-案卷封面.pdf"; |
| | | // pdfGenerateService.generatePdf(pdfPathF, ids[i]); |
| | | // // 2. 压缩PDF到ZIP文件 |
| | | // // 添加PDF文件到ZIP |
| | | // ZipEntry zipEntry2 = new ZipEntry(fna + adir +"/"+pdfPathF); |
| | | // zos.putNextEntry(zipEntry2); |
| | | // |
| | | // // 读取PDF文件内容并写入ZIP |
| | | // try (FileInputStream fis = new FileInputStream(pdfPathF)) { |
| | | // byte[] buffer = new byte[1024]; |
| | | // int len; |
| | | // while ((len = fis.read(buffer)) > 0) { |
| | | // zos.write(buffer, 0, len); |
| | | // } |
| | | // } |
| | | |
| | | // 读取PDF文件内容并写入ZIP |
| | | 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-卷内卷内目录的pdf |
| | | 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文件内容并写入ZIP |
| | | 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 |
| | | |
| | | |
| | |
| | | // System.out.println(bos2); |
| | | zos.putNextEntry(entryiv); |
| | | |
| | | |
| | | bos2.writeTo(zos); |
| | | |
| | | |
| | | //pdf目录封面 |
| | | String pdfPathF = "07-案卷封面.pdf"; |
| | | // pdfGenerateService.generatePdf(pdfPathF, id); |
| | | |
| | | try { |
| | | if (!getLicenseExcel()) { |
| | | System.out.println("授权失败"); |
| | | // return ; |
| | | } |
| | | // 读取Excel文件 |
| | | com.aspose.cells.Workbook wb = poiToAspose(util3.getWb()); |
| | | |
| | | // 获取需要导出的sheet(索引从0开始) |
| | | int targetSheetIndex = 1; |
| | | com.aspose.cells.Worksheet targetSheet = wb.getWorksheets().get(targetSheetIndex); |
| | | targetSheet.autoFitRows(true); |
| | | System.out.println("当前sheet名称:" + targetSheet.getName()); |
| | | System.out.println("当前sheet索引:" + targetSheet.getIndex()); |
| | | |
| | | // 隐藏所有其他工作表 |
| | | for (int j = 0; j < wb.getWorksheets().getCount(); j++) { |
| | | if (j != targetSheetIndex) { |
| | | wb.getWorksheets().get(j).setVisible(false); |
| | | } |
| | | } |
| | | |
| | | // 设置活动工作表为目标工作表 |
| | | wb.getWorksheets().setActiveSheetIndex(targetSheetIndex); |
| | | // 创建PDF保存选项 |
| | | com.aspose.cells.PdfSaveOptions pdfSaveOptions = new com.aspose.cells.PdfSaveOptions(); |
| | | pdfSaveOptions.setCompliance(com.aspose.cells.PdfCompliance.PDF_A_1_B); |
| | | // 创建临时字节输出流 |
| | | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| | | |
| | | // 将新的Workbook保存为PDF到临时流 |
| | | // newWorkbook.save(baos, com.aspose.cells.SaveFormat.PDF); |
| | | wb.save(baos, pdfSaveOptions); |
| | | |
| | | // 将PDF添加到ZIP文件 |
| | | ZipEntry entry07 = new ZipEntry(fna + adir +"/"+pdfPathF); |
| | | zos.putNextEntry(entry07); |
| | | zos.write(baos.toByteArray()); |
| | | // zos.closeEntry(); |
| | | // 直接将原始工作簿保存为PDF(只包含可见的工作表) |
| | | |
| | | long now = System.currentTimeMillis(); |
| | | // System.out.println("pdf转换成功,共耗时:" + ((now - old) / 1000.0) + "秒"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | // 打印详细错误信息 |
| | | System.err.println("转换失败:" + e.getMessage()); |
| | | e.printStackTrace(System.err); |
| | | } |
| | | |
| | | // ExcelUtil<ArchiveInfoVo> utilsv = new ExcelUtil<ArchiveInfoVo>(ArchiveInfoVo.class); |
| | | // |
| | | // |
| | |
| | | // List<ArchiveInfoVo> aivs = new ArrayList<>(); |
| | | // aivs.add(aIV); |
| | | // utilsv.byteOutputStreamExcel(boss, aivs,"Date List", ""); |
| | | bos2.writeTo(zos); |
| | | |
| | | |
| | | |
| | | |
| | |
| | | zos.putNextEntry(entr); |
| | | ByteOutputStream bos8 = new ByteOutputStream(); |
| | | |
| | | util2.exportExcelManySheet(bos6, mysheet); |
| | | util2.exportExcelManySheet(bos8, mysheet); |
| | | |
| | | // util1.byteOutputStreamExcel(bos1, dsvs,"Date List", ""); |
| | | bos8.writeTo(zos); |
| | | |
| | | |
| | | |
| | | |
| | | //08-卷内卷内目录的pdf |
| | | String pdf08Path= "08-卷内目录.pdf"; |
| | | try { |
| | | if (!getLicenseExcel()) { |
| | | System.out.println("授权失败"); |
| | | // return ; |
| | | } |
| | | // 读取Excel文件 |
| | | com.aspose.cells.Workbook wb1 = poiToAspose(util2.getWb()); |
| | | |
| | | // 获取需要导出的sheet(索引从0开始) |
| | | int targetSheetIndex = 1; |
| | | com.aspose.cells.Worksheet targetSheet = wb1.getWorksheets().get(targetSheetIndex); |
| | | targetSheet.autoFitRows(true); |
| | | System.out.println("当前sheet名称:" + targetSheet.getName()); |
| | | System.out.println("当前sheet索引:" + targetSheet.getIndex()); |
| | | |
| | | // 隐藏所有其他工作表 |
| | | for (int j = 0; j < wb1.getWorksheets().getCount(); j++) { |
| | | if (j != targetSheetIndex) { |
| | | wb1.getWorksheets().get(j).setVisible(false); |
| | | } |
| | | } |
| | | |
| | | // 设置活动工作表为目标工作表 |
| | | wb1.getWorksheets().setActiveSheetIndex(targetSheetIndex); |
| | | // 创建PDF保存选项 |
| | | com.aspose.cells.PdfSaveOptions pdfSaveOptions = new com.aspose.cells.PdfSaveOptions(); |
| | | pdfSaveOptions.setCompliance(com.aspose.cells.PdfCompliance.PDF_A_1_B); |
| | | // 创建临时字节输出流 |
| | | ByteArrayOutputStream baosm = new ByteArrayOutputStream(); |
| | | |
| | | // 将新的Workbook保存为PDF到临时流 |
| | | // newWorkbook.save(baos, com.aspose.cells.SaveFormat.PDF); |
| | | wb1.save(baosm, pdfSaveOptions); |
| | | |
| | | // 将PDF添加到ZIP文件 |
| | | ZipEntry entry2 = new ZipEntry(fna + adir +"/"+pdf08Path); |
| | | zos.putNextEntry(entry2); |
| | | zos.write(baosm.toByteArray()); |
| | | // zos.closeEntry(); |
| | | // 直接将原始工作簿保存为PDF(只包含可见的工作表) |
| | | |
| | | long now = System.currentTimeMillis(); |
| | | // System.out.println("pdf转换成功,共耗时:" + ((now - old) / 1000.0) + "秒"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | // 打印详细错误信息 |
| | | System.err.println("转换失败:" + e.getMessage()); |
| | | e.printStackTrace(System.err); |
| | | } |
| | | |
| | | |
| | | } |
| | | //把excel转为pdf |
| | | |
| | | // |
| | | // //08-卷内卷内目录的pdf |
| | | // 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文件内容并写入ZIP |
| | | // try (FileInputStream fis = new FileInputStream(pdf08Path)) { |
| | | // byte[] buffer = new byte[1024]; |
| | | // int len; |
| | | // while ((len = fis.read(buffer)) > 0) { |
| | | // zos.write(buffer, 0, len); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // |
| | | |
| | | |
| | | |
| | |
| | | //在压缩包中添加文件夹 |
| | | |
| | | //得到文件名frontCompWithZore(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-档案变更材料")) |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/05-档案变更材料/"+fname)); |
| | | else if(dc.getStage().equals("06-业务数据")) |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/06-业务数据/"+fname)); |
| | | else |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/"+fname)); |
| | | |
| | | 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(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-档案变更材料")) |
| | | zos.putNextEntry(new ZipEntry(fna + adir + "/05-档案变更材料/" + 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(); |
| | | } |
| | | } |
| | | |
| | | //删除压缩包 |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | //删除压缩包 |
| | | // if(file.exists()){ |
| | | // file.delete(); |
| | | // } |
| | |
| | | |
| | | System.out.println(filePath); |
| | | File tempFile = new File(filePath); |
| | | |
| | | //在压缩包中添加文件夹 |
| | | if(res) { |
| | | zos.putNextEntry(new ZipEntry("01-申请材料/")); |