调整:无通知区域时使用演示区域兜底
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user