Commit 5adb0e1f authored by rico.liu's avatar rico.liu

add while

parent 102318a3
...@@ -75,7 +75,7 @@ def dael_name_content(skuname,brand): ...@@ -75,7 +75,7 @@ def dael_name_content(skuname,brand):
return res.strip() return res.strip()
def upload_params_data(category,path): def upload_params_data(category,path,record_code_list):
df = pd.read_excel(path,converters = {'产品编码':str}) df = pd.read_excel(path,converters = {'产品编码':str})
...@@ -133,6 +133,8 @@ def upload_params_data(category,path): ...@@ -133,6 +133,8 @@ def upload_params_data(category,path):
process_index = 0 process_index = 0
index_ = Index() index_ = Index()
#SPU、SKU命名 #SPU、SKU命名
for index,row in df.iterrows(): for index,row in df.iterrows():
try: try:
...@@ -141,6 +143,9 @@ def upload_params_data(category,path): ...@@ -141,6 +143,9 @@ def upload_params_data(category,path):
print(index_(process_index,1), end='%') print(index_(process_index,1), end='%')
process_index+=1 process_index+=1
try:
sku = row['产品编码'] sku = row['产品编码']
brandname = row['产品品牌'] brandname = row['产品品牌']
try: try:
...@@ -150,6 +155,8 @@ def upload_params_data(category,path): ...@@ -150,6 +155,8 @@ def upload_params_data(category,path):
print(f"异常品牌: {brandname},请检查产品品牌表") print(f"异常品牌: {brandname},请检查产品品牌表")
break break
if sku in record_code_list:
continue
cursor_zi_new.execute(f"select pid from p_brand where id = {brand_code}") 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 = cursor_zi_new.fetchone()[0]
...@@ -477,9 +484,14 @@ def upload_params_data(category,path): ...@@ -477,9 +484,14 @@ def upload_params_data(category,path):
check_df = pd.DataFrame(data, columns=[tuple[0] for tuple in cursor_zi_new.description]) check_df = pd.DataFrame(data, columns=[tuple[0] for tuple in cursor_zi_new.description])
if check_df.empty: if check_df.empty:
cursor_zi_new.execute(f"insert into p_valuemap (spuid,valueid) values ({spuid}, {valueid})") cursor_zi_new.execute(f"insert into p_valuemap (spuid,valueid) values ({spuid}, {valueid})")
record_code_list.append(sku)
except:
print("处理异常请重跑")
return False,record_code_list
conn_zi_new.close() conn_zi_new.close()
print(f"{category}参数数据更新完成,命名完成") print(f"{category}参数数据更新完成,命名完成")
return True,record_code_list
def get_configure_price(): def get_configure_price():
#获取配件价格 #获取配件价格
...@@ -566,8 +578,15 @@ def check_configure_price(category,path,params_list): ...@@ -566,8 +578,15 @@ def check_configure_price(category,path,params_list):
category = '复印纸' category = '复印纸'
path = '/Users/rico/WorkSpace/1_Project/Company/中电中采/4_中电商品库功能类/更新库内参数并重新命名/复印纸参数确认(校验通过).xlsx' path = '/Users/rico/WorkSpace/1_Project/Company/中电中采/4_中电商品库功能类/更新库内参数并重新命名/复印纸参数确认(校验通过).xlsx'
record_code_list = []
flag,return_record_code_list = upload_params_data(category,path,record_code_list)
while not flag:
flag,return_record_code_list = upload_params_data(category,path,return_record_code_list)
upload_params_data(category,path)
#params_list = ['CPU型号', '产品子系列', '产品系列', '内存容量', '固态硬盘容量', '屏幕尺寸', '操作系统', '显存容量', '机械硬盘容量', '质保时间'] #params_list = ['CPU型号', '产品子系列', '产品系列', '内存容量', '固态硬盘容量', '屏幕尺寸', '操作系统', '显存容量', '机械硬盘容量', '质保时间']
#check_configure_price(category,path,params_list) #check_configure_price(category,path,params_list)
\ No newline at end of file
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