Commit 270ffbc7 authored by rico.liu's avatar rico.liu

update

parent 2d551df8
......@@ -1436,26 +1436,29 @@ def create_to_db(path,std_value_dict):
for index,row in new_df.iterrows():
id_ = str(row['id'])
brand = row['zi_brandname'].strip()
brand = str(row['zi_brandname'].strip())
brandcode = row['zi_brandcode'] # 建库需要的品牌编码
#创建SPU 获取SPUid
cursor_zi_new.execute(f"select pid from p_brand where id = {brandcode}")
father_brand_code = cursor_zi_new.fetchone()[0]
for spu_param in cat_subtitle_df[cat_subtitle_df['skuorspu'] == 'spu'].sort_values("Expr1")['subtitle'].tolist():
#创建SPU 获取SPUid
if category == '复印纸':
if '彩色' in row['产品系列']:
spu_brandname = brand
name = brand
else:
if father_brand_code == 0:
spu_brandname = brand
name = brand
else:
cursor_zi_new.execute(f"select name from p_brand where id = {father_brand_code}")
father_brand = cursor_zi_new.fetchone()[0].strip()
spu_brandname = father_brand
name = str(father_brand)
else:
spu_brandname = brand
name = str(spu_brandname)
name = brand
for spu_param in cat_subtitle_df[cat_subtitle_df['skuorspu'] == 'spu'].sort_values("Expr1")['subtitle'].tolist():
if spu_param == '产品品牌':
continue
else:
......
......@@ -10,8 +10,8 @@ from Excel数据处理func import *
path = r'E:\work\刘晓琦代码\客户数据处理(调接口)\原始客户数据\泰康人寿TKRS\20210315\泰康入库模板.xlsx'
channel_alias = 'TKRS'
batch = '2021-03-15'
channel_alias = 'AH'
batch = '2021-03-31'
#初始化数据
InitializeData(path,channel_alias)
......
......@@ -153,7 +153,8 @@ def LoadData(batch,channel_alias,mode):
#SKU排重
def SkuMatch(df,channel_alias,engine):
engine = 'SQL'
channel_alias = 'AH'
#创建数据库链接
mssql = MSSQL('123.57.45.119','ZI_Service')
cursor_zi_service = mssql._cur
......@@ -731,8 +732,10 @@ def GetPointCategoryDataDetail(df,channel_alias,batch):
else:
for requier_param,requier_param_var in zip(requier_param_list,requier_param_var_list):
try:
exec("%s_list.append('%s')"%(requier_param_var,params_standard[requier_param]))
except:
exec("%s_list.append('%s')"%(requier_param_var,'暂无数据'))
for requier_param,requier_param_var in zip(requier_param_list,requier_param_var_list):
......@@ -1561,26 +1564,29 @@ def create_to_db(path,std_value_dict):
for index,row in new_df.iterrows():
id_ = str(row['id'])
brand = row['zi_brandname'].strip()
brand = str(row['zi_brandname'].strip())
brandcode = row['zi_brandcode'] # 建库需要的品牌编码
#创建SPU 获取SPUid
cursor_zi_new.execute(f"select pid from p_brand where id = {brandcode}")
father_brand_code = cursor_zi_new.fetchone()[0]
for spu_param in cat_subtitle_df[cat_subtitle_df['skuorspu'] == 'spu'].sort_values("Expr1")['subtitle'].tolist():
#创建SPU 获取SPUid
if category == '复印纸':
if '彩色' in row['产品系列']:
spu_brandname = brand
name = brand
else:
if father_brand_code == 0:
spu_brandname = brand
name = brand
else:
cursor_zi_new.execute(f"select name from p_brand where id = {father_brand_code}")
father_brand = cursor_zi_new.fetchone()[0].strip()
spu_brandname = father_brand
name = str(father_brand)
else:
spu_brandname = brand
name = str(spu_brandname)
name = brand
for spu_param in cat_subtitle_df[cat_subtitle_df['skuorspu'] == 'spu'].sort_values("Expr1")['subtitle'].tolist():
if spu_param == '产品品牌':
continue
else:
......
......@@ -345,9 +345,12 @@ def stock_in_product(zi_brandname_list,zi_brandcode_list,zi_subcategoryname,zi_s
for brand,brandcode,cat,catcode,params,newname in zip(zi_brandname_list,zi_brandcode_list,zi_subcategoryname,zi_subcategorycode,std_params_list,newname_list):
brand = brand.strip()
brand = str(brand.strip())
brandcode = brandcode
cursor_zi_new.execute(f"select pid from p_brand where id = {brandcode}")
father_brand_code = cursor_zi_new.fetchone()[0]
if "新建品牌:" in brand:
create_brand = brand.replace("新建品牌:","")
res = stock_in_brand([create_brand])
......@@ -361,22 +364,22 @@ def stock_in_product(zi_brandname_list,zi_brandcode_list,zi_subcategoryname,zi_s
#创建SPU 获取SPUid
for spu_param in cat_subtitle_df[cat_subtitle_df['skuorspu'] == 'spu'].sort_values("Expr1")['subtitle'].tolist():
if category == '复印纸':
if '彩色' in row['产品系列']:
spu_brandname = brand
if '彩色' in params['产品系列']:
name = brand
else:
if father_brand_code == 0:
spu_brandname = brand
name = brand
else:
cursor_zi_new.execute(f"select name from p_brand where id = {father_brand_code}")
father_brand = cursor_zi_new.fetchone()[0].strip()
spu_brandname = father_brand
name = str(father_brand)
else:
spu_brandname = brand
name = str(spu_brandname)
name = brand
for spu_param in cat_subtitle_df[cat_subtitle_df['skuorspu'] == 'spu'].sort_values("Expr1")['subtitle'].tolist():
if spu_param == '产品品牌':
continue
else:
......@@ -1047,7 +1050,7 @@ def stock_in_attr_relationship(channel,categoryname_list,subtitle_list,outsubtit
for cat,subtitle,outsubtitle in zip(categoryname_list,subtitle_list,outsubtitle_list):
cursor_zi_new.execute(f"select id from Product_Relation_Attribute_Subtitle where ZI_SubCategoryCode = '{cat}' and ZI_SubTitle = '{subtitle}' and Other_SubTitle = '{outsubtitle}' and Source = '{channel}'")
cursor_zi_new.execute(f"select Index_ID from Product_Relation_Attribute_Subtitle where ZI_SubCategoryCode = '{cat}' and ZI_SubTitle = '{subtitle}' and Other_SubTitle = '{outsubtitle}' and Source = '{channel}'")
data = cursor_zi_new.fetchall()
check_df = pd.DataFrame(data, columns=[tuple[0] for tuple in cursor_zi_new.description])
if check_df.empty:
......
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