feat: 5G 指标和 4G、5G 的 MR 改从即席查询取实际数据,评估不再用模拟指标
- 5G 流量、RRC、利用率、扇区取 5G 小区容量周表,接通率和掉线率取 5GSA_CU 的周粒度,MR 取 5GMRO 的周粒度 - 4G 的 MR 采样、覆盖率、竞对和三个是否取 MR 月表:停闭前用拆除日上一个月,停闭后用当月 - 周边站的 MR 弱覆盖填弱于 -110dBm 的比例(100 减平台的占比),和模板阈值一致 - 多粒度的表在请求里带上选中的时间粒度和地理维度 - 判断公式逐项检查停闭后有没有数值,缺了显示「/」;4G 的 MR 月数据没出时汇总行的 MR 一项不判断 - 扇区成员把 5G 小区也算进来
This commit is contained in:
+48
-11
@@ -157,14 +157,24 @@ async def select_rows(
|
||||
field: str,
|
||||
values: list[str],
|
||||
wanted: tuple[str, ...] = (),
|
||||
*,
|
||||
time_dimension: str | None = None,
|
||||
geo_dimension: str | None = None,
|
||||
columns: list[dict] | None = None,
|
||||
) -> list[dict]:
|
||||
"""按 field 的取值清单查 [start, end] 的行,和页面一样把清单逗号拼进 in 条件,每批 IN_BATCH 个。wanted 给出时只取这些列。"""
|
||||
await ensure_session(client)
|
||||
columns = await _columns(client, tablename)
|
||||
"""按 field 的取值清单查 [start, end] 的行,和页面一样把清单逗号拼进 in 条件,每批 IN_BATCH 个。wanted 给出时只取这些列。
|
||||
|
||||
一张表有几种时间粒度或地理维度时,页面上选的那一种要用 time_dimension、geo_dimension 指明
|
||||
(时间:1 天、2 周、3 月;地理:0 小区),平台按它们换到对应的实际表;不指明会查不到数据。
|
||||
连着查几张表时,调用方可以自己先 ensure_session、用 table_columns 取好字段再传进来,省掉重复请求。
|
||||
"""
|
||||
if columns is None:
|
||||
await ensure_session(client)
|
||||
columns = await _columns(client, tablename)
|
||||
if not columns:
|
||||
raise NqiError("这张表没有可查的字段")
|
||||
head = columns[0]
|
||||
chosen = [column for column in columns if column.get("columnname") in wanted] if wanted else columns
|
||||
chosen = _pick(columns, wanted) if wanted else columns
|
||||
names = [value for value in dict.fromkeys(str(item).strip() for item in values) if value and "," not in value]
|
||||
timed = _has_time_column(columns)
|
||||
rows: list[dict] = []
|
||||
@@ -175,11 +185,34 @@ async def select_rows(
|
||||
at,
|
||||
{"datatype": "character", "feild": field, "feildName": "", "symbol": "in", "val": ",".join(names[offset : offset + IN_BATCH]), "whereCon": "and", "query": True},
|
||||
)
|
||||
rows.extend(await _fetch_all(client, head, chosen, where))
|
||||
rows.extend(await _fetch_all(client, head, chosen, where, time_dimension=time_dimension, geo_dimension=geo_dimension))
|
||||
return rows
|
||||
|
||||
|
||||
async def _fetch_all(client: NqiClient, head: dict, columns: list[dict], where: list[dict]) -> list[dict]:
|
||||
async def table_columns(client: NqiClient, tablename: str) -> list[dict]:
|
||||
"""一张表的字段和配置。要先 ensure_session。"""
|
||||
return await _columns(client, tablename)
|
||||
|
||||
|
||||
def _pick(columns: list[dict], wanted: tuple[str, ...]) -> list[dict]:
|
||||
"""多粒度的表里同一个字段会按粒度登记几次,只留第一次,免得查询里出现重复的列。"""
|
||||
chosen: dict[str, dict] = {}
|
||||
for column in columns:
|
||||
name = column.get("columnname")
|
||||
if name in wanted and name not in chosen:
|
||||
chosen[name] = column
|
||||
return list(chosen.values())
|
||||
|
||||
|
||||
async def _fetch_all(
|
||||
client: NqiClient,
|
||||
head: dict,
|
||||
columns: list[dict],
|
||||
where: list[dict],
|
||||
*,
|
||||
time_dimension: str | None = None,
|
||||
geo_dimension: str | None = None,
|
||||
) -> list[dict]:
|
||||
common = {
|
||||
"geographicdimension": head.get("geographicdimension") or "",
|
||||
"timedimension": head.get("timedimension") or "",
|
||||
@@ -188,7 +221,7 @@ async def _fetch_all(client: NqiClient, head: dict, columns: list[dict], where:
|
||||
"timeField": head.get("time_field") or "starttime",
|
||||
"cellField": head.get("cell_field") or "",
|
||||
"cityField": head.get("city_field") or "city",
|
||||
"result": _result_json(head, columns),
|
||||
"result": _result_json(head, columns, time_dimension=time_dimension, geo_dimension=geo_dimension),
|
||||
"where": json.dumps(where, ensure_ascii=False),
|
||||
}
|
||||
total, index_count = await _count(client, common)
|
||||
@@ -234,13 +267,17 @@ async def _count(client: NqiClient, common: dict) -> tuple[int, str]:
|
||||
return int(counted.get("count") or 0), str(counted.get("indexcount") or "0")
|
||||
|
||||
|
||||
def _result_json(head: dict, columns: list[dict]) -> str:
|
||||
"""页面在字段列表后还带 tableParams 和 columnname,缺了服务端返回 {"stat":"0","message":"null"}。"""
|
||||
def _result_json(head: dict, columns: list[dict], *, time_dimension: str | None = None, geo_dimension: str | None = None) -> str:
|
||||
"""页面在字段列表后还带 tableParams 和 columnname,缺了服务端返回 {"stat":"0","message":"null"}。
|
||||
|
||||
tableParams 是页面上选中的地理维度和时间粒度。只有一种粒度的表,配置里这两项是空的,原样带上;
|
||||
有几种的表要由调用方指明选哪一种。
|
||||
"""
|
||||
payload = {
|
||||
"result": [_field(column) for column in columns],
|
||||
"tableParams": {
|
||||
"supporteddimension": head.get("supporteddimension"),
|
||||
"supportedtimedimension": head.get("supportedtimedimension") or "",
|
||||
"supporteddimension": geo_dimension if geo_dimension is not None else head.get("supporteddimension"),
|
||||
"supportedtimedimension": time_dimension if time_dimension is not None else (head.get("supportedtimedimension") or ""),
|
||||
},
|
||||
"columnname": "",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user