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 | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 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 62688d0..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;
@@ -449,8 +450,12 @@
}
Integer insOrderId = insReportMapper.selectById(id).getInsOrderId();
InsOrder order = insOrderMapper.selectById(insOrderId);
- boolean isRawMater = order.getTypeSource() != null && order.getTypeSource().equals(1);
-
+ IfsInventoryQuantity ifsInventoryQuantity = null;
+ if(ObjectUtils.isNotEmpty(order.getIfsInventoryId())){
+ ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(order.getIfsInventoryId());
+ }
+ boolean isRawMater = order.getTypeSource() != null && !order.getTypeSource().equals(-1);
+ String contract = ObjectUtils.isNotEmpty(ifsInventoryQuantity)?ifsInventoryQuantity.getContract():order.getContract();//ifs鍩�
//鑾峰彇鍦烘墍鐨勬姤鍛婁笓鐢ㄧ珷
String sealUrl;
String laboratory = insOrderMapper.selectById(insReport.getInsOrderId()).getLaboratory();
@@ -461,7 +466,7 @@
} else {
type = "濮旀墭鎶ュ憡";
}
- sealUrl = insReportMapper.getLaboratoryByName(laboratory, type);
+ sealUrl = insReportMapper.getLaboratoryByName(laboratory, type,contract);
} catch (Exception e) {
throw new ErrorException(laboratory + "鎵句笉鍒版姤鍛婁笓鐢ㄧ珷");
}
@@ -520,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