ry-ocr/ (新)
本地发票识别微服务 (PaddleOCR 3.x + FastAPI, 8801)
- QR 优先: 扫到二维码即取开票时间/发票号/金额; 没扫到/格式不合法直接判非发票, 不跑 OCR
- 配置 QR_FULL_OCR 控制快路径(false, 0.2s)还是全字段(true, 4.5s)
- /recognize/invoice (multipart) + /recognize/invoice/by-path (本地路径, 白名单) + /recognize/text
- is_invoice / from_qr / qr_raw / qr_error / error_code 字段
- 12 字段发票抽取 (regex + 启发式, 左右主体识别)
- 超时保护 (15s 单页 / 60s 总流程) + PaddleOCR 单例 + ThreadPoolExecutor
ry-api/ruoyi-business/
- pom.xml: 加 hutool-http/json/core 5.8.27, lombok 1.18.30 (OcrClient @Slf4j 所需)
- ocr/: OcrClient + InvoiceResult/Fields/Line + ZipExtractor + InvoiceOcrScheduler
- oss/: OssUploader + OssConfMeta (OCR 识别后重传 OSS)
- config/: OcrConfig + OcrExecutorConfig (后台线程池)
- service/impl/InvoiceOcrService: 后台提交 OCR, ZIP 路径解压识别, 替换场景先清旧
- 会议材料 CRUD 全套 (BizMeetingAuditLog/Executor/Invoice/Material/Supervisor):
controller + service + mapper + domain + xml
ry-vue3/
- MeetingDetail.vue (新建): 会议详情页 (含评分维度章节, 改只读)
- Meetings.vue / OssFileUploader.vue / router / Login.vue: 适配新字段
ry-api/ruoyi-admin/
- RuoYiApplication.java + application.yml: 启用 @Async 异步支持
_self/
- manager_meetings.md / manager_meeting_detail.md: 文档
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
"""应用配置(从环境变量 / .env 读取)"""
|
|
from pathlib import Path
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
# 服务
|
|
app_host: str = "0.0.0.0"
|
|
app_port: int = 8801
|
|
|
|
# OCR
|
|
use_gpu: bool = False
|
|
ocr_lang: str = "ch"
|
|
# 模型: "mobile" (CPU 友好, 默认) / "server" (高精度, GPU 适用)
|
|
ocr_engine: str = "mobile"
|
|
|
|
# 上传 / PDF
|
|
max_upload_mb: int = 20
|
|
# 默认 150 DPI:清晰数字 PDF 150 已够,扫描件需调到 250~300
|
|
pdf_dpi: int = 150
|
|
|
|
# 路径接口允许的根目录(逗号分隔)。空 = 禁用路径接口
|
|
# 示例: "E:\\gitee\\guoju-hegui;D:\\uploads"
|
|
allowed_dirs: str = ""
|
|
|
|
# 识别超时(秒)- 单页 OCR / 整流程任一超时即返回失败
|
|
# CPU mobile 模型单页约 4 秒, 设 15s 留余量
|
|
ocr_page_timeout_s: int = 15
|
|
ocr_total_timeout_s: int = 60
|
|
|
|
# QR 识别:
|
|
# true = 扫到 QR 后仍跑全量 OCR + 字段抽取 (默认, 向后兼容)
|
|
# false = 扫到 QR 后直接返回 QR 里的 3 个核心字段 (开票时间/发票号/金额), 跳过 OCR
|
|
# 没扫到 QR 或 QR 格式不合法时一律回退到 OCR 流水线, 不受此开关影响
|
|
qr_full_ocr: bool = True
|
|
|
|
# 日志
|
|
log_level: str = "INFO"
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=str(Path(__file__).resolve().parent.parent / ".env"),
|
|
env_file_encoding="utf-8",
|
|
extra="ignore",
|
|
)
|
|
|
|
|
|
settings = Settings()
|