This commit is contained in:
HuangHai
2026-01-15 15:41:30 +08:00
parent 5172dbbc49
commit ba46eb15f6
20 changed files with 335 additions and 182 deletions

View File

@@ -235,3 +235,49 @@ class TeLaiDianService:
summary.append(f"{i:02d}h:{p.get('price')}")
logger.info(f"24小时价格概览: {' | '.join(summary)}")
return True
async def process_price_detail_data(self, station_name, hourly_schedule, total_piles=None, free_piles=None, piles_detail=None, parking_info=None, distance=None):
if not station_name or not hourly_schedule:
return False
now = datetime.now()
station_hash = self.get_hash(station_name, None)
async with await self.db.get_session() as session:
schedule_id = self.generate_id()
await self.station_price_schedule_model.save(
session=session,
id=schedule_id,
station_hash=station_hash,
schedule_json=hourly_schedule,
valid_start_time=now
)
current_hour = now.hour
current_price_info = None
if isinstance(hourly_schedule, list) and 0 <= current_hour < len(hourly_schedule):
current_price_info = hourly_schedule[current_hour] or {}
elif isinstance(hourly_schedule, dict):
current_price_info = hourly_schedule
else:
current_price_info = {}
status_id = self.generate_id()
await self.station_status_model.save(
session=session,
id=status_id,
station_hash=station_hash,
total_piles=total_piles,
free_piles=free_piles,
piles_detail_json=piles_detail,
parking_info=parking_info,
distance=distance,
current_price=current_price_info.get('price'),
pro_price=current_price_info.get('plus_price'),
market_price=current_price_info.get('market_price'),
valid_start_time=now
)
await session.commit()
return True