feat: 2026-07-11 全量更新 - 代办集成+会议室预定+知识迭代修复+UI统一+Bug修复
== 已部署上线 (9项) == - 代办事项真实数据源集成 (企微审批API 8bug修复链) - H5/坐席端 Logo样式统一+绿色背景 - 视频引导页修复 (localStorage key v2) - 坐席端 v9 Vue版本修复 (ElMessage._context) - 截图按钮 v10 修复 (getDisplayMedia user gesture) - 扫码样式恢复+H5扫码登录跳转修复 - H5截图快捷键提示 == 代码完成待部署 (3项) == - 知识迭代3Bug修复 (#8 POST端点/#7 MERGE幂等/#6 过期检查) - 会议室预定-小鱼易联终端 (40文件, 40/40测试通过) - IT资产升级审批推送 (asset_service.py) == 需求文档 (2项) == - 坐席端AI辅助消息框-PRD (4项新功能确认) - 坐席端布局优化建议 v2.0 (7天计划) == 新增文档 == - 日报-2026-07-11.md - 知识迭代Bug修复报告-20260711.md - 会议室预定-部署指南.md - CHANGELOG.md 更新 == 测试 == - test_todo_integration.py: 40/40 - test_meetingroom.py: 40/40 - test_bugfix_ki_suggestions.py: 21/21
This commit is contained in:
@@ -51,6 +51,8 @@ class ConnectionManager:
|
||||
self.active_connections: Dict[str, WebSocket] = {}
|
||||
# H5员工连接(employee_id → WebSocket)
|
||||
self.employee_connections: Dict[str, WebSocket] = {}
|
||||
# 终端连接(terminal_sn → WebSocket)— 小鱼易联终端大屏
|
||||
self.terminal_connections: Dict[str, WebSocket] = {}
|
||||
|
||||
# ==========================================================================
|
||||
# 坐席连接管理
|
||||
@@ -305,6 +307,84 @@ class ConnectionManager:
|
||||
|
||||
return sent_count
|
||||
|
||||
# ==========================================================================
|
||||
# 终端连接管理(小鱼易联终端大屏)
|
||||
# ==========================================================================
|
||||
|
||||
async def connect_terminal(self, terminal_sn: str, websocket: WebSocket, subprotocol: str = "") -> None:
|
||||
"""接受终端 WebSocket 握手并注册连接。
|
||||
|
||||
终端WS的token认证可选(无token时仅接收推送,不能发预定指令)。
|
||||
|
||||
如果同一终端重复连接(如页面刷新),旧连接会被覆盖。
|
||||
|
||||
Args:
|
||||
terminal_sn: 终端序列号
|
||||
websocket: FastAPI WebSocket 对象
|
||||
subprotocol: 协商的子协议(如 bearer.{token})
|
||||
"""
|
||||
await websocket.accept(subprotocol=subprotocol if subprotocol else None)
|
||||
|
||||
# 如果该终端已有连接,先关闭旧连接
|
||||
if terminal_sn in self.terminal_connections:
|
||||
old_ws = self.terminal_connections[terminal_sn]
|
||||
try:
|
||||
await old_ws.close()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.terminal_connections[terminal_sn] = websocket
|
||||
logger.info(
|
||||
f"终端 WebSocket 连接建立: terminal_sn={terminal_sn}, "
|
||||
f"当前在线终端数={len(self.terminal_connections)}"
|
||||
)
|
||||
|
||||
def disconnect_terminal(self, terminal_sn: str) -> None:
|
||||
"""从终端映射表中移除连接。
|
||||
|
||||
Args:
|
||||
terminal_sn: 终端序列号
|
||||
"""
|
||||
if terminal_sn in self.terminal_connections:
|
||||
del self.terminal_connections[terminal_sn]
|
||||
logger.info(
|
||||
f"终端 WebSocket 连接断开: terminal_sn={terminal_sn}, "
|
||||
f"当前在线终端数={len(self.terminal_connections)}"
|
||||
)
|
||||
|
||||
async def send_to_terminal(self, terminal_sn: str, data: dict) -> None:
|
||||
"""向指定终端发送消息。
|
||||
|
||||
如果发送失败(连接已断开),自动清理该连接。
|
||||
|
||||
Args:
|
||||
terminal_sn: 终端序列号
|
||||
data: 要发送的数据(会被序列化为 JSON)
|
||||
"""
|
||||
websocket = self.terminal_connections.get(terminal_sn)
|
||||
if not websocket:
|
||||
logger.debug(f"终端不在线,跳过推送: terminal_sn={terminal_sn}")
|
||||
return
|
||||
|
||||
try:
|
||||
await websocket.send_json(data)
|
||||
except Exception as e:
|
||||
logger.warning(f"终端 WebSocket 发送失败,清理连接: terminal_sn={terminal_sn}, error={e}")
|
||||
self.disconnect_terminal(terminal_sn)
|
||||
|
||||
async def broadcast_to_terminals(self, terminal_sns: List[str], data: dict) -> None:
|
||||
"""向多个终端批量推送消息。
|
||||
|
||||
Args:
|
||||
terminal_sns: 终端序列号列表
|
||||
data: 要发送的数据
|
||||
"""
|
||||
if not terminal_sns:
|
||||
return
|
||||
|
||||
for sn in terminal_sns:
|
||||
await self.send_to_terminal(sn, data)
|
||||
|
||||
# ==========================================================================
|
||||
# 辅助方法
|
||||
# ==========================================================================
|
||||
|
||||
Reference in New Issue
Block a user