Commit ded15f73 authored by sanlu's avatar sanlu

增加了上传到页面功能,需要放在服务器指定文件夹

parent 0bc1fce7
...@@ -385,6 +385,7 @@ class data_fetch(): ...@@ -385,6 +385,7 @@ class data_fetch():
def get_data_LXWL(self, sku): def get_data_LXWL(self, sku):
#print(sku)
self.sql_LXWL.cursor.execute(f"select sku,brand,name,category,createdate,url from product_detail where sku='{sku}'") self.sql_LXWL.cursor.execute(f"select sku,brand,name,category,createdate,url from product_detail where sku='{sku}'")
data = self.sql_LXWL.cursor.fetchall()[0] data = self.sql_LXWL.cursor.fetchall()[0]
data = list(data) data = list(data)
...@@ -559,20 +560,24 @@ class data_fetch(): ...@@ -559,20 +560,24 @@ class data_fetch():
with open(f'api_data/{self.source}_data_dict_{StyleTime}.txt', 'wb') as file: with open(f'api_data/{self.source}_data_dict_{StyleTime}.txt', 'wb') as file:
pickle.dump(data_dict, file) pickle.dump(data_dict, file)
save_dir = f'data/{StyleTime}_step3_needs_check'
if os.path.exists(save_dir) is False:
os.makedirs(save_dir)#检测是否存在文件夹,不存在就创建
data_table = pd.DataFrame.from_dict(data_dict, orient='index', dtype=None, columns=None) data_table = pd.DataFrame.from_dict(data_dict, orient='index', dtype=None, columns=None)
#data_table = self.tool.judge_peijian(data_table) #data_table = self.tool.judge_peijian(data_table)
data_table = data_table.reset_index() data_table = data_table.reset_index()
data_table.columns = ['SKU','品牌','指数品牌','指数品牌编码','产品名称','供应商子类','指数子类','指数子类编码','url','更新日期','参数项','产品型号','产品价格','来源'] data_table.columns = ['SKU','品牌','指数品牌','指数品牌编码','产品名称','供应商子类','指数子类','指数子类编码','url','更新日期','参数项','产品型号','产品价格','来源']
data_table.to_excel(f'api_data/{self.source}_data_{StyleTime}.xlsx',index=False) data_table.to_excel(f'data/{StyleTime}_step3_needs_check/{self.source}_data_{StyleTime}.xlsx',index=False) #总表
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',index=False) no_category_table.to_excel(f'data/{StyleTime}_step3_needs_check/{self.source}_no_category_data_{StyleTime}.xlsx',index=False)#没有子类对应打回的表
return_error(no_category_table)
data_table = data_table[data_table['指数子类编码'] != '没有匹配的指数子类编码'] data_table = data_table[data_table['指数子类编码'] != '没有匹配的指数子类编码']
data_table.to_excel(f'api_data/{self.source}_data_{StyleTime}_category_data.xlsx',index=False) data_table.to_excel(f'data/{StyleTime}_step3_needs_check/{self.source}_data_category_data_{StyleTime}.xlsx',index=False)#有子类对应需要确认的表,张力才下这个。
#self.data_table_80 = data_table[data_table['指数子类编码'].isin(self.class_80['指数编码'].tolist())] return_error(no_category_table)
#self.data_table_80.to_excel(f'api_data/{self.source}_data_80_{StyleTime}.xlsx') sql_zi_zh = sql_find('zi_zh', False)
#self.data_table_not80 = data_table[~data_table['指数子类编码'].isin(self.class_80['指数编码'].tolist())] 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')")#存入数据库,页面获取下载。
#self.data_table_not80.to_excel(f'api_data/{self.source}_data_not80_{StyleTime}.xlsx')
return data_table return data_table
if __name__ == '__main__': if __name__ == '__main__':
...@@ -600,7 +605,7 @@ if __name__ == '__main__': ...@@ -600,7 +605,7 @@ if __name__ == '__main__':
print('完毕!') print('完毕!')
''' '''
channel = 'DL' 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)
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