# -*- coding: utf-8 -*- """restore-collab-owner.py — collab 协同样例 owner 四字段还原(票 04 还原实录同款,F-13 圈定副作用) 期望态(票 04):owner=曾偲青(744842318024015872) / 部门=职员(744841292483133440) archive_status=1(seed 有意归档的第 17 个样例,不还原归档位) """ import io, sys, pymysql sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') COLLAB = '750844482391375872' 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 owner_user_id o, owner_user_name_snapshot onm, owner_dept_id od, " "owner_dept_name_snapshot odn FROM customer WHERE id=%s", (COLLAB,)) before = cur.fetchone() print('before:', {k: str(v) for k, v in before.items()}) cur.execute("UPDATE customer SET owner_user_id=744842318024015872, " "owner_user_name_snapshot='曾偲青', owner_dept_id=744841292483133440, " "owner_dept_name_snapshot='职员' WHERE id=%s", (COLLAB,)) print('updated rows =', cur.rowcount) cur.execute("SELECT owner_user_id o, owner_user_name_snapshot onm, owner_dept_id od, " "owner_dept_name_snapshot odn, archive_status ar FROM customer WHERE id=%s", (COLLAB,)) after = cur.fetchone() print('after :', {k: str(v) for k, v in after.items()}) ok = (str(after['o']) == '744842318024015872' and after['onm'] == '曾偲青' and str(after['od']) == '744841292483133440' and after['odn'] == '职员') print('RESTORE', 'OK ✅' if ok else 'MISMATCH ❌')