|
|
@@ -317,6 +317,19 @@ def collect_health(wind: Dict[str, Any], months: List[str]) -> Dict[str, Any]:
|
|
|
except Exception as exc:
|
|
|
errors.append(f"{month}: {exc}")
|
|
|
|
|
|
+ # 年度区间下,健康评估页面可能只有部分月份有有效结果;
|
|
|
+ # 取最后一个月有有效结果的月份作为单机明细(总分布按所有月份汇总)。
|
|
|
+ last_valid_month = None
|
|
|
+ for m in reversed(monthly):
|
|
|
+ if m.get("valid_count"):
|
|
|
+ last_valid_month = m.get("month")
|
|
|
+ break
|
|
|
+ latest_turbines = []
|
|
|
+ for m in monthly:
|
|
|
+ if m.get("month") == last_valid_month:
|
|
|
+ latest_turbines = m.get("turbines") or []
|
|
|
+ break
|
|
|
+
|
|
|
turbines = []
|
|
|
for x in latest_turbines:
|
|
|
subsystems = x.get("subsystems") or {}
|
|
|
@@ -339,19 +352,6 @@ def collect_health(wind: Dict[str, Any], months: List[str]) -> Dict[str, Any]:
|
|
|
vals = [t[key] for t in valid_turbines if t[key] is not None and t[key] >= 0]
|
|
|
subsys_avg[key] = round(sum(vals) / len(vals), 2) if vals else None
|
|
|
|
|
|
- # 年度区间下,健康评估页面可能只有部分月份有有效结果;
|
|
|
- # 取最后一个月有有效结果的月份作为单机明细(总分布按所有月份汇总)。
|
|
|
- last_valid_month = None
|
|
|
- for m in reversed(monthly):
|
|
|
- if m.get("valid_count"):
|
|
|
- last_valid_month = m.get("month")
|
|
|
- break
|
|
|
- latest_turbines = []
|
|
|
- for m in monthly:
|
|
|
- if m.get("month") == last_valid_month:
|
|
|
- latest_turbines = m.get("turbines") or []
|
|
|
- break
|
|
|
- valid_turbines = [t for t in latest_turbines if t.get("score", -1) >= 0]
|
|
|
latest_dist = (monthly[-1] if monthly else {}).get("distribution") or {}
|
|
|
return {
|
|
|
"available": bool(monthly) and bool(valid_turbines),
|