ticket/wwwroot/api/ticket_claim.dspy
yumoqing 54f2f2d597 feat: 工单管理模块初版——客户提问→agent预处理→人工运维→转派,接入平台待办
- 3表: tk_tickets(状态机+受理角色/人+agent锁)/tk_messages(客户可见/内部备注)/tk_transfers(append-only流水)
- core.py: 8态13迁移状态机全乐观锁; 转派候选动态查owner角色+'0'机构用户(不硬编码);
  默认受理角色params可配(ticket_default_role=owner.maintainer)
- agent.py: 异步poller(bid_flow范式), RAG检索'0'机构KB+历史工单, llm_call(org_id=0)
  LLM裁决能否回答(严格JSON), 硬门禁reply<20字符转人工, 故障≠答不了(fail_rounds>=3转人工),
  stale回收10min; 追问回流(agent_processing+owner空)立即拾取不等stale
- todos.py: 平台待办provider, 状态派生(客户待确认/角色池待认领/受理人待处理)
- init.py: load_ticket注册env+provider+poller(PIPELINE_MODE=web不启动)
- wwwroot: 客户我的工单页+建单表单, 运维工单管理页(队列切换), 详情弹窗(正文与操作同屏,按视角出按钮)
- load_path.py: logined全部API(业务权限服务端按current_role动态校验)+管理页壳owner三角色
- init/data.json: 7组码表+owner.maintainer角色种子(app_audit先例)
2026-09-10 16:17:58 +08:00

18 lines
702 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ticket_claim.dspy - 运维认领工单T7: human_pending→human_processing
# 入参: ticket_id
user_id = await get_user()
if not user_id:
return json.dumps({"success": False, "error": "请先登录"}, ensure_ascii=False)
ticket_id = (params_kw.get('ticket_id') or '').strip()
if not ticket_id:
return json.dumps({"success": False, "error": "缺少 ticket_id"}, ensure_ascii=False)
ok, result = await ticket_claim(ticket_id, user_id)
if ok:
return json.dumps({"success": True, "message": result.get('message', ''),
"data": result}, ensure_ascii=False)
code, msg = result
return json.dumps({"success": False, "error": msg, "code": code}, ensure_ascii=False)