新增功能: - 天网协作系统 (HTTP API 端口 6060) - 三种工作流 (查找图片/处理图片/转人工派单) - 图片任务数据库 (支持客户后续增加需求) - 图绘派单系统集成 (API: 8005) - 文字检测与加价 (60-80 元高价值订单) - 风险评估与接单判断 - 作图失败自动转人工 新增文档: - 项目功能汇总.md - 三种工作流功能说明.md - 文字加价功能说明.md - 风险评估功能说明.md - 图片任务数据库功能说明.md - 图绘派单系统集成说明.md - 作图失败转接人工说明.md - DEPLOYMENT.md - TIANWANG_INTEGRATION.md 核心修改: - core/pydantic_ai_agent.py - core/workflow.py - core/websocket_client.py - image/image_analyzer.py - services/service_tuhui_dispatch.py - db/image_tasks_db.py 版本:v1.0 日期:2026-02-28
42 lines
1.4 KiB
Python
Executable File
42 lines
1.4 KiB
Python
Executable File
# -*- coding: utf-8 -*-
|
||
"""
|
||
设计师在线状态 - 请求外部查询服务(转人工时按需调用)
|
||
|
||
接口: GET /online 返回 {online_users: ["lz", "ZuoWei"], ...}
|
||
本端用 online_users 同步本地 designer_online 表后派单。
|
||
"""
|
||
import os
|
||
import logging
|
||
from typing import List, Set
|
||
|
||
logger = logging.getLogger(__name__)
|
||
|
||
# 设计师在线查询服务,.env 配置 DESIGNER_ROSTER_API,如 http://huichang.online:8001/online
|
||
_API_URL = os.getenv("DESIGNER_ROSTER_API", "")
|
||
|
||
|
||
async def _fetch_online_users() -> Set[str]:
|
||
"""请求 GET /online,返回当前在线用户的 user_id 集合"""
|
||
if not _API_URL:
|
||
return set()
|
||
try:
|
||
import httpx
|
||
async with httpx.AsyncClient(timeout=10) as client:
|
||
r = await client.get(_API_URL)
|
||
r.raise_for_status()
|
||
data = r.json()
|
||
users = data.get("online_users", [])
|
||
return set(users) if isinstance(users, list) else set()
|
||
except Exception as e:
|
||
logger.debug(f"设计师在线查询失败: {e}")
|
||
return set()
|
||
|
||
|
||
async def poll_and_update_roster() -> None:
|
||
"""请求查询服务,同步在线状态到本地数据库"""
|
||
from db.designer_roster_db import update_online, get_all_wechat_user_ids
|
||
online_users = await _fetch_online_users()
|
||
all_ids = get_all_wechat_user_ids()
|
||
for uid in all_ids:
|
||
update_online(uid, uid in online_users)
|