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

update

parent bf9fc047
......@@ -21,7 +21,7 @@ import datetime
#初始化数据
def InitializeData(path):
#加载上传数据
df_product = pd.read_excel(path,sheet_name = '产品表模板')
df_product = df_product.fillna('无')
......@@ -61,9 +61,10 @@ def InitializeData(path):
id_ = row['序号']
sku = "无"
category = row['类别(模糊)']
brand = row['品牌(模糊)']
name = row['名称']
category = row['指数类别']
brand = row['指数品牌']
name = row['指数名称']
model = row['型号']
channel = row['操作人']
batch = time.strftime("%Y-%m-%d",time.localtime())
......@@ -77,14 +78,14 @@ def InitializeData(path):
url_source.append(price_source_dict[url_source_element])
except:
print(f"{url_source_element}无价格系统渠道对应")
return False
return False
url_source = str(url_source)
url_price = str(df_price[df_price['序号'] == id_]['电子商城价'].tolist())
insert_data.append((sku,name,brand,category,url_price,url,url_source,url_price,channel,channel,channel,batch))
insert_data.append((sku,name,brand,category,model,url_price,url,url_source,url_price,channel,channel,channel,batch))
cursor_zi_service.executemany(f"insert into product_all (sku,name,brand,category,price,url,url_source,url_price,channel,channel_id,channel_alias,batch) \
values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",insert_data)
cursor_zi_service.executemany(f"insert into product_all (sku,name,brand,category,model,price,url,url_source,url_price,channel,channel_id,channel_alias,batch) \
values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",insert_data)
mssql.Close()
mssql_new.Close()
......@@ -122,6 +123,47 @@ def LoadData(batch,channel_alias,mode):
mssql.Close()
return df
#获取其他建库信息(品牌编码,类别编码,产品名称)
def GetOtherProductInfo(df):
mssql_new = MSSQL('123.56.115.207','ZI_NEW')
cursor_zi_new = mssql_new._cur
mssql = MSSQL('123.57.45.119','ZI_Service')
cursor_zi_service = mssql._cur
#实例化进度条
index_ = Index()
counter = 1
print("开始获取其他建库信息(品牌编码,类别编码,产品名称)")
for index,row in df.iterrows():
try:
print(index_(counter, len(df)-1), end='%')
except:
print(index_(counter, 1), end='%')
counter += 1
id_ = row['id']
new_name = row['name']
zi_brandname = row['brand']
zi_subcategoryname = row['category']
cursor_zi_new.execute(f"select id from p_category where id not in (select distinct pid from p_category) and name = '{zi_subcategoryname}'")
zi_subcategorycode = cursor_zi_new.fetchone()[0]
cursor_zi_new.execute(f"select id from p_brand where id not in (select distinct pid from p_brand) and name = '{zi_brandname}'")
zi_brandcode = cursor_zi_new.fetchone()[0]
cursor_zi_service.execute(f"update product_all set new_name = '{new_name}',zi_brandname = '{zi_brandname}',zi_brandcode = 'zi_brandcode{}', \
zi_subcategoryname = '{zi_subcategoryname}',zi_subcategorycode = '{zi_subcategorycode}' where id = {id_}")
mssql_new.Close()
mssql.Close()
#分析获取数据基本信息
def AnalyseBasicInfo(df):
......@@ -601,7 +643,7 @@ def GetCollectDataDetail(df,channel_alias,batch):
export_df['zi_subcategoryname'] = zi_subcategoryname_list
export_df['param'] = param_list
export_df['value'] = value_list
export_df['new_name'] = new_name_list
#export_df['new_name'] = new_name_list
category = category.replace('/','_')
export_df.to_excel(writer,f"{category}参数数据")
......@@ -626,7 +668,8 @@ def CheckParamsData(path):
#加载库中参数项数据
cursor_zi_new.execute("select * from vw_property")
db_params = pd.DataFrame(cursor_zi_new.fetchall(), columns=[tuple[0] for tuple in cursor_zi_new.description])
db_params = db_params[db_params['identy'] != '0000']
db_params['standard_param'] = db_params['identy'].apply(lambda x: x[2])
db_params = db_params[db_params['standard_param'] != '0']
db_params['subtitle'] = db_params['subtitle'].apply(lambda x: x.strip())
......@@ -1989,18 +2032,21 @@ def upload_pic(pic_batch):
#建库模板路径
path = '/Users/rico/project/模板建库v2/历史数据/20201231_sxlq_nomatch/建库模板.xlsx'
path = '/Users/rico/project/模板建库v2/历史数据/20210311相机/相机建库模板3.11-何丽娟.xlsx'
#初始化数据
InitializeData(path)
#初始化参数
channel_alias = 'MBJK-LXQ'
batch = '2020-12-31'
channel_alias = 'HLJ-CZBJK'
batch = '2021-03-11'
#加载数据
df = LoadData(batch,channel_alias,'deal')
#获取其他建库信息(品牌编码,类别编码,产品名称)
GetOtherProductInfo(df)
'''
#分析获取数据基本信息(品牌,类别,型号)
AnalyseBasicInfo(df)
......@@ -2008,9 +2054,9 @@ AnalyseBasicInfo(df)
ExportToExcelBasicConfirm(batch,channel_alias)
#返回数据并更新
path = "/Users/rico/project/模板建库v2/历史数据/20201231_sxlq_nomatch/MBJK-LXQ基础信息确认2020-12-31.xlsx"
path = "/Users/rico/project/模板建库v2/历史数据/20210311相机/HLJ-CZBJK基础信息确认2021-03-11.xlsx"
UpdateBasicData(path)
'''
#获取建库数据
df = GetCollectData(batch,channel_alias)
......@@ -2022,7 +2068,7 @@ GetCollectDataDetail(df_crawled,channel_alias,batch)
#处理建库数据
path = "/Users/rico/project/模板建库v2/MBJK-LXQ建库产品参数确认2020-12-31.xlsx"
path = "/Users/rico/Downloads/HLJ-CDJK建库产品参数确认2021-01-21(1).xlsx"
##校验参数数据
std_value_dict = CheckParamsData(path)
......@@ -2041,7 +2087,7 @@ df = LoadData(batch,channel_alias,'collectDataConfirm')
df.to_excel(f"{channel_alias}建库信息确认{batch}.xlsx")
#建库信息结果确认更新
path = '/Users/rico/Downloads/tjx-mbjk建库信息确认2021-01-04(1).xlsx'
path = '/Users/rico/Downloads/CL-MBJK建库信息确认2021-01-28(1).xlsx'
UpdateCollectDataConfirm(path)
#产品建库,价格入库
......@@ -2056,5 +2102,3 @@ print(f"请处理{batch}批次的图片数据,有问题的图片直接删除
pic_batch = batch + "-1"
upload_pic(pic_batch)
\ 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