31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
from app.models import SessionLocal, DitRecord, OrderRecord
|
|
from app.services.fuzzy_matcher import normalize_pn_for_matching, normalize_id
|
|
|
|
db = SessionLocal()
|
|
try:
|
|
print("--- DIT Check ---")
|
|
dit = db.query(DitRecord).filter(DitRecord.erp_account == '184100').first()
|
|
if dit:
|
|
print(f"DIT Found: ID={dit.id}, Op={dit.op_id}, PN={dit.pn}, ERP={dit.erp_account}")
|
|
norm_pn = normalize_pn_for_matching(dit.pn)
|
|
print(f" Normalized PN: {norm_pn}")
|
|
|
|
print("\n--- Order Check ---")
|
|
orders = db.query(OrderRecord).filter(OrderRecord.cust_id == '184100').all()
|
|
print(f"Orders found for ERP 184100: {len(orders)}")
|
|
for o in orders:
|
|
o_norm_pn = normalize_pn_for_matching(o.pn)
|
|
print(f" Order ID={o.id}, No={o.order_no}, PN={o.pn}, NormPN={o_norm_pn}")
|
|
if o_norm_pn == norm_pn:
|
|
print(" !!! PN MATCH FOUND !!!")
|
|
else:
|
|
print("DIT with ERP 184100 not found")
|
|
# Search by name
|
|
dit = db.query(DitRecord).filter(DitRecord.customer.like('%瀚碩%')).first()
|
|
if dit:
|
|
print(f"DIT Found by name: ID={dit.id}, ERP={dit.erp_account}")
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
finally:
|
|
db.close()
|