"""评查详情聚合 VO。"""

from __future__ import annotations

from typing import Any

from pydantic import BaseModel, Field


class ReviewPointResultVO(BaseModel):
    """前端评查详情页所需的单条评查点结果。"""

    id: str | int = Field(..., description="评查结果ID")
    documentId: str = Field(..., description="文档ID")
    pointId: str | int = Field(..., description="评查点/规则ID")
    editAuditStatusId: str | int = Field("", description="人工审核状态ID")
    editAuditStatus: int = Field(0, description="人工审核状态")
    editAuditStatusMessage: str = Field("", description="人工审核意见")
    title: str = Field("", description="标题")
    pointName: str = Field("", description="评查点名称")
    pointCode: str = Field("", description="评查点编码")
    groupName: str = Field("", description="所属分组名")
    status: str = Field("success", description="success/warning/error/notApplicable")
    content: dict[str, Any] = Field(default_factory=dict, description="抽取字段内容")
    contentPage: dict[str, str] = Field(default_factory=dict, description="字段页码映射")
    suggestion: str = Field("", description="建议内容")
    postAction: str = Field("", description="后续动作")
    actionContent: Any = Field(default_factory=dict, description="动作配置")
    legalBasis: Any = Field(default_factory=dict, description="法律依据")
    evaluationConfig: Any = Field(default_factory=dict, description="评查配置")
    score: float = Field(0, description="分值")
    finalScore: float | None = Field(None, description="最终得分")
    machineScore: float | None = Field(None, description="机器得分")
    result: bool | None = Field(None, description="是否通过")
    failMessage: str = Field("", description="失败提示")
    passMessage: str = Field("", description="通过提示")
    evaluatedPointResultsLog: dict[str, Any] = Field(default_factory=dict, description="规则执行日志")


class ReviewPointStatsVO(BaseModel):
    """统计信息。"""

    total: int = Field(0, description="总数")
    success: int = Field(0, description="通过数")
    warning: int = Field(0, description="警告数")
    error: int = Field(0, description="错误数")
    score: float = Field(0, description="总分")


class ReviewPointInfoVO(BaseModel):
    """评查摘要信息。"""

    reviewTime: str = Field("", description="评查时间")
    reviewModel: str = Field("DeepSeek", description="评查模型")
    ruleGroup: str = Field("", description="规则组")
    result: str = Field("success", description="总体结果")
    issueCount: int = Field(0, description="问题数")


class ReviewPointsAggregateVO(BaseModel):
    """评查详情聚合响应。"""

    data: list[ReviewPointResultVO] = Field(default_factory=list, description="评查点结果")
    stats: ReviewPointStatsVO = Field(default_factory=ReviewPointStatsVO, description="统计信息")
    reviewInfo: ReviewPointInfoVO = Field(default_factory=ReviewPointInfoVO, description="评查摘要")
    document: dict[str, Any] | None = Field(default=None, description="文档信息")
    comparison_document: dict[str, Any] | None = Field(default=None, description="比对文档信息")
    scoring_proposals: list[dict[str, Any]] = Field(default_factory=list, description="评分提案")


class ReviewPointAuditVO(BaseModel):
    """评查点人工审核更新结果。"""

    reviewPointResultId: int = Field(..., description="规则结果ID")
    editAuditStatusId: int = Field(..., description="审核记录ID")
    editAuditStatus: int = Field(..., description="审核状态")
    overrideResult: bool | None = Field(default=None, description="人工覆盖结果")
    message: str = Field("", description="审核意见")


class DocumentConfirmVO(BaseModel):
    """文档确认评查结果。"""

    documentId: int = Field(..., description="文档ID")
    auditStatus: int = Field(..., description="文档审核状态")
