|
|
@@ -23,10 +23,10 @@ class MongoDBTools:
|
|
|
|
|
|
# 导出数据到excel
|
|
|
# 默认为按价格
|
|
|
- file_name_pre = "static\quote_data\\price_";
|
|
|
+ file_name_pre = 'price_'
|
|
|
if query_entity.query_type == 2:
|
|
|
# 按时间
|
|
|
- file_name_pre = "static\quote_data\\time_";
|
|
|
+ file_name_pre = 'time_'
|
|
|
if records is not None and len(records) > 0:
|
|
|
tools.export_to_excel(records, diff_records, query_entity.goods_code, file_name_pre)
|
|
|
print("time diff count: " + str(int(len(diff_records) /2)))
|
|
|
@@ -185,7 +185,12 @@ class MongoDBTools:
|
|
|
wb.active = 1 # 激活 'Sheet2',index 从 0 开始,1 表示第二个工作表
|
|
|
|
|
|
# 保存 Excel 文件
|
|
|
- file_name = file_name_pre + goods_code + "_" + datetime.now().strftime("%Y%m%d%H%M%S") + ".xlsx"
|
|
|
+ # 目标文件的目录
|
|
|
+ dir_path = os.path.join('static', 'quote_data')
|
|
|
+ # 检查目录是否存在,如果不存在则创建
|
|
|
+ if not os.path.exists(dir_path):
|
|
|
+ os.makedirs(dir_path)
|
|
|
+ file_name = os.path.join(dir_path, file_name_pre + goods_code + "_" + datetime.now().strftime("%Y%m%d%H%M%S") + ".xlsx")
|
|
|
wb.save(file_name)
|
|
|
|
|
|
print("quote date export to:" + file_name)
|