huangtf 2 роки тому
батько
коміт
6c701e2d38

+ 3 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/ArchiveFile.java

@@ -254,4 +254,7 @@ public class ArchiveFile extends BaseEntity {
 	@ApiModelProperty("页号")
 	private String pageNum;
 
+	@ApiModelProperty("文件大小")
+	Long fileSize;
+
 }

+ 3 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveFileAutoController.java

@@ -93,6 +93,9 @@ public class ArchiveFileAutoController extends BladeController {
                     List<ArchiveTreeContract> archiveTreeContracts = this.archiveTreeContractClient.queryAllChildByAncestors(saveVos.getNodeId());
                     if(archiveTreeContracts != null && archiveTreeContracts.size() >0){
                         archive.setTreeSort(archiveTreeContracts.get(0).getTreeSort());
+                        if (archiveTreeContracts.get(0).getStorageType()!= null){
+                            archive.setCarrierType(archiveTreeContracts.get(0).getStorageType().toString());
+                        }
                     }
 
                     archive.setAutoFileSort(l+archive.getAutoFileSort());

+ 14 - 1
blade-service/blade-archive/src/main/java/org/springblade/archive/service/IArchiveAutoPdfService.java

@@ -1,5 +1,9 @@
 package org.springblade.archive.service;
 
+import org.springblade.archive.entity.ArchivesAuto;
+import org.springblade.business.entity.ArchiveFile;
+
+import java.util.List;
 import java.util.Map;
 
 public interface IArchiveAutoPdfService {
@@ -7,6 +11,15 @@ public interface IArchiveAutoPdfService {
 
     public void test1();
 
+    //生成四要素,信息会写入archivesAuto
+    void buildArchiveFrontPdfs(Long projectId, ArchivesAuto archivesAuto,List<ArchiveFile> archiveFileList);
+
+    //打码,信息写入waitArchiveFiles
+    void builtFilePageNo(ArchivesAuto archivesAuto, List<ArchiveFile> waitArchiveFiles);
+
     // 单个pdf 生成
-    String getBussPdfInfo(Long pkeyId, Map<String, Object> DataInfo, String excelUrl, String filePath )throws Exception;
+    String getBussPdfInfo(String fileName, Map<String, Object> DataInfo, String excelUrl, String filePath )throws Exception;
+
+    //获取文件的pdf文件的url
+    String getPdfFileUrl(ArchiveFile file);
 }

+ 197 - 23
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchiveAutoPdfServiceImpl.java

@@ -2,6 +2,8 @@ package org.springblade.archive.service.impl;
 
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.itextpdf.text.Element;
+import com.itextpdf.text.pdf.*;
 import lombok.AllArgsConstructor;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.util.IOUtils;
@@ -25,10 +27,8 @@ import org.springblade.resource.feign.NewIOSSClient;
 import org.springframework.stereotype.Service;
 
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
+import java.io.*;
+import java.net.URLEncoder;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
@@ -49,15 +49,19 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
     public static final  String[] ARCHIVE_NUMBER = new String[]{"r_Archives_front","r_Archives_catalog","r_Archives_spare","r_Archives_back"};
 
     public static final Map<String, String> URL_MAP = new HashMap<>();
+    public static final Map<String, String> NAME_MAP = new HashMap<>();
 
     static {
         URL_MAP.put("r_Archives_front", "https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20230413/306c87ffc640699aa92d53a5f4e6d632.xlsx");
         URL_MAP.put("r_Archives_catalog", "https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20230413/f2a083fca685c646e4a47daaaa46f04b.xlsx");
         URL_MAP.put("r_Archives_spare", "https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20230414/3798f8c3db6f94c8fce63eec8c716d6c.xlsx");
         URL_MAP.put("r_Archives_back", "https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20230413/31081917b41e12b9b0359f6a9c1755bd.xlsx");
-    }
 
-    public static final  String LocalPath = "/www/wwwroot/Users/hongchuangyanfa/Desktop/";
+        NAME_MAP.put("r_Archives_front", "封面");
+        NAME_MAP.put("r_Archives_catalog", "卷内目录");
+        NAME_MAP.put("r_Archives_spare", "备考表");
+        NAME_MAP.put("r_Archives_back", "脊背");
+    }
 
 
     //测试数据
@@ -78,7 +82,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         String key1 =  "2__"+ dataVO1.getY() + "_" + dataVO1.getX();
         DataInfo.put(key1,"hahahahaa");
         try {
-            String url = getBussPdfInfo(pkeyId,DataInfo,excelUrl,file_path);
+            String url = getBussPdfInfo(pkeyId.toString(),DataInfo,excelUrl,file_path);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -205,30 +209,60 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         List<String> backUrls = new ArrayList<>();
         for (String number : numberFronts) {
             // 具体实现省略
-            buildFrontPdf(number, variables,frontUrls);
+            buildFrontPdf(archivesAuto,number, variables,frontUrls);
         }
 
         for (String number : numberBacks) {
             // 具体实现省略
-            buildFrontPdf(number, variables,backUrls);
+            buildFrontPdf(archivesAuto,number, variables,backUrls);
         }
+
     }
 
+    /**
+     * 打码
+     * @param archivesAuto
+     * @param waitArchiveFiles
+     */
+    public void builtFilePageNo(ArchivesAuto archivesAuto,List<ArchiveFile> waitArchiveFiles){
+        //声影的要不要打码
+        if (archivesAuto.getCarrierType()!= null &&
+                archivesAuto.getCarrierType().equals("5")) {
+            return;
+        }
+
+        List<String> urls = new ArrayList<>();
+        for (ArchiveFile f: waitArchiveFiles) {
+            String url = getPdfFileUrl(f);
+            urls.add(url);
+        }
+
+        List<String> pageUrls = FileUtils.doForPageNumberUseItextpdf(urls,newIOSSClient);
+        for(int i=0;i<waitArchiveFiles.size();i++){
+            waitArchiveFiles.get(i).setPdfFileUrl(pageUrls.get(i));
+        }
+
+        return;
+    }
+
+
+
     /**
      *
      * @param number  四要素的表名
      * @param variables 参数集
      * @param urls  返回的url
      */
-    public void buildFrontPdf(String number, Map<String,Object> variables,List<String> urls) {
+    public void buildFrontPdf(ArchivesAuto archivesAuto,String number, Map<String,Object> variables,List<String> urls) {
         // Step 1: Get the list of formulas using archiveFormulaConfigService
         List<ArchiveFormulaConfig> formulaConfigs = archiveFormulaConfigService.getByNumber(number);
 
-        String file_path = LocalPath;
+        String file_path = FileUtils.LocalPath;
         String excelUrl = getUrlByNumber(number);
         Map<String, Object> dataInfo = new HashMap<>();
 
         ArchiveFormulaConfig multiLineconfig = null;
+        String fileName = NAME_MAP.get(number)+ "-" + archivesAuto.getId();
 
         for (ArchiveFormulaConfig config : formulaConfigs) {
             String coords = config.getCoords();
@@ -249,11 +283,11 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         if (multiLineconfig != null) {
             String coords = multiLineconfig.getCoords();
             String formula = multiLineconfig.getFormula();
-            handleArchiveFile(coords, formula, variables, file_path, excelUrl, dataInfo,urls);
+            handleArchiveFile(coords, formula, variables, file_path, excelUrl, dataInfo,urls,fileName);
 
         }else {
             try {
-                String url = getBussPdfInfo(null, dataInfo, excelUrl, file_path);
+                String url = getBussPdfInfo(fileName, dataInfo, excelUrl, file_path);
                 urls.add(url);
             } catch (Exception e) {
                 e.printStackTrace();
@@ -274,7 +308,11 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
      */
     private void handleArchiveFile(String coords, String formula,
                                    Map<String,Object> variables,String file_path,
-                                   String excelUrl, Map<String, Object> dataInfo,List<String> urls){
+                                   String excelUrl, Map<String, Object> dataInfo,List<String> urls,String fileName){
+        //todo  目录多页合并一页,文件名带上
+
+
+        List<String> localUrls = new ArrayList<>();
         String[] coordArr = coords.split("~");
         if (coordArr.length == 2) {
             DataVO dataVO1 = FormulaUtil.convertCellToIndex(coordArr[0]);
@@ -313,8 +351,8 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
                         subIndex++;
                     }
                     try {
-                        String url = getBussPdfInfo(null, pageMap, excelUrl, file_path);
-                        urls.add(url);
+                        String url = getBussPdfInfo(fileName + subIndex, pageMap, excelUrl, file_path);
+                        localUrls.add(url);
                     } catch (Exception e) {
                         e.printStackTrace();
                     }
@@ -327,6 +365,16 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
                 }
             }
         }
+
+        //合并成一个
+        if (localUrls.size() > 1) {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            FileUtils.PdfCopyPublicMethods(bos, localUrls);
+            BladeFile bladeFile = newIOSSClient.updateFile(bos.toByteArray(),fileName);
+            if (bladeFile!= null ) {
+                urls.add(bladeFile.getLink());
+            }
+        }
     }
 
     /**
@@ -367,21 +415,21 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
     /**
      * 生成单张pdf
-     * @param pkeyId   生成pdf的id
+     * @param fileName   文件名
      * @param DataInfo  excel和数据
      * @param excelUrl  excel模板
      * @param filePath  本地路径
      * @return
      * @throws Exception
      */
-    public String getBussPdfInfo(Long pkeyId,Map<String, Object> DataInfo,String excelUrl,String filePath) throws Exception{
+    public String getBussPdfInfo(String fileName,Map<String, Object> DataInfo,String excelUrl,String filePath) throws Exception{
 
-        if (pkeyId == null) {
-            pkeyId = SnowFlakeUtil.getId();
+        if (fileName == null) {
+            fileName = SnowFlakeUtil.getId().toString();
         }
 
-        String pdfPath = filePath + "/pdf//" + pkeyId + ".pdf";
-        String excelPath = filePath + "/pdf//" + pkeyId + ".xlsx";
+        String pdfPath = filePath + "/pdf//" + fileName + ".pdf";
+        String excelPath = filePath + "/pdf//" + fileName + ".xlsx";
         File tabPdf = ResourceUtil.getFile(pdfPath);
         if (tabPdf.exists()) {
             tabPdf.delete();
@@ -465,7 +513,7 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         FileOutputStream outputStream = new FileOutputStream(excelPath);
         workbook.write(outputStream);
         FileUtils.setExcelScaleToPdf(excelPath, pdfPath);
-        BladeFile bladeFile = newIOSSClient.uploadFile(pkeyId + ".pdf", pdfPath);
+        BladeFile bladeFile = newIOSSClient.uploadFile(fileName + ".pdf", pdfPath);
 
         String pdfLink = "";
         if (bladeFile!= null ){
@@ -490,6 +538,9 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         Integer idx = 0;
         Integer iStartPage = 1;
         List<Map<String, Object>> fileMapList = new ArrayList<>();
+
+        //todo  增加获取总大小
+        Integer size = 0;
         for (ArchiveFile file:  datas) {
             idx++;
             //设置序号
@@ -508,11 +559,14 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
                 file.setPageNum(lastPageNum);
             }
 
+
+
             Map<String, Object> fileMap = new ObjectMapper().convertValue(file, Map.class);
             fileMapList.add(fileMap);
         }
         //设置总页数
         archive.setPageN(iStartPage - 1);
+        archive.setSize(size);
 
         // 找出最小和最大日期
         String minDate = "";
@@ -572,4 +626,124 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
         return url;
     }
 
+    /**
+     * @Description  给多个PDF添加页码,按顺序依次累加
+     * @Param [uris, storeName]
+     * @return java.util.List<java.lang.String>
+     * @Author yangyj
+     * @Date 2021.12.17 14:21
+     **/
+    public static List<String> doForPageNumberUseItextpdf(List<String> uris) throws IOException {
+        List<String> result = new ArrayList<>();
+        if(uris!= null && uris.size() > 0){
+            int cursor=0;
+            for(String u:uris) {
+                try {
+                    String url="";
+                    //todo 匿名访问特性
+                    String temporaryVisitUrl=u;
+                    if(temporaryVisitUrl.indexOf("?")!=-1){
+                        url = temporaryVisitUrl;
+                    }else{
+                        int lastIndexOf = u.lastIndexOf("/");
+                        String prefix=u.substring(0,lastIndexOf+1);
+                        String suffix=u.substring(lastIndexOf+1);
+                        url = prefix+ URLEncoder.encode(suffix,"UTF-8");
+                    }
+
+                    PdfReader pdfReader = new PdfReader(url);
+                    ByteArrayOutputStream out = new ByteArrayOutputStream();
+                    PdfStamper pdfStamper = new PdfStamper(pdfReader, out);
+                    int index = 1;
+                    boolean fi;
+//                    String path = u.replaceAll(FileUtils.DOMAIN_REG, "").replaceAll(".((?i)(pdf))$", "").replace("folderFile", FolderFileHelper.ARCHIVED_FILE).replace("showtmp",FolderFileHelper.ARCHIVED_FILE);
+
+                    String page = "page" + (cursor + 1);
+                    do {
+                        PdfContentByte over = pdfStamper.getOverContent(index);
+                        if (over != null) {
+                            over.beginText();
+                            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);
+                            over.setFontAndSize(bf, 16);
+                            over.setTextMatrix(30, 300);
+
+
+                            PdfArray pa = pdfReader.getPageN(index).getAsArray(new PdfName("MediaBox"));
+                            int width = pa.getAsNumber(2).intValue();
+                            int heigh = pa.getAsNumber(3).intValue();
+
+                            if(width>heigh){
+                                //横表旋转270
+                                pdfReader.getPageN(index).put(PdfName.ROTATE, new PdfNumber(270)); // 顺时针旋转270°
+                                //横表旋转后打页码坐标不一样
+                                over.showTextAligned(Element.ALIGN_LEFT, String.valueOf(cursor + index), heigh - 35, 20, 0);
+                            }else{
+                                over.showTextAligned(Element.ALIGN_LEFT, String.valueOf(cursor + index), width - 35, 20, 0);
+                            }
+                            over.endText();
+                            index++;
+                            fi = true;
+                        } else {
+                            /*累加*/
+                            cursor += index-1;
+                            /*重置*/
+                            fi = false;
+                            index = 1;
+                        }
+                    } while (fi);
+                    pdfStamper.close();
+                    page = page + "-" + cursor + ".pdf";
+//                    int lastindex = path.lastIndexOf("/");
+//                    String fileName = path.substring(lastindex + 1) + "-" + page;
+
+                    //newIOSSClient.uploadFile()
+
+                    //result.add(AliyunOSSUtil.uploadFile(out.toByteArray(), fileName, path.substring(0, lastindex), ".pdf", storeName));
+                    out.close();
+                }catch(Exception e){
+                    System.out.println(u+"文件不存在");
+                    /*用来占位置空*/
+                    result.add("");
+                    e.printStackTrace();
+                }
+            }
+        }
+        return result;
+    }
+
+
+    /**
+     * 获取指定文件的pdf文件
+     * @param file
+     * @return
+     */
+    public String getPdfFileUrl(ArchiveFile file){
+        //
+        String url = file.getPdfFileUrl();
+        if (StringUtil.isEmpty(url)) {
+            url = file.getFileUrl();
+        }
+
+        //todo 生成相册内容,待补充
+
+
+        return url;
+    }
+
+    /**
+     * 获取案卷的大小
+     * @param datas
+     * @param frontUrls
+     * @return
+     */
+    public Long getArchiveSize(List<ArchiveFile> datas,List<String> frontUrls){
+        //
+        return 0L;
+
+        //todo 生成相册内容,待补充
+
+
+
+    }
+
 }

+ 170 - 5
blade-service/blade-archive/src/main/java/org/springblade/archive/utils/FileUtils.java

@@ -3,10 +3,11 @@ package org.springblade.archive.utils;
 import com.aspose.cells.SaveFormat;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.itextpdf.text.Document;
-import com.itextpdf.text.pdf.PdfCopy;
-import com.itextpdf.text.pdf.PdfReader;
+import com.itextpdf.text.Element;
+import com.itextpdf.text.pdf.*;
 import com.sun.image.codec.jpeg.JPEGCodec;
 import com.sun.image.codec.jpeg.JPEGImageEncoder;
+import org.apache.commons.collections4.ListUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
 import org.apache.poi.ss.usermodel.ClientAnchor;
@@ -20,8 +21,10 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.vo.DataVO;
+import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.tool.utils.IoUtil;
 import org.springblade.core.tool.utils.ResourceUtil;
+import org.springblade.resource.feign.NewIOSSClient;
 
 import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServletResponse;
@@ -29,10 +32,8 @@ import java.awt.*;
 import java.awt.image.BufferedImage;
 import java.io.*;
 import java.net.URLEncoder;
-import java.util.Arrays;
-import java.util.HashMap;
+import java.util.*;
 import java.util.List;
-import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
@@ -40,6 +41,9 @@ import java.util.zip.ZipOutputStream;
 
 
 public class FileUtils {
+    public static final String DOMAIN_REG = "https?://[^\\.]*\\.oss-cn-shenzhen\\.aliyuncs\\.com/";
+
+    public static final  String LocalPath = "/www/wwwroot/Users/hongchuangyanfa/Desktop/";
 
     public static void batchDownloadFileToZip(List<String> urls, HttpServletResponse response){
         // 设置压缩流:直接写入response,实现边压缩边下载
@@ -401,6 +405,167 @@ public class FileUtils {
 
 
 
+    /**
+     * @Description  给多个PDF添加页码,按顺序依次累加
+     * @Param [uris, storeName]
+     * @return java.util.List<java.lang.String>
+     * @Author yangyj
+     * @Date 2021.12.17 14:21
+     **/
+    public static List<String> doForPageNumberUseItextpdf(List<String> uris, NewIOSSClient newIOSSClient)  {
+        List<String> result = new ArrayList<>();
+        if(uris!= null && uris.size() > 0){
+            int cursor=0;
+            for(String url:uris) {
+                try {
+                    //todo 匿名访问特性
+
+                    String fileNameWithExtension = url.substring(url.lastIndexOf("/") + 1); // 获取带有扩展名的文件名
+
+                    String fileNameWithoutExtension = fileNameWithExtension.substring(0, fileNameWithExtension.lastIndexOf("."));
+
+                    if (url.indexOf("https") >= 0 && url.indexOf("aliyuncs") >= 0) {
+                          int lastIndexOf = url.lastIndexOf("/");
+                          String prefix=url.substring(0,lastIndexOf+1);
+                          String suffix=url.substring(lastIndexOf+1);
+                          url = prefix+ URLEncoder.encode(suffix,"UTF-8");
+                    }
+                    PdfReader pdfReader = new PdfReader(url);
+                    ByteArrayOutputStream out = new ByteArrayOutputStream();
+                    PdfStamper pdfStamper = new PdfStamper(pdfReader, out);
+                    int index = 1;
+                    boolean fi;
+//                    String path = u.replaceAll(FileUtils.DOMAIN_REG, "").replaceAll(".((?i)(pdf))$", "").replace("folderFile", FolderFileHelper.ARCHIVED_FILE).replace("showtmp",FolderFileHelper.ARCHIVED_FILE);
+                    FileOutputStream fos = null;
+                    String page = "page" + (cursor + 1);
+                    do {
+                        PdfContentByte over = pdfStamper.getOverContent(index);
+                        if (over != null) {
+                            over.beginText();
+                            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);
+                            over.setFontAndSize(bf, 16);
+                            over.setTextMatrix(30, 300);
+
+
+                            PdfArray pa = pdfReader.getPageN(index).getAsArray(new PdfName("MediaBox"));
+                            int width = pa.getAsNumber(2).intValue();
+                            int heigh = pa.getAsNumber(3).intValue();
+
+                            if(width>heigh){
+                                //横表旋转270
+                                pdfReader.getPageN(index).put(PdfName.ROTATE, new PdfNumber(270)); // 顺时针旋转270°
+                                //横表旋转后打页码坐标不一样
+                                over.showTextAligned(Element.ALIGN_LEFT, String.valueOf(cursor + index), heigh - 35, 20, 0);
+                            }else{
+                                over.showTextAligned(Element.ALIGN_LEFT, String.valueOf(cursor + index), width - 35, 20, 0);
+                            }
+                            over.endText();
+                            index++;
+                            fi = true;
+                        } else {
+                            /*累加*/
+                            cursor += index-1;
+                            /*重置*/
+                            fi = false;
+                            index = 1;
+                        }
+                    } while (fi);
+                    pdfStamper.close();
+                    page = page + "-" + cursor + ".pdf";
+                    String fileName = fileNameWithoutExtension +  "-" +  page;
+                    String filePath = LocalPath + fileName;
+                    if (newIOSSClient!= null ) {
+                        BladeFile bladeFile  = newIOSSClient.updateFile(out.toByteArray(),fileName);
+                        result.add(bladeFile.getLink());
+                    }else {
+                        fos = new FileOutputStream(filePath);
+                        fos.write(out.toByteArray()); // 将数据写入到指定文件路径中
+                        result.add(filePath);
+                    }
+
+                    out.close();
+                }catch(Exception e){
+                    System.out.println(url+"文件不存在");
+                    /*用来占位置空*/
+                    result.add("");
+                    e.printStackTrace();
+                }
+            }
+        }
+        return result;
+    }
+
+
+    /**
+     * @Description 合并PDF
+     * @Param [bos:结果存在字节数组, uris:支持 file、http、jar等传输协议]
+     * @return void
+     * @Author yangyj
+     * @Date 2021.10.09 10:49
+     **/
+    public static void PdfCopyPublicMethods(ByteArrayOutputStream bos,List<String> uris){
+        
+        PdfReader reader = null;
+        Document doc = new Document();
+        PdfCopy pdfCopy = null;
+        try{
+            pdfCopy = new PdfCopy(doc, bos);
+            int pageCount;
+            doc.open();
+
+            for(String urlStr : uris){
+
+                try{
+                    String url=urlStr;
+                    String fileNameWithExtension = url.substring(url.lastIndexOf("/") + 1); // 获取带有扩展名的文件名
+
+                    String fileNameWithoutExtension = fileNameWithExtension.substring(0, fileNameWithExtension.lastIndexOf("."));
+
+                    if (url.indexOf("https") >= 0 && url.indexOf("aliyuncs") >= 0) {
+                        int lastIndexOf = url.lastIndexOf("/");
+                        String prefix=url.substring(0,lastIndexOf+1);
+                        String suffix=url.substring(lastIndexOf+1);
+                        url = prefix+ URLEncoder.encode(suffix,"UTF-8");
+                    }
+
+                    reader = new PdfReader(url);
+                    pageCount = reader.getNumberOfPages();
+
+                    for(int i = 0; i < pageCount; ++i){
+                        int is = i + 1;
+                        pdfCopy.addPage(pdfCopy.getImportedPage(reader,is));
+                    }
+                }catch (Exception e){
+                    e.printStackTrace();
+                } finally {
+                    if(reader != null){
+                        reader.close();
+                    }
+                }
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        } finally {
+            if(pdfCopy != null){
+                pdfCopy.flush();
+                pdfCopy.close();
+            }
+            doc.close();
+        }
+
+    }
+
+    public static void main(String[] args) {
+        String  file1 = "https://huazheng2021002.oss-cn-shenzhen.aliyuncs.com/folderFile/54e8a314de8a493d9f08a9d3cf7c/104850dea8ca485cbda677c11f0d0e6c/安康至来凤国家高速公路奉节至巫山(渝鄂界)段K13+690~K19+385ZB1合同段开工令-20230415064429.pdf";
+        String  file2 = "https://huazheng2021002.oss-cn-shenzhen.aliyuncs.com/folderFile/54e8a314de8a493d9f08a9d3cf7c/f596dc71c3264977a2cc2b8e5d348b38/1-20230415063812.pdf";
+        List<String> urls  = new ArrayList<>();
+        urls.add(file1);
+        urls.add(file2);
+
+        doForPageNumberUseItextpdf(urls,null);
+
+    }
+
 
 
 

+ 1 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/ArchiveFileMapper.xml

@@ -52,6 +52,7 @@
         <result column="is_auto_file" property="isAutoFile"/>
         <result column="is_archive" property="isArchive"/>
         <result column="page_num" property="pageNum"/>
+        <result column="file_size" property="fileSize"/>
     </resultMap>
     <update id="recoveryByIds">
         update u_archive_file set is_deleted = 0 where

+ 9 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/ArchiveTreeContractImpl.java

@@ -46,18 +46,25 @@ public class ArchiveTreeContractImpl implements ArchiveTreeContractClient {
 
     @Override
     public List<ArchiveTreeContract> getListByProjectId(Long projectId) {
-        return archiveTreeContractMapper.getListByProjectId(projectId);
+        List<ArchiveTreeContract> list = archiveTreeContractMapper.getListByProjectId(projectId);
+        archiveTreeContractService.fillDefaultArchiveAutoInfo(list);
+        return list;
     }
 
     @Override
     public List<ArchiveTreeContract> getSelectNodeByGroupId(Long projectId,Long archiveAutoGroupId) {
         List<ArchiveTreeContract> list = archiveTreeContractMapper.getSelectNodeByGroupId(projectId,archiveAutoGroupId);
+        archiveTreeContractService.fillDefaultArchiveAutoInfo(list);
         return list;
     }
 
     @Override
     public ArchiveTreeContract getArchiveTreeContractById(Long id) {
-        return null;
+        ArchiveTreeContract archiveTreeContract = archiveTreeContractService.getById(id);
+        List<ArchiveTreeContract> list = new ArrayList<>();
+        list.add(archiveTreeContract);
+        archiveTreeContractService.fillDefaultArchiveAutoInfo(list);
+        return archiveTreeContract;
     }
 
 

+ 2 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IArchiveTreeContractService.java

@@ -90,4 +90,6 @@ public interface IArchiveTreeContractService extends BaseService<ArchiveTreeCont
 
 	void  fillDefaultArchiveAutoInfo(List<ArchiveTreeContractVO2> tree,Long projectId);
 
+	void  fillDefaultArchiveAutoInfo(List<ArchiveTreeContract> archiveTreeContracts);
+
 }

+ 50 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveTreeContractServiceImpl.java

@@ -777,6 +777,7 @@ public class ArchiveTreeContractServiceImpl extends BaseServiceImpl<ArchiveTreeC
 
 	}
 
+
 	/**
 	 *
 	 * @param node
@@ -805,6 +806,55 @@ public class ArchiveTreeContractServiceImpl extends BaseServiceImpl<ArchiveTreeC
 		}
 	}
 
+	/**
+	 * 填充基本信息
+	 * @param archiveTreeContracts
+	 */
+	public  void  fillDefaultArchiveAutoInfo(List<ArchiveTreeContract> archiveTreeContracts){
+		Long projectId = archiveTreeContracts.get(0).getProjectId();
+		List<ContractInfo> contractInfos = contractInfoService.selectContractInfoPageByPid(projectId.toString());
+		if (contractInfos == null || contractInfos.size() == 0) {
+			return;
+		}
+		Map<Long,ContractInfo> contractMap = new LinkedHashMap<>();
+		for (ContractInfo contractInfo: contractInfos) {
+			if (contractInfo.getContractType() == 3) {
+				contractMap.put(0L,contractInfo);
+			}
+			contractMap.put(contractInfo.getId(),contractInfo);
+		}
+
+		for (ArchiveTreeContract node: archiveTreeContracts) {
+			Long contractId = 0L;
+			if (node.getContractId() != null ) {
+				contractId = node.getContractId();
+			}
+			ContractInfo contractInfo = contractMap.get(contractId);
+			if (contractInfo != null) {
+				if (StringUtils.isEmpty(node.getFileNumberPrefix())) {
+					node.setFileNumberPrefix(contractInfo.getPrefix());
+				}
+				if (StringUtils.isEmpty(node.getStorageTime()) && contractInfo.getStoragePeriod() != null) {
+					node.setStorageTime(contractInfo.getStoragePeriod().toString());
+				}
+				if (StringUtils.isEmpty(node.getRollor())) {
+					node.setRollor(contractInfo.getFiler());
+				}
+				if (StringUtils.isEmpty(node.getReviewer())) {
+					node.setReviewer(contractInfo.getReviewer());
+				}
+				if (StringUtils.isEmpty(node.getSpecification())) {
+					//默认30mm ,对应枚举 1
+					node.setSpecification("1");
+				}
+				//没有默认
+				if (StringUtils.isEmpty(node.getArchiveNameSuffix())) {
+					//node.setArchiveNameSuffix(contractInfo.getPrefix());
+				}
+			}
+		}
+	}
+