feat: 添加线索引擎、NLQ、场景检测、前端界面等核心功能模块

This commit is contained in:
freedakgmail
2026-06-16 08:15:15 +08:00
parent 7b1e2b10a8
commit 48340f6011
62 changed files with 6772 additions and 65 deletions
+1
View File
@@ -16,6 +16,7 @@ from app.config import get_settings
# 导入模型以注册到 Base.metadata
from app.datahub import models # noqa: F401,E402
from app.datahub import staging # noqa: F401,E402
from app.db import Base
config = context.config
@@ -0,0 +1,57 @@
"""源明细落地层:src_contract / src_channel_monthly
Revision ID: 0003_staging
Revises: 0002_clues_audit
Create Date: 2026-06
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
revision: str = "0003_staging"
down_revision: Union[str, None] = "0002_clues_audit"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"src_contract",
sa.Column("id", postgresql.UUID(as_uuid=True), primary_key=True),
sa.Column("contract_no", sa.String(64), nullable=False),
sa.Column("customer_key", sa.String(64), nullable=False),
sa.Column("customer_name", sa.String(256), nullable=True),
sa.Column("amount", sa.Float(), nullable=False),
sa.Column("sign_date", sa.Date(), nullable=True),
sa.Column("approval_threshold", sa.Float(), nullable=True),
sa.Column("approval_level", sa.String(32), nullable=True),
sa.Column("legal_person", sa.String(128), nullable=True),
sa.Column("register_address", sa.String(256), nullable=True),
sa.Column("pay_account", sa.String(64), nullable=True),
sa.Column("data_version_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("ingested_at", sa.DateTime(timezone=True), nullable=False),
)
op.create_index("ix_src_contract_customer", "src_contract", ["customer_key"])
op.create_table(
"src_channel_monthly",
sa.Column("id", postgresql.UUID(as_uuid=True), primary_key=True),
sa.Column("channel_key", sa.String(64), nullable=False),
sa.Column("cohort_label", sa.String(32), nullable=False),
sa.Column("month_index", sa.Integer(), nullable=False),
sa.Column("cohort_size", sa.Integer(), nullable=False, server_default="0"),
sa.Column("retained", sa.Integer(), nullable=False, server_default="0"),
sa.Column("commission_paid", sa.Float(), nullable=False, server_default="0"),
sa.Column("active_ratio", sa.Float(), nullable=False, server_default="0"),
sa.Column("zero_usage_ratio", sa.Float(), nullable=False, server_default="0"),
sa.Column("data_version_id", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("ingested_at", sa.DateTime(timezone=True), nullable=False),
)
op.create_index("ix_src_channel_key", "src_channel_monthly", ["channel_key"])
def downgrade() -> None:
op.drop_table("src_channel_monthly")
op.drop_table("src_contract")