浏览代码

upgrade POI package version; fix warnings

dengjia 1 月之前
父节点
当前提交
8cc2e064b5

+ 5 - 5
easier-report-biz/pom.xml

@@ -83,17 +83,17 @@
         <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi</artifactId>
-            <version>4.1.2</version>
+            <version>5.4.1</version>
         </dependency>
         <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi-ooxml</artifactId>
-            <version>4.1.2</version>
+            <version>5.4.1</version>
         </dependency>
         <dependency>
             <groupId>org.apache.poi</groupId>
             <artifactId>poi-scratchpad</artifactId>
-            <version>4.1.2</version>
+            <version>5.4.1</version>
         </dependency>
 
         <!-- XML 处理依赖 -->
@@ -135,7 +135,7 @@
         <dependency>
             <groupId>fr.opensagres.xdocreport</groupId>
             <artifactId>fr.opensagres.poi.xwpf.converter.xhtml</artifactId>
-            <version>2.0.2</version>
+            <version>2.1.0</version>
             <exclusions>
                 <exclusion>
                     <groupId>org.apache.poi</groupId>
@@ -150,7 +150,7 @@
         <dependency>
             <groupId>fr.opensagres.xdocreport</groupId>
             <artifactId>xdocreport</artifactId>
-            <version>2.0.6</version>
+            <version>2.1.0</version>
             <exclusions>
                 <exclusion>
                     <groupId>org.apache.poi</groupId>

+ 4 - 4
easier-report-biz/src/main/java/com/yaoyicloud/service/impl/ReportServiceImpl.java

@@ -7,8 +7,8 @@ import java.util.Map;
 
 import com.yaoyicloud.constant.enums.ReportType;
 import com.yaoyicloud.service.ReportService;
-import com.yaoyicloud.template.AcademicAssociationReport;
-import com.yaoyicloud.template.FoundationReport;
+// import com.yaoyicloud.template.AcademicAssociationReport;
+// import com.yaoyicloud.template.FoundationReport;
 import com.yaoyicloud.template.PlatformCompanyReport;
 import org.springframework.stereotype.Service;
 import lombok.RequiredArgsConstructor;
@@ -25,8 +25,8 @@ import lombok.extern.slf4j.Slf4j;
 @RequiredArgsConstructor
 public class ReportServiceImpl implements ReportService {
 
-    private final AcademicAssociationReport academicAssociationReport;
-    private final FoundationReport foundationReport;
+    // private final AcademicAssociationReport academicAssociationReport;
+    // private final FoundationReport foundationReport;
     private final PlatformCompanyReport platformCompanyReport;
 
 

+ 1 - 1
easier-report-biz/src/main/java/com/yaoyicloud/template/AbstractReportExporter.java

@@ -87,7 +87,7 @@ public abstract class AbstractReportExporter {
         // 构建新文件名
         String newFileName = baseName + "1" + extension;
         // 构建完整新路径
-        String newPdfPath = path.resolveSibling(newFileName).toString();
+        path.resolveSibling(newFileName).toString();
         return PdfProcessor.processPdf(reportBastPath, imagePath, mediumFontPath, 1);
     }
 

+ 0 - 1
easier-report-biz/src/main/java/com/yaoyicloud/template/PlatformCompanyReport.java

@@ -61,7 +61,6 @@ public class PlatformCompanyReport extends AbstractReportExporter {
     @Override
     protected void renderTemplate(String reportTempWordFile, String templatePath, ConfigureBuilder builder,
         Map<String, Object> data) throws IOException {
-        File file = new File(reportTempWordFile);
 
         Configure config = builder.build();
         XWPFTemplate template = XWPFTemplate.compile(templatePath, config).render(data);

+ 1 - 1
easier-report-biz/src/main/java/com/yaoyicloud/tools/OfficeUtil.java

@@ -80,6 +80,7 @@ public class OfficeUtil {
 
             };
 
+            @SuppressWarnings("deprecation")
             XHTMLOptions options = XHTMLOptions.create()
                     .setImageManager(imageManager)
                     .URIResolver(new FileURIResolver(imageDirFile) {
@@ -212,7 +213,6 @@ public class OfficeUtil {
     public static String convertHtmlToPdf(String htmlString, String outputPdfPath, List<String> fontPaths,
         boolean simpleFooter, int coverPageCount) throws IOException {
         File outputFile = new File(outputPdfPath);
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
         try (OutputStream os = new FileOutputStream(outputFile); PdfWriter writer = new PdfWriter(os);
             PdfDocument pdf = new PdfDocument(writer)) {
             String boldFont = null;

+ 4 - 6
easier-report-biz/src/main/java/com/yaoyicloud/tools/PdfProcessor.java

@@ -66,7 +66,7 @@ public class PdfProcessor {
                 addBackgroundToFirstPage(pdfDoc, backgroundImagePath);
             }
             // 标题背景样式
-            int coverPageCount = modifyHeadings(pdfDoc, tocEntities, coverPage);
+            modifyHeadings(pdfDoc, tocEntities, coverPage);
             // 目录
             if (tocEntities != null && !tocEntities.isEmpty()) {
                 generateTableOfContents(pdfDoc, tocEntities, fontPath, coverPage);
@@ -75,10 +75,7 @@ public class PdfProcessor {
         return outputPath;
     }
 
-
-
-
-    private static void updateHeadingPageNumbers(List<TocEntity> headings, List<Integer> deletedPages) {
+    protected static void updateHeadingPageNumbers(List<TocEntity> headings, List<Integer> deletedPages) {
         // 确保被删除的页码是升序排列(方便计算)
         Collections.sort(deletedPages);
 
@@ -98,6 +95,7 @@ public class PdfProcessor {
             heading.setPageNumber(originalPage - offset);
         }
     }
+
     public static String getNewPdfPath(String reportBastPath) {
         Path path = Paths.get(reportBastPath);
         // 获取文件名和扩展名
@@ -112,7 +110,7 @@ public class PdfProcessor {
         return newPdfPath;
     }
 
-    private static  List<Integer> removeBlankPages(PdfDocument pdfDoc) {
+    protected static  List<Integer> removeBlankPages(PdfDocument pdfDoc) {
         int totalPages = pdfDoc.getNumberOfPages();
         List<Integer> deletedPages = new ArrayList<>(); // 记录被删除的页