import sys,json from pathlib import Path sys.stdout.reconfigure(encoding='utf-8') sys.path.insert(0,str(Path('scripts/iqc-import-20261012/deps').resolve())) import pymysql c=pymysql.connect(host='36.213.150.237',port=10000,user='root',password=sys.stdin.readline().strip(),database='mom-hm',charset='utf8mb4',cursorclass=pymysql.cursors.DictCursor) out={} with c.cursor() as q: for t in ['mes_md_auto_code_rule','mes_md_auto_code_part','mes_md_auto_code_record']: q.execute('SELECT * FROM '+t+(' ORDER BY id DESC LIMIT 35' if t.endswith('record') else ''));out[t]=q.fetchall() for t in ['erp_sale_order','crm_sale_quotation','crm_contract','mes_pro_mps','mes_pro_work_order','mes_pro_task','mes_pro_feedback','mes_wm_batch','mes_wm_arrival_notice','mes_wm_item_receipt','mes_wm_product_issue','mes_wm_item_consume','mes_wm_product_produce','mes_wm_product_receipt','mes_wm_sales_notice','mes_wm_product_sales','mes_qc_iqc','mes_qc_ipqc','mes_qc_oqc','mes_qc_indicator_result','mes_qc_template']: q.execute('SHOW COLUMNS FROM '+t);cols=[x['Field'] for x in q.fetchall()];col='no' if 'no' in cols else 'code' q.execute('SELECT id,`'+col+'`,create_time FROM '+t+' WHERE `'+col+'` NOT LIKE %s ORDER BY id DESC LIMIT 5',('OCT0814-DEMO%',));out[t]=q.fetchall() Path(__file__).with_name('number-rules.json').write_text(json.dumps(out,ensure_ascii=False,indent=2,default=str),encoding='utf8') print(json.dumps(out,ensure_ascii=False,default=str))