| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560 |
- <!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>
|