|
|
@@ -160,11 +160,32 @@ def collect_overview_from_page(wind: Dict[str, Any], months: List[str]) -> Dict[
|
|
|
t["wind_sum"] += avg_wind * max(points, 1)
|
|
|
t["wind_points"] += max(points, 1)
|
|
|
|
|
|
+ # 数据完整度(分钟级),读取页面同源 data_integrity_minute 文件
|
|
|
+ comp_total_valid = 0
|
|
|
+ comp_total_expected = 0
|
|
|
+ comp_by_month: Dict[str, Any] = {}
|
|
|
+ for file_addr in integ_files:
|
|
|
+ text = fetch_minio_text(file_addr)
|
|
|
+ if not text:
|
|
|
+ continue
|
|
|
+ for row in _csv_rows(text):
|
|
|
+ month = (row.get("month") or "").strip()
|
|
|
+ valid = int(_f(row.get("valid_count") or 0))
|
|
|
+ expected = int(_f(row.get("expected_count") or 0))
|
|
|
+ if expected <= 0:
|
|
|
+ continue
|
|
|
+ comp_total_valid += valid
|
|
|
+ comp_total_expected += expected
|
|
|
+ m = comp_by_month.setdefault(month, {"v": 0, "e": 0})
|
|
|
+ m["v"] += valid
|
|
|
+ m["e"] += expected
|
|
|
+
|
|
|
monthly = []
|
|
|
for m in monthly_map.values():
|
|
|
m["gen_mwh"] = round(m["gen_kwh"] / 1000, 2)
|
|
|
m["avg_wind"] = round(m["wind_sum"] / m["wind_points"], 2) if m["wind_points"] else None
|
|
|
- m["completeness"] = None
|
|
|
+ cm = comp_by_month.get(m["month"])
|
|
|
+ m["completeness"] = round(cm["v"] / cm["e"] * 100, 2) if cm and cm["e"] else None
|
|
|
monthly.append(m)
|
|
|
monthly.sort(key=lambda x: x["month"])
|
|
|
|
|
|
@@ -192,11 +213,51 @@ def collect_overview_from_page(wind: Dict[str, Any], months: List[str]) -> Dict[
|
|
|
"equivalent_hours": round(total_kwh / capacity, 1) if capacity else None,
|
|
|
"avg_wind": round(weighted_wind / total_points, 2) if total_points else None,
|
|
|
"capacity_factor": None,
|
|
|
- "completeness": None,
|
|
|
+ "completeness": round(comp_total_valid / comp_total_expected * 100, 2) if comp_total_expected else None,
|
|
|
"integrity_files": integ_files,
|
|
|
}
|
|
|
|
|
|
|
|
|
+def collect_yaw_from_page(wind: Dict[str, Any], months: List[str]) -> Dict[str, Any]:
|
|
|
+ """静态偏航误差:读取页面同源 yaw_error 分析文件。"""
|
|
|
+ code = wind["code"]
|
|
|
+ start, end = months[0], months[-1]
|
|
|
+ batch = resolve_analysis_batch(code, start, end)
|
|
|
+ if not batch:
|
|
|
+ return {"available": False, "error": "偏航误差页面无覆盖所选时间段的分析批次", "turbines": []}
|
|
|
+ files = analysis_general_files(batch["batch_code"], ["yaw_error"]).get("yaw_error", [])
|
|
|
+ rows = []
|
|
|
+ for addr in files:
|
|
|
+ text = fetch_minio_text(addr)
|
|
|
+ if not text:
|
|
|
+ continue
|
|
|
+ rows.extend(_csv_rows(text))
|
|
|
+ if not rows:
|
|
|
+ return {"available": False, "error": "偏航误差页面无静态偏航结果", "turbines": []}
|
|
|
+ turbines = []
|
|
|
+ for r in rows:
|
|
|
+ turbines.append({
|
|
|
+ "name": r.get("wind_turbine_name") or r.get("wind_turbine_number"),
|
|
|
+ "code": r.get("wind_turbine_number"),
|
|
|
+ "avg": _f(r.get("avg_yaw_error")),
|
|
|
+ "abs_avg": _f(r.get("avg_abs_yaw_error")),
|
|
|
+ "abs_max": _f(r.get("max_abs_yaw_error")),
|
|
|
+ "count": int(_f(r.get("valid_count") or 0)),
|
|
|
+ })
|
|
|
+ turbines.sort(key=lambda x: x["abs_avg"], reverse=True)
|
|
|
+ over3 = [t for t in turbines if t["abs_avg"] > 3]
|
|
|
+ over5 = [t for t in turbines if t["abs_avg"] > 5]
|
|
|
+ return {
|
|
|
+ "available": True,
|
|
|
+ "turbines": turbines,
|
|
|
+ "avg_abs": round(sum(t["abs_avg"] for t in turbines) / len(turbines), 2) if turbines else None,
|
|
|
+ "over3": len(over3),
|
|
|
+ "over5": len(over5),
|
|
|
+ "over3_list": [t["name"] for t in over3],
|
|
|
+ "over5_list": [t["name"] for t in over5],
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
def collect_fault_from_page(wind: Dict[str, Any], months: List[str]) -> Dict[str, Any]:
|
|
|
"""故障诊断页面数据:读取 autodiag 保存结果(vibration_diagnosis_result),不查故障日志表。"""
|
|
|
code = wind["code"]
|