From bcb1d905904fd43034f7c95077336e5cb849eff1 Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期日, 18 一月 2026 23:17:22 +0800
Subject: [PATCH] 修改了对应代码
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java | 1616 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 1,432 insertions(+), 184 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 039f191..fa7ceef 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
@@ -1,58 +1,67 @@
package com.ruoyi.web.controller.archive;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import com.aspose.cells.PdfCompliance;
+import com.aspose.words.License;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.deepoove.poi.XWPFTemplate;
import com.itextpdf.text.*;
-import com.itextpdf.text.Font;
-import com.itextpdf.text.pdf.BaseFont;
+import com.itextpdf.text.Image;
import com.itextpdf.text.pdf.PdfPCell;
-import com.itextpdf.text.pdf.PdfPTable;
-import com.itextpdf.text.pdf.PdfWriter;
import com.ruoyi.common.config.RuoYiConfig;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.bean.BeanUtils;
+import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.poi.*;
+import com.ruoyi.domain.ArchiveProjectName;
import com.ruoyi.domain.ArchiveRecords;
import com.ruoyi.domain.DocumentMaterials;
import com.ruoyi.domain.vo.*;
-import com.ruoyi.framework.web.domain.server.Sys;
+import com.ruoyi.service.IArchiveProjectNameService;
import com.ruoyi.service.IArchiveRecordsService;
import com.ruoyi.service.IDocumentMaterialsService;
import com.ruoyi.service.impl.BarcodeService;
import com.ruoyi.service.impl.pdfGenerateService;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFDateUtil;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.ss.util.CellUtil;
-import org.apache.poi.xssf.usermodel.*;
+import org.apache.commons.imaging.ImageInfo;
+import org.apache.commons.imaging.Imaging;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.http.MediaType;
+import org.springframework.mock.web.MockMultipartFile;
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;
+import org.springframework.web.multipart.MultipartFile;
+import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
+import java.awt.*;
+import java.awt.Font;
+import java.awt.image.BufferedImage;
import java.io.*;
-import java.lang.reflect.Field;
-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.ArrayList;
-import java.util.Date;
+import java.util.*;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
-import static org.apache.poi.hssf.usermodel.HSSFCell.*;
+// 瀵煎叆ByteArrayOutputStream鐢ㄤ簬涓存椂瀛樺偍PDF鏁版嵁
+import java.io.ByteArrayOutputStream;
@RestController
@RequestMapping("/system/archiveAllExport")
@@ -66,10 +75,11 @@
private BarcodeService barcodeService;
@Autowired
private IDocumentMaterialsService documentMaterialsService;
-
+ @Autowired
+ private IArchiveProjectNameService iArchiveProjectNameService;
@Autowired
private IArchiveRecordsService iArchiveRecordsService;
-
+
// 鐢ㄤ簬鐢熸垚褰撳ぉ瀵煎嚭搴忓彿鐨勬柟娉�
private String generateDailySequence(String date) {
// 浣跨敤synchronized纭繚绾跨▼瀹夊叏
@@ -85,22 +95,289 @@
}
}
+ public boolean getLicense() {
+ boolean result = false;
+ try {
+ InputStream is = null;
+
+ ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
+ org.springframework.core.io.Resource[] resources = resolver.getResources("classpath:words.xml");
+ is = resources[0].getInputStream();
+ // 锟斤拷目锟斤拷lincense.xml锟斤拷路锟斤拷
+ License aposeLic = new License();
+ aposeLic.setLicense(is);
+ result = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ public boolean getLicenseExcel() {
+ boolean result = false;
+ InputStream is = null;
+ try {
+ ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
+ org.springframework.core.io.Resource[] resources = resolver.getResources("classpath:license.xml");
+ is = resources[0].getInputStream();
+ com.aspose.cells.License aposeLic = new com.aspose.cells.License();
+ aposeLic.setLicense(is);
+ result = true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ return result;
+ }
+ /**
+ * 灏咵xcel鎸囧畾瀛恠heet杞崲涓篜DF骞朵笅杞�
+ * @param response 鍝嶅簲瀵硅薄
+ * @param excelPath Excel鏂囦欢璺緞
+ * @param sheetName 瀛恠heet鍚嶇О
+ * @throws Exception 寮傚父淇℃伅
+ */
+ @PostMapping("/exportSheetToPdf")
+ public void exportSheetToPdf(HttpServletResponse response, String excelPath, String sheetName) throws Exception {
+ // 璁剧疆鍝嶅簲澶�
+ response.setContentType(MediaType.APPLICATION_PDF_VALUE);
+ response.setHeader("Content-Disposition", "attachment; filename=sheet.pdf");
+
+ try {
+ // 浣跨敤Aspose.Cells璇诲彇Excel鏂囦欢
+ com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook(excelPath);
+
+ // 鑾峰彇鎸囧畾鍚嶇О鐨勫瓙sheet
+ com.aspose.cells.Worksheet sheet = wb.getWorksheets().get(sheetName);
+
+ // 濡傛灉闇�瑕佽幏鍙栫储寮曟柟寮忕殑瀛恠heet锛屽彲浠ヤ娇鐢ㄤ互涓嬩唬鐮�
+ // com.aspose.cells.Worksheet sheet = wb.getWorksheets().get(0); // 鑾峰彇绗竴涓猻heet
+
+ // 鍒涘缓涓�涓柊鐨刉orkbook锛屽彧鍖呭惈鎸囧畾鐨剆heet
+ com.aspose.cells.Workbook newWorkbook = new com.aspose.cells.Workbook();
+ newWorkbook.getWorksheets().clear();
+ newWorkbook.getWorksheets().addCopy(sheet.getName());
+
+ // 灏咵xcel杞崲涓篜DF瀛楄妭鏁扮粍
+ java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
+ newWorkbook.save(baos, com.aspose.cells.SaveFormat.PDF);
+ byte[] pdfBytes = baos.toByteArray();
+
+ // 灏哖DF杈撳嚭鍒板搷搴旀祦
+ try (ServletOutputStream os = response.getOutputStream()) {
+ os.write(pdfBytes);
+ os.flush();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ /**
+ * 灏咵xcel鎵�鏈夊瓙sheet杞崲涓篜DF骞舵墦鍖呬笅杞�
+ * @param response 鍝嶅簲瀵硅薄
+ * @param excelPath Excel鏂囦欢璺緞
+ * @throws Exception 寮傚父淇℃伅
+ */
+ @PostMapping("/exportAllSheetsToPdf")
+ public void exportAllSheetsToPdf(HttpServletResponse response, String excelPath) throws Exception {
+ // 璁剧疆鍝嶅簲澶�
+ response.setContentType("application/zip");
+ response.setHeader("Content-Disposition", "attachment; filename=all_sheets.zip");
+
+ try (ServletOutputStream os = response.getOutputStream();
+ ZipOutputStream zos = new ZipOutputStream(os)) {
+
+ // 浣跨敤Aspose.Cells璇诲彇Excel鏂囦欢
+ com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook(excelPath);
+
+ // 鑾峰彇鎵�鏈塻heet
+ com.aspose.cells.WorksheetCollection sheets = wb.getWorksheets();
+
+ // 閬嶅巻鎵�鏈塻heet
+ for (int i = 0; i < sheets.getCount(); i++) {
+ com.aspose.cells.Worksheet sheet = sheets.get(i);
+ String sheetName = sheet.getName();
+
+ // 鍒涘缓涓�涓柊鐨刉orkbook锛屽彧鍖呭惈褰撳墠sheet
+ com.aspose.cells.Workbook newWorkbook = new com.aspose.cells.Workbook();
+ newWorkbook.getWorksheets().clear();
+ newWorkbook.getWorksheets().addCopy(sheet.getName());
+
+ // 鍒涘缓涓存椂瀛楄妭杈撳嚭娴�
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ // 灏嗘柊鐨刉orkbook淇濆瓨涓篜DF鍒颁复鏃舵祦
+ newWorkbook.save(baos, com.aspose.cells.SaveFormat.PDF);
+ byte[] pdfBytes = baos.toByteArray();
+
+ // 鑾峰彇PDF鎬婚〉鏁�
+
+ // 灏哖DF娣诲姞鍒癦IP鏂囦欢
+ ZipEntry entry = new ZipEntry(sheetName + ".pdf");
+ zos.putNextEntry(entry);
+ zos.write(pdfBytes);
+ zos.closeEntry();
+
+ System.out.println("Excel瀛恠heet \"" + sheetName + "\" 杞崲涓篜DF鎴愬姛");
+ }
+
+ System.out.println("Excel鎵�鏈夊瓙sheet杞崲涓篜DF骞舵墦鍖呮垚鍔�");
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) throws IOException
{
+
+
+ if (!getLicense()) {
+ return;
+ }
+
+ try {
+
+ // 鑾峰彇 Word 妯℃澘鎵�鍦ㄨ矾寰�
+ String filepath = "09-澶囪�冭〃.docx";
+ // 閫氳繃 XWPFTemplate 缂栬瘧鏂囦欢骞舵覆鏌撴暟鎹埌妯℃澘涓�
+ XWPFTemplate template = XWPFTemplate.compile(filepath).render(
+ new HashMap<String, Object>(){{
+ put("pages", 67);
+
+ }});
+
+ String renderedDocPath = "rendered_output.docx";
+ File renderedFile = new File(renderedDocPath);
+
+
+
+ try {
+ // 灏嗗畬鎴愭暟鎹覆鏌撶殑鏂囨。鍐欏嚭
+ template.writeAndClose(new FileOutputStream(renderedFile));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+
+ File file = new File("test1.pdf");
+ FileOutputStream os = new FileOutputStream(file);
+ com.aspose.words.Document doc = new com.aspose.words.Document("rendered_output.docx");
+
+ doc.save(os, com.aspose.words.SaveFormat.PDF);//全锟斤拷支锟斤拷DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF 锟洁互转锟斤拷
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+
+ if (!getLicenseExcel()) {
+ System.out.println("鎺堟潈澶辫触");
+ return ;
+ }
+ String inpath= "妗堝嵎灏侀潰.xls";
+ long old = System.currentTimeMillis();
+
+ // 璁剧疆鍝嶅簲澶�
+ response.setContentType("application/pdf");
+ response.setHeader("Content-Disposition", "attachment; filename=import_template.pdf");
+
+ try {
+ // 璇诲彇Excel鏂囦欢
+ com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook(inpath);
+
+ // 鑾峰彇闇�瑕佸鍑虹殑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 i = 0; i < wb.getWorksheets().getCount(); i++) {
+ if (i != targetSheetIndex) {
+ wb.getWorksheets().get(i).setVisible(false);
+ }
+ }
+
+ // 璁剧疆娲诲姩宸ヤ綔琛ㄤ负鐩爣宸ヤ綔琛�
+ wb.getWorksheets().setActiveSheetIndex(targetSheetIndex);
+
+ // 鍒涘缓PDF淇濆瓨閫夐」
+ com.aspose.cells.PdfSaveOptions pdfSaveOptions = new com.aspose.cells.PdfSaveOptions();
+
+ // 璁剧疆椤甸潰绫诲瀷涓篈4
+
+
+ // 纭繚鎵�鏈夊垪鍦ㄤ竴椤典笂
+ pdfSaveOptions.setAllColumnsInOnePagePerSheet(true);
+
+ // 璁剧疆鎵撳嵃椤甸潰绫诲瀷涓洪粯璁�
+ pdfSaveOptions.setCompliance(PdfCompliance.PDF_A_1_B); // 璁剧疆 PDF 鍏煎鎬ф爣鍑�
+
+ // 鐩存帴灏嗗師濮嬪伐浣滅翱淇濆瓨涓篜DF锛堝彧鍖呭惈鍙鐨勫伐浣滆〃锛�
+ wb.save(response.getOutputStream(), pdfSaveOptions);
+
+ 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);
+
+ // 杩斿洖閿欒淇℃伅
+ response.reset();
+ response.setContentType("text/plain;charset=utf-8");
+ response.getWriter().write("瀵煎嚭澶辫触锛�" + e.getMessage());
+ response.getWriter().flush();
+ }
+
//瀵煎嚭鍗烽潰灏侀潰浠g爜
ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(55L);
List<ArchiveInfoVo> arsi = new ArrayList<>();
arsi.add(aIV);
+
+
+ String date = "";
+ if(arsi.get(0).getPreparationDate()!=null) {
+ System.out.println(arsi.get(0).getPreparationDate().toString() + "]]]]]]]]");
+
+ System.out.println(DateUtil.parseCST(arsi.get(0).getPreparationDate().toString()));
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ DateTime dat = DateUtil.parseCST(arsi.get(0).getPreparationDate().toString());
+ date = new SimpleDateFormat("yyyy-MM-dd").format(dat);
+ }
+
+
+ String tmpSec = "妗e彿:" +
+ arsi.get(0).getRecordId() +
+ ";妗f棣嗭紙瀹わ級鍙�:" + arsi.get(0).getArchiveRoomNumber()+
+ ";缂╁井鍙�:" + arsi.get(0).getMicrofilmNumber()+
+ ";鍙戞枃鍙�:" + arsi.get(0).getInquiryNumber()+
+ ";妗堝嵎棰樺悕:" + arsi.get(0).getCaseTitle() +
+ ";缂栧埗鏃ユ湡:" + date +
+ ";缂栧埗鍗曚綅:" + arsi.get(0).getPreparationUnit() +
+ ";淇濈鏈熼檺:" + arsi.get(0).getRetentionPeriod() +
+ ";瀵嗙骇:" + arsi.get(0).getSecurityClassification();
+
String recordId = aIV.getRecordId();
byte[] imgr = barcodeService.generateBarcodeImage(recordId);
- byte[] sedcode = pdfGenerateService.createQrCodeN(recordId, 30, 30);
+ byte[] sedcode = pdfGenerateService.createQrCodeN(tmpSec, 100, 100);
ExcelExp e1 = new ExcelExp("妗堝嵎灏侀潰鏁版嵁",arsi, ArchiveInfoVo.class);
ExcelExp e2 = new ExcelExp("妗堝嵎灏侀潰", arsi, recordId, imgr,sedcode, ArchiveInfoVo.class);
List<ExcelExp> mysheet = new ArrayList<ExcelExp>();
@@ -186,7 +463,7 @@
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
String formattedDate = date.format(formatter);
System.out.println(formattedDate);
-
+
// 鐢熸垚褰撳ぉ瀵煎嚭搴忓彿
String sequence = generateDailySequence(formattedDate);
String fna = "GH" + formattedDate + sequence + "/";
@@ -208,6 +485,7 @@
//绉讳氦娓呭崟
List<ArchiveRecordSmall> lrs = iArchiveRecordsService.findByIds(archiveRecords);
+ //鐢靛瓙鏂囦欢鐨勪釜鏁�
System.out.println(lrs);
System.out.println("99999999990000");
ZipEntry entry1 = new ZipEntry(fna + "绉讳氦娓呭崟" + ".xls");
@@ -215,7 +493,7 @@
- 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);
@@ -234,20 +512,202 @@
- for(int i = 0; i < ids.length; i++) {
+ System.out.println(ids.length);
+ System.out.println("------------------");
+ for(int i = 0; i < ids.length; i++) {
+ System.out.println(ids[i]);
+ ArchiveRecords archiveRecords1 = iArchiveRecordsService.selectArchiveRecordsById(ids[i]);
+ ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(ids[i]);
// 鑾峰彇鏂囦欢鐨勪繚瀛樹綅缃�,璇诲彇鏁版嵁搴�,
DocumentMaterials documentMaterials = new DocumentMaterials();
documentMaterials.setRecordId(ids[i]);
- List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(ids[i]);
- System.out.println(docs.size()+"----009");
+
+ //鐢熸垚鏂扮殑璁板綍锛屼笉淇濆瓨鍐嶆暟鎹簱
+ List<DocumentMaterials> docAllInfo = documentMaterialsService.SelectAllRecordsByPageNumbersToList(ids[i], archiveRecords1.getPageCount());
+ //鎶奃ocumentMaterils杞埌docs
+ List<DocumentMaterialsVoLarge> docs = new ArrayList<>();
+ int nstar = 1;
+
+ //缁熻3涓潗鏂欑殑涓暟
+ int texPages = 0;
+ int picPages = 0;
+ int patPages = 0;
+ for (DocumentMaterials mater : docAllInfo) {
+ // physcialService.mySave(physcial);
+ DocumentMaterialsVoLarge docum = new DocumentMaterialsVoLarge();
+ BeanUtils.copyProperties(mater, docum);
+ docum.setRecordId(archiveRecords1.getRecordId());
+ docum.setNum(nstar++);
+ docs.add(docum);
+ if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("鏂囧瓧鏉愭枡"))
+ texPages++;
+ if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("鍥炬牱鏉愭枡"))
+ patPages++;
+ if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("鐓х墖鏉愭枡"))
+ picPages++;
+ }
+
+
+
+ //鎶婇檮浠跺拰璁板綍涓�涓�瀵瑰簲
+ String fileSysPath = RuoYiConfig.getUploadPath();
+ AjaxResult ajax = AjaxResult.success();
+ String path = fileSysPath + File.separator + ids[i];
+ File desc = new File(fileSysPath + File.separator + ids[i]);
+ System.out.println("44444444444444456666666666666666");
+ if (!desc.exists())
+ {
+ throw new RuntimeException("鐢靛瓙鏂囦欢淇℃伅娌℃湁涓婁紶锛岃琛ュ厖锛�");
+ }
+
+
+ Map<String, String> fileMap = new HashMap<>();
+ try (Stream<Path> paths = Files.walk(Paths.get(path))) {
+ fileMap = paths
+ .filter(Files::isRegularFile)
+ .collect(Collectors.toMap(
+ // Key: 鏂囦欢鍚嶅墠缂�锛堜笉甯︽墿灞曞悕锛�
+ Path -> {
+ String fileNam = Path.getFileName().toString();
+ int dotIndex = fileNam.lastIndexOf('.');
+ return dotIndex > 0 ? fileNam.substring(0, dotIndex) : fileNam;
+ },
+ // Value: 鏂囦欢鍏ㄨ矾寰�
+ Path::toString,
+ // 澶勭悊閲嶅閿殑鎯呭喌锛堝鏋滄湁鐩稿悓鍓嶇紑鐨勬枃浠讹級
+ (existing, replacement) -> existing
+ ));
+
+ }
+
+
+ //閲嶆柊灏佽涓�涓媎ocs,鍜岄檮浠剁粦瀹氬啀涓�璧�
+
+ for (int k = 0; k < docs.size(); k++) {
+ DocumentMaterialsVoLarge dc = docs.get(k);
+ if (dc.getSecurityLevel() != null && (dc.getSecurityLevel().equals("璇ラ〉鍙﹀瓨") ||
+ dc.getSecurityLevel().equals("绉樺瘑") || dc.getSecurityLevel().equals("鍐呴儴鐢ㄩ��") ||
+ dc.getSecurityLevel().equals("鍐呴儴鐢ㄥ浘"))) {
+ // 鏇挎崲涓轰簡鍑嗗濂界殑鍥惧儚
+ String fp = fileSysPath + "\\glc.jpg";
+ Path path1 = Paths.get(fp);
+ // 鎷垮埌鍥惧儚灞炴��
+ BufferedImage bufferedImage = ImageIO.read(Files.newInputStream(path1));
+ int wid = bufferedImage.getWidth();
+ int hei = bufferedImage.getHeight();
+ double sz = Double.parseDouble(String.format("%.2f", Files.size(path1) * 1.0 / 1024));
+
+ // 鎷垮埌鍥惧儚鐨刣pi淇℃伅
+ ImageInfo info = Imaging.getImageInfo(Files.readAllBytes(path1));
+ int wdpi = info.getPhysicalWidthDpi();
+ int hdpi = info.getPhysicalHeightDpi();
+
+ // 璁$畻fileNumber
+ // Long fileNumber = documentMaterialsService.getFiNum(nam, recordId);
+ // 璁$畻sizeType
+ String sizeType = getPageSize(wid * hei);
+
+ Graphics2D g2d = bufferedImage.createGraphics();
+ g2d.setFont(new java.awt.Font("瀹嬩綋", Font.BOLD, 80)); // 璁剧疆瀛椾綋鏍峰紡鍜屽ぇ灏�
+ g2d.setColor(Color.black);
+ String pageNumber = dc.getPageNumber() + "";
+ int fontHeight = g2d.getFontMetrics().getHeight();
+ int x = bufferedImage.getWidth() - g2d.getFontMetrics().stringWidth(pageNumber) - 80;
+ int y = bufferedImage.getHeight() - fontHeight / 2 - 100;
+ g2d.drawString(pageNumber, x, y);
+ g2d.dispose();
+
+ // 灏咮ufferedImage杞崲涓篗ultipartFile
+ MultipartFile multipartFile = null;
+ ByteArrayOutputStream ost = new ByteArrayOutputStream();
+ ImageIO.write(bufferedImage, "jpg", ost);
+ InputStream input = new ByteArrayInputStream(ost.toByteArray());
+ multipartFile = new MockMultipartFile(pageNumber, pageNumber + ".jpg", "text/plain", input);
+
+ // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О
+ String fileName1 = FileUploadUtils.upload(fileSysPath, multipartFile);
+ // filePath = fileName1;
+ dc.setWidth((long) wid);
+ dc.setHeight((long) hei);
+ dc.setFileSize(sz);
+ dc.setFormat(".jpg");
+ dc.setHorizontalResolution((long) wdpi);
+ dc.setVerticalResolution((long) hdpi);
+ dc.setSizeType(sizeType);
+ fileMap.put(dc.getPageNumber()+"", fileName1);
+ // dc.set
+ // 鏇存柊鏁版嵁搴�
+ // documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber, wid, hei, wdpi, hdpi, sz, fileName1, "jpg", recordId);
+
+// urls.add(serverConfig.getUrl() + fileName1);
+// fileNames.add(fileName1);
+// newFileNames.add(FileUtils.getName(fileName1));
+// originalFilenames.add(pageNumber + ".jpg");
+ }
+ else {
+ //鏂囦欢鍚嶇О
+ // String pname = nams[1];
+ // ajax.put("url", url);
+ //鎷垮埌鍥惧儚灞炴��
+ System.out.println(dc.getPageNumber());
+ String fip = fileMap.get(dc.getPageNumber().toString());
+// 鍒涘缓 File 瀵硅薄
+ if (fip == null) {
+ // 琛ラ浂鍒�4浣嶏紙鏍规嵁浣犵殑闇�姹傝皟鏁翠綅鏁帮級
+ String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue());
+ fip = fileMap.get(paddedKey);
+ }
+ File fils = new File(fip);
+
+// 浣跨敤 ImageIO 璇诲彇鍥剧墖
+ BufferedImage image = ImageIO.read(fils);
+ BufferedImage bufferedImage = ImageIO.read(fils);
+ int wid = bufferedImage.getWidth();
+ int hei = bufferedImage.getHeight();
+ double sz = Double.parseDouble(String.format("%.2f", fils.length()*1.0/1024));
+ System.out.println(wid+":"+hei+":"+sz);
+ //鎷垮埌鍥惧儚鐨刣pi淇℃伅
+ byte[] bytesArray = new byte[(int) fils.length()];
+
+ FileInputStream fis = new FileInputStream(fils);
+ fis.read(bytesArray); //read file into bytes[]
+
+ ImageInfo info = Imaging.getImageInfo(bytesArray);
+
+
+ int wdpi = info.getPhysicalWidthDpi() ;
+ int hdpi = info.getPhysicalHeightDpi();
+ // System.out.println("DPI: " + info.getPhysicalWidthDpi()+nam+"dds");
+
+ fis.close();
+ //璁$畻fileNumber
+ // Long fileNumber = documentMaterialsService.getFiNum(dc.getPageNumber(), id);
+ //璁$畻sizeType
+ String sizeType = getPageSize(wid*hei);
+
+ dc.setWidth((long) wid);
+ dc.setHeight((long) hei);
+ dc.setFileSize(sz);
+ dc.setFormat(".jpg");
+ dc.setHorizontalResolution((long) wdpi);
+ dc.setVerticalResolution((long) hdpi);
+ dc.setSizeType(sizeType);
+ }
+ }
+
+ List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(ids[i].toString(), archiveRecords1.getPageCount());
+
+// List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(ids[i]);
+// 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 + "/"));
@@ -264,55 +724,155 @@
}
//娣诲姞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);
+// 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);
+// }
+// }
- // 璇诲彇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
+
+
+
+
+// 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);
+// }
+// }
+
+
//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);
+ // pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), id);
+ //鎷垮埌鐩稿叧鏁版嵁
+ List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(ids[i]));
- // 璇诲彇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);
- }
+ LocalDate currentDate = LocalDate.now();
+
+
+ String cdt = currentDate.getYear()+"骞�"+currentDate.getMonthValue()+"鏈�"+currentDate.getDayOfMonth()+"鏃�";
+
+ 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()!=null&&documentMaterialFileStyle.getFileStyle().equals("鏂囧瓧鏉愭枡"))
+// texPages = documentMaterialFileStyle.getCnt();
+// if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鍥炬牱鏉愭枡"))
+// patPages = documentMaterialFileStyle.getCnt();
+// if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鐓х墖鏉愭枡"))
+// picPages = documentMaterialFileStyle.getCnt();
+// }
+// }
+
+
+ String compName = "骞垮窞鐩堝妗f绠$悊鏈夐檺鍏徃";
+ String li_person = "浠囩縺";
+ String sh_person = "鏇剧憺鑾�";
+
+ if(!StringUtils.isEmpty(archiveRecords1.getLiPerson()))
+ li_person = archiveRecords1.getLiPerson();
+ ArchiveProjectName tmp = new ArchiveProjectName();
+ tmp.setName(archiveRecords1.getProjectName());
+ List<ArchiveProjectName> projectName = iArchiveProjectNameService.selectArchiveProjectNameList(tmp);
+ if(!projectName.isEmpty())
+ {
+ if(!StringUtils.isEmpty(projectName.get(0).getCompanyName()))
+ compName = projectName.get(0).getCompanyName();
+ if(!StringUtils.isEmpty(projectName.get(0).getCreatePerson()))
+ sh_person = projectName.get(0).getCreatePerson();
}
+ 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("company", compName);
+ hs.put("liPerson", li_person);
+ hs.put("shPerson", sh_person);
+ hs.put("time", cdt);
+
+ if (!getLicense()) {
+ System.out.println("娌℃湁鐩稿叧璇佷功锛�");
+ }
+
+
+ try {
+
+ ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
+ org.springframework.core.io.Resource resource = resolver.getResource("classpath:09.docx");
+// String filepath = resource.getFile().getAbsolutePath();
+// // 閫氳繃 XWPFTemplate 缂栬瘧鏂囦欢骞舵覆鏌撴暟鎹埌妯℃澘涓�
+// XWPFTemplate template = XWPFTemplate.compile(filepath).render(hs
+// );
+
+ InputStream inputStream = resource.getInputStream();
+ // 閫氳繃 XWPFTemplate 缂栬瘧鏂囦欢骞舵覆鏌撴暟鎹埌妯℃澘涓�
+ XWPFTemplate template = XWPFTemplate.compile(inputStream).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();
+ // 灏哤ord鏂囨。杞崲涓篜DF瀛楄妭鏁扮粍
+ 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);
+
+ } 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");
@@ -320,9 +880,33 @@
List<ArchiveInfoVo> arsi = new ArrayList<>();
arsi.add(aIV);
+ String dates = "";
+ if(arsi.get(0).getPreparationDate()!=null) {
+ System.out.println(arsi.get(0).getPreparationDate().toString() + "]]]]]]]]");
+
+ System.out.println(DateUtil.parseCST(arsi.get(0).getPreparationDate().toString()));
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ DateTime dat = DateUtil.parseCST(arsi.get(0).getPreparationDate().toString());
+ dates = new SimpleDateFormat("yyyy-MM-dd").format(dat);
+ }
+
+
+ String tmpSec = "妗e彿:" +
+ arsi.get(0).getRecordId() +
+ ";妗f棣嗭紙瀹わ級鍙�:" + arsi.get(0).getArchiveRoomNumber()+
+ ";缂╁井鍙�:" + arsi.get(0).getMicrofilmNumber()+
+ ";鍙戞枃鍙�:" + arsi.get(0).getInquiryNumber()+
+ ";妗堝嵎棰樺悕:" + arsi.get(0).getCaseTitle() +
+ ";缂栧埗鏃ユ湡:" + dates +
+ ";缂栧埗鍗曚綅:" + arsi.get(0).getPreparationUnit() +
+ ";淇濈鏈熼檺:" + arsi.get(0).getRetentionPeriod() +
+ ";瀵嗙骇:" + arsi.get(0).getSecurityClassification();
+
+
+
String recordId1 = aIV.getRecordId();
byte[] imgr1 = barcodeService.generateBarcodeImage(recordId1);
- byte[] sedcode = pdfGenerateService.createQrCodeN(recordId1, 30, 30);
+ byte[] sedcode = pdfGenerateService.createQrCodeN(tmpSec, 200, 200);
ExcelExp e3 = new ExcelExp("妗堝嵎灏侀潰鏁版嵁",arsi, ArchiveInfoVo.class);
ExcelExp e4 = new ExcelExp("妗堝嵎灏侀潰", arsi, recordId1, imgr1,sedcode, ArchiveInfoVo.class);
List<ExcelExp> mysheet1 = new ArrayList<ExcelExp>();
@@ -336,6 +920,67 @@
// 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);
+ // 纭繚瀛椾綋宓屽叆鍒癙DF涓�
+
+
+ // 鍒涘缓涓存椂瀛楄妭杈撳嚭娴�
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ // 灏嗘柊鐨刉orkbook淇濆瓨涓篜DF鍒颁复鏃舵祦
+ // newWorkbook.save(baos, com.aspose.cells.SaveFormat.PDF);
+ wb.save(baos, pdfSaveOptions);
+
+ // 灏哖DF娣诲姞鍒癦IP鏂囦欢
+ ZipEntry entry07 = new ZipEntry(fna + adir +"/"+pdfPathF);
+ zos.putNextEntry(entry07);
+ zos.write(baos.toByteArray());
+ // zos.closeEntry();
+ // 鐩存帴灏嗗師濮嬪伐浣滅翱淇濆瓨涓篜DF锛堝彧鍖呭惈鍙鐨勫伐浣滆〃锛�
+
+ 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);
//
//
@@ -343,7 +988,7 @@
// List<ArchiveInfoVo> aivs = new ArrayList<>();
// aivs.add(aIV);
// utilsv.byteOutputStreamExcel(boss, aivs,"Date List", "");
- bos2.writeTo(zos);
+
@@ -359,7 +1004,7 @@
//鎷垮埌鍗峰唴鐩綍鐨別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());
+ res1.getTitle(), res1.getDate(), res1.getPageNumberFormatted(), res1.getRemarks())).collect(Collectors.toList());
if(!dsvs.isEmpty()) {
String recordId = dsvs.get(0).getRecordId();
byte[] imgr = barcodeService.generateBarcodeImage(recordId);
@@ -375,60 +1020,150 @@
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-鍗峰唴鍗峰唴鐩綍鐨刾df
+ 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();
+
+ // 灏嗘柊鐨刉orkbook淇濆瓨涓篜DF鍒颁复鏃舵祦
+ // newWorkbook.save(baos, com.aspose.cells.SaveFormat.PDF);
+ wb1.save(baosm, pdfSaveOptions);
+
+ // 灏哖DF娣诲姞鍒癦IP鏂囦欢
+ ZipEntry entry2 = new ZipEntry(fna + adir +"/"+pdf08Path);
+ zos.putNextEntry(entry2);
+ zos.write(baosm.toByteArray());
+ // zos.closeEntry();
+ // 鐩存帴灏嗗師濮嬪伐浣滅翱淇濆瓨涓篜DF锛堝彧鍖呭惈鍙鐨勫伐浣滆〃锛�
+
+ 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);
+ }
+
+
}
//鎶奺xcel杞负pdf
+
+//
+// //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);
+// }
+// }
+// }
+//
+//
byte[] buf = new byte[1024];
for (DocumentMaterialsVoLarge dc : docs) {
- String filePath = dc.getUrl();
- if(filePath==null)
- continue;
- filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/");
+ String filePath = fileMap.get(dc.getPageNumber().toString());
+
+ // filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/");
System.out.println(filePath);
+ if (filePath == null) {
+ // 琛ラ浂鍒�4浣嶏紙鏍规嵁浣犵殑闇�姹傝皟鏁翠綅鏁帮級
+ String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue());
+ filePath = fileMap.get(paddedKey);
+ }
+ if(filePath==null)
+ continue;
+
+ if(filePath.contains("profile"))
+ filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/");
+
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));
+ String fname = "";
+ if(dc.getFileNumber()!=null&&dc.getPageNumber()!=null) {
+ fname = frontCompWithZore(4, dc.getFileNumber().intValue()) + "-" + dc.getTitle() + "-" + frontCompWithZore(4, dc.getPageNumber().intValue()) + "."
+ + filePath.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();
}
- }
- //鍒犻櫎鍘嬬缉鍖�
+ 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();
// }
@@ -464,8 +1199,6 @@
-
-
/**
* 鎵撳寘涓嬭浇
* @param response
@@ -474,20 +1207,201 @@
@PostMapping("/export/{id}")
public void packDownload(HttpServletResponse response, @PathVariable Long id) throws Exception {
+
+
// 鑾峰彇鏂囦欢鐨勪繚瀛樹綅缃�,璇诲彇鏁版嵁搴�,
DocumentMaterials documentMaterials = new DocumentMaterials();
documentMaterials.setRecordId(id);
- List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(id);
- System.out.println(docs.size()+"----009");
+ // List<DocumentMaterialsVoLarge> docs = documentMaterialsService.selectDocumentMaterialsAllByRecordId(id);
+ //鏍规嵁id鎷垮埌pageNumber
+ ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(id);
+ System.out.println(aIV.getPageCount() + "++++++++++++++++==");
+ //鐢熸垚鏂扮殑璁板綍锛屼笉淇濆瓨鍐嶆暟鎹簱
+ List<DocumentMaterials> docAllInfo = documentMaterialsService.SelectAllRecordsByPageNumbersToList(id, aIV.getPageCount());
+ if (docAllInfo==null||docAllInfo.isEmpty())
+ {
+ throw new RuntimeException("璇疯ˉ鍏呭畬鏁翠俊鎭紝鐒跺悗瀵煎嚭ISO鍖咃紒");
+ }
+ //鎶奃ocumentMaterils杞埌docs
+ List<DocumentMaterialsVoLarge> docs = new ArrayList<>();
+ int nstar = 1;
+ int texPages = 0;
+ int patPages = 0;
+ int picPages = 0;
+ for (DocumentMaterials mater : docAllInfo) {
+ // physcialService.mySave(physcial);
+ DocumentMaterialsVoLarge docum = new DocumentMaterialsVoLarge();
+ BeanUtils.copyProperties(mater, docum);
+ docum.setRecordId(aIV.getRecordId());
+ docum.setNum(nstar++);
+ docs.add(docum);
+ if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("鏂囧瓧鏉愭枡"))
+ texPages++;
+ if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("鍥炬牱鏉愭枡"))
+ patPages++;
+ if(mater.getFileStyle()!=null&&mater.getFileStyle().equals("鐓х墖鏉愭枡"))
+ picPages++;
+ }
+ System.out.println(docs.size()+"----009");
//.selectDocumentMaterialsList(documentMaterials);
- List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString());
- if(dsvs==null||dsvs.isEmpty())
+
+ //鎶婇檮浠跺拰璁板綍涓�涓�瀵瑰簲
+ String fileSysPath = RuoYiConfig.getUploadPath();
+ AjaxResult ajax = AjaxResult.success();
+ String path = fileSysPath + File.separator + id;
+ File desc = new File(fileSysPath + File.separator + id);
+ System.out.println("44444444444444456666666666666666");
+ if (!desc.exists())
{
throw new RuntimeException("鐢靛瓙鏂囦欢淇℃伅娌℃湁涓婁紶锛岃琛ュ厖锛�");
}
- ArchiveInfoVo aIV = iArchiveRecordsService.selectByRecordId(id);
+
+
+ Map<String, String> fileMap = new HashMap<>();
+ try (Stream<Path> paths = Files.walk(Paths.get(path))) {
+ fileMap = paths
+ .filter(Files::isRegularFile)
+ .collect(Collectors.toMap(
+ // Key: 鏂囦欢鍚嶅墠缂�锛堜笉甯︽墿灞曞悕锛�
+ Path -> {
+ String fileNam = Path.getFileName().toString();
+ int dotIndex = fileNam.lastIndexOf('.');
+ return dotIndex > 0 ? fileNam.substring(0, dotIndex) : fileNam;
+ },
+ // Value: 鏂囦欢鍏ㄨ矾寰�
+ Path::toString,
+ // 澶勭悊閲嶅閿殑鎯呭喌锛堝鏋滄湁鐩稿悓鍓嶇紑鐨勬枃浠讹級
+ (existing, replacement) -> existing
+ ));
+
+ }
+ List<DocumentMaterialsVo> dsvs = documentMaterialsService.findArchMInfo(id.toString(), aIV.getPageCount());
+
+ //閲嶆柊灏佽涓�涓媎ocs,鍜岄檮浠剁粦瀹氬啀涓�璧�
+
+ for (int i = 0; i < docs.size(); i++) {
+ DocumentMaterialsVoLarge dc = docs.get(i);
+ if (dc.getSecurityLevel() != null && (dc.getSecurityLevel().equals("璇ラ〉鍙﹀瓨") ||
+ dc.getSecurityLevel().equals("绉樺瘑") || dc.getSecurityLevel().equals("鍐呴儴鐢ㄩ��") ||
+ dc.getSecurityLevel().equals("鍐呴儴鐢ㄥ浘"))) {
+ // 鏇挎崲涓轰簡鍑嗗濂界殑鍥惧儚
+ String fp = fileSysPath + "\\glc.jpg";
+ Path path1 = Paths.get(fp);
+ // 鎷垮埌鍥惧儚灞炴��
+ BufferedImage bufferedImage = ImageIO.read(Files.newInputStream(path1));
+ int wid = bufferedImage.getWidth();
+ int hei = bufferedImage.getHeight();
+ double sz = Double.parseDouble(String.format("%.2f", Files.size(path1) * 1.0 / 1024));
+
+ // 鎷垮埌鍥惧儚鐨刣pi淇℃伅
+ ImageInfo info = Imaging.getImageInfo(Files.readAllBytes(path1));
+ int wdpi = info.getPhysicalWidthDpi();
+ int hdpi = info.getPhysicalHeightDpi();
+
+ // 璁$畻fileNumber
+ // Long fileNumber = documentMaterialsService.getFiNum(nam, recordId);
+ // 璁$畻sizeType
+ String sizeType = getPageSize(wid * hei);
+
+ Graphics2D g2d = bufferedImage.createGraphics();
+ g2d.setFont(new java.awt.Font("瀹嬩綋", Font.BOLD, 80)); // 璁剧疆瀛椾綋鏍峰紡鍜屽ぇ灏�
+ g2d.setColor(Color.black);
+ String pageNumber = dc.getPageNumber() + "";
+ int fontHeight = g2d.getFontMetrics().getHeight();
+ int x = bufferedImage.getWidth() - g2d.getFontMetrics().stringWidth(pageNumber) - 80;
+ int y = bufferedImage.getHeight() - fontHeight / 2 - 100;
+ g2d.drawString(pageNumber, x, y);
+ g2d.dispose();
+
+ // 灏咮ufferedImage杞崲涓篗ultipartFile
+ MultipartFile multipartFile = null;
+ ByteArrayOutputStream ost = new ByteArrayOutputStream();
+ ImageIO.write(bufferedImage, "jpg", ost);
+ InputStream input = new ByteArrayInputStream(ost.toByteArray());
+ multipartFile = new MockMultipartFile(pageNumber, pageNumber + ".jpg", "text/plain", input);
+
+ // 涓婁紶骞惰繑鍥炴柊鏂囦欢鍚嶇О
+ String fileName1 = FileUploadUtils.upload(fileSysPath, multipartFile);
+ // filePath = fileName1;
+ dc.setWidth((long) wid);
+ dc.setHeight((long) hei);
+ dc.setFileSize(sz);
+ dc.setFormat(".jpg");
+ dc.setHorizontalResolution((long) wdpi);
+ dc.setVerticalResolution((long) hdpi);
+ dc.setSizeType(sizeType);
+ System.out.println(fileName1);
+ System.out.println("gggggggggggggggg999999999999");
+ fileMap.put(dc.getPageNumber()+"", fileName1);
+ // dc.set
+ // 鏇存柊鏁版嵁搴�
+ // documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber, wid, hei, wdpi, hdpi, sz, fileName1, "jpg", recordId);
+
+// urls.add(serverConfig.getUrl() + fileName1);
+// fileNames.add(fileName1);
+// newFileNames.add(FileUtils.getName(fileName1));
+// originalFilenames.add(pageNumber + ".jpg");
+ }
+ else {
+ //鏂囦欢鍚嶇О
+ // String pname = nams[1];
+ // ajax.put("url", url);
+ //鎷垮埌鍥惧儚灞炴��
+ System.out.println(dc.getPageNumber());
+ String fip = fileMap.get(dc.getPageNumber().toString());
+ // 濡傛灉鐩存帴鍖归厤澶辫触锛屽皾璇曡ˉ闆跺尮閰�
+ if (fip == null) {
+ // 琛ラ浂鍒�4浣嶏紙鏍规嵁浣犵殑闇�姹傝皟鏁翠綅鏁帮級
+ String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue());
+ fip = fileMap.get(paddedKey);
+ }
+// 鍒涘缓 File 瀵硅薄
+ if(fip==null||fip.equals(""))
+ {
+ throw new RuntimeException("鐢靛瓙鏂囦欢淇℃伅娌℃湁涓婁紶瀹屾暣锛岃琛ュ厖锛�");
+
+
+ }
+
+ File file = new File(fip);
+
+// 浣跨敤 ImageIO 璇诲彇鍥剧墖
+ BufferedImage image = ImageIO.read(file);
+ BufferedImage bufferedImage = ImageIO.read(file);
+ int wid = bufferedImage.getWidth();
+ int hei = bufferedImage.getHeight();
+ double sz = Double.parseDouble(String.format("%.2f", file.length()*1.0/1024));
+ System.out.println(wid+":"+hei+":"+sz);
+ //鎷垮埌鍥惧儚鐨刣pi淇℃伅
+ byte[] bytesArray = new byte[(int) file.length()];
+
+ FileInputStream fis = new FileInputStream(file);
+ fis.read(bytesArray); //read file into bytes[]
+
+ ImageInfo info = Imaging.getImageInfo(bytesArray);
+
+
+ int wdpi = info.getPhysicalWidthDpi() ;
+ int hdpi = info.getPhysicalHeightDpi();
+ // System.out.println("DPI: " + info.getPhysicalWidthDpi()+nam+"dds");
+
+ fis.close();
+ //璁$畻fileNumber
+ // Long fileNumber = documentMaterialsService.getFiNum(dc.getPageNumber(), id);
+ //璁$畻sizeType
+ String sizeType = getPageSize(wid*hei);
+
+ dc.setWidth((long) wid);
+ dc.setHeight((long) hei);
+ dc.setFileSize(sz);
+ dc.setFormat(".jpg");
+ dc.setHorizontalResolution((long) wdpi);
+ dc.setVerticalResolution((long) hdpi);
+ dc.setSizeType(sizeType);
+ }
+ }
System.out.println(dsvs.size());
List<String> paths = new ArrayList<>();
// System.out.println(docs);
@@ -508,7 +1422,8 @@
String datumName = "user";
//鍘嬬缉鏂囦欢
List<String> filePathList = paths;
- File file = compressedFileToZip(docs, dsvs, aIV, id);
+ //鎶奷ocmentMaterial杞负
+ File file = compressedFileToZip(docs, dsvs, aIV, id, fileMap, texPages, patPages, picPages);
System.out.println(file.getName());
String fileName =aIV.getRecordId()+".zip";
@@ -549,6 +1464,29 @@
}
+ public com.aspose.cells.Workbook poiToAspose(org.apache.poi.ss.usermodel.Workbook poiWorkbook) throws Exception {
+ // 涓存椂鏂囦欢璺緞
+ String tempFilePath = "temp_workbook.xlsx";
+
+ try {
+ // 1. 灏咥pache POI Workbook淇濆瓨涓轰复鏃舵枃浠�
+ try (FileOutputStream fos = new FileOutputStream(tempFilePath)) {
+ poiWorkbook.write(fos);
+ }
+
+ // 2. 浣跨敤Aspose鍔犺浇涓存椂鏂囦欢
+ com.aspose.cells.Workbook asposeWorkbook = new com.aspose.cells.Workbook(tempFilePath);
+
+ return asposeWorkbook;
+
+ } finally {
+ // 娓呯悊涓存椂鏂囦欢
+ File tempFile = new File(tempFilePath);
+ if (tempFile.exists()) {
+ tempFile.delete();
+ }
+ }
+ }
@@ -579,7 +1517,10 @@
// 鍘嬬缉鏂囦欢
- private File compressedFileToZip(List<DocumentMaterialsVoLarge> docs, List<DocumentMaterialsVo> dsvs, ArchiveInfoVo aIV, Long id) throws Exception {
+ private File compressedFileToZip(List<DocumentMaterialsVoLarge> docs, List<DocumentMaterialsVo> dsvs, ArchiveInfoVo aIV, Long id, Map<String, String> fileMap,
+ int texPages,
+ int patPages,
+ int picPages) throws Exception {
//鍘嬬缉鍖呭叿浣撳悕绉帮紙鎷兼帴鏃堕棿鎴抽槻姝㈤噸鍚嶏級
String datumName = "";
String zipFileName =dsvs.get(0).getDocumentNumber()+aIV.getRecordId()+ ".zip";
@@ -597,53 +1538,139 @@
//鍘嬬缉鏂囦欢
zos = new ZipOutputStream(os);
- //pdf鐩綍灏侀潰
- String pdfPathF = "07-妗堝嵎灏侀潰.pdf";
- pdfGenerateService.generatePdf(pdfPathF, id);
- // 2. 鍘嬬缉PDF鍒癦IP鏂囦欢
- // 娣诲姞PDF鏂囦欢鍒癦IP
- ZipEntry zipEntry = new ZipEntry(pdfPathF);
- zos.putNextEntry(zipEntry);
- // 璇诲彇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;
- 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);
+ // pdfGenerateService.generateFileStyleInfo(pdf09Path, aIV.getRecordId(), id);
+ //鎷垮埌鐩稿叧鏁版嵁
+ // List<DocumentMaterialFileStyle> dmfs = documentMaterialsService.findFileStyleInfo(Math.toIntExact(id));
- // 璇诲彇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);
- }
+ LocalDate currentDate = LocalDate.now();
+
+
+ String cdt = currentDate.getYear()+"骞�"+currentDate.getMonthValue()+"鏈�"+currentDate.getDayOfMonth()+"鏃�";
+
+ HashMap<String, Object> hs = new HashMap<String, Object>();
+ int allPages = 0;
+// int texPages = 0;
+// int picPages = 0;
+// int patPages = 0;
+// if(!docs.isEmpty())
+// {
+// for(DocumentMaterialsVoLarge documentMaterialFileStyle:docs)
+// {
+// if(documentMaterialFileStyle!=null&&documentMaterialFileStyle.getFileStyle().equals("鏂囧瓧鏉愭枡"))
+// texPages = documentMaterialFileStyle.getCnt();
+// if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鍥炬牱鏉愭枡"))
+// patPages = documentMaterialFileStyle.getCnt();
+// if(documentMaterialFileStyle.getFileStyle()!=null&&documentMaterialFileStyle.getFileStyle().equals("鐓х墖鏉愭枡"))
+// picPages = documentMaterialFileStyle.getCnt();
+// }
+// }
+
+ String compName = "骞垮窞鐩堝妗f绠$悊鏈夐檺鍏徃";
+ String li_person = "浠囩縺";
+ String sh_person = "鏇剧憺鑾�";
+ ArchiveRecords archiveRecords = iArchiveRecordsService.selectArchiveRecordsById(id);
+ if(!StringUtils.isEmpty(archiveRecords.getLiPerson()))
+ li_person = archiveRecords.getLiPerson();
+ ArchiveProjectName tmp = new ArchiveProjectName();
+ tmp.setName(archiveRecords.getProjectName());
+ List<ArchiveProjectName> projectName = iArchiveProjectNameService.selectArchiveProjectNameList(tmp);
+ if(!projectName.isEmpty())
+ {
+ if(!StringUtils.isEmpty(projectName.get(0).getCompanyName()))
+ compName = projectName.get(0).getCompanyName();
+ if(!StringUtils.isEmpty(projectName.get(0).getCreatePerson()))
+ sh_person = projectName.get(0).getCreatePerson();
}
+
+ 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("company", compName);
+ hs.put("liPerson", li_person);
+ hs.put("shPerson", sh_person);
+ hs.put("time", cdt);
+
+ if (!getLicense()) {
+ System.out.println("娌℃湁鐩稿叧璇佷功锛�");
+ }
+
+
+ try {
+
+ // 鑾峰彇 Word 妯℃澘鎵�鍦ㄨ矾寰�
+ ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
+ org.springframework.core.io.Resource resource = resolver.getResource("classpath:09.docx");
+// String filepath = resource.getFile().getAbsolutePath();
+// // 閫氳繃 XWPFTemplate 缂栬瘧鏂囦欢骞舵覆鏌撴暟鎹埌妯℃澘涓�
+// XWPFTemplate template = XWPFTemplate.compile(filepath).render(hs
+// );
+
+ InputStream inputStream = resource.getInputStream();
+ // 閫氳繃 XWPFTemplate 缂栬瘧鏂囦欢骞舵覆鏌撴暟鎹埌妯℃澘涓�
+ XWPFTemplate template = XWPFTemplate.compile(inputStream).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();
+
+ // 灏哤ord鏂囨。杞崲涓篜DF瀛楄妭鏁扮粍
+ doc.save(baobk, com.aspose.words.SaveFormat.PDF);//全锟斤拷支锟斤拷DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF 锟洁互转锟斤拷
+// byte[] pdfBytes = baobk.toByteArray();
+
+ // 鑾峰彇PDF鎬婚〉鏁�
+
+
+ // 灏哖DF娣诲姞鍒癦IP鏂囦欢
+ ZipEntry entry09 = new ZipEntry(pdf09Path);
+ zos.putNextEntry(entry09);
+ baobk.writeTo(zos);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+
+
+ // com.aspose.words.Document doc = new com.aspose.words.Document("09.docx");
+
+
+
+
+
+// // 鍘嬬缉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);
+// }
+// }
@@ -654,9 +1681,33 @@
List<ArchiveInfoVo> arsi = new ArrayList<>();
arsi.add(aIV);
+
+ String date = "";
+ if(arsi.get(0).getPreparationDate()!=null) {
+ System.out.println(arsi.get(0).getPreparationDate().toString() + "]]]]]]]]");
+
+ System.out.println(DateUtil.parseCST(arsi.get(0).getPreparationDate().toString()));
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ DateTime dat = DateUtil.parseCST(arsi.get(0).getPreparationDate().toString());
+ date = new SimpleDateFormat("yyyy-MM-dd").format(dat);
+ }
+
+
+ String tmpSec = "妗e彿:" +
+ arsi.get(0).getRecordId() +
+ ";妗f棣嗭紙瀹わ級鍙�:" + arsi.get(0).getArchiveRoomNumber()+
+ ";缂╁井鍙�:" + arsi.get(0).getMicrofilmNumber()+
+ ";鍙戞枃鍙�:" + arsi.get(0).getInquiryNumber()+
+ ";妗堝嵎棰樺悕:" + arsi.get(0).getCaseTitle() +
+ ";缂栧埗鏃ユ湡:" + date +
+ ";缂栧埗鍗曚綅:" + arsi.get(0).getPreparationUnit() +
+ ";淇濈鏈熼檺:" + arsi.get(0).getRetentionPeriod() +
+ ";瀵嗙骇:" + arsi.get(0).getSecurityClassification();
+
+
String recordId1 = aIV.getRecordId();
byte[] imgr1 = barcodeService.generateBarcodeImage(recordId1);
- byte[] sedcode = pdfGenerateService.createQrCodeN(recordId1, 30, 30);
+ byte[] sedcode = pdfGenerateService.createQrCodeN(tmpSec, 200, 200);
ExcelExp e3 = new ExcelExp("妗堝嵎灏侀潰鏁版嵁",arsi, ArchiveInfoVo.class);
ExcelExp e4 = new ExcelExp("妗堝嵎灏侀潰", arsi, recordId1, imgr1,sedcode, ArchiveInfoVo.class);
List<ExcelExp> mysheet1 = new ArrayList<ExcelExp>();
@@ -670,14 +1721,72 @@
// System.out.println(bos2);
zos.putNextEntry(entryiv);
-// ExcelUtil<ArchiveInfoVo> utilsv = new ExcelUtil<ArchiveInfoVo>(ArchiveInfoVo.class);
-//
+ 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 i = 0; i < wb.getWorksheets().getCount(); i++) {
+ if (i != targetSheetIndex) {
+ wb.getWorksheets().get(i).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();
+
+ // 灏嗘柊鐨刉orkbook淇濆瓨涓篜DF鍒颁复鏃舵祦
+ // newWorkbook.save(baos, com.aspose.cells.SaveFormat.PDF);
+ wb.save(baos, pdfSaveOptions);
+
+ // 灏哖DF娣诲姞鍒癦IP鏂囦欢
+ ZipEntry entry = new ZipEntry(pdfPathF);
+ zos.putNextEntry(entry);
+ zos.write(baos.toByteArray());
+ // zos.closeEntry();
+ // 鐩存帴灏嗗師濮嬪伐浣滅翱淇濆瓨涓篜DF锛堝彧鍖呭惈鍙鐨勫伐浣滆〃锛�
+
+ 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);
+ }
+
+
+
+
//
// 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");
@@ -690,12 +1799,12 @@
//鎷垮埌鍗峰唴鐩綍鐨別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());
+ res.getTitle(), res.getDate(), res.getPageNumberFormatted(), 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);
+ ExcelExp e2 = new ExcelExp("鍗峰唴鐩綍", list2, recordId, imgr, DocumentMaterialsVoSmall.class);
List<ExcelExp> mysheet = new ArrayList<ExcelExp>();
mysheet.add(e1);
mysheet.add(e2);
@@ -712,6 +1821,78 @@
bos1.writeTo(zos);
//鎶奺xcel杞负pdf
+ //08-鍗峰唴鍗峰唴鐩綍鐨刾df
+ 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 i = 0; i < wb1.getWorksheets().getCount(); i++) {
+ if (i != targetSheetIndex) {
+ wb1.getWorksheets().get(i).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();
+
+ // 灏嗘柊鐨刉orkbook淇濆瓨涓篜DF鍒颁复鏃舵祦
+ // newWorkbook.save(baos, com.aspose.cells.SaveFormat.PDF);
+ wb1.save(baosm, pdfSaveOptions);
+
+ // 灏哖DF娣诲姞鍒癦IP鏂囦欢
+ ZipEntry entry2 = new ZipEntry(pdf08Path);
+ zos.putNextEntry(entry2);
+ zos.write(baosm.toByteArray());
+ // zos.closeEntry();
+ // 鐩存帴灏嗗師濮嬪伐浣滅翱淇濆瓨涓篜DF锛堝彧鍖呭惈鍙鐨勫伐浣滆〃锛�
+
+ 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);
+ }
+
+
+
+
+ //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);
+// }
+// }
+
+
@@ -719,13 +1900,57 @@
byte[] buf = new byte[1024];
for (DocumentMaterialsVoLarge dc : docs) {
- String filePath = dc.getUrl();
+ String filePath = fileMap.get(dc.getPageNumber().toString());
+
+
+// else {
+// // 鏂囦欢鍚嶇О
+// String pname = nams[1];
+//
+// // 鎷垮埌鍥惧儚灞炴��
+// BufferedImage bufferedImage = ImageIO.read(file.getInputStream());
+// int wid = bufferedImage.getWidth();
+// int hei = bufferedImage.getHeight();
+// double sz = Double.parseDouble(String.format("%.2f", file.getSize() * 1.0 / 1024));
+//
+// // 鎷垮埌鍥惧儚鐨刣pi淇℃伅
+// ImageInfo info = Imaging.getImageInfo(file.getBytes());
+// int wdpi = info.getPhysicalWidthDpi();
+// int hdpi = info.getPhysicalHeightDpi();
+// // 璁$畻fileNumber
+// Long fileNumber = documentMaterialsService.getFiNum(nam, recordId);
+// // 璁$畻sizeType
+// String sizeType = getPageSize(wid * hei);
+//
+// // 鏇存柊鏁版嵁搴�
+// // documentMaterialsService.updateByPageNumber(nam, sizeType, fileNumber, wid, hei, wdpi, hdpi, sz, fileName, pname, recordId);
+////
+//// urls.add(url);
+//// fileNames.add(fileName);
+//// newFileNames.add(FileUtils.getName(fileName));
+//// originalFilenames.add(fname);
+// }
+//
+
+
+ if (filePath == null) {
+ // 琛ラ浂鍒�4浣嶏紙鏍规嵁浣犵殑闇�姹傝皟鏁翠綅鏁帮級
+ String paddedKey = frontCompWithZore(4, dc.getPageNumber().intValue());
+ filePath = fileMap.get(paddedKey);
+ System.out.println(paddedKey);
+
+ }
+ System.out.println(filePath);
+
if(filePath==null)
continue;
- filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/");
- System.out.println(filePath);
+ if(filePath.contains("profile"))
+ filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/");
+
File tempFile = new File(filePath);
+ System.out.println(filePath);
+ System.out.println(tempFile.length());
//鍦ㄥ帇缂╁寘涓坊鍔犳枃浠跺す
if(res) {
zos.putNextEntry(new ZipEntry("01-鐢宠鏉愭枡/"));
@@ -737,25 +1962,32 @@
res = false;
}
//寰楀埌鏂囦欢鍚峟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("01-鐢宠鏉愭枡/"+fname));
- else if(dc.getStage().equals("02-鍔炴杩囩▼鏉愭枡"))
- zos.putNextEntry(new ZipEntry("02-鍔炴杩囩▼鏉愭枡/"+fname));
- else if(dc.getStage().equals("03-缁撹鎬ф枃浠�"))
- zos.putNextEntry(new ZipEntry("03-缁撹鎬ф枃浠�/"+fname));
- else if(dc.getStage().equals("04-鍏朵粬鏉愭枡")) {
- zos.putNextEntry(new ZipEntry("04-鍏朵粬鏉愭枡/" + fname));
+ String fname = "";
+ // if(dc.getFileNumber()!=null&&dc.getPageNumber()!=null) {
+
+ if(dc.getFileNumber()!=null&&dc.getPageNumber()!=null) {
+ // fname = frontCompWithZore(4, dc.getFileNumber().intValue()) + "-" + dc.getTitle() + "-" + frontCompWithZore(4, dc.getPageNumber().intValue()) + "."
+ // + filePath.split("\\.")[1];
+ fname = frontCompWithZore(4, dc.getFileNumber().intValue()) +"-" + dc.getTitle() + "-" + frontCompWithZore(4, dc.getPageNumber().intValue()) + "."
+ + filePath.split("\\.")[1];
+
+ System.out.println(fname);
+ if (dc.getStage().equals("01-鐢宠鏉愭枡"))
+ zos.putNextEntry(new ZipEntry("01-鐢宠鏉愭枡/" + fname));
+ else if (dc.getStage().equals("02-鍔炴杩囩▼鏉愭枡"))
+ zos.putNextEntry(new ZipEntry("02-鍔炴杩囩▼鏉愭枡/" + fname));
+ else if (dc.getStage().equals("03-缁撹鎬ф枃浠�"))
+ zos.putNextEntry(new ZipEntry("03-缁撹鎬ф枃浠�/" + fname));
+ else if (dc.getStage().equals("04-鍏朵粬鏉愭枡")) {
+ zos.putNextEntry(new ZipEntry("04-鍏朵粬鏉愭枡/" + fname));
+ } else if (dc.getStage().equals("05-妗f鍙樻洿鏉愭枡"))
+ zos.putNextEntry(new ZipEntry("05-妗f鍙樻洿鏉愭枡/" + fname));
+ else if (dc.getStage().equals("06-涓氬姟鏁版嵁"))
+ zos.putNextEntry(new ZipEntry("06-涓氬姟鏁版嵁/" + fname));
+ else
+ zos.putNextEntry(new ZipEntry(fname));
+
}
- else if(dc.getStage().equals("05-妗f鍙樻洿鏉愭枡"))
- zos.putNextEntry(new ZipEntry("05-妗f鍙樻洿鏉愭枡/"+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);
@@ -791,5 +2023,21 @@
}
return file;
}
-
+ public String getPageSize(double du)
+ {
+ if(du <= 8699840 * 1.5)
+ return "A4";
+ else if(du <= 17403188 * 1.5)
+ return "A3";
+ else if(du <= 34811347 * 1.5)
+ return "A2";
+ else if(du <= 69622674 * 1.5)
+ return "A1";
+ else
+ return "A0";
+ }
}
+
+
+
+
--
Gitblit v1.9.1