Commit 4178386f authored by sanlu's avatar sanlu

微调

parent f66a0059
......@@ -136,7 +136,10 @@ def param_extract_function(data_table,channel):
product_param_dict['产品型号'] = producttype
name_param_dict = model.param_extract(name)#名称提取参数项
if categorycode in crawl_category_list:
try:
crawl_param_dict = crawler.crawl_zol(producttype)
except TypeError:
crawl_param_dict = {}
else:
crawl_param_dict = {}
for param_key_name in name_param_dict.keys():
......@@ -221,7 +224,10 @@ def param_extract_function(data_table,channel):
if '产品型号' not in product_param_dict.keys():
product_param_dict['产品型号'] = producttype
if categorycode in crawl_category_list:
try:
crawl_param_dict = crawler.crawl_zol(producttype)
except TypeError:
crawl_param_dict = {}
else:
crawl_param_dict = {}
for param_key_ori in product_param_dict.keys():
......@@ -265,13 +271,14 @@ def param_extract_function(data_table,channel):
update_table['subcategorycode'].append(categorycode)#
update_table_df = pd.DataFrame.from_dict(update_table)
update_table_df.to_excel('update_data_test.xlsx')
update_table_df.to_excel(f'data_upload_history/product_parameter_process_{now_time}_{channel}.xlsx')
product_table.to_excel(f'data_upload_history/product_api_data_{now_time}_{channel}.xlsx')
update_table_df.to_sql('Product_Parameter_Process', sql_ZIdatabase.engine, if_exists='append', index=False)
product_table.to_sql('Product_Api_Data', sql_ZIdatabase.engine, if_exists='append', index=False)
update_sku_list = set(list(product_table['SKU']))
channel_sql = sql_find(database=f'ZH_{channel}')
update_sku_list = set(list(product_table['productId']))
channel_sql = sql_find(database=f'ZH_{channel}',localhost=False)
for sku in update_sku_list:
channel_sql.cursor.execute(f"update product_all set state='9' where sku='{sku}'")
channel_sql.cursor.execute(f"update product_all set state='9' where sku='{sku}' and state='8'")
return update_table_df
def return_error(table):
......@@ -576,7 +583,7 @@ class data_fetch():
data_table.to_excel(f'data/{StyleTime}_step3_needs_check/{self.source}_data_category_data_{StyleTime}.xlsx',index=False)#有子类对应需要确认的表,张力才下这个。
return_error(no_category_table)
sql_zi_zh = sql_find('zi_zh', False)
sql_zi_zh.cursor(f"insert into filestep(period,step,initfilename,filepath) values('{StyleTime}','3','{self.source}_data_category_data_{StyleTime}.xlsx','/root/program/newProductCheck/online_progrom/code/data/{StyleTime}_step3_needs_check')")#存入数据库,页面获取下载。
sql_zi_zh.cursor(f"insert into filestep(period,step,initfilename,filepath) values('{StyleTime}','7','{self.source}_data_category_data_{StyleTime}.xlsx','/root/program/newProductCheck/online_progrom/code/data/{StyleTime}_step3_needs_check')")#存入数据库,页面获取下载。
return data_table
......@@ -604,8 +611,11 @@ if __name__ == '__main__':
thread_DW.join()
print('完毕!')
'''
channel = 'SN'
data_api = data_fetch(model='LXWL_model', localhost=False, source=f'ZH_{channel}')
data_api_table = data_api.run()
#param_extract_function(data_api_table,channel)
'''
data_api_table = pd.read_excel('ZH_SN_data_2020-01-13wbp.xlsx',converters={'SKU':str,'指数品牌编码':str,'指数子类编码':str})
channel = 'SN'
param_extract_function(data_api_table,channel)
......@@ -2,8 +2,13 @@ import pandas as pd
import time
from function import *
sql_LXWL = sql_find('ZH_DL', False)
sku = '101016853PCS'
sql_LXWL.cursor.execute(f"select zi_subcategoryname,zi_subcategorycode from product_all where sku='{sku}'")
ZI_SubCategory_data = sql_LXWL.cursor.fetchone()
print(ZI_SubCategory_data[0] is None)
\ No newline at end of file
channel_sql = sql_find(database='ZH_SN',localhost=False)
f = open('临时.txt','r',encoding='utf-8')
update_sku_list = []
for line in f:
update_sku_list.append(str(line).split('\n')[0])
m=0
for sku in update_sku_list:
m+=1
print(m,end='\r')
channel_sql.cursor.execute(f"update product_all set state='9' where sku='{sku}' and state='8'")
\ No newline at end of file
This diff is collapsed.
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