fix: 优化核心包
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from enum import Enum
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
|
||||
@@ -46,6 +46,16 @@ class JobCard(BaseModel):
|
||||
tags: list[str] = Field(default_factory=list, description="业务标签列表")
|
||||
confidence: float = Field(ge=0, le=1, description="数据置信度,范围 0~1")
|
||||
|
||||
@field_validator("start_time", mode="after")
|
||||
@classmethod
|
||||
def normalize_start_time(cls, value: datetime) -> datetime:
|
||||
shanghai_tz = timezone(timedelta(hours=8))
|
||||
if value.tzinfo is None:
|
||||
value = value.replace(tzinfo=shanghai_tz)
|
||||
else:
|
||||
value = value.astimezone(shanghai_tz)
|
||||
return value.replace(second=0, microsecond=0)
|
||||
|
||||
|
||||
class WorkerCard(BaseModel):
|
||||
worker_id: str = Field(description="工人唯一 ID")
|
||||
|
||||
Reference in New Issue
Block a user