|
@@ -239,7 +239,23 @@ def collect_fault_from_page(wind: Dict[str, Any], months: List[str]) -> Dict[str
|
|
|
def collect_algorithm_health_from_page(wind: Dict[str, Any], months: List[str]) -> Dict[str, Any]:
|
|
def collect_algorithm_health_from_page(wind: Dict[str, Any], months: List[str]) -> Dict[str, Any]:
|
|
|
"""算法健康评估页面数据:/AnalysisMulti/health-assessment/detail。"""
|
|
"""算法健康评估页面数据:/AnalysisMulti/health-assessment/detail。"""
|
|
|
code = wind["code"]
|
|
code = wind["code"]
|
|
|
- month = months[-1]
|
|
|
|
|
|
|
+ month = None
|
|
|
|
|
+ # 在所选时间段内取页面最新可用期次(例如选择 2024-12 时回退到 2024-11)
|
|
|
|
|
+ try:
|
|
|
|
|
+ pr = requests.get(
|
|
|
|
|
+ "http://127.0.0.1:8888/health-assessment/periods",
|
|
|
|
|
+ params={"fieldCode": code},
|
|
|
|
|
+ timeout=30,
|
|
|
|
|
+ )
|
|
|
|
|
+ pr.raise_for_status()
|
|
|
|
|
+ periods = [x.get("period") for x in (pr.json().get("data") or [])]
|
|
|
|
|
+ periods = [x for x in periods if x and months[0] <= x <= months[-1]]
|
|
|
|
|
+ if periods:
|
|
|
|
|
+ month = max(periods)
|
|
|
|
|
+ except Exception:
|
|
|
|
|
+ month = None
|
|
|
|
|
+ if not month:
|
|
|
|
|
+ return {"available": False, "error": "算法健康评估页面在所选时间段内无可用期次", "turbines": []}
|
|
|
try:
|
|
try:
|
|
|
r = requests.get(
|
|
r = requests.get(
|
|
|
"http://127.0.0.1:8888/health-assessment/detail",
|
|
"http://127.0.0.1:8888/health-assessment/detail",
|