'commit'
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user