- 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先例)
32 lines
1.2 KiB
Plaintext
32 lines
1.2 KiB
Plaintext
# ticket_create.dspy - 客户建单(R1)
|
||
# 入参: title, description, category?, priority?, attachments?(JSON数组字符串)
|
||
|
||
user_id = await get_user()
|
||
if not user_id:
|
||
return json.dumps({"success": False, "error": "请先登录"}, ensure_ascii=False)
|
||
|
||
org_id = await get_userorgid()
|
||
title = (params_kw.get('title') or '').strip()
|
||
description = (params_kw.get('description') or '').strip()
|
||
category = (params_kw.get('category') or 'other').strip()
|
||
priority = (params_kw.get('priority') or 'normal').strip()
|
||
|
||
attachments = None
|
||
att_raw = (params_kw.get('attachments') or '').strip()
|
||
if att_raw:
|
||
try:
|
||
attachments = json.loads(att_raw)
|
||
if not isinstance(attachments, list):
|
||
attachments = None
|
||
except Exception:
|
||
attachments = None
|
||
|
||
ok, result = await create_ticket(user_id, org_id, title, description,
|
||
category=category, priority=priority,
|
||
attachments=attachments)
|
||
if ok:
|
||
return json.dumps({"success": True, "message": "工单已提交,智能助手正在处理",
|
||
"data": result}, ensure_ascii=False)
|
||
code, msg = result
|
||
return json.dumps({"success": False, "error": msg, "code": code}, ensure_ascii=False)
|