From 8e1b1fc209c9603dbe994ef41d8d64d3dc35b357 Mon Sep 17 00:00:00 2001 From: john Date: Thu, 17 Sep 2026 17:16:43 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=82=80=E8=AF=B7=E5=87=BD=20PDF=20?= =?UTF-8?q?=E8=90=BD=E6=AC=BE=E6=9C=BA=E6=9E=84=E5=90=8D/=E5=A7=93?= =?UTF-8?q?=E5=90=8D=E5=8D=A0=E4=BD=8D=E7=AC=A6=E5=85=BC=E5=AE=B9=E6=AF=8F?= =?UTF-8?q?=E5=AD=97=E7=A9=BA=E6=A0=BC=E6=8E=92=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 落款机构 ORG_TEXT 扩展为无空格与每字空格两种写法 ("北京整合医学学会" / "北 京 整 合 医 学 学 会") - 姓名占位符扩展为 "xxx" / "x x x" 两种, 大小写由 toLowerCase 归一 - 盖章取全文最后一个匹配, 未匹配日志文案同步更新 Co-Authored-By: Claude Code --- .../service/InvitationPdfService.java | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/ry-api/ruoyi-business/src/main/java/com/ruoyi/business/service/InvitationPdfService.java b/ry-api/ruoyi-business/src/main/java/com/ruoyi/business/service/InvitationPdfService.java index 582defa..ca13c96 100644 --- a/ry-api/ruoyi-business/src/main/java/com/ruoyi/business/service/InvitationPdfService.java +++ b/ry-api/ruoyi-business/src/main/java/com/ruoyi/business/service/InvitationPdfService.java @@ -56,10 +56,10 @@ public class InvitationPdfService { /** 公章尺寸 (宽高, px), 复用 PdfService 劳务协议章口径 */ private static final float SEAL_WIDTH = 120f; private static final float SEAL_HEIGHT = 120f; - /** 需盖章的落款机构名 (取全文最后一个) */ - private static final String ORG_TEXT = "北京整合医学学会"; - /** 姓名占位符 (忽略大小写, 兼容 xxx / XXX) */ - private static final String PLACEHOLDER = "xxx"; + /** 需盖章的落款机构名 (取全文最后一个), 兼容无空格/每字空格两种排版 */ + private static final String[] ORG_TEXTS = {"北京整合医学学会", "北 京 整 合 医 学 学 会"}; + /** 姓名占位符 (忽略大小写, 由 toLowerCase 归一), 兼容无空格/带空格两种排版 */ + private static final String[] PLACEHOLDERS = {"xxx", "x x x"}; /** 按 URL 下载邀请函模板 PDF 字节 (批量发送时对同一会议只调用一次) */ public byte[] downloadTemplate(String url) { @@ -144,21 +144,27 @@ public class InvitationPdfService { } String lower = full.toLowerCase(Locale.ROOT); - int i = 0; - while ((i = lower.indexOf(PLACEHOLDER, i)) >= 0) { - nameTargets.add(buildNameTarget(charInfos, i, PLACEHOLDER.length(), p)); - i += PLACEHOLDER.length(); + // 姓名占位符: 兼容无空格/带空格两种写法 (xxx / x x x, 大小写由 toLowerCase 归一) + for (String ph : PLACEHOLDERS) { + int i = 0; + while ((i = lower.indexOf(ph, i)) >= 0) { + nameTargets.add(buildNameTarget(charInfos, i, ph.length(), p)); + i += ph.length(); + } } - int j = 0; - while ((j = full.indexOf(ORG_TEXT, j)) >= 0) { - seal = buildSealTarget(charInfos, j, ORG_TEXT.length(), p); - j += ORG_TEXT.length(); + // 落款机构: 兼容无空格/每字空格两种写法, 取全文最后一个匹配 + for (String org : ORG_TEXTS) { + int j = 0; + while ((j = full.indexOf(org, j)) >= 0) { + seal = buildSealTarget(charInfos, j, org.length(), p); + j += org.length(); + } } } // 第二遍: 叠加 if (nameTargets.isEmpty()) { - log.warn("[invitation] 未找到占位符 xxx, 跳过姓名替换"); + log.warn("[invitation] 未找到姓名占位符 (xxx / x x x), 跳过姓名替换"); } else { PdfFont cjkFont = PdfFontFactory.createFont("simsun.ttc,0", PdfEncodings.IDENTITY_H, false); for (NameTarget t : nameTargets) { @@ -166,7 +172,7 @@ public class InvitationPdfService { } } if (seal == null) { - log.warn("[invitation] 未找到 '{}', 跳过盖章", ORG_TEXT); + log.warn("[invitation] 未找到落款机构名 (北京整合医学学会), 跳过盖章"); } else { drawSeal(doc, seal); }