29 lines
1.2 KiB
Python
Executable File
29 lines
1.2 KiB
Python
Executable File
# -*- coding: utf-8 -*-
|
|
import pandas as pd
|
|
|
|
kd = pd.read_excel('物料清单正查_1.xlsx', sheet_name='树形单据体')
|
|
kd = kd[kd['子项物料编码'].notna()].copy()
|
|
kd['code'] = kd['子项物料编码'].astype(str).str.strip()
|
|
kd['lv'] = kd['BOM层级'].astype(str).str.strip()
|
|
|
|
out = []
|
|
# 9000013420-A01 在金蝶中的记录(含层级0)
|
|
sub = kd[kd['code'] == '9000013420-A01']
|
|
out.append(f"=== 9000013420-A01 在金蝶文件中出现 {len(sub)} 次 ===")
|
|
for _, r in sub.iterrows():
|
|
out.append(f" 层级={r['lv']} BOM版本={r['BOM版本']} 数据状态={r['数据状态']} 子项类型={r['子项类型']} 用量类型={r['用量类型']} 是否跳层={r['是否跳层']} 物料属性={r['物料属性']}")
|
|
|
|
# 它的父级是谁
|
|
def kd_parent(lv):
|
|
parts = lv.split('.')
|
|
return '.'.join(parts[:-1]) if len(parts) > 1 else ''
|
|
for _, r in sub.iterrows():
|
|
plv = kd_parent(r['lv'])
|
|
parent_rows = kd[kd['lv'] == plv]
|
|
for _, pr in parent_rows.iterrows():
|
|
out.append(f" 其父级: 层级{plv} 编码={pr['code']} 名称={pr['物料名称']} 跳层={pr['是否跳层']}")
|
|
|
|
with open('kd_bomver.txt', 'w', encoding='utf-8') as f:
|
|
f.write('\n'.join(out))
|
|
print("done")
|