""" 报价文件完成短协调。 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 clear_quote_file_ready(work_order_no: str) -> None: """采用后改选:清掉就绪键,避免续办再进成交跟进。""" no = (work_order_no or "").strip() if not no: return try: client = get_redis_runtime().client client.raw.delete(client.key(QUOTE_FILE_READY, no)) 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