feat: 益选 OCR 订单处理系统初始提交
- 智能供应商识别(蓉城易购/烟草/杨碧月/通用) - 百度 OCR 表格识别集成 - 规则引擎(列映射/数据清洗/单位转换/规格推断) - 条码映射管理与云端同步(Gitea REST API) - 云端同步支持:条码映射、供应商配置、商品资料、采购模板 - 拖拽一键处理(图片→OCR→Excel→合并) - 191 个单元测试 - 移除无用的模板管理功能 - 清理 IDE 产物目录 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""错误处理工具模块"""
|
||||
|
||||
from tkinter import messagebox
|
||||
from typing import Optional
|
||||
|
||||
from app.core.utils.log_utils import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def show_error_dialog(title: str, message: str, suggestion: Optional[str] = None):
|
||||
try:
|
||||
full_msg = message
|
||||
if suggestion:
|
||||
full_msg = f"{message}\n\n建议操作:\n- {suggestion}"
|
||||
messagebox.showerror(title, full_msg)
|
||||
except Exception as e:
|
||||
logger.debug(f"显示错误对话框失败: {e}")
|
||||
|
||||
|
||||
def get_error_suggestion(message: str) -> Optional[str]:
|
||||
msg = (message or "").lower()
|
||||
if 'openpyxl' in msg or ('engine' in msg and 'xlsx' in msg):
|
||||
return '安装依赖:pip install openpyxl'
|
||||
if 'xlrd' in msg or ('engine' in msg and 'xls' in msg):
|
||||
return '安装依赖:pip install xlrd'
|
||||
if 'timeout' in msg or 'timed out' in msg:
|
||||
return '检查网络,增大API超时时间或稍后重试'
|
||||
if 'invalid access_token' in msg or 'access token' in msg:
|
||||
return '刷新百度OCR令牌或检查api_key/secret_key'
|
||||
if '429' in msg or 'too many requests' in msg:
|
||||
return '降低识别频率或稍后重试'
|
||||
if '模板文件不存在' in msg or ('no such file' in msg and '模板' in msg):
|
||||
return '在系统设置中选择正确的模板文件路径'
|
||||
if '没有找到采购单' in msg or '未在 data/result 目录下找到采购单' in msg:
|
||||
return '确认data/result目录内存在采购单文件'
|
||||
if 'permission denied' in msg:
|
||||
return '以管理员权限运行或更改目录写入权限'
|
||||
return None
|
||||
Reference in New Issue
Block a user