|
|
|
@ -195,7 +195,7 @@ class Prediksi:
|
|
|
|
"raw_loss_output_MW", raw_loss_output_price
|
|
|
|
"raw_loss_output_MW", raw_loss_output_price
|
|
|
|
, created_by, created_at
|
|
|
|
, created_by, created_at
|
|
|
|
) VALUES (
|
|
|
|
) VALUES (
|
|
|
|
%s, %s, 0, 1, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, 'Sys', NOW()
|
|
|
|
%s, %s, 0, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, 'Sys', NOW()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
@ -226,40 +226,44 @@ class Prediksi:
|
|
|
|
max_seq = max_seq + 1
|
|
|
|
max_seq = max_seq + 1
|
|
|
|
# Update values from API
|
|
|
|
# Update values from API
|
|
|
|
api_data = await fetch_api_data(equipment_id, row["year"])
|
|
|
|
api_data = await fetch_api_data(equipment_id, row["year"])
|
|
|
|
if api_data:
|
|
|
|
if api_data and "data" in api_data and isinstance(api_data["data"], list) and len(api_data["data"]) > 0:
|
|
|
|
# # Get current num_fail
|
|
|
|
# Get current num_fail (ensure numeric)
|
|
|
|
cm_interval_prediction = api_data["data"][0]["num_fail"]
|
|
|
|
try:
|
|
|
|
|
|
|
|
cm_interval_prediction = float(api_data["data"][0].get("num_fail", row.get("cm_interval", 1)))
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
|
|
|
|
cm_interval_prediction = float(row.get("cm_interval", 1)) if not pd.isna(row.get("cm_interval", None)) else 1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
cm_interval_prediction = (
|
|
|
|
# Fallback: ensure numeric scalar, not a tuple
|
|
|
|
(
|
|
|
|
try:
|
|
|
|
float(row["cm_interval"])
|
|
|
|
val = float(row.get("cm_interval", 1))
|
|
|
|
if float(row["cm_interval"]) >= 1
|
|
|
|
cm_interval_prediction = val if val >= 1 else 1.0
|
|
|
|
else 1
|
|
|
|
except Exception:
|
|
|
|
),
|
|
|
|
cm_interval_prediction = 1.0
|
|
|
|
)
|
|
|
|
|
|
|
|
records_to_insert.append(
|
|
|
|
records_to_insert.append(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
str(uuid4()),
|
|
|
|
str(uuid4()),
|
|
|
|
int(max_seq),
|
|
|
|
int(max_seq),
|
|
|
|
float(row["year"]),
|
|
|
|
float(row["pm_interval"]) if not pd.isna(row.get("pm_interval", None)) else 0.0,
|
|
|
|
|
|
|
|
float(row["year"]) if not pd.isna(row.get("year", None)) else 0.0,
|
|
|
|
equipment_id,
|
|
|
|
equipment_id,
|
|
|
|
cm_interval_prediction,
|
|
|
|
cm_interval_prediction,
|
|
|
|
float(row["cm_cost"]),
|
|
|
|
float(row["cm_cost"]) if not pd.isna(row.get("cm_cost", None)) else 0.0,
|
|
|
|
float(row["cm_labor_time"]),
|
|
|
|
float(row["cm_labor_time"]) if not pd.isna(row.get("cm_labor_time", None)) else 0.0,
|
|
|
|
float(row["cm_labor_human"]),
|
|
|
|
float(row["cm_labor_human"]) if not pd.isna(row.get("cm_labor_human", None)) else 0.0,
|
|
|
|
float(row["pm_cost"]),
|
|
|
|
float(row["pm_cost"]) if not pd.isna(row.get("pm_cost", None)) else 0.0,
|
|
|
|
float(row["pm_labor_time"]),
|
|
|
|
float(row["pm_labor_time"]) if not pd.isna(row.get("pm_labor_time", None)) else 0.0,
|
|
|
|
float(row["pm_labor_human"]),
|
|
|
|
float(row["pm_labor_human"]) if not pd.isna(row.get("pm_labor_human", None)) else 0.0,
|
|
|
|
float(row["oh_interval"]),
|
|
|
|
float(row["oh_interval"]) if not pd.isna(row.get("oh_interval", None)) else 0.0,
|
|
|
|
float(row["oh_cost"]),
|
|
|
|
float(row["oh_cost"]) if not pd.isna(row.get("oh_cost", None)) else 0.0,
|
|
|
|
float(row["oh_labor_time"]),
|
|
|
|
float(row["oh_labor_time"]) if not pd.isna(row.get("oh_labor_time", None)) else 0.0,
|
|
|
|
float(row["oh_labor_human"]),
|
|
|
|
float(row["oh_labor_human"]) if not pd.isna(row.get("oh_labor_human", None)) else 0.0,
|
|
|
|
float(row["predictive_interval"]),
|
|
|
|
float(row["predictive_interval"]) if not pd.isna(row.get("predictive_interval", None)) else 0.0,
|
|
|
|
float(row["predictive_material_cost"]),
|
|
|
|
float(row["predictive_material_cost"]) if not pd.isna(row.get("predictive_material_cost", None)) else 0.0,
|
|
|
|
float(row["predictive_labor_time"]),
|
|
|
|
float(row["predictive_labor_time"]) if not pd.isna(row.get("predictive_labor_time", None)) else 0.0,
|
|
|
|
float(row["predictive_labor_human"]),
|
|
|
|
float(row["predictive_labor_human"]) if not pd.isna(row.get("predictive_labor_human", None)) else 0.0,
|
|
|
|
float(row["loss_output_mw"]),
|
|
|
|
float(row["loss_output_mw"]) if not pd.isna(row.get("loss_output_mw", None)) else 0.0,
|
|
|
|
float(row["loss_price"]),
|
|
|
|
float(row["loss_price"]) if not pd.isna(row.get("loss_price", None)) else 0.0,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@ -522,4 +526,8 @@ async def main(RELIABILITY_APP_URL=RELIABILITY_APP_URL):
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
asyncio.run(main())
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
asyncio.run(
|
|
|
|
|
|
|
|
main()
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|