v3.1 + 批次0: 智能回复重构基线 - ApprovalMatcher + 关键词降级 + 文档速修 + v4.0任务书面化
This commit is contained in:
@@ -1,99 +1,81 @@
|
||||
# 代办事项时序图
|
||||
|
||||
## 1. 代办列表查询流程
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant FE as 前端 TodoPanel
|
||||
participant API as GET /api/todo-items
|
||||
participant Agg as TodoAggregatorService
|
||||
participant Cache as Redis Cache
|
||||
participant Appr as ApprovalTodoService
|
||||
participant Wecom as 企微审批API
|
||||
participant ITSM as ITSMService
|
||||
participant ITSM_API as ITSM OpenAPI
|
||||
participant U as 坐席用户
|
||||
participant UI as UserInfoBar.vue
|
||||
participant CA as ChatArea.vue
|
||||
participant Store as ConversationStore
|
||||
participant API as message.ts API
|
||||
participant BE as Backend API
|
||||
participant DB as Database
|
||||
|
||||
FE->>API: GET /api/todo-items?type=approval
|
||||
API->>Agg: get_todo_list(agent_userid, type="approval")
|
||||
Agg->>Cache: GET todo:cache:{userid}:approval
|
||||
alt 缓存命中
|
||||
Cache-->>Agg: cached_data
|
||||
Agg-->>API: {items, total, cached:true}
|
||||
else 缓存未命中
|
||||
Agg->>Agg: asyncio.gather(approval_svc, itsm_svc, return_exceptions=True)
|
||||
par 并行查询审批
|
||||
Agg->>Appr: get_todo_list()
|
||||
Appr->>Wecom: getapprovaldata(sp_status=1, templates=18)
|
||||
Wecom-->>Appr: sp_no_list
|
||||
Appr->>Appr: asyncio.gather(getapprovaldetail × N)
|
||||
loop 每个sp_no并发获取详情
|
||||
Appr->>Wecom: getapprovaldetail(sp_no)
|
||||
Wecom-->>Appr: approval_detail
|
||||
end
|
||||
Appr->>Appr: _filter_by_current_approver(details)
|
||||
Appr->>Appr: _map_to_todo_item(detail)
|
||||
Appr-->>Agg: List[TodoItemData]
|
||||
and 并行查询工单
|
||||
Agg->>ITSM: get_todo_list()
|
||||
Note over ITSM: ITSM列表API待实现<br/>当前返回空列表+日志告警
|
||||
ITSM-->>Agg: List[TodoItemData] (空)
|
||||
end
|
||||
Agg->>Agg: merge + sort by priority
|
||||
Agg->>Cache: SET todo:cache:{userid}:approval TTL=45s
|
||||
Agg-->>API: {items, total, cached:false}
|
||||
end
|
||||
API-->>FE: {code:0, data:{items, total}}
|
||||
```
|
||||
Note over U,DB: ========== 阶段1:打开历史模式 ==========
|
||||
|
||||
## 2. 代办详情查询流程
|
||||
U->>UI: 点击"历史会话"开关按钮
|
||||
UI->>CA: $emit('toggle-history')
|
||||
CA->>Store: enableHistoryMode()
|
||||
Store->>Store: historyMode = true, historyLoading = true
|
||||
Store->>API: getHistoryMessages(employeeId, {limit:50, current_conversation_id})
|
||||
API->>BE: GET /api/employees/{employee_id}/history-messages?limit=50
|
||||
BE->>DB: SELECT conversations WHERE employee_id=?
|
||||
DB-->>BE: 会话ID列表 [conv1, conv2, conv3...]
|
||||
BE->>DB: SELECT messages WHERE conversation_id IN (...) ORDER BY created_at DESC LIMIT 51
|
||||
DB-->>BE: 消息列表 (50条 + 1条判断has_more)
|
||||
BE->>DB: 对每个会话查首条employee消息, 取前20字
|
||||
DB-->>BE: conversation_summaries {conv1:"摘要1", conv2:"摘要2"...}
|
||||
BE-->>API: {items:[...], has_more:true, conversation_summaries:{...}}
|
||||
API-->>Store: HistoryMessageListData
|
||||
Store->>Store: historyMessages = items.reverse() (ASC排序)
|
||||
Store->>Store: historyHasMore = has_more
|
||||
Store->>Store: historyCursor = historyMessages[0].id
|
||||
Store->>Store: historyConversationSummaries = conversation_summaries
|
||||
Store->>Store: historyLoading = false
|
||||
Store-->>CA: displayMessages 响应更新 (返回historyMessages)
|
||||
CA->>CA: 渲染消息列表 + 插入ConversationSeparator
|
||||
CA->>CA: 隐藏 ReplyBox + ReplySuggestArea (只读模式)
|
||||
CA-->>U: 显示合并历史时间线
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant FE as 前端 TaskDetailView
|
||||
participant API as GET /api/todo-items/{id}
|
||||
participant Agg as TodoAggregatorService
|
||||
participant Appr as ApprovalTodoService
|
||||
participant ITSM as ITSMService
|
||||
participant Wecom as 企微审批API
|
||||
participant ITSM_API as ITSM OpenAPI
|
||||
Note over U,DB: ========== 阶段2:向上滚动加载更多 ==========
|
||||
|
||||
FE->>API: GET /api/todo-items/approval:{sp_no}
|
||||
API->>Agg: get_todo_detail(agent_userid, item_id, todo_type="approval")
|
||||
|
||||
alt type == "approval"
|
||||
Agg->>Appr: get_todo_detail(sp_no)
|
||||
Appr->>Wecom: getapprovaldetail(sp_no)
|
||||
Wecom-->>Appr: approval_detail
|
||||
Appr->>Appr: _map_to_todo_item(detail)
|
||||
Appr-->>Agg: TodoItemData
|
||||
else type == "ticket"
|
||||
Agg->>ITSM: get_todo_detail(workitem_id)
|
||||
ITSM->>ITSM_API: POST /openapi/v1/process/workitem/detail
|
||||
ITSM_API-->>ITSM: {code:20000, data:{workitem_detail}}
|
||||
ITSM->>ITSM: _map_to_todo_item(detail)
|
||||
ITSM-->>Agg: TodoItemData
|
||||
end
|
||||
|
||||
Agg-->>API: TodoItemData
|
||||
API-->>FE: {code:0, data:{item}}
|
||||
```
|
||||
U->>CA: 向上滚动到顶部
|
||||
CA->>Store: loadMoreHistory()
|
||||
Store->>Store: historyLoading = true
|
||||
Store->>API: getHistoryMessages(employeeId, {limit:50, before:historyCursor})
|
||||
API->>BE: GET /api/employees/{employee_id}/history-messages?limit=50&before={msgId}
|
||||
BE->>DB: 获取before消息的created_at
|
||||
BE->>DB: SELECT messages WHERE conv IN (...) AND created_at < before_time ORDER BY DESC LIMIT 51
|
||||
DB-->>BE: 更旧的消息列表
|
||||
BE->>DB: 对新涉及的会话查首条employee消息摘要
|
||||
DB-->>BE: 补充 conversation_summaries
|
||||
BE-->>API: {items:[...], has_more:false, conversation_summaries:{...}}
|
||||
API-->>Store: HistoryMessageListData
|
||||
Store->>Store: historyMessages = newItems.reverse() + historyMessages (前插)
|
||||
Store->>Store: historyCursor = historyMessages[0].id (更新游标)
|
||||
Store->>Store: historyHasMore = has_more
|
||||
Store->>Store: merge conversation_summaries
|
||||
Store->>Store: historyLoading = false
|
||||
Store-->>CA: displayMessages 更新
|
||||
CA-->>U: 显示更多历史消息 + 新分隔条
|
||||
|
||||
## 3. ITSM 签名认证流程
|
||||
Note over U,DB: ========== 阶段3:关闭历史模式 ==========
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant Svc as ITSMService
|
||||
participant Signer as ITSMSigner
|
||||
participant API as ITSM OpenAPI
|
||||
U->>UI: 再次点击"历史会话"开关
|
||||
UI->>CA: $emit('toggle-history')
|
||||
CA->>Store: disableHistoryMode()
|
||||
Store->>Store: historyMode = false
|
||||
Store->>Store: 清空 historyMessages, historyCursor, historyConversationSummaries
|
||||
Store-->>CA: displayMessages 返回 messages (正常数据源)
|
||||
CA->>CA: 恢复 ReplyBox + ReplySuggestArea
|
||||
CA-->>U: 显示当前会话正常消息
|
||||
|
||||
Svc->>Svc: timestamp = str(int(time.time()*1000))
|
||||
Svc->>Signer: compute_signature(app_id, timestamp, app_secret, biz_data)
|
||||
Signer->>Signer: sign_params = {appId, timestamp, appSecret, bizData}
|
||||
Signer->>Signer: sort by key ASC
|
||||
Signer->>Signer: concat all values → canonicalized_str
|
||||
Signer->>Signer: quote_plus(canonicalized_str)
|
||||
Signer->>Signer: sha1(q2).hexdigest().upper()
|
||||
Signer-->>Svc: sign_str
|
||||
Svc->>API: POST url, headers={appId, timestamp, sign}, json=body
|
||||
API-->>Svc: {code:20000, data:{...}}
|
||||
```
|
||||
Note over U,DB: ========== 阶段4:切换会话自动重置 ==========
|
||||
|
||||
U->>CA: 点击左栏其他会话
|
||||
CA->>Store: selectConversation(newConvId)
|
||||
Store->>Store: resetHistoryState() — historyMode=false, 清空历史状态
|
||||
Store->>Store: currentConversationId = newConvId
|
||||
Store->>API: getMessages(newConvId, {limit:50})
|
||||
API->>BE: GET /api/conversations/{newConvId}/messages?limit=50
|
||||
BE-->>API: 正常消息列表
|
||||
API-->>Store: MessageListData
|
||||
Store->>Store: messages = data.items
|
||||
Store-->>CA: displayMessages 返回 messages
|
||||
CA-->>U: 显示新会话消息 (历史模式已关闭)
|
||||
|
||||
Reference in New Issue
Block a user