Kaynağa Gözat

解决内存溢出问题

chendayu 2 yıl önce
ebeveyn
işleme
08eb74ad15

+ 13 - 14
PAS/src/main/java/cn/cslg/pas/service/patentPDF/PatentPDFService.java

@@ -30,26 +30,25 @@ import java.util.List;
 @Slf4j
 @Service
 public class PatentPDFService extends ServiceImpl<PatentInstructionMapper, PatentInstruction> {
-    //private final PatentInstructionService patentInstructionService;
     private final FileUtils fileUtils;
 
     public void queryPatentPdfFirstPages(List<String> patentNos) throws IOException {
         log.info("开始处理【导出多件专利pdf首页】的业务,业务参数为patentNos:{}", patentNos);
 
         //根据专利号patentNos查询出所有pdf文档数据
-//        List<PatentInstruction> patentInstructions = patentInstructionService.list(new LambdaQueryWrapper<PatentInstruction>().in(PatentInstruction::getPatentNo, patentNos));
-//
-//        for (PatentInstruction patentInstruction : patentInstructions) {
-//            String filePath = fileUtils.getSystemPath() + patentInstruction.getUrl();
-//            PDDocument doc = PDDocument.load(new File(filePath));
-//            Splitter splitter = new Splitter();
-//            splitter.setStartPage(1);
-//            splitter.setEndPage(1);
-//            PDDocument neededDoc = splitter.split(doc).get(0);
-//            File pdfFirstPageFile = new File("合并多件专利的pdf首页.pdf");
-//            neededDoc.save(pdfFirstPageFile);
-//
-//        }
+        List<PatentInstruction> patentInstructions = this.list(new LambdaQueryWrapper<PatentInstruction>().in(PatentInstruction::getPatentNo, patentNos));
+
+        for (PatentInstruction patentInstruction : patentInstructions) {
+            String filePath = fileUtils.getSystemPath() + patentInstruction.getUrl();
+            PDDocument doc = PDDocument.load(new File(filePath));
+            Splitter splitter = new Splitter();
+            splitter.setStartPage(1);
+            splitter.setEndPage(1);
+            PDDocument neededDoc = splitter.split(doc).get(0);
+            File pdfFirstPageFile = new File("合并多件专利的pdf首页.pdf");
+            neededDoc.save(pdfFirstPageFile);
+
+        }
 
     }