import sys,json from pathlib import Path from collections import Counter sys.stdout.reconfigure(encoding='utf-8') sys.path.insert(0,str(Path(__file__).parent/'iqc-import-20261012/deps')) import pymysql tables=['mes_pro_route','mes_pro_route_process','mes_pro_route_product','mes_pro_route_product_bom','mes_md_product_bom','mes_md_item','mes_pro_work_order_process','mes_pro_work_order_bom','mes_pro_work_order'] data={} with pymysql.connect(host='36.213.150.237',port=10000,user='root',password=sys.stdin.readline().strip(),database='mom-hm',charset='utf8mb4',connect_timeout=15,cursorclass=pymysql.cursors.DictCursor) as c: with c.cursor() as q: for t in tables: q.execute('SELECT * FROM '+t+' WHERE deleted=0 ORDER BY id');data[t]=q.fetchall() print(json.dumps({'table':t,'count':len(data[t]),'sample':data[t][:1]},ensure_ascii=False,default=str)) out=Path(__file__).parent/'schedule-diagnosis-20261015' (out/'route-material-snapshot.json').write_text(json.dumps(data,ensure_ascii=False,default=str,indent=2),encoding='utf-8') print(json.dumps({'routeStatuses':dict(Counter(r['status'] for r in data['mes_pro_route'])),'outputFilled':sum(bool(r['output_item_id']) for r in data['mes_pro_route_process'])},ensure_ascii=False))