小明同学 1 dia atrás
pai
commit
c6a7fa67e9

BIN
forecast-algorithm/.DS_Store


+ 130 - 36
forecast-algorithm/README.md

@@ -1,24 +1,22 @@
-# 光伏功率预测使用说明
+# 光伏功率预测API部署使用说明
+![](https://img.shields.io/badge/Python-3.10-blue) ![](https://img.shields.io/badge/Pytorch-2.6.0+cu124-blue) ![](https://img.shields.io/badge/FastAPI-0.138.0-red)
 
-本文档说明 `forecast-algorithm` 中功率预测算法的运行方式,以及通过 `main.py` 启动 FastAPI 服务并调用预测接口的方法。
+> 本文档说明 `forecast-algorithm` 中功率预测算法的运行方式,以及通过 `main.py` 启动 FastAPI 服务并调用预测接口的方法。
+
+<img src="assets/API_home_page.png" alt="image-20261026105801289" style="zoom:35%;"/>
 
 ## 1. 功能概览
 
 | 类型 | 模型 | 输入长度 | 输出长度 | 时间分辨率 | 预测范围 |
 |---|---|---:|---:|---:|---:|
+| 超短期 | / | / | / | / | / |
 | 短期 | GRU / v24 | 288 | 288 | 15 分钟 | 3 天 |
 | 中期 | GRU / v24 | 960 | 960 | 15 分钟 | 10 天 |
 
-短期和中期预测分别由以下脚本执行:
-
-```text
-medium_short_term/scripts/prediction_short.py
-medium_short_term/scripts/prediction_medium.py
-```
-
 预测结果写入 PostgreSQL:
 
 ```text
+超短期:/
 短期:data_short_term_power_forecast_raw
 中期:data_medium_term_power_forecast_raw
 ```
@@ -27,26 +25,94 @@ medium_short_term/scripts/prediction_medium.py
 
 ```text
 forecast-algorithm/
-├── main.py                              FastAPI 启动入口
-├── medium_short_term/
-│   ├── requirements.txt                 Python 依赖
+├── main.py                              FastAPI 启动入口,提供预测 API 和首页
+├── README.md                            项目与 API 使用说明
+├── requirements.txt                     项目通用 Python 依赖
+├── config/
+│   └── config.yaml                      数据库、模型路径和 FastAPI 配置
+├── templates/
+│   └── api_home.html                    API 单页使用说明首页
+├── assets/
+│   └── API_home_page.png                API 首页预览图
+│
+├── medium_short_term/                   短期和中期功率预测
+│   ├── README.md                        短期/中期预测说明
+│   ├── requirements.txt                 模型运行依赖
+│   ├── base/
+│   │   └── base_model.py                模型基类
+│   ├── layers/
+│   │   └── layers.py                    公共网络层
 │   ├── model/                           模型结构
+│   │   ├── GRU.py
+│   │   ├── DLinear.py
+│   │   ├── TSMixer.py
+│   │   ├── TCN.py
+│   │   ├── Mamba.py
+│   │   ├── CNN_LSTM.py
+│   │   ├── TransformerEn.py
+│   │   └── lightbgm.py
 │   ├── scripts/
 │   │   ├── ModelLoading.py              模型与归一化器加载
+│   │   ├── pipeline.py                  训练数据处理管线
 │   │   ├── prediction_short.py          短期预测入口
-│   │   └── prediction_medium.py         中期预测入口
+│   │   ├── prediction_medium.py         中期预测入口
+│   │   └── run.sh                       批量预测脚本
+│   ├── utils/
+│   │   ├── metrics_utils.py             评估指标
+│   │   ├── processed.py                 数据预处理
+│   │   ├── train_utils.py               训练工具
+│   │   └── weather_utils.py             气象数据处理
+│   ├── test/
+│   │   └── prediction_test.py           预测测试脚本
 │   └── saved_model/                     模型权重目录
-│       └── <场站>/<模型>/<序列长度>/<特征版本>/
-└── ultra_short_term/                    超短期预测
-```
-
-模型目录示例:
-
-```text
-medium_short_term/saved_model/JMJD01/GRU/288/v24/
-├── best_model.pth
-├── best_tpe_params.json
-└── scaler.pkl
+│       └── <场站>/
+│           └── <模型>/
+│               └── <序列长度>/
+│                   └── <特征版本>/
+│                       ├── best_model.pth
+│                       ├── best_tpe_params.json
+│                       └── scaler.pkl
+│
+└── ultra_short_term/                    超短期光伏功率预测
+    ├── README.md                        超短期预测说明
+    ├── requirements.txt                 超短期预测依赖
+    ├── run.py                           超短期预测入口
+    ├── run.sh                           运行脚本
+    ├── install.sh                       安装脚本
+    ├── ultra_short_pv.py                超短期预测主逻辑
+    ├── pv_inputs.py                     输入数据构造
+    ├── pv_io.py                          输入输出处理
+    ├── config.json                      超短期默认配置
+    ├── deployment_config.json           部署配置
+    ├── input_schema.json                输入数据格式定义
+    ├── SHA256SUMS.json                  模型文件校验信息
+    ├── configs/
+    │   └── sites.yaml                   场站配置
+    ├── pv_forecast/
+    │   ├── __init__.py
+    │   ├── ec_latest.py                 最新 EC 气象数据
+    │   ├── features.py                  特征处理
+    │   └── mspf_pv/                     光伏预测模型目录
+    ├── models/
+    │   ├── mspf_pv/                     超短期模型
+    │   └── mspf_pv_e10a/                备选模型
+    ├── examples/
+    │   └── call_model.py                模型调用示例
+    ├── docs/
+    │   ├── 超短期光伏预测部署文档.docx
+    │   └── 输入输出与接入说明.md
+    ├── test_data/
+    │   ├── JMJD01_input.npz
+    │   ├── JMJD01_reference.npz
+    │   ├── YUWEI_input.npz
+    │   ├── YUWEI_reference.npz
+    │   ├── ZHONGXIN_input.npz
+    │   └── ZHONGXIN_reference.npz
+    ├── tests/
+    │   └── test_forecast.py
+    ├── test.sh                          测试运行脚本
+    ├── test_deployment.py               部署测试
+    └── output/                          超短期预测输出与测试日志
 ```
 
 ## 3. 支持场站
@@ -56,6 +122,7 @@ medium_short_term/saved_model/JMJD01/GRU/288/v24/
 | JMJD01 | 江门光伏场 | 4050 kW | 22.555907 | 113.135232 |
 | YUWEI | 北流煜炜光伏场 | 3000 kW | 22.615142 | 110.305066 |
 | ZHONGXIN | 清远忠信光伏场 | 2250 kW | 23.542156 | 112.996233 |
+| ... |  |  |  |  |
 
 ## 4. 运行环境
 
@@ -82,26 +149,42 @@ python -m pip install -r medium_short_term/requirements.txt
 
 ## 5. 数据库配置
 
-数据库配置位于:
-
-```text
-数据库 112.124.19.19:5432/electricitypostgres/ow9NV!lkf
-medium_short_term/scripts/prediction_short.py
-medium_short_term/scripts/prediction_medium.py
+```sh
+目前是测试数据库,手动导入数据库环境变量
+export PGHOST="112.124.19.19"
+export PGPORT="5432"
+export PGDATABASE="electricity"
+export PGUSER="postgres"
+export PGPOSSWORD="ow9NV!lkf"
 ```
 
 ## 6. 启动 FastAPI 服务
 
-在项目根目录执行:
+修改配置文件**config/config.yaml**
 
-```bash
-cd ~/forecast/forecast-algorithm
+```yaml
+FastAPI: # 关于fast api的配置
+  host: "0.0.0.0" 
+  port: 8000
+
+model: # 关于超短期,短期,中期模型权重和模型脚本路径配置
+	# 项目路径('/Users/hm/Desktop/forecast/forecast-algorithm')+算法路径('medium_short_term/scripts/prediction_short.py')
+  short_algorithm_file: '/Users/hm/Desktop/forecast/forecast-algorithm/medium_short_term/scripts/prediction_short.py'
+  medium_algorithm_file: '/Users/hm/Desktop/forecast/forecast-algorithm/medium_short_term/scripts/prediction_medium.py'
+  # 项目路径('/Users/hm/Desktop/forecast/forecast-algorithm')+权重路径('medium_short_term/saved_model')
+  saved_model_root: "/Users/hm/Desktop/forecast/forecast-algorithm/medium_short_term/saved_model"
+
+```
+
+在**forecast-algorithm**目录执行:
+
+```sh
 python main.py
 ```
 
 默认监听:
 
-```text
+```python
 http://0.0.0.0:8000
 ```
 
@@ -111,6 +194,13 @@ http://0.0.0.0:8000
 http://127.0.0.1:8000
 ```
 
+> 访问http://127.0.0.1:8000展示API主页信息
+
+<img src="assets/API_home_page.png" alt="image-20261026105801289" style="zoom:25%;"/>
+
+
+
+
 ## 7. 调用短期预测接口
 
 接口:
@@ -126,7 +216,9 @@ GET /api/v1/power/short
 | `projs` | 是 | 场站代码,例如 `JMJD01` |
 | `init_time` | 是 | 上海时间,格式 `YYYY-MM-DD HH:MM:SS` |
 
-浏览器访问:
+浏览器访问事例:
+
+> 预报2026-11-25:08:00:00(北京时间),短期功率预报,结果写入数据库
 
 ```text
 http://127.0.0.1:8000/api/v1/power/short?projs=JMJD01&init_time=2026-11-25%2008:00:00
@@ -159,7 +251,9 @@ GET /api/v1/power/medium
 | `projs`     | 是   | 场站代码,例如 `JMJD01`              |
 | `init_time` | 是   | 上海时间,格式 `YYYY-MM-DD HH:MM:SS` |
 
-浏览器访问:
+浏览器访问事例:
+
+> 预报2026-11-25:08:00:00(北京时间),中期功率预报,结果写入数据库
 
 ```text
 http://127.0.0.1:8000/api/v1/power/medium?projs=JMJD01&init_time=2026-11-25%2008:00:00

BIN
forecast-algorithm/__pycache__/main.cpython-314.pyc


BIN
forecast-algorithm/assets/API_home_page.png


+ 8 - 0
forecast-algorithm/config/config.yaml

@@ -0,0 +1,8 @@
+FastAPI:
+  host: "0.0.0.0"
+  port: 8000
+
+model:
+  short_algorithm_file: '/Users/hm/Desktop/forecast/forecast-algorithm/medium_short_term/scripts/prediction_short.py'
+  medium_algorithm_file: '/Users/hm/Desktop/forecast/forecast-algorithm/medium_short_term/scripts/prediction_medium.py'
+  saved_model_root: "/Users/hm/Desktop/forecast/forecast-algorithm/medium_short_term/saved_model"

+ 43 - 50
forecast-algorithm/main.py

@@ -1,17 +1,42 @@
 from fastapi import FastAPI, HTTPException
+from fastapi.responses import HTMLResponse
 import sys
 import subprocess
+import yaml
+import os
 
 app = FastAPI()
 
-
-@app.get("/")
+# 读取配置文件
+BASE_DIR = os.path.dirname(os.path.abspath(__file__))
+with open(os.path.join(BASE_DIR,"config/config.yaml"), "r", encoding="utf-8") as f:
+    config = yaml.safe_load(f)
+
+PROJECT_DEFAULTS = {
+    "JMJD01": {
+        "lat": 22.555907,
+        "lon": 113.135232,
+        "capacity": 4050,
+    },
+    "YUWEI": {
+        "lat": 22.615142,
+        "lon": 110.305066,
+        "capacity": 3000,
+    },
+    "ZHONGXIN": {
+        "lat": 23.542156,
+        "lon": 112.996233,
+        "capacity": 2250,
+    },
+}
+
+API_HOME_PATH = os.path.join(BASE_DIR, "templates", "api_home.html")
+
+
+@app.get("/", response_class=HTMLResponse)
 def root():
-    return {
-        "message": "服务运行中",
-        "predict_api": "/api/v1/predictions",
-        "docs": "/docs",
-    }
+    with open(API_HOME_PATH, "r", encoding="utf-8") as f:
+        return f.read()
 
 
 @app.get("/api/v1/power/short")
@@ -19,24 +44,6 @@ def create_prediction(
     projs:str = 'JMJD01',
     init_time: str = "2026-11-25 08:00:00"
 ):
-    PROJECT_DEFAULTS = {
-        "JMJD01": {
-            "lat": 22.555907,
-            "lon": 113.135232,
-            "capacity": 4050,
-        },
-        "YUWEI": {
-            "lat": 22.615142,
-            "lon": 110.305066,
-            "capacity": 3000,
-        },
-        "ZHONGXIN": {
-            "lat": 23.542156,
-            "lon": 112.996233,
-            "capacity": 2250,
-        },
-    }
-
     if projs not in PROJECT_DEFAULTS:
         raise HTTPException(
             status_code=400,
@@ -45,7 +52,7 @@ def create_prediction(
 
     cmd = [
         sys.executable,
-        "/Users/hm/Desktop/forecast/forecast-algorithm/medium_short_term/scripts/prediction_short.py",
+        config['model']['short_algorithm_file'],
         "--projs", projs ,
         "--model_name", 'GRU',
         "--release", 'v24',
@@ -54,14 +61,14 @@ def create_prediction(
         "--short_term_seq", "288",
         "--medium_term_seq", "960",
         "--capacity", str(PROJECT_DEFAULTS[f'{projs}']['capacity']),
-        "--saved_model_root", "/Users/hm/Desktop/forecast/forecast-algorithm/medium_short_term/saved_model",
+        "--saved_model_root", config['model']['saved_model_root'],
         "--saved_result_root", "-",
         "--init_time", init_time,
     ]
 
     result = subprocess.run(
         cmd,
-        cwd="/Users/hm/Desktop/forecast/forecast-algorithm",
+        cwd=BASE_DIR,
         capture_output=True,
         text=True,
     )
@@ -90,24 +97,6 @@ def create_prediction(
     projs:str = 'JMJD01',
     init_time: str = "2026-11-25 08:00:00"
 ):
-    PROJECT_DEFAULTS = {
-        "JMJD01": {
-            "lat": 22.555907,
-            "lon": 113.135232,
-            "capacity": 4050,
-        },
-        "YUWEI": {
-            "lat": 22.615142,
-            "lon": 110.305066,
-            "capacity": 3000,
-        },
-        "ZHONGXIN": {
-            "lat": 23.542156,
-            "lon": 112.996233,
-            "capacity": 2250,
-        },
-    }
-
     if projs not in PROJECT_DEFAULTS:
         raise HTTPException(
             status_code=400,
@@ -116,7 +105,7 @@ def create_prediction(
 
     cmd = [
         sys.executable,
-        "/Users/hm/Desktop/forecast/forecast-algorithm/medium_short_term/scripts/prediction_medium.py",
+        config['model']['medium_algorithm_file'],
         "--projs", projs ,
         "--model_name", 'GRU',
         "--release", 'v24',
@@ -125,14 +114,14 @@ def create_prediction(
         "--short_term_seq", "288",
         "--medium_term_seq", "960",
         "--capacity", str(PROJECT_DEFAULTS[f'{projs}']['capacity']),
-        "--saved_model_root", "/Users/hm/Desktop/forecast/forecast-algorithm/medium_short_term/saved_model",
+        "--saved_model_root", config['model']['saved_model_root'],
         "--saved_result_root", "-",
         "--init_time", init_time,
     ]
 
     result = subprocess.run(
         cmd,
-        cwd="/Users/hm/Desktop/forecast/forecast-algorithm",
+        cwd=BASE_DIR,
         capture_output=True,
         text=True,
     )
@@ -158,4 +147,8 @@ def create_prediction(
 if __name__ == "__main__":
     import uvicorn
 
-    uvicorn.run(app, host="0.0.0.0", port=8000)
+    uvicorn.run(
+        app, 
+        host=config['FastAPI']['host'], 
+        port=config['FastAPI']['port']
+    )            

BIN
forecast-algorithm/medium_short_term/.DS_Store


+ 1 - 1
forecast-algorithm/medium_short_term/scripts/prediction_medium.py

@@ -30,7 +30,7 @@ DB_CONFIG = {
     "port": int(os.getenv("PGPORT", "5432")),
     "dbname": os.getenv("PGDATABASE", "electricity"),
     "user": os.getenv("PGUSER", "postgres"),
-    "password": 'ow9NV!lkf',
+    "password": os.getenv("PGPOSSWORD", "ow9NV!lkf"),
     "connect_timeout": 10,
 }
 

+ 1 - 1
forecast-algorithm/medium_short_term/scripts/prediction_short.py

@@ -30,7 +30,7 @@ DB_CONFIG = {
     "port": int(os.getenv("PGPORT", "5432")),
     "dbname": os.getenv("PGDATABASE", "electricity"),
     "user": os.getenv("PGUSER", "postgres"),
-    "password": 'ow9NV!lkf',
+    "password": os.getenv("PGPOSSWORD", "ow9NV!lkf"),
     "connect_timeout": 10,
 }
 

+ 560 - 0
forecast-algorithm/templates/api_home.html

@@ -0,0 +1,560 @@
+<!doctype html>
+<html lang="zh-CN">
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1">
+  <title>OuLiPower 光伏功率预测 API</title>
+  <style>
+    :root {
+      --bg: #f4f7f5;
+      --paper: #ffffff;
+      --ink: #17251f;
+      --muted: #66756e;
+      --line: #dce5e0;
+      --accent: #126b4d;
+      --accent-soft: #e5f4ed;
+      --accent-dark: #0b4f39;
+      --warning: #8a5b12;
+      --warning-soft: #fff5dc;
+      --code: #13241d;
+      --shadow: 0 18px 45px rgba(30, 61, 49, 0.08);
+    }
+
+    * { box-sizing: border-box; }
+
+    body {
+      margin: 0;
+      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
+        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
+      background:
+        radial-gradient(circle at 8% 0%, #d8eee3 0, transparent 28rem),
+        radial-gradient(circle at 100% 8%, #eaf0d9 0, transparent 24rem),
+        var(--bg);
+      color: var(--ink);
+      min-height: 100vh;
+      line-height: 1.65;
+    }
+
+    .wrap {
+      width: min(1180px, calc(100% - 36px));
+      margin: 0 auto;
+      padding: 36px 0 52px;
+    }
+
+    .hero {
+      display: grid;
+      grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr);
+      gap: 20px;
+      margin-bottom: 22px;
+    }
+
+    .card {
+      background: rgba(255, 255, 255, .92);
+      border: 1px solid var(--line);
+      border-radius: 22px;
+      box-shadow: var(--shadow);
+    }
+
+    .hero-main {
+      padding: 34px 36px;
+      position: relative;
+      overflow: hidden;
+    }
+
+    .hero-main::after {
+      content: "";
+      position: absolute;
+      width: 230px;
+      height: 230px;
+      right: -70px;
+      bottom: -100px;
+      border-radius: 50%;
+      background: linear-gradient(145deg, #c9eedb, #eef5df);
+      opacity: .8;
+    }
+
+    .eyebrow {
+      display: inline-flex;
+      align-items: center;
+      gap: 8px;
+      padding: 7px 12px;
+      border-radius: 999px;
+      background: var(--accent-soft);
+      color: var(--accent-dark);
+      font-size: 13px;
+      font-weight: 700;
+      letter-spacing: .02em;
+    }
+
+    .dot {
+      width: 8px;
+      height: 8px;
+      border-radius: 50%;
+      background: #19a56d;
+      box-shadow: 0 0 0 4px rgba(25, 165, 109, .12);
+    }
+
+    h1 {
+      margin: 18px 0 10px;
+      font-size: clamp(30px, 4vw, 50px);
+      line-height: 1.16;
+      letter-spacing: -.035em;
+    }
+
+    .lead {
+      max-width: 700px;
+      margin: 0;
+      color: var(--muted);
+      font-size: 16px;
+    }
+
+    .hero-actions {
+      display: flex;
+      flex-wrap: wrap;
+      gap: 10px;
+      margin-top: 24px;
+      position: relative;
+      z-index: 1;
+    }
+
+    .btn {
+      border: 1px solid transparent;
+      border-radius: 12px;
+      padding: 10px 16px;
+      font: inherit;
+      font-weight: 700;
+      cursor: pointer;
+      text-decoration: none;
+      display: inline-flex;
+      align-items: center;
+      justify-content: center;
+      gap: 8px;
+      transition: .18s ease;
+    }
+
+    .btn-primary {
+      color: white;
+      background: var(--accent);
+    }
+
+    .btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); }
+
+    .btn-ghost {
+      color: var(--accent-dark);
+      background: white;
+      border-color: #bcd6ca;
+    }
+
+    .btn-ghost:hover { background: var(--accent-soft); }
+
+    .hero-side {
+      padding: 24px;
+      display: flex;
+      flex-direction: column;
+      justify-content: space-between;
+      gap: 20px;
+      background: linear-gradient(160deg, #163f31, #0d2b21);
+      color: white;
+      border-color: #163f31;
+    }
+
+    .hero-side h2 {
+      font-size: 16px;
+      margin: 0 0 14px;
+      color: #cce8da;
+    }
+
+    .stat {
+      display: grid;
+      grid-template-columns: 1fr 1fr;
+      gap: 12px;
+    }
+
+    .stat-item {
+      padding: 14px;
+      border-radius: 14px;
+      background: rgba(255, 255, 255, .08);
+      border: 1px solid rgba(255, 255, 255, .1);
+    }
+
+    .stat-item strong {
+      display: block;
+      font-size: 24px;
+      line-height: 1;
+      margin-bottom: 6px;
+    }
+
+    .stat-item span { font-size: 12px; color: #bcd6ca; }
+
+    .section-title {
+      display: flex;
+      align-items: end;
+      justify-content: space-between;
+      gap: 16px;
+      margin: 30px 2px 12px;
+    }
+
+    .section-title h2 {
+      margin: 0;
+      font-size: 23px;
+      letter-spacing: -.02em;
+    }
+
+    .section-title p {
+      margin: 0;
+      color: var(--muted);
+      font-size: 13px;
+    }
+
+    .grid-2 {
+      display: grid;
+      grid-template-columns: repeat(2, minmax(0, 1fr));
+      gap: 18px;
+    }
+
+    .api-card { padding: 24px; }
+
+    .api-card-head {
+      display: flex;
+      align-items: center;
+      justify-content: space-between;
+      gap: 12px;
+      margin-bottom: 12px;
+    }
+
+    .method {
+      font-size: 12px;
+      font-weight: 800;
+      letter-spacing: .05em;
+      color: var(--accent-dark);
+      background: var(--accent-soft);
+      border-radius: 999px;
+      padding: 5px 10px;
+    }
+
+    .api-card h3 { margin: 0; font-size: 19px; }
+
+    .api-path {
+      display: block;
+      margin: 10px 0 16px;
+      border-radius: 12px;
+      padding: 11px 13px;
+      background: var(--code);
+      color: #d9f5e8;
+      font-family: "SFMono-Regular", Consolas, monospace;
+      font-size: 13px;
+      overflow-wrap: anywhere;
+    }
+
+    .api-card p { color: var(--muted); margin: 0 0 15px; }
+
+    .badge-row { display: flex; flex-wrap: wrap; gap: 7px; }
+
+    .badge {
+      padding: 5px 9px;
+      border-radius: 8px;
+      background: #f1f5f3;
+      border: 1px solid var(--line);
+      color: #52625b;
+      font-size: 12px;
+    }
+
+    .panel { padding: 25px; }
+
+    .form-grid {
+      display: grid;
+      grid-template-columns: 1fr 1.2fr auto auto;
+      align-items: end;
+      gap: 12px;
+    }
+
+    label {
+      display: block;
+      font-size: 12px;
+      font-weight: 700;
+      color: #50615a;
+      margin-bottom: 6px;
+    }
+
+    input, select {
+      width: 100%;
+      border: 1px solid #cbd9d2;
+      border-radius: 11px;
+      background: white;
+      padding: 11px 12px;
+      color: var(--ink);
+      font: inherit;
+      outline: none;
+      min-height: 44px;
+    }
+
+    input:focus, select:focus {
+      border-color: var(--accent);
+      box-shadow: 0 0 0 3px rgba(18, 107, 77, .12);
+    }
+
+    .result-box {
+      margin-top: 18px;
+      min-height: 160px;
+      border-radius: 14px;
+      border: 1px solid #203a31;
+      background: #0e1a16;
+      color: #d9f5e8;
+      padding: 16px;
+      overflow: auto;
+      max-height: 360px;
+      font-family: "SFMono-Regular", Consolas, monospace;
+      font-size: 12px;
+      white-space: pre-wrap;
+      word-break: break-word;
+    }
+
+    .notice {
+      display: flex;
+      gap: 12px;
+      padding: 15px 17px;
+      margin-top: 18px;
+      border-radius: 13px;
+      background: var(--warning-soft);
+      color: var(--warning);
+      border: 1px solid #f0dfb5;
+      font-size: 13px;
+    }
+
+    .notice strong { white-space: nowrap; }
+
+    .code-block {
+      margin: 0;
+      border-radius: 14px;
+      padding: 18px;
+      background: #0e1a16;
+      color: #d9f5e8;
+      overflow: auto;
+      font-family: "SFMono-Regular", Consolas, monospace;
+      font-size: 12px;
+      line-height: 1.65;
+      white-space: pre;
+    }
+
+    .station-list {
+      display: grid;
+      grid-template-columns: repeat(3, minmax(0, 1fr));
+      gap: 12px;
+    }
+
+    .station {
+      padding: 18px;
+      border-radius: 15px;
+      background: #fbfffd;
+      border: 1px solid var(--line);
+    }
+
+    .station strong { display: block; margin-bottom: 5px; }
+    .station code { color: var(--accent-dark); font-weight: 700; }
+    .station small { color: var(--muted); }
+
+    footer {
+      display: flex;
+      justify-content: space-between;
+      gap: 16px;
+      color: #7d8b84;
+      font-size: 12px;
+      padding: 22px 2px 0;
+    }
+
+    @media (max-width: 920px) {
+      .hero, .grid-2 { grid-template-columns: 1fr; }
+      .form-grid { grid-template-columns: 1fr 1fr; }
+      .form-grid .btn { width: 100%; }
+      .station-list { grid-template-columns: 1fr; }
+    }
+
+    @media (max-width: 620px) {
+      .wrap { width: min(100% - 22px, 1180px); padding-top: 18px; }
+      .hero-main, .panel, .api-card { padding: 21px; border-radius: 18px; }
+      .hero-side { border-radius: 18px; }
+      .form-grid { grid-template-columns: 1fr; }
+      footer { flex-direction: column; }
+    }
+  </style>
+</head>
+<body>
+  <main class="wrap">
+    <section class="hero">
+      <div class="card hero-main">
+        <span class="eyebrow"><span class="dot"></span> OuLiPower Prediction Service</span>
+        <h1>光伏功率预测 API</h1>
+        <p class="lead">
+          基于气象预报数据与 GRU 模型,为江门、北流煜炜、清远忠信三个光伏场站生成短期和中期功率预测,并写入业务数据库。
+        </p>
+        <div class="hero-actions">
+          <a class="btn btn-primary" href="/docs">打开 Swagger 文档</a>
+          <a class="btn btn-ghost" href="#quick-test">快速测试接口</a>
+        </div>
+      </div>
+
+      <aside class="card hero-side">
+        <div>
+          <h2>预测能力</h2>
+          <div class="stat">
+            <div class="stat-item">
+              <strong>288</strong>
+              <span>短期预测点<br>未来 3 天</span>
+            </div>
+            <div class="stat-item">
+              <strong>960</strong>
+              <span>中期预测点<br>未来 10 天</span>
+            </div>
+          </div>
+        </div>
+        <div class="badge-row">
+          <span class="badge">15 分钟分辨率</span>
+          <span class="badge">GRU v24</span>
+          <span class="badge">自动写入数据库</span>
+        </div>
+      </aside>
+    </section>
+
+    <div class="section-title">
+      <h2>API 接口</h2>
+      <p>当前接口为同步 GET 请求,预测完成后返回执行结果</p>
+    </div>
+
+    <section class="grid-2">
+      <article class="card api-card">
+        <div class="api-card-head">
+          <h3>短期功率预测</h3>
+          <span class="method">GET</span>
+        </div>
+        <code class="api-path">/api/v1/power/short</code>
+        <p>请求短期模型,输出未来 3 天共 288 个 15 分钟功率点。</p>
+        <div class="badge-row">
+          <span class="badge">projs=场站代码</span>
+          <span class="badge">init_time=上海时间</span>
+        </div>
+      </article>
+
+      <article class="card api-card">
+        <div class="api-card-head">
+          <h3>中期功率预测</h3>
+          <span class="method">GET</span>
+        </div>
+        <code class="api-path">/api/v1/power/medium</code>
+        <p>请求中期模型,输出未来 10 天共 960 个 15 分钟功率点。</p>
+        <div class="badge-row">
+          <span class="badge">projs=场站代码</span>
+          <span class="badge">init_time=上海时间</span>
+        </div>
+      </article>
+    </section>
+
+    <div class="section-title">
+      <h2>支持场站</h2>
+      <p>projs 参数使用以下场站代码</p>
+    </div>
+
+    <section class="station-list">
+      <div class="station">
+        <strong>江门光伏场</strong>
+        <code>JMJD01</code><br>
+        <small>装机容量 4,050 kW</small>
+      </div>
+      <div class="station">
+        <strong>北流煜炜光伏场</strong>
+        <code>YUWEI</code><br>
+        <small>装机容量 3,000 kW</small>
+      </div>
+      <div class="station">
+        <strong>清远忠信光伏场</strong>
+        <code>ZHONGXIN</code><br>
+        <small>装机容量 2,250 kW</small>
+      </div>
+    </section>
+
+    <div class="section-title" id="quick-test">
+      <h2>快速测试</h2>
+      <p>选择场站和起报时间后直接调用接口</p>
+    </div>
+
+    <section class="card panel">
+      <div class="form-grid">
+        <div>
+          <label for="station">场站</label>
+          <select id="station">
+            <option value="JMJD01">JMJD01 · 江门</option>
+            <option value="YUWEI">YUWEI · 北流煜炜</option>
+            <option value="ZHONGXIN">ZHONGXIN · 清远忠信</option>
+          </select>
+        </div>
+        <div>
+          <label for="init-time">起报时间(上海时间)</label>
+          <input id="init-time" type="datetime-local" step="1">
+        </div>
+        <button class="btn btn-primary" onclick="runPrediction('short')">短期预测</button>
+        <button class="btn btn-ghost" onclick="runPrediction('medium')">中期预测</button>
+      </div>
+
+      <div class="result-box" id="result">等待请求……</div>
+
+      <div class="notice">
+        <strong>调用提示</strong>
+        <span>接口会等待模型完成后再返回。请确保起报时间为上海时间,并且数据库和模型文件配置正确。</span>
+      </div>
+    </section>
+
+    <div class="section-title">
+      <h2>调用示例</h2>
+      <p>可直接复制到终端执行</p>
+    </div>
+
+    <pre class="code-block">curl -G "http://127.0.0.1:8000/api/v1/power/short" \
+  --data-urlencode "projs=JMJD01" \
+  --data-urlencode "init_time=2026-11-29 08:00:00"
+
+curl -G "http://127.0.0.1:8000/api/v1/power/medium" \
+  --data-urlencode "projs=JMJD01" \
+  --data-urlencode "init_time=2026-11-29 08:00:00"</pre>
+
+    <footer>
+      <span>OuLiPower V1.0 · Short / Medium Term Forecast API</span>
+      <span><a href="/docs">Swagger</a> · <a href="/redoc">ReDoc</a></span>
+    </footer>
+  </main>
+
+  <script>
+    const station = document.getElementById("station");
+    const initTime = document.getElementById("init-time");
+    const result = document.getElementById("result");
+
+    function defaultDateTime() {
+      const now = new Date();
+      const pad = (n) => String(n).padStart(2, "0");
+      return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}T08:00:00`;
+    }
+
+    initTime.value = defaultDateTime();
+
+    function toApiTime(value) {
+      return value.replace("T", " ") + (value.length === 16 ? ":00" : "");
+    }
+
+    async function runPrediction(period) {
+      const params = new URLSearchParams({
+        projs: station.value,
+        init_time: toApiTime(initTime.value)
+      });
+
+      const url = `/api/v1/power/${period}?${params.toString()}`;
+      result.textContent = `正在请求:${url}\n\n预测任务执行中,请稍候……`;
+
+      try {
+        const response = await fetch(url);
+        const body = await response.json();
+        result.textContent = JSON.stringify(body, null, 2);
+      } catch (error) {
+        result.textContent = `请求失败:\n${error}`;
+      }
+    }
+  </script>
+</body>
+</html>