|
@@ -310,10 +310,10 @@ def collect_health(wind: Dict[str, Any], months: List[str]) -> Dict[str, Any]:
|
|
|
"min_score": round(min(valid), 2) if valid else None,
|
|
"min_score": round(min(valid), 2) if valid else None,
|
|
|
"max_score": round(max(valid), 2) if valid else None,
|
|
"max_score": round(max(valid), 2) if valid else None,
|
|
|
"distribution": dist,
|
|
"distribution": dist,
|
|
|
|
|
+ "turbines": items,
|
|
|
|
|
+ "valid_count": len(valid),
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
- if month == assess_months[-1]:
|
|
|
|
|
- latest_turbines = items
|
|
|
|
|
except Exception as exc:
|
|
except Exception as exc:
|
|
|
errors.append(f"{month}: {exc}")
|
|
errors.append(f"{month}: {exc}")
|
|
|
|
|
|
|
@@ -339,7 +339,20 @@ 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]
|
|
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
|
|
subsys_avg[key] = round(sum(vals) / len(vals), 2) if vals else None
|
|
|
|
|
|
|
|
- latest_dist = monthly[-1]["distribution"] if monthly else {}
|
|
|
|
|
|
|
+ # 年度区间下,健康评估页面可能只有部分月份有有效结果;
|
|
|
|
|
+ # 取最后一个月有有效结果的月份作为单机明细(总分布按所有月份汇总)。
|
|
|
|
|
+ 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 {
|
|
return {
|
|
|
"available": bool(monthly) and bool(valid_turbines),
|
|
"available": bool(monthly) and bool(valid_turbines),
|
|
|
"months": monthly,
|
|
"months": monthly,
|