feat(file-check): 更新文件检核工具 API Key 配置及相关文档

This commit is contained in:
hugo committed 2026-06-17 22:29:15 +08:00
1 parent 634dee4b81
commit 55cf7ff734
74 files changed
+1525 -1182

No files matched your search

@@ -23,6 +23,7 @@ from app.services.shipping_notice.export import _storage_root
def task_notice_upload_path(task_no: str, filename: str) -> Path:
"""生成任务级发货通知附件落盘路径(notice_uploads/{task_no}/{filename})。"""
safe_task = re.sub(r"[^\w\-]+", "_", str(task_no or "").strip()) or "unknown"
name = str(filename or "").strip() or "notice"
safe_name = re.sub(r"[^\w\-.]+", "_", name)[:120] or "notice"
@@ -30,6 +31,7 @@ def task_notice_upload_path(task_no: str, filename: str) -> Path:
def save_task_notice_upload(task_no: str, filename: str, data: bytes) -> Path:
"""保存发货通知附件字节流并返回落盘路径。"""
path = task_notice_upload_path(task_no, filename)
path.parent.mkdir(parents=True, exist_ok=True)
path.write_bytes(data)
@@ -118,6 +120,12 @@ def _blocks_to_text(blocks: list[Block]) -> str:
def extract_notice_text(file_path: Path) -> tuple[str, dict[str, Any]]:
"""
从发货通知附件抽取纯文本(PDF/DOCX/CSV/图片 OCR/EML/HTML 等)。
Returns:
tuple[str, dict]: (抽取文本, meta 含 warnings 与 file_type)。
"""
path = Path(file_path)
ext = path.suffix.lower().lstrip(".")
ctx = Context(file_type=ext)
@@ -153,6 +161,7 @@ def extract_notice_text(file_path: Path) -> tuple[str, dict[str, Any]]:
def guess_source_type(filename: str) -> str:
"""按扩展名推断 source_type(pdf / email / manual)。"""
ext = str(Path(filename or "").suffix or "").lower().lstrip(".")
if ext in {"pdf"}:
return "pdf"
@@ -162,6 +171,7 @@ def guess_source_type(filename: str) -> str:
def max_notice_chars() -> int:
"""发货通知正文最大字符数(SHIPPING_NOTICE_NOTICE_TEXT_MAX_CHARS,默认 200000)。"""
raw = str(current_app.config.get("SHIPPING_NOTICE_NOTICE_TEXT_MAX_CHARS") or "").strip()
try:
value = int(raw) if raw else 0