feat(loader_pdf): 提取 XFA 数据集并更新上下文信息

- 添加 XFA 数据集提取功能
- 更新上下文以包含提取的 XFA 文本
- 增加相关测试以验证 XFA 数据集的提取
This commit is contained in:
hugo committed 2026-06-29 14:46:22 +08:00
1 parent 1fc9976ca3
commit f434402530
2 files changed
+122

No files matched your search

@@ -13,6 +13,24 @@ from app.services.shipping_notice.reservation_id import (
)
def test_extract_notice_text_reads_xfa_pdf_datasets():
"""XFA 表单型 PO 的订单字段应进入 raw_text,避免只抽页面文本漏明细。"""
from pathlib import Path
from app.services.shipping_notice.notice_upload import extract_notice_text
pdf_path = Path(__file__).resolve().parents[2] / "docs" / "prototype" / "4510038672.pdf"
text, meta = extract_notice_text(pdf_path)
assert meta["file_type"] == "pdf"
assert "pdf xfa datasets extracted" in meta["warnings"]
assert "HEADER/EBELN: 4510038672" in text
assert "HEADER/SHIPMENT_TEXT: 1000144510" in text
assert "TEMP-S000218922" in text
assert "MPN:D4-A08AR12000001" in text
assert "EINDT=2026-06-23" in text
def test_extract_reservation_id_from_pr_number():
assert extract_reservation_id("ADU_S-ENCWIW260528126265@1000140351") == "1000140351"
assert find_reservation_id_in_document("PR Number: ADU_S-ENCWIW260528126265@1000140351") == "1000140351"