v88 功能增强:产品落盘持久化 + 生图网关适配 + 模板导出优化
- 产品持久化:每完成一个产品立即追加写入 products_pending.jsonl,崩溃不丢已完成产品,finish 读盘合并后统一写模板 - 503 致命错误提前终止:compose/product/seed_shot 端到端识别,提前终止搜索分析,丢弃未完成简报,保留已完成落盘产品直接合成模板 - 模特分配:material_library 合格模特图按任务序号独立随机,同 SPU 多款不再共用同一模特 - 图像网关适配:execution_mode/background 默认不再传入 yunfei 等标准网关,base_url 需带 /v1;429/5xx/空响应退避重试 - Pinterest 分析:删除 term 注入与纯文本降级,失败直接放弃;图片上传前 PIL 完整性校验;suitable_for_print=False 过滤丢弃 - 模板导出:不再产生空白 xlsx,文件名=模板原文件名_已填写;写入前按货号末 3 位升序排序 - 删除对接文档.md,更新 README,gitignore 排除测试产物
This commit is contained in:
@@ -20,14 +20,8 @@ from graph.validate import with_fallback
|
||||
def _template_out_path(prod_dir: Path, tpl_name: str) -> Path:
|
||||
"""模板输出路径:默认 {tpl_name}_已填写.xlsx;已存在/被占用则自动换名加序号(同款号多产品不互相覆盖)。"""
|
||||
base = prod_dir / f"{tpl_name}_已填写.xlsx"
|
||||
try:
|
||||
with open(base, "ab"):
|
||||
pass
|
||||
except OSError:
|
||||
pass
|
||||
else:
|
||||
if not base.exists():
|
||||
return base
|
||||
if not base.exists():
|
||||
return base
|
||||
for i in range(2, 100):
|
||||
cand = prod_dir / f"{tpl_name}_已填写_{i}.xlsx"
|
||||
if not cand.exists():
|
||||
@@ -95,6 +89,7 @@ def template_export_node(state: Dict[str, Any]) -> Dict[str, Any]:
|
||||
sku_codes = [r.get("sku_code") or ""]
|
||||
batch.append({
|
||||
"spu_code": r.get("spu_code", ""),
|
||||
"img_code": r.get("img_code", ""),
|
||||
"sku_codes": sku_codes,
|
||||
"images": [],
|
||||
"spu_per_color": True, # 每颜色一个独立 SPU 块(单色多 SPU)
|
||||
@@ -107,13 +102,24 @@ def template_export_node(state: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"seed_shot_urls": r.get("seed_shot_urls") or [],
|
||||
})
|
||||
|
||||
# 写入模板前按货号(前端自定义前缀+3位计数,如 DG001)最后3位从小到大排序,按顺序插入
|
||||
def _tail_num(rec: Dict[str, Any]) -> tuple:
|
||||
code = str(rec.get("img_code") or rec.get("oss_code") or "")
|
||||
try:
|
||||
return (0, int(code[-3:]))
|
||||
except ValueError:
|
||||
return (1, 0)
|
||||
batch.sort(key=_tail_num)
|
||||
|
||||
exported: List[str] = []
|
||||
if batch:
|
||||
out = _template_out_path(prod_dir, "商品上传")
|
||||
# 输出文件名 = 模板原文件名 + _已填写(如 NEW-波兰男黑T恤_已填写.xlsx)
|
||||
out = _template_out_path(prod_dir, Path(tp).stem)
|
||||
try:
|
||||
out = export_products(
|
||||
db_path, batch, tdir, tp, str(out),
|
||||
markup_percent=float(pcfg.get("markup_percent") or 0),
|
||||
suggested_price_ratio=float(pcfg.get("suggested_price_ratio") or 0),
|
||||
)
|
||||
for r in products:
|
||||
if (r.get("composite_path") or r.get("printed_path")) and (r.get("en_title") or "").strip():
|
||||
|
||||
Reference in New Issue
Block a user