刷核销机制

# 读取Excel文件的第一列内容
import pandas as pd
from datetime import datetime
import random

# 读取 Excel 文件
df = pd.read_excel('法人客户核销机制单独刷入20241228.xlsx')

# 生成十八位随机纯数字字符串
def generate_random_number_string(length):
    # 生成随机数字字符串
    random_string = ''.join([str(random.randint(1, 9)) for _ in range(length)])
    return random_string

# 调用函数生成18位随机纯数字字符串
current_id = generate_random_number_string(18)

# 生成当前时间
current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')

customers = []

with open("hexiaojizhi.sql", 'w', encoding='utf-8') as file:
    print("select * from `customer`.`corporate_customer_ou_bank_info` where corporate_customer_id in "
          "( select id from `customer`.`corporate_customer` WHERE deleted = 0 and code in (")
    for index, row in df.iterrows():
        customerCode = row['客户编码']
        ouCode = row['OU代码']
        verification_mechanism = row['核销机制']  # FIRST_IN_FIRST_OUT  VERIFY_BY_ORDER

        if customerCode in customers:
            continue
        else:
            corporate_customer_change_request_id = current_id

            # 生成插入 SQL 语句,并使用当前的唯一递增 ID
            insert_sql = f"""INSERT INTO `customer`.`corporate_customer_change_request` 
            (`id`, `corporate_customer_id`, `code`, `full_name`, `type`, `legal_representative_name`, 
            `legal_representative_identity_number`, `legal_representative_phone_number`, 
            `internal_customer`, `virtual_customer`, `certification_no`, `tax_identification_number`, 
            `india_pan_card_number`, `india_small_micro_enterprise_number`,
             `taxpayer_qualification`, `listed`, `cooperation_status`, `change_request_status`, `duns_number`,
              `country`, `country_id`, `registered_address`, `registered_capital`, `establishment_date`, 
              `business_start_date`, `business_end_date`, `business_scope`, `vat_number`, `eu_business_customer_classification`, 
              `remark`, `contacts`, `attachments`, `payment_banks`, `receiver_banks`, `associated`,
               `ous`, `payment_terms_id`, `bill_to_addresses`, `create_time`, `update_time`, `suggestion`, 
               `create_by`, `update_by`, `delete_time`, `deleted`, `invoice_address`, `invoice_bank`, `province`, 
               `province_id`, `change_request_type`, `quit_reason`, `related_business_customer_ids`, 
               `case_no`, `upload_attachments`, `business_line_type`) 
               VALUES ('{corporate_customer_change_request_id}', (SELECT id FROM `customer`.`corporate_customer` WHERE code = '{customerCode}' and deleted = 0), 
               '', '', 'STATE_OWNED', NULL, NULL, NULL, b'0', b'0', '', NULL, NULL, NULL, NULL, b'0', 'NORMAL', 'PASSED', NULL, '', '', '', 
               NULL, '{current_time}', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, b'0', '',
                NULL, NULL, '{current_time}', '{current_time}', '', 'W9090316', 'W9090316', NULL, b'0', NULL, 
                NULL, NULL, NULL, 'CREATE_OR_UPDATE', NULL, NULL, NULL, NULL, NULL);"""

            print("\"" + str(customerCode) + "\",")
            customers.append(customerCode)
            file.write(insert_sql + '\n')  # 将 SQL 语句写入文件,每条 SQL 语句换行

        # 生成插入 SQL 语句,并使用当前的唯一递增 ID
        insert_sql = f"""INSERT INTO `customer`.`corporate_customer_ou_bank_info`
               (`id`, `corporate_customer_id`, `corporate_customer_change_request_id`, `ou_id`, `ou_code`, `verification_mechanism`, `create_time`, `create_by`, `update_time`, `update_by`, `deleted`) 
               VALUES 
               ('{current_id}',  (SELECT id FROM `customer`.`corporate_customer` WHERE code = '{customerCode}' and deleted = 0), 
               '{corporate_customer_change_request_id}', (SELECT ou_id FROM `base`.`t_ou` WHERE ou_name = '{ouCode}'),
               '{ouCode}', '{verification_mechanism}', '{current_time}', 'xxxxx', '{current_time}', 'xxxxx', 0);"""

        current_id = str(int(current_id) + 1)


    print("\"\"));")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值