44e77dcb0e
**重构前**(旧编号 02-11): - docs/02-产品需求/ → 00 产品规划/PRD - docs/03-技术架构/ → 01-05 子目录散落 - docs/04-原型设计/ → 01-02 产品设计(HTML 原型) - docs/05-原型设计/ → screens/ - docs/06-测试素材/ → 02-E2E / 03-功能 / 04-版本测试 - docs/07-项目管理/ → 任务说明书/日报/计划 - docs/08-安全审计/ → 审计报告 - docs/09-堡垒运维/ → toolbox / deploy - docs/10-项目管理/ → 任务说明书(重复) - docs/11-历史归档/ → deploy-nas-archived **重构后**(新编号 00-07,语义化): - docs/00-产品开发流程与文档管理规范.md - docs/00-版本迭代总览.md - docs/01-产品文档/ (PRD/原型/认证/会话/AI 服务/坐席/集成) - docs/02-技术文档/ (技术方案/架构图/重构记录/前端改造/实现配置) - docs/03-测试文档/ (E2E/功能用例/版本报告/缺陷单) - docs/04-运维文档/ (部署运维/运维指南) - docs/05-运营文档/ (品牌推广/用户手册) - docs/06-安全审计/ (审计报告) - docs/07-项目管理/ (任务说明书/日报/计划/看板) **净收益**: - 目录编号与产品文档管理规范对齐(按文档阶段 01-07 编号) - 消除 02-产品需求 与 10-项目管理 的编号重叠 - 子目录按文档类型分组(如 01-产品文档/00-产品规划、01-产品文档/01-认证与登录) - 把运维/安全/项目管理从 0X 散落改为 04/06/07 合计 494 文件 + 78495 行 / - 14076 行
272 lines
8.8 KiB
Plaintext
272 lines
8.8 KiB
Plaintext
# 复杂场景重构第一阶段 — 类图
|
|
|
|
> **关联文档**: `复杂场景重构第一阶段-架构设计.md` §3
|
|
|
|
---
|
|
|
|
```mermaid
|
|
classDiagram
|
|
direction TB
|
|
|
|
%% ==================== 数据模型层 ====================
|
|
namespace Models {
|
|
class AutoSession {
|
|
+String id
|
|
+String conversation_id
|
|
+String employee_id
|
|
+String agent_id
|
|
+String scenario_key
|
|
+String status
|
|
+String mode
|
|
+Float confidence
|
|
+JSON intent
|
|
+String current_action_id
|
|
+String title
|
|
+DateTime auto_close_at
|
|
+DateTime paused_at
|
|
+DateTime resolved_at
|
|
+String closed_by
|
|
+JSON meta
|
|
+DateTime created_at
|
|
+DateTime updated_at
|
|
}
|
|
|
|
class AutoAction {
|
|
+String id
|
|
+String session_id
|
|
+Integer action_index
|
|
+String action_type
|
|
+String adapter
|
|
+String risk_level
|
|
+String title
|
|
+String description
|
|
+String status
|
|
+JSON payload
|
|
+JSON result
|
|
+String error
|
|
+String approved_by
|
|
+DateTime approved_at
|
|
}
|
|
|
|
class InformationItem {
|
|
+String id
|
|
+String session_id
|
|
+String name
|
|
+String value
|
|
+JSON modifiers
|
|
+Boolean is_filled
|
|
+Boolean is_locked
|
|
+Integer version
|
|
+JSON update_history
|
|
+DateTime created_at
|
|
+DateTime updated_at
|
|
}
|
|
|
|
class ApprovalTicket {
|
|
+String id
|
|
+String action_id
|
|
+String session_id
|
|
+String approver_id
|
|
+String channel
|
|
+String status
|
|
+String reason
|
|
+String decision_note
|
|
+DateTime decided_at
|
|
}
|
|
|
|
class ScenarioConfig {
|
|
+String id
|
|
+String scenario_key
|
|
+String name
|
|
+String description
|
|
+Boolean enabled
|
|
+JSON trigger_conditions
|
|
+JSON actions
|
|
+JSON approval_strategy
|
|
+String current_version_id
|
|
}
|
|
}
|
|
|
|
%% ==================== 服务层 ====================
|
|
namespace Services {
|
|
class IntentRouter {
|
|
-db: AsyncSession
|
|
-audit: Any
|
|
+detect(description: str, employee_id: str) Dict
|
|
+detect_global_intent(text: str) Dict
|
|
-_keyword_fallback_global(text: str) Dict
|
|
}
|
|
|
|
class DifyClient {
|
|
-base_url: str
|
|
-api_key: str
|
|
-timeout: float
|
|
+detect_intent(description: str, employee_id: str) Dict
|
|
-_parse_intent(answer: str) Dict
|
|
-_parse_global_intent(answer: str) Dict
|
|
-_fallback_intent(description: str) Dict
|
|
-_fallback_global_intent(text: str) Dict
|
|
+test_connection() Dict
|
|
}
|
|
|
|
class AutoSessionService {
|
|
-db: AsyncSession
|
|
-redis: Any
|
|
-audit: Any
|
|
+create_session(...) AutoSession
|
|
+get_session(session_id) AutoSession
|
|
+list_sessions(...) List
|
|
+start(session_id) void
|
|
+pause_session(session_id, reason) AutoSession
|
|
+resume_session(employee_id, session_id) dict
|
|
+list_paused_sessions(employee_id) List
|
|
+correct_info(session_id, field, new_value) InformationItem
|
|
+supplement_info(session_id, field, value) InformationItem
|
|
+agent_resume(session_id, agent_id) AutoSession
|
|
+agent_close(session_id, agent_id) AutoSession
|
|
+takeover(session_id, agent_id) AutoSession
|
|
+resolve_feedback(session_id, satisfied) AutoSession
|
|
-_build_resume_point(session) dict
|
|
-_save_resume_point(session, snapshot) void
|
|
-_load_resume_point(session_id) dict
|
|
}
|
|
|
|
class InformationItemService {
|
|
-db: AsyncSession
|
|
-redis: Any
|
|
+create_item(session_id, name, value, modifiers) InformationItem
|
|
+get_items(session_id) List~InformationItem~
|
|
+get_item(session_id, name) InformationItem
|
|
+correct_value(session_id, name, new_value) InformationItem
|
|
+supplement_value(session_id, name, value) InformationItem
|
|
+lock_items_for_action(session_id, action_id) void
|
|
+check_downstream_impact(session_id, field) bool
|
|
+get_pending_required_items(session_id) List~str~
|
|
}
|
|
|
|
class ActionExecutor {
|
|
-db: AsyncSession
|
|
-redis: Any
|
|
-audit: Any
|
|
-approval: ApprovalService
|
|
-rollback: RollbackService
|
|
+run(session_id) void
|
|
+resume(session_id, action_id, decision) void
|
|
-_do_execute(session, action, mapping, clients) void
|
|
-_on_action_failed(session, action, exc) void
|
|
-_finish_success(session) void
|
|
}
|
|
|
|
class TimeoutCleaner {
|
|
-db_factory: async_sessionmaker
|
|
-redis: Any
|
|
+run_once() int
|
|
+run_scheduled(interval: int) void
|
|
-_scan_and_close() int
|
|
-_notify_timeout(session_id) void
|
|
}
|
|
|
|
class ProgressPublisher {
|
|
+publish_progress(session_id, step, message) void
|
|
+publish_action_required(session_id, action, ticket) void
|
|
+publish_resolved(session_id, summary) void
|
|
+publish_takeover(session_id, reason) void
|
|
+publish_error(session_id, code, message) void
|
|
+publish_paused(session_id, title, paused_at, hint) void
|
|
+publish_resumed(session_id, title, resumed_at, step) void
|
|
+publish_timeout_closed(session_id, closed_at, reason) void
|
|
+publish_info_corrected(session_id, field, old, new, ver) void
|
|
+publish_info_supplemented(session_id, field, supp, new) void
|
|
-_publish(event_type, session_id, data) void
|
|
}
|
|
}
|
|
|
|
%% ==================== Schema 层 ====================
|
|
namespace Schemas {
|
|
class GlobalIntentResult {
|
|
+Optional~str~ global_intent
|
|
+Optional~str~ scenario_key
|
|
+float confidence
|
|
+Optional~str~ corrected_field
|
|
+Optional~str~ old_value
|
|
+Optional~str~ new_value
|
|
+Optional~str~ supplement_field
|
|
+Optional~str~ supplement_value
|
|
+str raw
|
|
+str error
|
|
}
|
|
|
|
class PauseRequest {
|
|
+Optional~str~ reason
|
|
}
|
|
|
|
class ResumeRequest {
|
|
+Optional~str~ session_id
|
|
}
|
|
|
|
class CorrectRequest {
|
|
+str field
|
|
+str new_value
|
|
+Optional~str~ old_value
|
|
}
|
|
|
|
class SupplementRequest {
|
|
+str field
|
|
+str value
|
|
}
|
|
|
|
class InformationItemResponse {
|
|
+str id
|
|
+str session_id
|
|
+str name
|
|
+str value
|
|
+List~str~ modifiers
|
|
+bool is_filled
|
|
+bool is_locked
|
|
+int version
|
|
+List~dict~ update_history
|
|
+Optional~str~ updated_at
|
|
}
|
|
|
|
class ResumePointResponse {
|
|
+str session_id
|
|
+str title
|
|
+Optional~str~ scenario_key
|
|
+str current_step
|
|
+Optional~str~ paused_at
|
|
+List~str~ pending_items
|
|
+List~InformationItemResponse~ info_items
|
|
}
|
|
|
|
class PausedSessionItem {
|
|
+str session_id
|
|
+str title
|
|
+Optional~str~ scenario_key
|
|
+Optional~str~ paused_at
|
|
+str paused_duration
|
|
}
|
|
}
|
|
|
|
%% ==================== 关系 ====================
|
|
AutoSession "1" --> "*" InformationItem : session_id 关联
|
|
AutoSession "1" --> "*" AutoAction : session_id 关联
|
|
AutoSession "1" --> "*" ApprovalTicket : session_id 关联
|
|
ScenarioConfig --> AutoSession : scenario_key 匹配
|
|
|
|
AutoSessionService --> AutoSession : 管理生命周期
|
|
AutoSessionService --> InformationItemService : 委托信息项操作
|
|
AutoSessionService --> IntentRouter : 使用意图识别
|
|
AutoSessionService --> ActionExecutor : 调用续行执行
|
|
AutoSessionService --> ProgressPublisher : 推送事件
|
|
|
|
IntentRouter --> DifyClient : 调用 Dify 识别
|
|
InformationItemService --> InformationItem : CRUD
|
|
TimeoutCleaner --> AutoSessionService : 调用 auto_close
|
|
TimeoutCleaner --> ProgressPublisher : 推送超时事件
|
|
ProgressPublisher --> AutoSession : 推送状态变更
|
|
|
|
InformationItemResponse ..> InformationItem : 序列化
|
|
ResumePointResponse ..> InformationItemResponse : 包含
|
|
GlobalIntentResult ..> IntentRouter : 返回类型
|
|
```
|