feat: 工参按地市和日期入库,先查库再从大数据平台取
即席查询取工参属性,OpenCode 导出当天全市 CGI 和经纬度,按 CGI 合并后存成快照;即席查询失败或 CGI 对不上时改由 OpenCode 一并导出属性。拆除前后的工参日期按库优先、逐月回溯的规则选取,多个任务取同一天时只取一次。即席查询 getTableCount 出错不再被当成 0 行。
This commit is contained in:
+48
-2
@@ -1,8 +1,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timezone
|
||||
from datetime import date, datetime, timezone
|
||||
|
||||
from sqlalchemy import JSON, Boolean, DateTime, Integer, String, Text, UniqueConstraint
|
||||
from sqlalchemy import JSON, BigInteger, Boolean, Date, DateTime, Float, ForeignKey, Index, Integer, String, Text, UniqueConstraint
|
||||
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
||||
|
||||
|
||||
@@ -82,6 +82,52 @@ class CollectionSource(Base):
|
||||
last_error: Mapped[str] = mapped_column(Text, default="")
|
||||
|
||||
|
||||
class GongcanSnapshot(Base):
|
||||
"""某地市某一天的全量 4G/5G 小区工参。status 兼作取数锁:loading 时别的任务等它。"""
|
||||
|
||||
__tablename__ = "gongcan_snapshot"
|
||||
__table_args__ = (UniqueConstraint("city", "snapshot_date", name="uq_gongcan_city_date"),)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
||||
city: Mapped[str] = mapped_column(String(32))
|
||||
snapshot_date: Mapped[date] = mapped_column(Date)
|
||||
status: Mapped[str] = mapped_column(String(16), default="loading")
|
||||
attr_source: Mapped[str] = mapped_column(String(16), default="")
|
||||
lte_cells: Mapped[int] = mapped_column(Integer, default=0)
|
||||
nr_cells: Mapped[int] = mapped_column(Integer, default=0)
|
||||
located_cells: Mapped[int] = mapped_column(Integer, default=0)
|
||||
error: Mapped[str] = mapped_column(Text, default="")
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utcnow)
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utcnow)
|
||||
|
||||
|
||||
class GongcanCell(Base):
|
||||
__tablename__ = "gongcan_cell"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("snapshot_id", "cgi", "tech", name="uq_gongcan_cell"),
|
||||
Index("ix_gongcan_cell_site", "snapshot_id", "site_name"),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True)
|
||||
snapshot_id: Mapped[int] = mapped_column(ForeignKey("gongcan_snapshot.id", ondelete="CASCADE"))
|
||||
tech: Mapped[str] = mapped_column(String(4))
|
||||
cgi: Mapped[str] = mapped_column(String(64))
|
||||
cell_name: Mapped[str] = mapped_column(Text, default="")
|
||||
site_name: Mapped[str] = mapped_column(Text, default="")
|
||||
latitude: Mapped[float | None] = mapped_column(Float, nullable=True)
|
||||
longitude: Mapped[float | None] = mapped_column(Float, nullable=True)
|
||||
network_type: Mapped[str] = mapped_column(Text, default="")
|
||||
node_id: Mapped[str] = mapped_column(Text, default="")
|
||||
node_name: Mapped[str] = mapped_column(Text, default="")
|
||||
area: Mapped[str] = mapped_column(Text, default="")
|
||||
town: Mapped[str] = mapped_column(Text, default="")
|
||||
state: Mapped[str] = mapped_column(Text, default="")
|
||||
cover_type: Mapped[str] = mapped_column(Text, default="")
|
||||
frequency_band: Mapped[str] = mapped_column(Text, default="")
|
||||
vendor: Mapped[str] = mapped_column(Text, default="")
|
||||
azimuth: Mapped[str] = mapped_column(Text, default="")
|
||||
|
||||
|
||||
class ExportTask(Base):
|
||||
__tablename__ = "export_task"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user