From 2e378480e4920042ce57cc853ed33b35bcd580aa Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 24 九月 2026 17:50:00 +0800
Subject: [PATCH] fix(report): 解决Word报告生成中PNG图片压缩率问题

---
 inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java
index 3bda5d4..3ccac7e 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java
@@ -43,6 +43,7 @@
 import com.ruoyi.system.mapper.UserMapper;
 import com.ruoyi.system.service.InformationNotificationService;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.openxml4j.util.ZipSecureFile;
 import org.apache.poi.xwpf.usermodel.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -524,7 +525,18 @@
 
     @Override
     public int wordInsertUrl(Map<String, Object> map, String url) {
-        XWPFTemplate template = XWPFTemplate.compile(url).render(map);
+        XWPFTemplate template;
+        synchronized (ZipSecureFile.class) {
+            double originalMinInflateRatio = ZipSecureFile.getMinInflateRatio();
+            try {
+                // 鍏煎鎶ュ憡涓帇缂╃巼杈冮珮鐨勭函鑹�/閫忔槑 PNG锛岀紪璇戝悗绔嬪嵆鎭㈠ POI 瀹夊叏闃堝�笺��
+                ZipSecureFile.setMinInflateRatio(0.001D);
+                template = XWPFTemplate.compile(url);
+            } finally {
+                ZipSecureFile.setMinInflateRatio(originalMinInflateRatio);
+            }
+        }
+        template.render(map);
         try {
             template.writeAndClose(Files.newOutputStream(Paths.get(url)));
         } catch (IOException e) {

--
Gitblit v1.9.3