← 回到冰箱
Amazon Ops · DEMO
补货审批工作流
用一组预设补货文件演示从导出到人工确认,再到两份结果成对校验的完整链路。
自动化最危险的地方,是它不知道自己该停
你敢让它自己跑吗?
18 行合成数据3 个异常埋在里面
补货会花掉真钱。程序能算建议,但不该替人确认范围。先选择是否保留这道闸门。
打开透明层:查看判断依据与源码
校验是怎么做的范围 + 数量两道断言
审批表和发货表必须包含完全相同的 SKU 范围,逐项数量也必须守住确认结果。
assert set(approval.sku) == set(shipping.sku)assert sum(approval.qty) == sum(shipping.qty)
为什么先写临时目录成对发布或全部撤销
两份文件先在临时目录完成并互相校验,全部通过后才一起发布。
temp = create_temporary_output_dir()write_pair(temp)validate_pair(temp)publish_pair(temp)
完整处理顺序
01
batch = load_batch('examples/batch.json')# 读取合成补货批次,不接触访客文件02
source_files = discover_workbooks(batch.input_dir)# 定位导出、库存和审批模板03
source_files = reject_temporary_files(source_files)# 忽略锁文件与未完成下载04
rows = validate_schema(batch['rows'])# 检查 SKU 与数量字段05
rows = normalize_headers_and_whitespace(rows)# 统一字段别名并清理不可见字符06
rows = filter_marketplace(rows, market='US')# 只保留明确目标站点07
index = build_exact_sku_index(rows)# 建立精确索引,拒绝模糊匹配08
assert_no_duplicate_skus(index)# 重复 SKU 在正式生成前阻断09
candidates = preview_replenishment(index)# 此时只生成候选范围10
exceptions = collect_blocking_exceptions(candidates)# 集中展示缺失库存与异常数量11
confirmed = await_operator_confirmation(candidates)# 在业务判断点暂停12
confirmed = lock_confirmed_scope(confirmed)# 确认后冻结本批商品范围13
workspace = create_temporary_output_dir()# 先在临时目录生成,避免半成品14
approval = write_approval(confirmed)# 写入审批结果15
shipment = write_shipment(confirmed)# 同步写入发货结果16
assert_same_scope(approval, shipment)# 两份结果必须包含相同 SKU17
assert_quantity_conservation(approval, shipment)# 回读并验证数量守恒18
publish_pair(workspace, output_dir)# 全部通过后一次性交付两份结果