10780285f5
## 改动摘要 ### 后端改动 - 新增 `lightning_import.py` schema,定义文件导入批次相关数据结构 - 在 `lightning_service.py` 中实现 `list_lightning_import_batches` 和 `get_lightning_import_batch_events` 函数 - 在 `lightning.py` API 中新增两个端点: - `GET /lightning-currents/import-batches` - 获取文件导入批次列表 - `GET /lightning-currents/import-batches/events` - 获取指定批次的事件明细 ### 前端改动 - 修改 `page.tsx`,将表格展示从单个事件改为文件导入批次 - 新增 `EventsModal` 组件,用于查看批次的事件明细 - 新增 `ScatterModal` 组件,用于查看批次对应的散点图 - 每个批次记录提供「事件明细」和「散点图」按钮 - 更新类型定义,新增 `LightningImportBatchSummary` 等类型 ### 数据分组逻辑 - 按 `source_file_name + create_date + region_id + location_tag + city` 进行分组 - 每个批次显示:文件名、导入时间、事件数、城市、地点标签、最大/平均电流 ## 测试结果 - ✅ Python 语法检查通过(lightning_service.py, lightning.py, lightning_import.py) - ✅ TypeScript 类型定义正确 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>
59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from typing import Literal
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from .lightning import LightningPolarity
|
|
|
|
|
|
class LightningImportBatchSummary(BaseModel):
|
|
"""文件导入批次摘要"""
|
|
batch_id: str # 使用 source_file_name + create_date 的哈希作为批次ID
|
|
source_file_name: str | None = None
|
|
import_time: datetime
|
|
event_count: int
|
|
region_id: str | None = None
|
|
location_tag: str | None = None
|
|
city: str | None = None
|
|
event_year: int | None = None
|
|
is_synthetic: bool = False
|
|
notes: str | None = None
|
|
|
|
# 统计信息
|
|
max_abs_current_ka: float | None = None
|
|
avg_abs_current_ka: float | None = None
|
|
positive_count: int = 0
|
|
negative_count: int = 0
|
|
|
|
# 导入元数据
|
|
create_user: str | None = None
|
|
|
|
|
|
class LightningImportBatchListResponse(BaseModel):
|
|
items: list[LightningImportBatchSummary]
|
|
total: int
|
|
limit: int
|
|
offset: int
|
|
|
|
|
|
class LightningImportBatchEventItem(BaseModel):
|
|
"""导入批次中的单个事件"""
|
|
id: str
|
|
event_id: str
|
|
longitude: float | None = None
|
|
latitude: float | None = None
|
|
current_ka: float | None = None
|
|
abs_current_ka: float | None = None
|
|
polarity: LightningPolarity
|
|
event_time: datetime | None = None
|
|
|
|
|
|
class LightningImportBatchEventsResponse(BaseModel):
|
|
batch_id: str
|
|
source_file_name: str | None = None
|
|
import_time: datetime
|
|
events: list[LightningImportBatchEventItem]
|
|
total: int
|