diff --git a/apps/platform_ui/services.py b/apps/platform_ui/services.py index b9a0247..5b92352 100644 --- a/apps/platform_ui/services.py +++ b/apps/platform_ui/services.py @@ -109,6 +109,88 @@ def get_platform_demo_context(): {"label": "业务资料切片", "value": "342"}, {"label": "最近人工校订", "value": "2 次"}, ] + governance_sections = [ + {"title": "法规规则包", "desc": "维护章节规则、要求项与模板字段映射。"}, + {"title": "RAG 文档源", "desc": "统一管理法规资料、业务资料和模板来源。"}, + {"title": "RAG 切片", "desc": "查看切片摘要、召回状态和证据命中历史。"}, + {"title": "字段 Schema", "desc": "维护强一致字段、回填字段和来源优先级。"}, + {"title": "责任人映射", "desc": "按章节和风险类型维护飞书责任人实体。"}, + {"title": "飞书通知配置", "desc": "固定支持 task_completed / task_failed 两类通知。"}, + ] + rag_chunks = [ + { + "chunk_id": "chunk-001", + "document_name": "资料要求说明", + "chapter": "CH1", + "summary": "CH1.11.5 沟通记录需保留可追溯留痕。", + "status": "已启用", + }, + { + "chunk_id": "chunk-002", + "document_name": "批准证明文件格式要求", + "chapter": "CH1", + "summary": "注册证输出模板需满足固定版式字段映射。", + "status": "待重建", + }, + ] + field_schemas = [ + { + "field_code": "product_name", + "field_name": "产品名称", + "field_type": "string", + "fillable": "是", + "strict_consistency": "是", + "status": "启用", + }, + { + "field_code": "storage_condition", + "field_name": "储存条件", + "field_type": "string", + "fillable": "是", + "strict_consistency": "否", + "status": "待校订", + }, + ] + owner_mappings = [ + { + "owner_role": "注册资料负责人", + "owner_name": "张三", + "department": "注册事务部", + "chapter_scope": "CH1", + "risk_scope": "字段冲突 / 缺失项", + "feishu_user_id": "ou_demo_1", + "feishu_open_id": "on_demo_1", + "feishu_name": "张三", + "notify_enabled": "是", + }, + { + "owner_role": "注册申报负责人", + "owner_name": "李四", + "department": "临床注册组", + "chapter_scope": "CH2-CH6", + "risk_scope": "完整性风险 / 导出阻断", + "feishu_user_id": "ou_demo_2", + "feishu_open_id": "on_demo_2", + "feishu_name": "李四", + "notify_enabled": "是", + }, + ] + feishu_configs = [ + { + "config_name": "注册审核完成通知", + "notify_reason": "task_completed", + "channel": "群机器人", + "message_template": "审核完成摘要 + @处理人", + "status": "启用", + }, + { + "config_name": "注册审核异常通知", + "notify_reason": "task_failed", + "channel": "群机器人", + "message_template": "异常摘要 + @处理人", + "status": "启用", + }, + ] mcp_connectors = [ {"name": "飞书任务通知", "kind": "协同办公", "auth": "App Token", "status": "已连接", "sync": "5 分钟前"}, {"name": "法规规则源导入", "kind": "法规服务", "auth": "文件轮询", "status": "待验证", "sync": "今天 08:50"}, @@ -333,6 +415,11 @@ def get_platform_demo_context(): "knowledge_sources": knowledge_sources, "rule_tree": rule_tree, "knowledge_stats": knowledge_stats, + "governance_sections": governance_sections, + "rag_chunks": rag_chunks, + "field_schemas": field_schemas, + "owner_mappings": owner_mappings, + "feishu_configs": feishu_configs, "knowledge_filters": knowledge_filters, "knowledge_form": knowledge_form, "rule_form": rule_form, diff --git a/templates/platform_ui/knowledge_base.html b/templates/platform_ui/knowledge_base.html index 27ebb51..2c9d0c7 100644 --- a/templates/platform_ui/knowledge_base.html +++ b/templates/platform_ui/knowledge_base.html @@ -1,12 +1,12 @@ {% extends "base.html" %} -{% block title %}知识库配置{% endblock %} +{% block title %}知识库{% endblock %} {% block content %}
@@ -18,49 +18,54 @@ {% endfor %}
+
+ {% for section in governance_sections %} +
+

{{ section.title }}

+

{{ section.desc }}

+
+ {% endfor %} +
+
-

操作栏

-

把知识库做成传统后台,而不是只读展示页。

-
-
- 新增知识源 - 新增规则项 - 批量删除 +

法规规则包

+

按章-条-要求项-模板字段维护规则包,并向审核节点输出结构化依据。

-
-
- - -
-
- - -
-
- - -
+ +
-
+
-

知识源管理

-

传统 CRUD 列表,直接在表格里做查看、编辑、删除。

+

RAG 文档源

+

支持法规、模板与业务资料分层管理。

@@ -72,32 +77,16 @@ 类型 范围 状态 - 负责人 - 更新时间 - 操作 {% for source in knowledge_sources %} - {{ source.code }} -
{{ source.name }}
- {{ source.type }} - {{ source.scope }} - - - {{ source.status }} - - - {{ source.owner }} - {{ source.updated_at }} - -
- 查看 - 编辑 - 删除 -
- + {{ source.code }} + {{ source.name }} + {{ source.type }} + {{ source.scope }} + {{ source.status }} {% endfor %} @@ -105,73 +94,69 @@
-
-
-

{{ knowledge_form.title }}

-
- {% for field in knowledge_form.fields %} -
- - -
- {% endfor %} - -
-
- -
-

批量操作

-
    -
  • 支持批量启用 / 停用知识源
  • -
  • 支持批量重建切片
  • -
  • 支持批量删除过期规则
  • -
-
-
-
- -
-

规则项管理

-

规则项也用传统表格管理,支持新增、编辑、删除。

+

RAG 切片

+

展示切片摘要、章节与召回状态。

- + + - - + - - {% for item in rule_tree %} + {% for chunk in rag_chunks %} - - - - - - + + + + + + + {% endfor %} + +
编码切片 ID文档 章节规则名称模板字段摘要 状态操作
{{ item.code }}{{ item.chapter }}
{{ item.item }}
{{ item.field }}
- - {{ item.status }} - - -
- 查看 - 编辑 - 删除 -
-
{{ chunk.chunk_id }}{{ chunk.document_name }}{{ chunk.chapter }}{{ chunk.summary }}{{ chunk.status }}
+
+
+
+ +
+
+
+
+

字段 Schema

+

维护强一致字段、回填字段和来源优先级。

+
+
+
+ + + + + + + + + + + + + {% for field in field_schemas %} + + + + + + + {% endfor %} @@ -180,19 +165,77 @@
-

{{ rule_form.title }}

-
- {% for field in rule_form.fields %} -
- - -
- {% endfor %} -
- 保存规则项 - 删除规则项 +
+
+

责任人映射

+

责任人实体字段直接按通知载荷口径展示。

+
+
字段编码字段名称类型可回填强一致状态
{{ field.field_code }}{{ field.field_name }}{{ field.field_type }}{{ field.fillable }}{{ field.strict_consistency }}{{ field.status }}
+ + + + + + + + + + + + + + + {% for item in owner_mappings %} + + + + + + + + + + + + {% endfor %} + +
owner_roleowner_namedepartmentchapter_scoperisk_scopefeishu_user_idfeishu_open_idfeishu_namenotify_enabled
{{ item.owner_role }}{{ item.owner_name }}{{ item.department }}{{ item.chapter_scope }}{{ item.risk_scope }}{{ item.feishu_user_id }}{{ item.feishu_open_id }}{{ item.feishu_name }}{{ item.notify_enabled }}
+
+ +
+
+
+

飞书通知配置

+

V1 Demo 固定支持 `task_completed` 与 `task_failed` 两类通知。

+
+
+
+ + + + + + + + + + + + {% for item in feishu_configs %} + + + + + + + + {% endfor %} + +
配置名称notify_reason渠道消息模板状态
{{ item.config_name }}{{ item.notify_reason }}{{ item.channel }}{{ item.message_template }}{{ item.status }}
+
+
{% endblock %} diff --git a/tests/test_platform_ui.py b/tests/test_platform_ui.py new file mode 100644 index 0000000..934df90 --- /dev/null +++ b/tests/test_platform_ui.py @@ -0,0 +1,32 @@ +from django.urls import reverse + + +def test_knowledge_base_page_shows_governance_sections(client): + response = client.get(reverse("platform_ui:knowledge-base")) + + content = response.content.decode("utf-8") + assert response.status_code == 200 + assert "法规规则包" in content + assert "RAG 文档源" in content + assert "RAG 切片" in content + assert "字段 Schema" in content + assert "责任人映射" in content + assert "飞书通知配置" in content + + +def test_knowledge_base_page_shows_owner_mapping_fields_and_notify_reasons(client): + response = client.get(reverse("platform_ui:knowledge-base")) + + content = response.content.decode("utf-8") + assert response.status_code == 200 + assert "owner_role" in content + assert "owner_name" in content + assert "department" in content + assert "chapter_scope" in content + assert "risk_scope" in content + assert "feishu_user_id" in content + assert "feishu_open_id" in content + assert "feishu_name" in content + assert "notify_enabled" in content + assert "task_completed" in content + assert "task_failed" in content diff --git a/tests/test_scenarios.py b/tests/test_scenarios.py index 1438fb9..130ee18 100644 --- a/tests/test_scenarios.py +++ b/tests/test_scenarios.py @@ -127,3 +127,14 @@ audit: assert "有效场景" in content assert "配置异常" in content assert "invalid.yaml" in content + + +def test_home_page_uses_four_top_level_product_entries(client): + response = client.get("/") + + content = response.content.decode("utf-8") + assert response.status_code == 200 + assert "审核智能体" in content + assert "资料包" in content + assert "知识库" in content + assert "处理历史" in content