From 2d59c3e55978bd93741dae7a8ff21cf63b9ecf25 Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期三, 14 一月 2026 21:16:57 +0800
Subject: [PATCH] 修改了对应代码
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/archiveAllExportController.java | 440 +++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 414 insertions(+), 26 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 1c42d4a..d3900de 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
@@ -4,11 +4,16 @@
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.Image;
import com.itextpdf.text.pdf.PdfPCell;
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;
@@ -21,18 +26,29 @@
import com.ruoyi.service.impl.BarcodeService;
import com.ruoyi.service.impl.pdfGenerateService;
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
+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.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;
@@ -40,6 +56,7 @@
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -499,17 +516,177 @@
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()+"----7777");
+
+ //鐢熸垚鏂扮殑璁板綍锛屼笉淇濆瓨鍐嶆暟鎹簱
+ List<DocumentMaterials> docAllInfo = documentMaterialsService.SelectAllRecordsByPageNumbersToList(ids[i], archiveRecords1.getPageCount());
+ //鎶奃ocumentMaterils杞埌docs
+ List<DocumentMaterialsVoLarge> docs = new ArrayList<>();
+ int nstar = 1;
+ 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);
+ }
+
+
+
+ //鎶婇檮浠跺拰璁板綍涓�涓�瀵瑰簲
+ 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()+"", fp);
+ // 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 瀵硅薄
+ 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();
@@ -604,7 +781,7 @@
String compName = "骞垮窞鐩堝妗f绠$悊鏈夐檺鍏徃";
String li_person = "浠囩縺";
String sh_person = "鏇剧憺鑾�";
- ArchiveRecords archiveRecords1 = iArchiveRecordsService.selectArchiveRecordsById(ids[i]);
+
if(!StringUtils.isEmpty(archiveRecords1.getLiPerson()))
li_person = archiveRecords1.getLiPerson();
ArchiveProjectName tmp = new ArchiveProjectName();
@@ -912,10 +1089,10 @@
byte[] buf = new byte[1024];
for (DocumentMaterialsVoLarge dc : docs) {
- String filePath = dc.getUrl();
+ String filePath = fileMap.get(dc.getPageNumber().toString());
if(filePath==null)
continue;
- filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/");
+ // filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/");
System.out.println(filePath);
File tempFile = new File(filePath);
@@ -927,7 +1104,7 @@
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];
+ + filePath.split("\\.")[1];
if (dc.getStage().equals("01-鐢宠鏉愭枡"))
zos.putNextEntry(new ZipEntry(fna + adir + "/01-鐢宠鏉愭枡/" + fname));
else if (dc.getStage().equals("02-鍔炴杩囩▼鏉愭枡"))
@@ -992,8 +1169,6 @@
-
-
/**
* 鎵撳寘涓嬭浇
* @param response
@@ -1002,20 +1177,183 @@
@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;
+ 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);
+ }
+ 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);
+ fileMap.put(dc.getPageNumber()+"", fp);
+ // 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||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);
@@ -1036,7 +1374,8 @@
String datumName = "user";
//鍘嬬缉鏂囦欢
List<String> filePathList = paths;
- File file = compressedFileToZip(docs, dsvs, aIV, id);
+ //鎶奷ocmentMaterial杞负
+ File file = compressedFileToZip(docs, dsvs, aIV, id, fileMap);
System.out.println(file.getName());
String fileName =aIV.getRecordId()+".zip";
@@ -1130,7 +1469,7 @@
// 鍘嬬缉鏂囦欢
- 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) throws Exception {
//鍘嬬缉鍖呭叿浣撳悕绉帮紙鎷兼帴鏃堕棿鎴抽槻姝㈤噸鍚嶏級
String datumName = "";
String zipFileName =dsvs.get(0).getDocumentNumber()+aIV.getRecordId()+ ".zip";
@@ -1510,14 +1849,45 @@
byte[] buf = new byte[1024];
for (DocumentMaterialsVoLarge dc : docs) {
- String filePath = dc.getUrl();
+ String filePath = fileMap.get(dc.getPageNumber().toString());
if(filePath==null)
continue;
- filePath = filePath.replace("/profile/", RuoYiConfig.getProfile() + "/");
- System.out.println(filePath);
+// 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);
+// }
+//
+
+
+
+
File tempFile = new File(filePath);
-
+ System.out.println(filePath);
+ System.out.println(tempFile.length());
//鍦ㄥ帇缂╁寘涓坊鍔犳枃浠跺す
if(res) {
zos.putNextEntry(new ZipEntry("01-鐢宠鏉愭枡/"));
@@ -1530,9 +1900,15 @@
}
//寰楀埌鏂囦欢鍚峟rontCompWithZore(4, dc.get)+
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.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-鍔炴杩囩▼鏉愭枡"))
@@ -1584,7 +1960,19 @@
}
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