43 lines
1.8 KiB
Python
Executable File
43 lines
1.8 KiB
Python
Executable File
# -*- coding: utf-8 -*-
|
|
import pandas as pd
|
|
from collections import Counter
|
|
|
|
kd = pd.read_excel('物料清单正查_1.xlsx', sheet_name='树形单据体')
|
|
kd = kd[kd['子项物料编码'].notna()].copy()
|
|
kd = kd[kd['BOM层级'].astype(str).str.strip() != '0']
|
|
kd['code'] = kd['子项物料编码'].astype(str).str.strip()
|
|
kd['lv'] = kd['BOM层级'].astype(str).str.strip()
|
|
|
|
def kd_parent(lv):
|
|
parts = lv.split('.')
|
|
return '.'.join(parts[:-1]) if len(parts) > 1 else ''
|
|
kd['parent_lv'] = kd['lv'].apply(kd_parent)
|
|
lv2code = {'0': 'CG0S175E0000120'}
|
|
for _, r in kd.iterrows():
|
|
lv2code[r['lv']] = r['code']
|
|
kd['parent'] = kd['parent_lv'].map(lv2code)
|
|
|
|
out = []
|
|
out.append(f"金蝶子项总数: {len(kd)}")
|
|
|
|
# 1) 9000013420-A01 在金蝶里的所有出现位置及属性
|
|
sub = kd[kd['code'] == '9000013420-A01']
|
|
out.append("\n=== 9000013420-A01 (天线LORA组件) 在金蝶中的记录 ===")
|
|
for _, r in sub.iterrows():
|
|
out.append(f" 层级={r['lv']} 父级={r['parent']} BOM版本={r['BOM版本']} 数据状态={r['数据状态']} 子项类型={r['子项类型']} 用量类型={r['用量类型']} 是否跳层={r['是否跳层']}")
|
|
|
|
# 2) 其他6个多出的子件在金蝶中的情况
|
|
extras = ['3010006240-A01','100401813A-B01','7010001640-A01','101200320','A0304005467A']
|
|
out.append("\n=== 数据库多出的子件在金蝶中的全部出现 ===")
|
|
for c in extras:
|
|
s = kd[kd['code'] == c]
|
|
if len(s) == 0:
|
|
out.append(f" {c}: 金蝶文件中完全不存在")
|
|
else:
|
|
for _, r in s.iterrows():
|
|
out.append(f" {c}: 出现于层级{r['lv']} 父级={r['parent']} 禁用状态={r['子项物料禁用状态']} 失效日期={r['失效日期']}")
|
|
|
|
with open('kd_check.txt', 'w', encoding='utf-8') as f:
|
|
f.write('\n'.join(out))
|
|
print("done")
|