30 lines
1.3 KiB
Python
Executable File
30 lines
1.3 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['name'] = kd['物料名称'].astype(str).str.strip()
|
|
kd['lv'] = kd['BOM层级'].astype(str).str.strip()
|
|
|
|
out = []
|
|
# 层级 1.11 是什么
|
|
p = kd[kd['lv'].isin(['1.11', '1.11.1', '1.11.2'])]
|
|
out.append("=== 金蝶中 1.11 / 1.11.1 / 1.11.2 ===")
|
|
for _, r in p.iterrows():
|
|
out.append(f" 层级={r['lv']} 编码={r['code']} 名称={r['name']} 跳层={r['是否跳层']} 子项类型={r['子项类型']}")
|
|
|
|
# 数据库中 9000010400-A01 的直接子件里含 LORA 的
|
|
db = pd.read_csv('db_bom2.csv', dtype=str)
|
|
db['code'] = db['ChildMaterialId'].astype(str).str.strip()
|
|
db['parent'] = db['ParentMaterialId'].astype(str).str.strip()
|
|
sub = db[db['parent'] == '9000010400-A01']
|
|
out.append(f"\n=== 数据库中 9000010400-A01 直接子件数: {len(sub)} ===")
|
|
lora = sub[sub.apply(lambda r: 'LORA' in str(r['MaterialName']).upper() or '3420' in r['code'], axis=1)]
|
|
for _, r in lora.iterrows():
|
|
out.append(f" {r['code']} {r['MaterialName']} Level={r['Level']}")
|
|
|
|
with open('kd_111.txt', 'w', encoding='utf-8') as f:
|
|
f.write('\n'.join(out))
|
|
print("done")
|