'commit'
This commit is contained in:
@@ -16,6 +16,7 @@ from Model.StationProfile import StationProfile
|
||||
from Model.StationStatus import StationStatus
|
||||
from Model.StationPriceSchedule import StationPriceSchedule
|
||||
from Apps.YeLiTe.Config.Setting import PRICE_FLATTEN_TO_24H
|
||||
import re
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -89,7 +90,17 @@ class YeLiTeService:
|
||||
except Exception as e:
|
||||
logger.error(f"更新任务结束日志失败: {e}")
|
||||
|
||||
async def process_price_detail_data(self, station_name, hourly_schedule, address=None, distance=None) -> bool:
|
||||
async def process_price_detail_data(
|
||||
self,
|
||||
station_name,
|
||||
hourly_schedule,
|
||||
address=None,
|
||||
distance=None,
|
||||
total_piles=None,
|
||||
free_piles=None,
|
||||
piles_detail=None,
|
||||
parking_info=None,
|
||||
) -> bool:
|
||||
if not station_name or not hourly_schedule:
|
||||
return False
|
||||
|
||||
@@ -98,6 +109,54 @@ class YeLiTeService:
|
||||
|
||||
schedule_to_save = hourly_schedule
|
||||
|
||||
standardized_piles = []
|
||||
total = total_piles or 0
|
||||
free = free_piles or 0
|
||||
|
||||
if isinstance(piles_detail, list):
|
||||
for idx, p in enumerate(piles_detail):
|
||||
try:
|
||||
t = int(p.get("total", 0))
|
||||
f = int(p.get("idle", p.get("free", 0)))
|
||||
total += t
|
||||
free += f
|
||||
standardized_piles.append(
|
||||
{
|
||||
"pile_no": f"G{idx+1}",
|
||||
"type": p.get("type", "未知"),
|
||||
"power": "",
|
||||
"status_text": f"空闲{f}/总{t}",
|
||||
"remark": "列表页忙闲",
|
||||
}
|
||||
)
|
||||
except Exception:
|
||||
continue
|
||||
elif isinstance(piles_detail, str):
|
||||
piles_str = piles_detail
|
||||
nums = re.findall(r"\d+", piles_str)
|
||||
if len(nums) >= 2:
|
||||
try:
|
||||
f_val = int(nums[-2])
|
||||
t_val = int(nums[-1])
|
||||
free += f_val
|
||||
total += t_val
|
||||
standardized_piles.append(
|
||||
{
|
||||
"pile_no": "G1",
|
||||
"type": "未知",
|
||||
"power": "",
|
||||
"status_text": piles_str,
|
||||
"remark": "列表页忙闲(字符串)",
|
||||
}
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if standardized_piles:
|
||||
total_piles = total
|
||||
free_piles = free
|
||||
piles_detail = standardized_piles
|
||||
|
||||
use_flatten = (PRICE_FLATTEN_TO_24H_GLOBAL or PRICE_FLATTEN_TO_24H) and isinstance(hourly_schedule, list)
|
||||
|
||||
if use_flatten:
|
||||
@@ -181,11 +240,12 @@ class YeLiTeService:
|
||||
session=session,
|
||||
id=status_id,
|
||||
station_hash=station_hash,
|
||||
total_piles=None,
|
||||
free_piles=None,
|
||||
piles_detail_json=None,
|
||||
current_price=current_price_info.get("price"),
|
||||
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"),
|
||||
valid_start_time=now,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user