From 1484e72c3532679f9f3df7c2e918a18c7a4f9feb Mon Sep 17 00:00:00 2001 From: xiaoxue_admin <9283713@qq.com> Date: Tue, 23 Jun 2026 00:50:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=A9=E5=A4=A7x=E5=9D=90=E6=A0=87?= =?UTF-8?q?=E8=8C=83=E5=9B=B41200-2600=20+=20code=5Fmap=E4=BC=98=E5=85=88?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E5=90=AB=E6=A8=AA=E6=9D=A0=E7=9A=84=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. x坐标范围从1500-2600扩大到1200-2600 修复第二个2203.01(x=1297)被过滤导致错过完整名的问题 2. code_map更新逻辑:inline文本含横杠→用新名覆盖旧名 让2203.01第二次出现(含完整三级名)覆盖第一次(仅一级名) --- core/parser.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/parser.py b/core/parser.py index 1208001..323c0cf 100644 --- a/core/parser.py +++ b/core/parser.py @@ -163,8 +163,8 @@ class K3VoucherParser: if cy < y_lower - 100 or cy > y_debit_val: continue - # x坐标:科目代码通常在表格中间区域 - if cx < 1500 or cx > 2600: + # x坐标:科目代码通常在表格中间偏左区域 + if cx < 1200 or cx > 2600: continue t = text.strip() @@ -185,6 +185,8 @@ class K3VoucherParser: # 提取名称 — 按用户规则:取最后一个横杠之后的文字 name = t[m.end():].lstrip('--—= ') + # 记录原始inline文本是否含横杠(判断完整性用) + inline_has_dash = max(name.rfind('-'), name.rfind('-'), name.rfind('—')) >= 0 name = re.sub(r'[\d.\-—=]+$', '', name).strip() name = name.lstrip('-—-=') @@ -198,8 +200,8 @@ class K3VoucherParser: # 去重:优先保留带完整名称的行 if code_part in code_map: existing = codes[code_map[code_part]] - # 已有名称为空,而新行有名称 → 更新 - if (not existing['name'] or len(existing['name']) < 2) and len(name) >= 2: + # 新名称的原文本含横杠(更完整)→ 更新 + if inline_has_dash or ((not existing['name'] or len(existing['name']) < 2) and len(name) >= 2): existing['name'] = name existing['y_pos'] = cy existing['x_pos'] = cx