You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
1.3 KiB
25 lines
1.3 KiB
|
21 hours ago
|
# -*- coding: utf-8 -*-
|
||
|
|
"""diag-collab.py — seed 中 collab 样例期望态 + 部门名快照核对"""
|
||
|
|
import io, sys, json, pymysql
|
||
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
||
|
|
|
||
|
|
ids = json.load(open('.scratch/customer-e2e/seed-ids.json', encoding='utf-8'))
|
||
|
|
print('customer keys:', list(ids.get('customers', {}).keys()))
|
||
|
|
for k, v in ids.get('customers', {}).items():
|
||
|
|
if str(v.get('id')) == '750844482391375872' or 'collab' in k or '协同' in str(v.get('name', '')):
|
||
|
|
print(f'seed[{k}] =', json.dumps(v, ensure_ascii=False))
|
||
|
|
|
||
|
|
conn = pymysql.connect(host='8.129.84.155', port=3306, user='root', password='Itc@123456',
|
||
|
|
database='crm', charset='utf8mb4', autocommit=True,
|
||
|
|
connect_timeout=10, cursorclass=pymysql.cursors.DictCursor)
|
||
|
|
with conn.cursor() as cur:
|
||
|
|
cur.execute("SELECT id, dept_name, parent_id, ancestors FROM sys_dept "
|
||
|
|
"WHERE id IN ('744841292483133440','744841292348915712')")
|
||
|
|
for r in cur.fetchall():
|
||
|
|
print('dept:', r['id'], r['dept_name'], 'parent=', r['parent_id'])
|
||
|
|
cur.execute("SELECT id, dept_name FROM sys_dept WHERE ancestors LIKE %s LIMIT 5",
|
||
|
|
('%744841292348915712%',))
|
||
|
|
print('本部子树样例 5:')
|
||
|
|
for r in cur.fetchall():
|
||
|
|
print(' ', r['id'], r['dept_name'])
|