把 任意格式 的客户排产/计划/需求 Excel,归一化成公司的 三个标准模板,并支持新旧版本差异标注。
id 给脚本用)#id模板形态典型源文件demand_schedule客户需求排产表标识列 + 横向 周/日 需求量 + 合计 + CS备注横向表、T+2 真单/预报、滚动计划、物料到货计划、各客户需求下发表(绝大多数客户表都属这类)plan_tracking计划跟踪跟单表按成品料号跟踪 库存/已交/未交/结余/在制/欠料/月度预测跟单个人表、到货进度+库存表dip_schedule工厂DIP排产计划表工单维度 + 白班/夜班 日排程 + UPH/人力/线体工厂内部 DIP 工单排产表、配料明细、返工工单
模板的列定义、别名词典、分类关键词、差异主键全部集中在
reference/templates_schema.json( 单一事实来源,要调整列就改这里)。模板的 画像与判别要点 见reference/classification.md, 完整操作流程与排错 见reference/workflow.md。
脚本依赖 pandas openpyxl xlrd(读 .xls 需 xlrd)。缺失时让用户/会话执行:
bash
pip install -r requirements.txt # 或: pip install pandas openpyxl xlrd
inspect_form.py,看清每个 sheet 的列数与日期提示,再决定 --sheet。自动选 sheet 只是兜底,复杂簿常选错。合计 用公式自动算。日期解析不确定时在报告里有 ⚠️低 标记,复核它。所有命令在 skill 目录下执行, <file> 为客户文件路径。
bash
python3 scripts/inspect_form.py "<file>" ["<file2>" ...]
打印每个 sheet 的维度、合并单元格、前几行预览、疑似表头行/日期列。据此选定 sheet 与表头行。
bash
python3 scripts/classify_form.py "<file>" [...] # 加 --json 出结构化结果
输出每个文件的判定模板 + 置信度。 置信度 = high 可直接用; medium/low 必须你打开文件复核 后再敲定 id。
bash
python3 scripts/extract_form.py "<file>" --template <id> --out work/<name>.norm.json
# 复杂文件按需覆盖: --sheet "3月" --header-row 0 --data-start 2 --year 2026 --mapping map.json
打印 列映射报告(每列 → 标识/数值/日期/略 + 置信度)。 逐行核对:
map.json 用 --mapping 覆盖(格式见报告提示或 reference/workflow.md)。--mapping 指定 iso。bash
python3 scripts/fill_template.py work/*.norm.json --template <id> --out-dir out/ [--dedup]
.norm.json 会合并成 一份 模板(行拼接、日期区取并集)——满足「多个表统一成一个」。--dedup 按模板主键合并重复料号。输出文件自动命名, 末尾带生成时刻精确到分钟(如 客户需求排产表_20260227_20260602-1430.xlsx: 20260227 =数据日期, 20260602-1430 =生成时刻)。bash
python3 scripts/diff_forms.py --new <新文件|.norm.json> --old <旧文件|.norm.json> \
--template <id> --out "out/差异标注.xlsx"
--new/--old 可直接传 原始 Excel(脚本内部自动熔解)或已熔解的 .norm.json。*.diff.json 报告。bash
python3 scripts/build_clean_templates.py # 输出到 assets/templates/
三个 已重命名、无示例数据 的空白模板,给用户当格式参考。实际转换输出由 fill_template.py 产生(日期区随数据展开)。
bash
python3 scripts/classify_form.py "客户来的表.xlsx" # → demand_schedule (high)
python3 scripts/extract_form.py "客户来的表.xlsx" --template demand_schedule --out work/new.norm.json
python3 scripts/fill_template.py work/new.norm.json --out-dir out/ # → out/客户需求排产表_YYYYMMDD.xlsx
python3 scripts/diff_forms.py --new work/new.norm.json --old "库里/上一版.xlsx" --template demand_schedule --out "out/差异标注.xlsx"
更细的边界处理(多 sheet 选择、双行表头、月粒度需求、计划版本列误判、 --mapping 写法)见 reference/workflow.md。