This commit is contained in:
HuangHai
2026-01-12 20:11:18 +08:00
parent f4b398227e
commit ac79e44282
18 changed files with 155 additions and 85 deletions

View File

@@ -125,6 +125,69 @@ class AiTeJiYiChongService:
logger.info(f"场站详情处理完成: {name}")
return detail
async def process_station_list_hybrid(self, image_path, device_info=None) -> list:
"""
基于混合模式处理场站列表 (图形学切片 + 本地 OCR)
"""
station_list = await ReadImageKit.get_stations_hybrid(image_path, device_info=device_info)
if not station_list:
return []
processed_stations = []
async with await self.db.get_session() as session:
for station in station_list:
name = station.get("station_name")
if not name:
continue
station_hash = self.get_hash(name)
now = datetime.now()
station["station_hash"] = station_hash
# 1. 保存 Profile
profile_id = self.generate_id()
await self.station_profile_model.save(
session=session,
id=profile_id,
station_hash=station_hash,
operator=self.operator,
station_name=name,
valid_start_time=now
)
station["profile_id"] = profile_id
station["valid_start_time"] = now.isoformat()
# 2. 保存 Status (解析价格和电桩)
status_id = self.generate_id()
# 处理 piles 字段
piles_data = station.get("piles")
total, free = 0, 0
if isinstance(piles_data, list):
for p in piles_data:
total += int(p.get("total", 0))
free += int(p.get("free", 0))
await self.station_status_model.save(
session=session,
id=status_id,
station_hash=station_hash,
total_piles=total,
free_piles=free,
piles_detail_json=piles_data,
current_price=float(station.get("price", 0)) if station.get("price") else 0.0,
parking_info=station.get("parking", ""),
distance=station.get("distance", ""),
valid_start_time=now
)
station["status_id"] = status_id
processed_stations.append(station)
await session.commit()
return processed_stations
async def process_station_list_vl(self, image_path, device_info=None) -> list:
"""
基于 VL 模式处理场站列表