feat: 采集按分组选表和固定时刻运行,号池可检查凭证,管理页不再退出

This commit is contained in:
2026-11-09 17:55:31 +08:00
parent 152cf92df9
commit 78ad5cea6b
19 changed files with 554 additions and 247 deletions
+32 -5
View File
@@ -85,19 +85,46 @@ async def categories(client: NqiClient) -> list[dict]:
return result
async def tables(client: NqiClient, code: int) -> list[dict]:
async def catalog_tree(client: NqiClient) -> list[dict]:
await ensure_session(client)
payload = await _post_json(client, f"{PAGE}/searchSecondMenu", {"code": code})
payload = await _post_json(client, f"{ADHOC}/index/searchTableType", {})
rows = payload.get("CFG_ADHOC_CODE") if isinstance(payload, dict) else None
if not isinstance(rows, list):
raise NqiError("没有取到查询分类")
groups = []
for row in rows:
if not isinstance(row, dict) or row.get("code") is None:
continue
name = str(row.get("name_cn") or "").strip()
if not name:
continue
code = int(row["code"])
menu = await _post_json(client, f"{PAGE}/searchSecondMenu", {"code": code})
groups.append({"code": code, "name": name, "tables": _table_rows(menu)})
groups.sort(key=lambda item: item["code"])
return groups
def _table_rows(payload: object) -> list[dict]:
if not isinstance(payload, list):
raise NqiError("没有取到这个分类下的表")
return []
result = []
for row in payload:
if not isinstance(row, dict):
continue
tablename = str(row.get("tablename") or "").strip()
name = str(row.get("tablename_cn") or tablename).strip()
title = str(row.get("tablename_cn") or tablename).strip()
if tablename:
result.append({"tablename": tablename, "name": name})
result.append({"tablename": tablename, "name": title})
return result
async def tables(client: NqiClient, code: int) -> list[dict]:
await ensure_session(client)
payload = await _post_json(client, f"{PAGE}/searchSecondMenu", {"code": code})
result = _table_rows(payload)
if not isinstance(payload, list):
raise NqiError("没有取到这个分类下的表")
return result