1
This commit is contained in:
1 parent
78576f5745
commit
63b997a7e4
68 files changed
+3680
-1413
No files matched your search
@@ -194,7 +194,15 @@ from app.models.shipping_inventory_preparation import (
|
||||
from app.models.shipping_inventory_mapping import ShippingInventoryMapping
|
||||
from app.models.training import TrainingRecord, TrainingConfig, TrainingConfigResource
|
||||
from app.models.user import LoginAudit, User, UserDefaultAgent, UserFavoriteAgent, UserHomepageConfig
|
||||
from app.models.voucher_check import VoucherCheckInvoiceState, VoucherCheckRunItem
|
||||
from app.models.voucher_check import (
|
||||
VoucherCheckFileResult,
|
||||
VoucherCheckInvoiceState,
|
||||
VoucherCheckNotification,
|
||||
VoucherCheckProfile,
|
||||
VoucherCheckRun,
|
||||
VoucherCheckRunItem,
|
||||
VoucherCheckSubject,
|
||||
)
|
||||
from app.models.contract_payment import (
|
||||
ContractPaymentAlert,
|
||||
ContractPaymentAlertBatch,
|
||||
@@ -381,6 +389,11 @@ __all__ = [
|
||||
'ShippingTaskInventoryRpaAttempt',
|
||||
'VoucherCheckInvoiceState',
|
||||
'VoucherCheckRunItem',
|
||||
'VoucherCheckProfile',
|
||||
'VoucherCheckRun',
|
||||
'VoucherCheckSubject',
|
||||
'VoucherCheckFileResult',
|
||||
'VoucherCheckNotification',
|
||||
'ContractPaymentContract',
|
||||
'ContractPaymentAttachment',
|
||||
'ContractPaymentNode',
|
||||
|
||||
@@ -34,6 +34,7 @@ class QuickQuestion(Base):
|
||||
"""
|
||||
常用问题表
|
||||
用途:存储全局/用户常用问题;全局条目(user_id 为空)可配置标准答案并启用 FAQ 缓存命中。
|
||||
is_enabled 控制工作台首页快捷入口;cache_enabled 控制聊天是否跳过 Dify 直答,二者独立。
|
||||
"""
|
||||
|
||||
__tablename__ = 'quick_questions'
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"""
|
||||
backend/app/models/voucher_check.py
|
||||
|
||||
用途:立账凭证检核单票最新状态与批次明细 ORM。
|
||||
用途:立账凭证检核 ORM。含旧一票一状态表,以及销售一期单文件结果引擎表。
|
||||
依赖:models.base.Base、schedule_runs。
|
||||
逻辑:runner/persistence 写入;query_service 与工作台 API 读取;增量跳过依赖 invoice_states。
|
||||
逻辑:旧 runner 写 invoice_states/run_items;新引擎写 profiles/runs/subjects/file_results/notifications。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -112,3 +112,156 @@ class VoucherCheckRunItem(Base):
|
||||
error_message: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
checked_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
|
||||
|
||||
class VoucherCheckProfile(Base):
|
||||
"""已发布 Profile 版本;批次绑定不可变快照,运行时不以本表热更新覆盖。"""
|
||||
|
||||
__tablename__ = "voucher_check_profiles"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("profile_code", "version", name="uq_voucher_check_profiles_code_version"),
|
||||
Index("ix_voucher_check_profiles_status", "status"),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
||||
profile_code: Mapped[str] = mapped_column(String(32), nullable=False)
|
||||
version: Mapped[str] = mapped_column(String(32), nullable=False)
|
||||
definition_json: Mapped[dict] = mapped_column(JSON, nullable=False)
|
||||
status: Mapped[str] = mapped_column(String(24), nullable=False, default="published")
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
DateTime,
|
||||
default=datetime.utcnow,
|
||||
onupdate=datetime.utcnow,
|
||||
nullable=False,
|
||||
)
|
||||
|
||||
|
||||
class VoucherCheckRun(Base):
|
||||
"""一次检核批次;列表统计取本表快照,不在查询时重算单文件结果。"""
|
||||
|
||||
__tablename__ = "voucher_check_runs"
|
||||
__table_args__ = (
|
||||
Index("ix_voucher_check_runs_period_profile", "period_month", "profile_code"),
|
||||
Index("ix_voucher_check_runs_status", "status"),
|
||||
Index("ix_voucher_check_runs_finished_at", "finished_at"),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
||||
schedule_run_id: Mapped[Optional[int]] = mapped_column(
|
||||
BigInteger,
|
||||
ForeignKey("schedule_runs.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
)
|
||||
run_no: Mapped[str] = mapped_column(String(64), nullable=False)
|
||||
profile_code: Mapped[str] = mapped_column(String(32), nullable=False)
|
||||
profile_version: Mapped[str] = mapped_column(String(32), nullable=False)
|
||||
profile_snapshot_json: Mapped[dict] = mapped_column(JSON, nullable=False)
|
||||
period_month: Mapped[date] = mapped_column(Date, nullable=False)
|
||||
mode: Mapped[str] = mapped_column(String(24), nullable=False, default="incremental")
|
||||
status: Mapped[str] = mapped_column(String(24), nullable=False, default="running")
|
||||
subject_count: Mapped[int] = mapped_column(BigInteger, nullable=False, default=0)
|
||||
archived_file_count: Mapped[int] = mapped_column(BigInteger, nullable=False, default=0)
|
||||
skipped_file_count: Mapped[int] = mapped_column(BigInteger, nullable=False, default=0)
|
||||
missing_file_count: Mapped[int] = mapped_column(BigInteger, nullable=False, default=0)
|
||||
missing_invoice_count: Mapped[int] = mapped_column(BigInteger, nullable=False, default=0)
|
||||
technical_error_count: Mapped[int] = mapped_column(BigInteger, nullable=False, default=0)
|
||||
staged_file_count: Mapped[int] = mapped_column(BigInteger, nullable=False, default=0)
|
||||
stats_json: Mapped[Optional[dict]] = mapped_column(JSON, nullable=True)
|
||||
started_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
finished_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
|
||||
|
||||
class VoucherCheckSubject(Base):
|
||||
"""批次内一张销售 invoice 主体。"""
|
||||
|
||||
__tablename__ = "voucher_check_subjects"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("run_id", "invoice_no", name="uq_voucher_check_subjects_run_invoice"),
|
||||
Index("ix_voucher_check_subjects_invoice_no", "invoice_no"),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
||||
run_id: Mapped[int] = mapped_column(
|
||||
BigInteger,
|
||||
ForeignKey("voucher_check_runs.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
invoice_no: Mapped[str] = mapped_column(String(128), nullable=False)
|
||||
invoice_date: Mapped[Optional[date]] = mapped_column(Date, nullable=True)
|
||||
source_fingerprint: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
|
||||
attributes_json: Mapped[Optional[dict]] = mapped_column(JSON, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
|
||||
|
||||
class VoucherCheckFileResult(Base):
|
||||
"""invoice × 文件规则 的单文件结果,是缺件统计与 Excel 的真相源。"""
|
||||
|
||||
__tablename__ = "voucher_check_file_results"
|
||||
__table_args__ = (
|
||||
UniqueConstraint(
|
||||
"run_id",
|
||||
"invoice_no",
|
||||
"rule_code",
|
||||
name="uq_voucher_check_file_results_run_invoice_rule",
|
||||
),
|
||||
Index("ix_voucher_check_file_results_status", "run_id", "status"),
|
||||
Index("ix_voucher_check_file_results_invoice", "invoice_no"),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
||||
run_id: Mapped[int] = mapped_column(
|
||||
BigInteger,
|
||||
ForeignKey("voucher_check_runs.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
subject_id: Mapped[Optional[int]] = mapped_column(
|
||||
BigInteger,
|
||||
ForeignKey("voucher_check_subjects.id", ondelete="SET NULL"),
|
||||
nullable=True,
|
||||
)
|
||||
invoice_no: Mapped[str] = mapped_column(String(128), nullable=False)
|
||||
rule_code: Mapped[str] = mapped_column(String(64), nullable=False)
|
||||
rule_name: Mapped[str] = mapped_column(String(128), nullable=False)
|
||||
source_type: Mapped[str] = mapped_column(String(32), nullable=False)
|
||||
expected_name: Mapped[Optional[str]] = mapped_column(String(512), nullable=True)
|
||||
matched_name: Mapped[Optional[str]] = mapped_column(String(512), nullable=True)
|
||||
source_folder_id: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
|
||||
source_item_id: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
|
||||
archive_folder_id: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
|
||||
archive_item_id: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
|
||||
source_path: Mapped[Optional[str]] = mapped_column(String(1024), nullable=True)
|
||||
archive_path: Mapped[Optional[str]] = mapped_column(String(1024), nullable=True)
|
||||
status: Mapped[str] = mapped_column(String(24), nullable=False)
|
||||
missing_reason: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
||||
error_code: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
|
||||
error_message: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
source_fingerprint: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
|
||||
checked_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
|
||||
|
||||
class VoucherCheckNotification(Base):
|
||||
"""一个检核批次对应一条企微汇总通知审计。"""
|
||||
|
||||
__tablename__ = "voucher_check_notifications"
|
||||
__table_args__ = (Index("ix_voucher_check_notifications_status", "send_status"),)
|
||||
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
||||
run_id: Mapped[int] = mapped_column(
|
||||
BigInteger,
|
||||
ForeignKey("voucher_check_runs.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
unique=True,
|
||||
)
|
||||
excel_filename: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
||||
recipient_user_ids_json: Mapped[Optional[list]] = mapped_column(JSON, nullable=True)
|
||||
send_status: Mapped[str] = mapped_column(String(32), nullable=False)
|
||||
skip_reason: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
||||
summary_json: Mapped[Optional[dict]] = mapped_column(JSON, nullable=True)
|
||||
sent_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
Reference in new issue
Block a user