Commit d206e0f2 authored by rico.liu's avatar rico.liu

update

parent 6a1ed07e
......@@ -77,6 +77,8 @@ def dael_name_content(skuname,brand):
def upload_params_data(category,path,record_code_list):
print("初始化。。。")
df = pd.read_excel(path,converters = {'产品编码':str})
#创建新产品库链接
try:
......@@ -129,6 +131,12 @@ def upload_params_data(category,path,record_code_list):
data_dict['stdvalue'] = data_dict['stdvalue'].apply(lambda x : x.upper())
single_data_dict = data_dict
#获取品牌
cursor_zi_new.execute(f"select id,name,pid from p_brand where id not in (select distinct pid from p_brand)")
brand_df = pd.DataFrame(cursor_zi_new.fetchall(), columns=[tuple[0] for tuple in cursor_zi_new.description])
#去掉*标识
current_list = df.columns.tolist()
update_list = [col[1:] if col[0] == '*' else col for col in current_list]
......@@ -138,6 +146,8 @@ def upload_params_data(category,path,record_code_list):
process_index = 0
index_ = Index()
print("初始化完成")
#SPU、SKU命名
for index,row in df.iterrows():
try:
......@@ -149,8 +159,7 @@ def upload_params_data(category,path,record_code_list):
sku = row['产品编码']
brandname = row['产品品牌']
try:
cursor_zi_new.execute(f"select id from p_brand where name = '{brandname}' and id not in (select distinct pid from p_brand)")
brand_code = cursor_zi_new.fetchone()[0]
brand_code = brand_df[brand_df['name'] == brandname]['id'].tolist()[0]
except:
print(f"异常品牌: {brandname},请检查产品品牌表")
break
......@@ -158,9 +167,7 @@ def upload_params_data(category,path,record_code_list):
if sku in record_code_list:
continue
cursor_zi_new.execute(f"select pid from p_brand where id = {brand_code}")
father_brand_code = cursor_zi_new.fetchone()[0]
father_brand_code = brand_df[brand_df['id'] == brand_code]['pid'].tolist()[0]
#cursor_zi_new.execute(f"select id,spuid from p_sku where sku = '{sku}'")
searchsku_df = sku_df[sku_df['sku'] == sku][['id']]
......@@ -184,8 +191,7 @@ def upload_params_data(category,path,record_code_list):
spu_brandname = brandname
else:
try:
cursor_zi_new.execute(f"select name from p_brand where id = {father_brand_code}")
father_brand = cursor_zi_new.fetchone()[0].strip()
father_brand = brand_df[brand_df['id'] == father_brand_code]['name'].tolist()[0]
except:
print(f"{brandname},异常品牌编码: {father_brand_code},请检查产品品牌表")
break
......@@ -234,7 +240,16 @@ def upload_params_data(category,path,record_code_list):
cursor_zi_new.execute(f"update p_sku set spuid = '{spuid}' where id = '{skuid}'")
params = dict(zip(subtitle_list,[row[subtitle] for subtitle in subtitle_list]))
#params = dict(zip(subtitle_list,[row[subtitle] for subtitle in subtitle_list]))
params = {}
for subtitle in subtitle_list:
try:
value = row[subtitle]
except:
continue
params.update({subtitle:value})
for key in list(params.keys()):
if params[key] == '无参数,需补充':
params.pop(key)
......@@ -265,8 +280,7 @@ def upload_params_data(category,path,record_code_list):
if father_brand_code == 0:
value = brandname
else:
cursor_zi_new.execute(f"select name from p_brand where id = {father_brand_code}")
father_brand = cursor_zi_new.fetchone()[0].strip()
father_brand = brand_df[brand_df['id'] == father_brand_code]['name'].tolist()[0]
value = father_brand
value = value.replace("FATHER","")
else:
......@@ -443,9 +457,11 @@ def upload_params_data(category,path,record_code_list):
for subtitle in subtitle_list:
value = str(row[subtitle]).strip().upper()
if value == '无参数,需补充':
try:
value = str(row[subtitle]).strip().upper()
except:
continue
if value == '无参数,需补充' or value == '无参数,需补充' or value == '暂无数据':
continue
subtitleid = subtitle_id_dict[subtitle]
......@@ -626,8 +642,8 @@ def check_configure_price(category,path,params_list):
category = '碎纸机'
path = '/Users/rico/WorkSpace/1_Project/Company/中电中采/4_中电商品库功能类/更新库内参数并重新命名/碎纸机参数确认(校验通过).xlsx'
category = '多功能一体机'
path = '/Users/rico/Downloads/多功能一体机参数确认2021-12-24(1)(1)(校验通过).xlsx'
record_code_list = []
flag,return_record_code_list = upload_params_data(category,path,record_code_list)
......
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