1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| import sys,json
| from pathlib import Path
| P=Path(__file__).parent
| sys.stdout.reconfigure(encoding='utf8')
| 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)
| with c.cursor() as q:
| q.execute('SELECT NOW() now');now=q.fetchone()['now'];summary=[];snapshot={}
| for t,f in [('crm_sale_quotation','quotation_time'),('crm_contract','order_date'),('erp_sale_order','order_time'),('crm_invoice','invoice_time'),('crm_receivable','return_time'),('crm_receivable_plan','return_time'),('crm_business','deal_time')]:
| q.execute('SELECT * FROM '+t+' WHERE deleted=0 ORDER BY id');rs=q.fetchall();snapshot[t]=rs
| dates=[r[f] for r in rs if r[f]]
| summary.append({'table':t,'field':f,'active':len(rs),'has_date':len(dates),'different':sum(r[f] is not None and r[f]!=r['create_time'] for r in rs),'future_dates':sum(d>now for d in dates),'earliest':min(dates) if dates else None,'latest':max(dates) if dates else None})
| for t in ['crm_contract_product','crm_sale_quotation_product','erp_sale_order_items']:
| q.execute('SELECT * FROM '+t+' WHERE deleted=0 ORDER BY id');snapshot[t]=q.fetchall()
| (P/'business-date-preview.json').write_text(json.dumps({'now':now,'summary':summary,'tables':snapshot},ensure_ascii=False,default=str,indent=2),encoding='utf8')
| print(json.dumps(summary,ensure_ascii=False,default=str))
| c.close()
|
|