Files
shanxia2.0/backend/app/schemas/pl/quota_planning.py
T

56 lines
2.3 KiB
Python

"""公开请求只允许选择真实来源/证件和人工条件,不接受业务数量/单位/租户覆盖。"""
from decimal import Decimal
from typing import List, Literal, Optional
from pydantic import Field
from app.schemas.pl.quota_cert import InputBody
class SourcePair(InputBody):
source_stop_type: Literal['load', 'delivery']
source_stop_product_id: str = Field(min_length=1, max_length=64)
related_stop_product_ids: List[str] = Field(default_factory=list)
class ManualQuantity(InputBody):
permit_kind: Literal['purchase', 'transport']
source_id: str = Field(min_length=1, max_length=100)
permit_id: str = Field(min_length=1, max_length=64)
source_quantity: Decimal = Field(ge=0, max_digits=18, decimal_places=6, allow_inf_nan=False)
permit_quantity: Decimal = Field(ge=0, max_digits=18, decimal_places=6, allow_inf_nan=False)
note: str = Field(min_length=1, max_length=1000)
class CertCondition(InputBody):
cert_type: Literal['purchase', 'transport']
cert_id: str = Field(min_length=1, max_length=64)
cert_revision: int = Field(ge=1)
source_fingerprint: str = Field(min_length=64, max_length=64)
parties_confirmed: bool
route_confirmed: bool = False
note: str = Field(min_length=1, max_length=1000)
class PlanQuotaConfiguration(InputBody):
# 可回传服务端值;不作为版本选择依据。
measurement_version: Optional[Literal['legacy_single_side', 'per_stop_v2']] = None
source_mapping: Optional[List[SourcePair]] = None
purchase_cert_ids: List[str] = Field(default_factory=list)
transport_cert_ids: List[str] = Field(default_factory=list)
manual_allocations: List[ManualQuantity] = Field(default_factory=list)
conditions: List[CertCondition] = Field(default_factory=list)
class PlanQuotaOperation(InputBody):
operation_id: str = Field(min_length=1, max_length=64)
allow_supplement: bool = False
configuration: Optional[PlanQuotaConfiguration] = None
manual_actuals: List[ManualQuantity] = Field(default_factory=list)
reason: str = Field('', max_length=1000)
evidence_urls: Optional[str] = None
source_note: Optional[str] = Field(None, max_length=1000)
class PlanQuotaPreview(PlanQuotaConfiguration):
target_license_plate: Optional[str] = Field(None, max_length=100)
target_trailer_no: Optional[str] = Field(None, max_length=100)