From 26e91597abdcb2f4c4d2c5b2b29c3b86a1332528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B8=85?= Date: Wed, 2 Sep 2026 18:27:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(ocr-dashboard):=20=E9=80=8F=E4=BC=A0?= =?UTF-8?q?=E6=8C=89=E4=B8=BB=E4=BD=93=E5=90=8D=E8=B7=A8=E6=89=B9=E6=AC=A1?= =?UTF-8?q?=E9=87=87=E9=9B=86=E8=AE=B0=E5=BD=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ocr_dashboard_service.py 新增 list_collections_by_subject() 函数 - get_series() 增加 subject_name 参数 - app.py 新增路由 /api/v1/data-dashboard/ocr/batches/subject//collections - 透传代理至 xiaoti-framework crawler 服务 --- app.py | 10 ++++++++++ ocr_dashboard_service.py | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index e079179..3702bdc 100644 --- a/app.py +++ b/app.py @@ -23,6 +23,7 @@ from ocr_dashboard_service import ( get_summary as get_ocr_dashboard_summary, list_batches as list_ocr_batches, list_collections as list_ocr_collections, + list_collections_by_subject as list_ocr_collections_by_subject, list_evidences as list_ocr_evidences, list_configured_notes as list_ocr_configured_notes, export_evidences as export_ocr_evidences, @@ -393,6 +394,14 @@ def create_app() -> Flask: def query_ocr_dashboard_collections(batch_key: str): return jsonify({"data": list_ocr_collections(batch_key), "request_id": g.request_id}) + @app.route("/api/v1/data-dashboard/ocr/batches/subject//collections", methods=["GET"]) + def query_ocr_collections_by_subject(subject_name: str): + return jsonify({"data": list_ocr_collections_by_subject( + subject_name, + request.args.get("start_date", "").strip(), + request.args.get("end_date", "").strip(), + ), "request_id": g.request_id}) + @app.route("/api/v1/data-dashboard/ocr/summary", methods=["GET"]) def query_ocr_dashboard_summary(): return jsonify({"data": get_ocr_dashboard_summary( @@ -406,6 +415,7 @@ def create_app() -> Flask: def query_ocr_dashboard_series(): return jsonify({"data": get_ocr_dashboard_series( request.args.get("batch_key", "").strip(), + request.args.get("subject_name", "").strip(), request.args.get("start_date", "").strip(), request.args.get("end_date", "").strip(), ), "request_id": g.request_id}) diff --git a/ocr_dashboard_service.py b/ocr_dashboard_service.py index 6347acb..cf18c83 100644 --- a/ocr_dashboard_service.py +++ b/ocr_dashboard_service.py @@ -49,6 +49,16 @@ def list_collections(batch_key: str) -> list[dict[str, Any]]: return _get(f"/xhs/ocr/batches/{batch_key.strip()}/collections") or [] +def list_collections_by_subject(subject_name: str, start_date: str = "", end_date: str = "") -> list[dict[str, Any]]: + """按主体名查询该主体下所有批次的采集任务。用于同名主体多批次合并展示。""" + if not subject_name.strip(): + raise TaskError("OCR_SUBJECT_REQUIRED", "subject_name 不能为空", 422) + return _get( + f"/xhs/ocr/batches/subject/{subject_name.strip()}/collections", + {"start_date": start_date, "end_date": end_date}, + ) or [] + + def get_summary(batch_key: str = "", collection_key: str = "", start_date: str = "", end_date: str = "") -> dict[str, Any]: data = _get("/xhs/ocr/dashboard/summary", { @@ -125,9 +135,9 @@ def _overlay_acceptance_questions(data: dict[str, Any], batch_key: str) -> dict[ return data -def get_series(batch_key: str = "", start_date: str = "", end_date: str = "") -> dict[str, Any]: +def get_series(batch_key: str = "", subject_name: str = "", start_date: str = "", end_date: str = "") -> dict[str, Any]: return _get("/xhs/ocr/dashboard/series", { - "batch_key": batch_key, "start_date": start_date, "end_date": end_date, + "batch_key": batch_key, "subject_name": subject_name, "start_date": start_date, "end_date": end_date, }) or {"items": [], "subjects": []}