Commit 1241ae1d authored by Jialin's avatar Jialin

代码更新

parent 46cdf40a
......@@ -13,7 +13,7 @@ import os
def duplicate_product_update(filepath,sheet_name=0):
df=pd.read_excel(filepath,sheet_name=sheet_name,converters={'产品编码': str})
df=pd.read_excel(filepath,sheet_name=sheet_name,converters={'产品编码': str, '正确产品编码':str, '产品名称': str, '正确产品名称':str})
conn_zi_new=pymssql.connect(host='123.56.115.207', user='zgcprice3311', password='zgcprice20200628', database='ZI_NEW', autocommit=True)
cursor_zi_new=conn_zi_new.cursor()
conn_zi_test=pymssql.connect(host='123.56.115.207', user='zgcprice3311', password='zgcprice20200628',
......@@ -31,13 +31,20 @@ def duplicate_product_update(filepath,sheet_name=0):
logname = f"{folderpath}/重复产品更新{timestr}.txt"
with open(f"{logname}", 'w', encoding='utf-8') as f:
for index,row in df.iterrows():
print(f"index:{index}",file=f)
if type(row['正确产品编码']) == float:
continue
product_id=row['产品编码']
product_id_correct=row['正确产品编码']
product_name_correct=row['正确产品名称'] # .split('(')[0].strip()
product_name = row['产品名称']
product_name_correct = row['正确产品名称']
if product_id == product_id_correct and product_name==product_name_correct:
continue
print(f"index:{index}", file=f)
cursor_zi_new.execute(f"update p_sku set state=6, skuname='{product_name_correct}' where sku='{product_id}' ")
print(f" if successful: p_sku表,sku编码为'{product_id}'的数据,state被改为6,skuname被改为'{product_name_correct}'", file=f)
product_name_repeated = product_name_correct + f"(sku:{product_id};重复sku:{product_id_correct})"
cursor_zi_new.execute(f"update p_sku set state=6, skuname='{product_name_repeated}' where sku='{product_id}' ")
print(f" if successful: p_sku表,sku编码为'{product_id}'的数据,state被改为6,skuname被改为'{product_name_repeated}'", file=f)
cursor_zi_new.execute(f"update Productcode_Sku set sku='{product_id_correct}' where sku='{product_id}' ")
print(f" if successful: Productcode_Sku表,sku编码为'{product_id}'的数据,sku被改为'{product_id_correct}'", file=f)
cursor_zdindex.execute("select top 1 max(periods) from zd_electricity_price")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment