From 37d80e6c8b16cd5d113f34fbe1f89b91ccdf1529 Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Tue, 31 Mar 2026 18:42:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=9A=E6=97=A0=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E5=8C=BA=E5=9F=9F=E6=97=B6=E4=BD=BF=E7=94=A8=E6=BC=94?= =?UTF-8?q?=E7=A4=BA=E5=8C=BA=E5=9F=9F=E5=85=9C=E5=BA=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/agent_dispatcher.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/services/agent_dispatcher.py b/app/services/agent_dispatcher.py index a43ac9c..2aef6a0 100644 --- a/app/services/agent_dispatcher.py +++ b/app/services/agent_dispatcher.py @@ -191,11 +191,9 @@ class AgentDispatcher: session.pending_manual_order_area_id = "" session.pending_manual_order_area_name = "" session.pending_manual_order_area_options = self._list_notify_areas() - session.state = "waiting_manual_order_area" - if not session.pending_manual_order_area_options: - session.reset() - return "已收到图片,但当前没有可选区域,请联系管理员先配置通知区域。" + session.pending_manual_order_area_options = [self._get_demo_area()] + session.state = "waiting_manual_order_area" return ( "已收到图片,准备创建手动工单。\n" @@ -242,7 +240,7 @@ class AgentDispatcher: ) assignees = self._get_area_assignees(area["area_id"]) - if not assignees: + if not assignees and area["area_id"] != self._get_demo_area()["area_id"]: return f"区域【{area['area_name']}】当前未绑定责任人,请重新选择其他区域。" session.pending_manual_order_area_id = area["area_id"] @@ -254,6 +252,8 @@ class AgentDispatcher: session.pending_manual_order_remark = "" if content in {"无", "没有", "none", "None"} else content session.state = "waiting_manual_order_confirm" assignees = self._get_area_assignees(session.pending_manual_order_area_id) + if not assignees and session.pending_manual_order_area_id == self._get_demo_area()["area_id"]: + assignees = [{"person_name": "演示用户", "wechat_uid": user_id, "role": "demo"}] assignee_names = "、".join(person["person_name"] for person in assignees) remark = session.pending_manual_order_remark or "无" return ( @@ -298,6 +298,10 @@ class AgentDispatcher: finally: db.close() + @staticmethod + def _get_demo_area() -> Dict[str, str]: + return {"index": "1", "area_id": "demo-area", "area_name": "\u6f14\u793a\u533a\u57df"} + @staticmethod def _format_area_options(areas: List[Dict[str, str]]) -> str: return "\n".join(f"{item['index']}. {item['area_name']}" for item in areas) @@ -339,8 +343,10 @@ class AgentDispatcher: async def _create_manual_order(self, user_id: str, session) -> str: """创建手动工单并通知区域绑定人员。""" assignees = self._get_area_assignees(session.pending_manual_order_area_id) - if not assignees: + if not assignees and session.pending_manual_order_area_id != self._get_demo_area()["area_id"]: return f"区域【{session.pending_manual_order_area_name}】当前未绑定责任人,工单未创建。" + if not assignees: + assignees = [{"person_name": "演示用户", "wechat_uid": user_id, "role": "demo"}] from app.services.wechat_service import get_wechat_service from app.services.work_order_service import get_work_order_service