refactor(server): user_agent/steward/ocr 等服务重构并适配关联任务

- user_agent 拆分 application/locations/knowledge/response/review 四个子模块,接入申请位置语义与关联草稿分支
- steward planner/runtime/slot/plan_builder 决策链路重构,travel_reimbursement_calculator/orchestrator_expense_query 适配
- ocr/document_preview/document_intelligence/receipt_folder 复用预览与资产缓存,expense_claim_draft_flow/application_handoff 适配
- pyproject.toml 新增依赖,paddleocr bootstrap 脚本与 server_start.sh 调整
- 更新差旅/交通/通信等财务规则表,同步 document_intelligence/ocr/receipt_folder/user_agent 等测试
This commit is contained in:
caoxiaozhu
2026-06-24 10:42:24 +08:00
parent 332f77389d
commit 0264a4b5b4
41 changed files with 1273 additions and 182 deletions

View File

@@ -1,6 +1,7 @@
from __future__ import annotations
from datetime import UTC, datetime
from threading import Lock
from sqlalchemy import select
from sqlalchemy.orm import Session
@@ -16,11 +17,23 @@ from app.schemas.notification_state import (
class NotificationStateService:
_storage_ready_bind_ids: set[int] = set()
_storage_ready_lock = Lock()
def __init__(self, db: Session) -> None:
self.db = db
def ensure_storage_ready(self) -> None:
Base.metadata.create_all(bind=self.db.get_bind(), tables=[NotificationState.__table__])
bind = self.db.get_bind()
bind_id = id(bind)
if bind_id in self._storage_ready_bind_ids:
return
with self._storage_ready_lock:
if bind_id in self._storage_ready_bind_ids:
return
Base.metadata.create_all(bind=bind, tables=[NotificationState.__table__])
self._storage_ready_bind_ids.add(bind_id)
def list_states(self, current_user: CurrentUserContext) -> NotificationStateListRead:
self.ensure_storage_ready()