feat(export): 批量导出后生成 AI 穿搭 Excel,每印花子目录一行 (§17.23)
添加印花批量导出完成后,自动在输出目录生成与时间戳目录同名的 xlsx 文件(docs/02 §6.12);每个有效印花子目录一行,C 列指向该子目录路径, AI 穿搭页直接选取即可触发目录扇出逻辑(§19.12),无需手工填写 Excel。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
from typing import List, Sequence, Tuple
|
||||
|
||||
from openpyxl import load_workbook
|
||||
from openpyxl import Workbook, load_workbook
|
||||
|
||||
from core.models import OutfitResult, OutfitTask
|
||||
|
||||
@@ -149,6 +149,27 @@ def read_all_rows(excel_path):
|
||||
workbook.close()
|
||||
|
||||
|
||||
_OUTFIT_SOURCE_HEADERS = ["标题", "货号", "衣服图路径", "生成结果图片路径", "完成状态", "失败原因"]
|
||||
|
||||
|
||||
def write_outfit_source_excel(excel_path, rows):
|
||||
"""Create an AI-outfit source Excel alongside a compose run directory (docs/02 §6.12).
|
||||
|
||||
rows: ordered sequence of (print_name, subdir_path) pairs.
|
||||
subdir_path should end with a path separator so AI穿搭 treats it as a directory.
|
||||
Columns: A=print_name, B=empty(货号可空), C=subdir_path, D/E/F=empty (AI穿搭 writes back).
|
||||
"""
|
||||
rows = list(rows)
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.append(_OUTFIT_SOURCE_HEADERS)
|
||||
for print_name, subdir_path in rows:
|
||||
ws.append([print_name, None, subdir_path, None, None, None])
|
||||
wb.save(str(excel_path))
|
||||
wb.close()
|
||||
logger.info("Wrote outfit source Excel: %s (%d rows)", excel_path, len(rows))
|
||||
|
||||
|
||||
def write_outfit_result(excel_path, result):
|
||||
"""Write one outfit result to columns D/E/F and save immediately."""
|
||||
if not isinstance(result, OutfitResult):
|
||||
|
||||
Reference in New Issue
Block a user