import pandas as pd
from datetime import datetime
df = pd.read_excel('法人客户联系人信息单独刷入.xlsx')
current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
levels = {
"总经理": "GENERAL_MANAGER",
"副总裁": "VICE_PRESIDENT",
"总监": "DIRECTOR",
"部门经理": "THE_DEPARTMENT_MANAGER",
"员工": "EMPLOYEE"
}
types = {
"MDM0701": "BUSINESS",
"MDM0702": "DELIVERY",
"MDM0703": "QUALITY",
"MDM0705": "INFORMATION_SECURITY_INTERFACE_PERSON",
"MDM0707": "RECEIVER",
"MDM0706": "FINANCIAL",
"MDM0708": "TECHNOLOGY",
"MDM0704": "CSR"
}
with open("lianxiren.sql", 'w', encoding='utf-8') as file:
for index, row in df.iterrows():
customerCode = row['客户编码']
nodeCode = row['节点编码']
name = row['联系人姓名']
type = row['联系人类型']
level = row['联系人级别']
phoneNumber = row['联系人电话']
email = row['联系人邮箱']
abbreviationCode = row['法人简码']
update_sql = f"""UPDATE `customer`.`corporate_customer` SET update_time = '{current_time}',update_by = 'script',
contacts = '[{{"name":"{name}","type":"{types[type]}","level":"{levels[level]}","abbreviationCode":"{abbreviationCode}"
"code":"{nodeCode}","phoneNumber":"{phoneNumber}","email":"{email}","enable":true,"defaultContact":false}}]'
WHERE code = '{customerCode}' and deleted = 0;"""
print(update_sql)
file.write(update_sql + '\n')