Commit fe6dac33 authored by sanlu's avatar sanlu

添加了返回错误类产品到回馈表中和进入页面数据置9的功能

parent b09a5e32
This diff is collapsed.
...@@ -255,8 +255,29 @@ def param_extract_function(data_table,channel): ...@@ -255,8 +255,29 @@ def param_extract_function(data_table,channel):
update_table_df.to_excel('update_data_test.xlsx') update_table_df.to_excel('update_data_test.xlsx')
update_table_df.to_sql('Product_Parameter_Process', sql_ZIdatabase.engine, if_exists='append', index=False) 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) 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}')
for sku in update_sku_list:
channel_sql.cursor.execute(f"update product_all set state='9' where sku={sku}")
return update_table_df return update_table_df
def return_error(table):
sql_zi_zh = sql_find('zi_zh', False)
NowTime = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())
#table = pd.read_excel('api_data/ZH_SN_no_category_data_2019-12-27.xlsx', dtype = {'SKU' : str})
table = table[['SKU','产品名称','url','来源']]
l = len(table)
create_time_list = []
remark_list = []
for i in range(l):
create_time_list.append(NowTime)
remark_list.append('类别对应错误')
table['remark'] = remark_list
table['create_time'] = create_time_list
table.columns = ['sku','name','url','source','remark','create_time']
table.to_sql('API_returnErrorData', sql_zi_zh.engine, if_exists='append', index=False)
class data_fetch(): class data_fetch():
def __init__(self, model = 'LXWL_model', localhost = True, source = 'ZH_LXWL'): def __init__(self, model = 'LXWL_model', localhost = True, source = 'ZH_LXWL'):
''' '''
...@@ -384,7 +405,10 @@ class data_fetch(): ...@@ -384,7 +405,10 @@ class data_fetch():
symbol = 1 symbol = 1
self.sql_LXWL.cursor.execute(f"select price from product_price where sku='{sku}'") self.sql_LXWL.cursor.execute(f"select price from product_price where sku='{sku}'")
price = self.sql_LXWL.cursor.fetchone()[0] try:
price = self.sql_LXWL.cursor.fetchone()[0]
except TypeError:
price = decimal.Decimal(0)
data.append(price) data.append(price)
data.append(ZIname) data.append(ZIname)
...@@ -500,6 +524,7 @@ class data_fetch(): ...@@ -500,6 +524,7 @@ class data_fetch():
data_table.to_excel(f'api_data/{self.source}_data_{StyleTime}.xlsx') data_table.to_excel(f'api_data/{self.source}_data_{StyleTime}.xlsx')
no_category_table = data_table[data_table['指数子类编码'] == '没有匹配的指数子类编码'] no_category_table = data_table[data_table['指数子类编码'] == '没有匹配的指数子类编码']
no_category_table.to_excel(f'api_data/{self.source}_no_category_data_{StyleTime}.xlsx') no_category_table.to_excel(f'api_data/{self.source}_no_category_data_{StyleTime}.xlsx')
return_error(no_category_table)
data_table = data_table[data_table['指数子类编码'] != '没有匹配的指数子类编码'] data_table = data_table[data_table['指数子类编码'] != '没有匹配的指数子类编码']
#self.data_table_80 = data_table[data_table['指数子类编码'].isin(self.class_80['指数编码'].tolist())] #self.data_table_80 = data_table[data_table['指数子类编码'].isin(self.class_80['指数编码'].tolist())]
#self.data_table_80.to_excel(f'api_data/{self.source}_data_80_{StyleTime}.xlsx') #self.data_table_80.to_excel(f'api_data/{self.source}_data_80_{StyleTime}.xlsx')
...@@ -508,7 +533,7 @@ class data_fetch(): ...@@ -508,7 +533,7 @@ class data_fetch():
return data_table return data_table
if __name__ == '__main__': if __name__ == '__main__':
channel = 'OFS' channel = 'SN'
data_api = data_fetch(model='LXWL_model', localhost=False, source=f'ZH_{channel}') data_api = data_fetch(model='LXWL_model', localhost=False, source=f'ZH_{channel}')
data_api_table = data_api.run() data_api_table = data_api.run()
#param_extract_function(data_api_table,channel) #param_extract_function(data_api_table,channel)
\ No newline at end of file
from lstm_predict import LSTMNER import pandas as pd
import time
from function import *
model = LSTMNER('0101') def return_error(table):
model.param_extract('联想 ThinkPad E580 ThinkPad E580(02CD)15.6英寸轻薄窄边框笔记本电脑(i5-8250U 8G 256G PCIeSSD+1T 2G独显 FHD)黑色(计价单位:台)') sql_zi_zh = sql_find('zi_zh', False)
\ No newline at end of file NowTime = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())
#table = pd.read_excel('api_data/ZH_SN_no_category_data_2019-12-27.xlsx', dtype = {'SKU' : str})
table = table[['SKU','产品名称','url','来源']]
l = len(table)
create_time_list = []
remark_list = []
for i in range(l):
create_time_list.append(NowTime)
remark_list.append('类别对应错误')
table['remark'] = remark_list
table['create_time'] = create_time_list
table.columns = ['sku','name','url','source','remark','create_time']
table.to_sql('API_returnErrorData', sql_zi_zh.engine, if_exists='append', index=False)
\ 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