feat: complete multimodal ticket intake

This commit is contained in:
hailin
2026-07-27 18:59:28 +08:00
parent 96452934a3
commit 93065c0a00
39 changed files with 6443 additions and 267 deletions

View File

@@ -2,7 +2,6 @@ from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand, CommandError
from apps.tickets.draft_services import (
confirm_draft,
create_agent_run_for_draft,
execute_draft_analysis,
)
@@ -29,38 +28,12 @@ class Command(BaseCommand):
run = create_agent_run_for_draft(draft)
execute_draft_analysis(draft.id, run.id)
draft.refresh_from_db()
if draft.status != "ready":
if draft.status != "ticket_created" or draft.confirmed_ticket_id is None:
raise CommandError(f"真实文本分析失败: {draft.error_code} {draft.error_message}")
fields = {
**draft.current_fields,
"title": draft.current_fields.get("title") or "生产采集任务未更新",
"description": draft.current_fields.get("description") or draft.source_text,
"category_code": "technical_issue",
"priority": draft.current_fields.get("priority")
if draft.current_fields.get("priority") in {"low", "medium", "high", "urgent"}
else "high",
"problem_performance": draft.current_fields.get("problem_performance")
or "采集进度长时间未更新",
"problem_object": draft.current_fields.get("problem_object") or "JOB-1024",
"submitter_name": draft.current_fields.get("submitter_name") or "验收用户",
"submitter_org": draft.current_fields.get("submitter_org") or "验收机构",
"environment": draft.current_fields.get("environment") or "生产环境",
"impact_scope": draft.current_fields.get("impact_scope") or "单个客户",
"related_system": draft.current_fields.get("related_system") or "数据采集平台",
}
draft.current_fields = fields
draft.revision += 1
draft.save(update_fields=["current_fields", "revision", "updated_at"])
revision = draft.revision
first = confirm_draft(draft.public_id, revision, user)
second = confirm_draft(draft.public_id, revision, user)
if first.confirmed_ticket_id != second.confirmed_ticket_id:
raise CommandError("重复确认创建了不同工单")
self.stdout.write(
self.style.SUCCESS(
"Ticket intake acceptance passed: "
f"draft={draft.public_id} run={run.public_id} "
f"ticket={first.confirmed_ticket.ticket_no} decision={first.decision}"
f"ticket={draft.confirmed_ticket.ticket_no} decision={draft.decision}"
)
)