云
18 小时以前 9dc4057ee86abf7a69e7d7a8720a41efa8dabdcc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import sys,json
from pathlib import Path
P=Path(__file__).parent
sys.path.insert(0,str(P.parent/'iqc-import-20261012/deps'))
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)
s={}
with c.cursor() as q:
 for t in ['mes_qc_ipqc','mes_wm_batch']:
  q.execute('SELECT id,work_order_id,task_id FROM `'+t+'` WHERE deleted=0 AND (work_order_id IS NOT NULL AND work_order_id<>0 OR task_id IS NOT NULL AND task_id<>0)');s[t]=q.fetchall()
 for t in ['crm_permission','crm_follow_up_record']:
  q.execute('SELECT biz_type,COUNT(*) n FROM `'+t+'` WHERE deleted=0 AND biz_type IN (5,9) GROUP BY biz_type');s[t]=q.fetchall()
 for t in ['storage_attachment','system_storage_attachment']:
  q.execute('SELECT record_type,COUNT(*) n FROM `'+t+'` WHERE deleted=0 GROUP BY record_type');s[t]=q.fetchall()
 for t in ['mes_wm_product_issue','mes_wm_product_issue_line','mes_wm_return_issue','mes_wm_return_issue_line','mes_wm_item_consume','mes_wm_product_produce']:
  q.execute('SHOW COLUMNS FROM `'+t+'`');cols=[r['Field'] for r in q.fetchall()]
  q.execute('SELECT COUNT(*) n FROM `'+t+'` WHERE deleted=0');s[t]={'count':q.fetchone()['n'],'columns':cols}
print(json.dumps(s,ensure_ascii=False,default=str));(P/'sales-production-delete-dependencies.json').write_text(json.dumps(s,ensure_ascii=False,default=str,indent=2),encoding='utf8')
c.close()