1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| 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
| P=Path(__file__).parent
| 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,read_timeout=60)
| tables=['mdm_item','mdm_unit_measure','mes_md_item','mes_md_unit_measure','mes_md_workstation','mes_pro_route','mes_pro_route_product','mes_pro_route_process','mes_pro_route_product_bom','mes_pro_process','mes_qc_template','mes_qc_template_item','mes_qc_template_indicator','mes_qc_indicator','mes_wm_material_stock','mes_wm_batch','mes_wm_warehouse','mes_wm_warehouse_location','mes_wm_warehouse_area','mes_pro_task_issue','mes_energy_record','crm_contract','erp_sale_order','erp_sale_order_items','mes_qc_oqc','mes_qc_ipqc','crm_customer','crm_business_status','system_dict_data']
| data={}
| tables += ['mes_pd_process_param_template','mes_pd_process_param_template_detail','mes_pd_process_param']
| with c.cursor() as q:
| q.execute('SELECT NOW() now');data['db_now']=q.fetchone()['now']
| for t in tables:
| q.execute('SELECT * FROM `'+t+'` WHERE deleted=0 ORDER BY id');data[t]=q.fetchall()
| q.execute('SELECT id,username,nickname,dept_id,status FROM system_users WHERE deleted=0');data['users']=q.fetchall()
| (P/'assets.json').write_text(json.dumps(data,ensure_ascii=False,indent=2,default=str),encoding='utf8')
| mdm={x['id']:x for x in data['mdm_item']};routes={x['item_id']:x['route_id'] for x in data['mes_pro_route_product']}
| items=[]
| for m in data['mes_md_item']:
| x=mdm.get(m['mdm_item_id'])
| if x and m['id'] in routes:items.append({'mes_id':m['id'],'mdm_id':x['id'],'same_id':m['id']==x['id'],'code':m['code'],'name':m['name'],'spec':m.get('specification'),'route':routes[m['id']],'mes_unit':m['unit_measure_id'],'mdm_unit':x['unit_measure_id'],'price':x.get('sales_price')})
| print(json.dumps({'candidate_products':items,'db_now':str(data['db_now'])},ensure_ascii=False))
| c.close()
|
|