'commit'
This commit is contained in:
@@ -4,6 +4,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import zipfile
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import Any, Dict, List, Optional, Set
|
from typing import Any, Dict, List, Optional, Set
|
||||||
@@ -512,13 +513,11 @@ async def export_excel(operator: str, output_path: str, *, limit: Optional[int]
|
|||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
# 配置:默认导出所有数据,如果需要测试少量数据,可以将 None 改为数字,如 10
|
|
||||||
limit = None
|
limit = None
|
||||||
|
|
||||||
# 供应商列表
|
|
||||||
operators = ["新电途", "特来电", "驿来特", "艾特吉易充"]
|
operators = ["新电途", "特来电", "驿来特", "艾特吉易充"]
|
||||||
|
excel_paths: List[str] = []
|
||||||
|
|
||||||
# 构建默认输出目录
|
|
||||||
ts = datetime.now().strftime("%Y%m%d_%H%M%S")
|
ts = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||||
export_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "Excel", ts)
|
export_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "Excel", ts)
|
||||||
if not os.path.exists(export_dir):
|
if not os.path.exists(export_dir):
|
||||||
@@ -538,9 +537,22 @@ async def main():
|
|||||||
try:
|
try:
|
||||||
final_path = await export_excel(operator, output_path, limit=limit)
|
final_path = await export_excel(operator, output_path, limit=limit)
|
||||||
logger.info(f"{operator} 导出完成: {final_path}")
|
logger.info(f"{operator} 导出完成: {final_path}")
|
||||||
|
excel_paths.append(final_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"{operator} 导出失败: {e}")
|
logger.error(f"{operator} 导出失败: {e}")
|
||||||
|
|
||||||
|
if excel_paths:
|
||||||
|
zip_filename = f"充电场站数据_{ts}.zip"
|
||||||
|
zip_path = os.path.join(export_dir, zip_filename)
|
||||||
|
try:
|
||||||
|
with zipfile.ZipFile(zip_path, "w", compression=zipfile.ZIP_DEFLATED) as zf:
|
||||||
|
for path in excel_paths:
|
||||||
|
if os.path.isfile(path):
|
||||||
|
zf.write(path, arcname=os.path.basename(path))
|
||||||
|
logger.info(f"ZIP 打包完成: {zip_path}")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"ZIP 打包失败: {e}")
|
||||||
|
|
||||||
logger.info("所有导出任务已结束。")
|
logger.info("所有导出任务已结束。")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
BIN
Tools/__pycache__/T7_Export.cpython-310.pyc
Normal file
BIN
Tools/__pycache__/T7_Export.cpython-310.pyc
Normal file
Binary file not shown.
Reference in New Issue
Block a user