Files
inquiry_robot/inquiry-agent/agent/redis_coord/quote_file.py
T

44 lines
1.3 KiB
Python

"""
报价文件完成短协调。
Worker LibreOffice 出完文件后写键;HTTP 进程读键,把 wait_file 切到成交跟进。
不当六态、不当 checkpoint。TTL 一周,过期当未完成。
"""
from __future__ import annotations
import logging
from agent.redis_coord.keys import QUOTE_FILE_READY
from agent.redis_coord.runtime import get_redis_runtime
logger = logging.getLogger(__name__)
_TTL_SEC = 7 * 24 * 3600
def mark_quote_file_ready(work_order_no: str) -> None:
"""Worker 出完报价文件后调用;HTTP 进程据此结束「请稍候」。"""
no = (work_order_no or "").strip()
if not no:
return
try:
client = get_redis_runtime().client
client.raw.set(client.key(QUOTE_FILE_READY, no), "1", ex=_TTL_SEC)
logger.info("报价文件已就绪 wo=%s", no)
except Exception:
logger.exception("写报价文件就绪键失败 wo=%s", no)
def is_quote_file_ready(work_order_no: str) -> bool:
"""HTTP 读:文件是否已经发出。读失败当未完成,继续请稍候。"""
no = (work_order_no or "").strip()
if not no:
return False
try:
client = get_redis_runtime().client
return bool(client.raw.get(client.key(QUOTE_FILE_READY, no)))
except Exception:
logger.exception("读报价文件就绪键失败 wo=%s", no)
return False