gaoluyang
2026-10-15 e40a608ef9bf51db294d8eefada6a8e2e80cebca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import sys,json
from pathlib import Path
from collections import Counter
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)
s={}
with c.cursor() as q:
 q.execute("SELECT table_name FROM information_schema.tables WHERE table_schema=DATABASE() AND table_name LIKE 'mes_dv_%'");ts=[x['TABLE_NAME'] for x in q.fetchall()]
 for t in ts:
  q.execute('SHOW CREATE TABLE '+t);ddl=q.fetchone()['Create Table'];q.execute('SELECT * FROM '+t+' WHERE deleted=0 ORDER BY id');rows=q.fetchall();s[t]={'ddl':ddl,'rows':rows}
  if 'record' in t or t=='mes_dv_check_plan':
   print(ddl);print('记录数量',len(rows),'样例',json.dumps(rows[:2],ensure_ascii=False,default=str))
   if t in ['mes_dv_check_record','mes_dv_mainten_record']:
    f='check_time' if 'check_record' in t else 'mainten_time';selected=[x for x in rows if x[f] is not None and x[f].strftime('%Y-%m-%d')>='2026-10-01' and x[f].strftime('%Y-%m-%d')<='2026-10-07'];print('国庆记录',len(selected),Counter(x['status'] for x in selected))
 q.execute("SELECT dict_type,value,label FROM system_dict_data WHERE deleted=0 AND (dict_type LIKE '%check_record_status%' OR dict_type LIKE '%mainten_record_status%')");print('状态字典',q.fetchall())
(P/'before.json').write_text(json.dumps(s,ensure_ascii=False,default=str,indent=2),encoding='utf8')
c.close()