This commit is contained in:
HuangHai
2026-01-21 08:41:47 +08:00
parent 306a3a4127
commit e51dc18d06
40 changed files with 1309 additions and 965 deletions

View File

@@ -21,7 +21,7 @@ from Util import Win32Patch
Win32Patch.patch()
from Config.Config import DB_URL
from DbKit.Db import Db
from Model.YltAnalyticsModel import YltAnalyticsModel
try:
from openpyxl import Workbook
@@ -175,46 +175,17 @@ def _set_column_widths(ws, widths: dict[int, float]):
class DorisExcelExporter:
def __init__(self, db_url: str):
self.db = Db(db_url=db_url)
async def init(self):
await self.db.init_db()
async def close(self):
try:
await self.db.close()
finally:
if getattr(self.db, "engine", None):
await self.db.engine.dispose()
def __init__(self, db_url: str = None):
self.model = YltAnalyticsModel()
async def init(self):
pass # Model handles initialization if needed
async def close(self):
pass # Model handles closing if needed
async def fetch_current_station_rows(self, operator: str) -> List[Dict[str, Any]]:
sql = """
SELECT
p.station_hash,
p.station_name,
p.address,
p.coord_x,
p.coord_y,
s.total_piles AS total_guns,
s.free_piles AS free_guns,
s.piles_detail_json,
s.current_price,
s.pro_price,
s.parking_info,
s.distance,
s.valid_start_time AS status_update_time,
pr.schedule_json,
pr.valid_start_time AS schedule_update_time
FROM t_station_profile_scd p
LEFT JOIN t_station_status_scd s
ON p.station_hash = s.station_hash AND s.is_current = 1
LEFT JOIN t_station_price_schedule_scd pr
ON p.station_hash = pr.station_hash AND pr.is_current = 1
WHERE p.is_current = 1 AND p.operator = :operator
ORDER BY p.station_name
"""
return await self.db.find(sql, {"operator": operator})
return await self.model.fetch_current_station_rows(operator)
def extract_hourly_prices_from_schedule(schedule_json: Any) -> List[Optional[float]]: