api_home.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. <!doctype html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>OuLiPower 光伏功率预测 API</title>
  7. <style>
  8. :root {
  9. --bg: #f4f7f5;
  10. --paper: #ffffff;
  11. --ink: #17251f;
  12. --muted: #66756e;
  13. --line: #dce5e0;
  14. --accent: #126b4d;
  15. --accent-soft: #e5f4ed;
  16. --accent-dark: #0b4f39;
  17. --warning: #8a5b12;
  18. --warning-soft: #fff5dc;
  19. --code: #13241d;
  20. --shadow: 0 18px 45px rgba(30, 61, 49, 0.08);
  21. }
  22. * { box-sizing: border-box; }
  23. body {
  24. margin: 0;
  25. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
  26. "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  27. background:
  28. radial-gradient(circle at 8% 0%, #d8eee3 0, transparent 28rem),
  29. radial-gradient(circle at 100% 8%, #eaf0d9 0, transparent 24rem),
  30. var(--bg);
  31. color: var(--ink);
  32. min-height: 100vh;
  33. line-height: 1.65;
  34. }
  35. .wrap {
  36. width: min(1180px, calc(100% - 36px));
  37. margin: 0 auto;
  38. padding: 36px 0 52px;
  39. }
  40. .hero {
  41. display: grid;
  42. grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr);
  43. gap: 20px;
  44. margin-bottom: 22px;
  45. }
  46. .card {
  47. background: rgba(255, 255, 255, .92);
  48. border: 1px solid var(--line);
  49. border-radius: 22px;
  50. box-shadow: var(--shadow);
  51. }
  52. .hero-main {
  53. padding: 34px 36px;
  54. position: relative;
  55. overflow: hidden;
  56. }
  57. .hero-main::after {
  58. content: "";
  59. position: absolute;
  60. width: 230px;
  61. height: 230px;
  62. right: -70px;
  63. bottom: -100px;
  64. border-radius: 50%;
  65. background: linear-gradient(145deg, #c9eedb, #eef5df);
  66. opacity: .8;
  67. }
  68. .eyebrow {
  69. display: inline-flex;
  70. align-items: center;
  71. gap: 8px;
  72. padding: 7px 12px;
  73. border-radius: 999px;
  74. background: var(--accent-soft);
  75. color: var(--accent-dark);
  76. font-size: 13px;
  77. font-weight: 700;
  78. letter-spacing: .02em;
  79. }
  80. .dot {
  81. width: 8px;
  82. height: 8px;
  83. border-radius: 50%;
  84. background: #19a56d;
  85. box-shadow: 0 0 0 4px rgba(25, 165, 109, .12);
  86. }
  87. h1 {
  88. margin: 18px 0 10px;
  89. font-size: clamp(30px, 4vw, 50px);
  90. line-height: 1.16;
  91. letter-spacing: -.035em;
  92. }
  93. .lead {
  94. max-width: 700px;
  95. margin: 0;
  96. color: var(--muted);
  97. font-size: 16px;
  98. }
  99. .hero-actions {
  100. display: flex;
  101. flex-wrap: wrap;
  102. gap: 10px;
  103. margin-top: 24px;
  104. position: relative;
  105. z-index: 1;
  106. }
  107. .btn {
  108. border: 1px solid transparent;
  109. border-radius: 12px;
  110. padding: 10px 16px;
  111. font: inherit;
  112. font-weight: 700;
  113. cursor: pointer;
  114. text-decoration: none;
  115. display: inline-flex;
  116. align-items: center;
  117. justify-content: center;
  118. gap: 8px;
  119. transition: .18s ease;
  120. }
  121. .btn-primary {
  122. color: white;
  123. background: var(--accent);
  124. }
  125. .btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); }
  126. .btn-ghost {
  127. color: var(--accent-dark);
  128. background: white;
  129. border-color: #bcd6ca;
  130. }
  131. .btn-ghost:hover { background: var(--accent-soft); }
  132. .hero-side {
  133. padding: 24px;
  134. display: flex;
  135. flex-direction: column;
  136. justify-content: space-between;
  137. gap: 20px;
  138. background: linear-gradient(160deg, #163f31, #0d2b21);
  139. color: white;
  140. border-color: #163f31;
  141. }
  142. .hero-side h2 {
  143. font-size: 16px;
  144. margin: 0 0 14px;
  145. color: #cce8da;
  146. }
  147. .stat {
  148. display: grid;
  149. grid-template-columns: 1fr 1fr;
  150. gap: 12px;
  151. }
  152. .stat-item {
  153. padding: 14px;
  154. border-radius: 14px;
  155. background: rgba(255, 255, 255, .08);
  156. border: 1px solid rgba(255, 255, 255, .1);
  157. }
  158. .stat-item strong {
  159. display: block;
  160. font-size: 24px;
  161. line-height: 1;
  162. margin-bottom: 6px;
  163. }
  164. .stat-item span { font-size: 12px; color: #bcd6ca; }
  165. .section-title {
  166. display: flex;
  167. align-items: end;
  168. justify-content: space-between;
  169. gap: 16px;
  170. margin: 30px 2px 12px;
  171. }
  172. .section-title h2 {
  173. margin: 0;
  174. font-size: 23px;
  175. letter-spacing: -.02em;
  176. }
  177. .section-title p {
  178. margin: 0;
  179. color: var(--muted);
  180. font-size: 13px;
  181. }
  182. .grid-2 {
  183. display: grid;
  184. grid-template-columns: repeat(2, minmax(0, 1fr));
  185. gap: 18px;
  186. }
  187. .api-card { padding: 24px; }
  188. .api-card-head {
  189. display: flex;
  190. align-items: center;
  191. justify-content: space-between;
  192. gap: 12px;
  193. margin-bottom: 12px;
  194. }
  195. .method {
  196. font-size: 12px;
  197. font-weight: 800;
  198. letter-spacing: .05em;
  199. color: var(--accent-dark);
  200. background: var(--accent-soft);
  201. border-radius: 999px;
  202. padding: 5px 10px;
  203. }
  204. .api-card h3 { margin: 0; font-size: 19px; }
  205. .api-path {
  206. display: block;
  207. margin: 10px 0 16px;
  208. border-radius: 12px;
  209. padding: 11px 13px;
  210. background: var(--code);
  211. color: #d9f5e8;
  212. font-family: "SFMono-Regular", Consolas, monospace;
  213. font-size: 13px;
  214. overflow-wrap: anywhere;
  215. }
  216. .api-card p { color: var(--muted); margin: 0 0 15px; }
  217. .badge-row { display: flex; flex-wrap: wrap; gap: 7px; }
  218. .badge {
  219. padding: 5px 9px;
  220. border-radius: 8px;
  221. background: #f1f5f3;
  222. border: 1px solid var(--line);
  223. color: #52625b;
  224. font-size: 12px;
  225. }
  226. .panel { padding: 25px; }
  227. .form-grid {
  228. display: grid;
  229. grid-template-columns: 1fr 1.2fr auto auto;
  230. align-items: end;
  231. gap: 12px;
  232. }
  233. label {
  234. display: block;
  235. font-size: 12px;
  236. font-weight: 700;
  237. color: #50615a;
  238. margin-bottom: 6px;
  239. }
  240. input, select {
  241. width: 100%;
  242. border: 1px solid #cbd9d2;
  243. border-radius: 11px;
  244. background: white;
  245. padding: 11px 12px;
  246. color: var(--ink);
  247. font: inherit;
  248. outline: none;
  249. min-height: 44px;
  250. }
  251. input:focus, select:focus {
  252. border-color: var(--accent);
  253. box-shadow: 0 0 0 3px rgba(18, 107, 77, .12);
  254. }
  255. .result-box {
  256. margin-top: 18px;
  257. min-height: 160px;
  258. border-radius: 14px;
  259. border: 1px solid #203a31;
  260. background: #0e1a16;
  261. color: #d9f5e8;
  262. padding: 16px;
  263. overflow: auto;
  264. max-height: 360px;
  265. font-family: "SFMono-Regular", Consolas, monospace;
  266. font-size: 12px;
  267. white-space: pre-wrap;
  268. word-break: break-word;
  269. }
  270. .notice {
  271. display: flex;
  272. gap: 12px;
  273. padding: 15px 17px;
  274. margin-top: 18px;
  275. border-radius: 13px;
  276. background: var(--warning-soft);
  277. color: var(--warning);
  278. border: 1px solid #f0dfb5;
  279. font-size: 13px;
  280. }
  281. .notice strong { white-space: nowrap; }
  282. .code-block {
  283. margin: 0;
  284. border-radius: 14px;
  285. padding: 18px;
  286. background: #0e1a16;
  287. color: #d9f5e8;
  288. overflow: auto;
  289. font-family: "SFMono-Regular", Consolas, monospace;
  290. font-size: 12px;
  291. line-height: 1.65;
  292. white-space: pre;
  293. }
  294. .station-list {
  295. display: grid;
  296. grid-template-columns: repeat(3, minmax(0, 1fr));
  297. gap: 12px;
  298. }
  299. .station {
  300. padding: 18px;
  301. border-radius: 15px;
  302. background: #fbfffd;
  303. border: 1px solid var(--line);
  304. }
  305. .station strong { display: block; margin-bottom: 5px; }
  306. .station code { color: var(--accent-dark); font-weight: 700; }
  307. .station small { color: var(--muted); }
  308. footer {
  309. display: flex;
  310. justify-content: space-between;
  311. gap: 16px;
  312. color: #7d8b84;
  313. font-size: 12px;
  314. padding: 22px 2px 0;
  315. }
  316. @media (max-width: 920px) {
  317. .hero, .grid-2 { grid-template-columns: 1fr; }
  318. .form-grid { grid-template-columns: 1fr 1fr; }
  319. .form-grid .btn { width: 100%; }
  320. .station-list { grid-template-columns: 1fr; }
  321. }
  322. @media (max-width: 620px) {
  323. .wrap { width: min(100% - 22px, 1180px); padding-top: 18px; }
  324. .hero-main, .panel, .api-card { padding: 21px; border-radius: 18px; }
  325. .hero-side { border-radius: 18px; }
  326. .form-grid { grid-template-columns: 1fr; }
  327. footer { flex-direction: column; }
  328. }
  329. </style>
  330. </head>
  331. <body>
  332. <main class="wrap">
  333. <section class="hero">
  334. <div class="card hero-main">
  335. <span class="eyebrow"><span class="dot"></span> OuLiPower Prediction Service</span>
  336. <h1>光伏功率预测 API</h1>
  337. <p class="lead">
  338. 基于气象预报数据与 GRU 模型,为江门、北流煜炜、清远忠信三个光伏场站生成短期和中期功率预测,并写入业务数据库。
  339. </p>
  340. <div class="hero-actions">
  341. <a class="btn btn-primary" href="/docs">打开 Swagger 文档</a>
  342. <a class="btn btn-ghost" href="#quick-test">快速测试接口</a>
  343. </div>
  344. </div>
  345. <aside class="card hero-side">
  346. <div>
  347. <h2>预测能力</h2>
  348. <div class="stat">
  349. <div class="stat-item">
  350. <strong>288</strong>
  351. <span>短期预测点<br>未来 3 天</span>
  352. </div>
  353. <div class="stat-item">
  354. <strong>960</strong>
  355. <span>中期预测点<br>未来 10 天</span>
  356. </div>
  357. </div>
  358. </div>
  359. <div class="badge-row">
  360. <span class="badge">15 分钟分辨率</span>
  361. <span class="badge">GRU v24</span>
  362. <span class="badge">自动写入数据库</span>
  363. </div>
  364. </aside>
  365. </section>
  366. <div class="section-title">
  367. <h2>API 接口</h2>
  368. <p>当前接口为同步 GET 请求,预测完成后返回执行结果</p>
  369. </div>
  370. <section class="grid-2">
  371. <article class="card api-card">
  372. <div class="api-card-head">
  373. <h3>短期功率预测</h3>
  374. <span class="method">GET</span>
  375. </div>
  376. <code class="api-path">/api/v1/power/short</code>
  377. <p>请求短期模型,输出未来 3 天共 288 个 15 分钟功率点。</p>
  378. <div class="badge-row">
  379. <span class="badge">projs=场站代码</span>
  380. <span class="badge">init_time=上海时间</span>
  381. </div>
  382. </article>
  383. <article class="card api-card">
  384. <div class="api-card-head">
  385. <h3>中期功率预测</h3>
  386. <span class="method">GET</span>
  387. </div>
  388. <code class="api-path">/api/v1/power/medium</code>
  389. <p>请求中期模型,输出未来 10 天共 960 个 15 分钟功率点。</p>
  390. <div class="badge-row">
  391. <span class="badge">projs=场站代码</span>
  392. <span class="badge">init_time=上海时间</span>
  393. </div>
  394. </article>
  395. </section>
  396. <div class="section-title">
  397. <h2>支持场站</h2>
  398. <p>projs 参数使用以下场站代码</p>
  399. </div>
  400. <section class="station-list">
  401. <div class="station">
  402. <strong>江门光伏场</strong>
  403. <code>JMJD01</code><br>
  404. <small>装机容量 4,050 kW</small>
  405. </div>
  406. <div class="station">
  407. <strong>北流煜炜光伏场</strong>
  408. <code>YUWEI</code><br>
  409. <small>装机容量 3,000 kW</small>
  410. </div>
  411. <div class="station">
  412. <strong>清远忠信光伏场</strong>
  413. <code>ZHONGXIN</code><br>
  414. <small>装机容量 2,250 kW</small>
  415. </div>
  416. </section>
  417. <div class="section-title" id="quick-test">
  418. <h2>快速测试</h2>
  419. <p>选择场站和起报时间后直接调用接口</p>
  420. </div>
  421. <section class="card panel">
  422. <div class="form-grid">
  423. <div>
  424. <label for="station">场站</label>
  425. <select id="station">
  426. <option value="JMJD01">JMJD01 · 江门</option>
  427. <option value="YUWEI">YUWEI · 北流煜炜</option>
  428. <option value="ZHONGXIN">ZHONGXIN · 清远忠信</option>
  429. </select>
  430. </div>
  431. <div>
  432. <label for="init-time">起报时间(上海时间)</label>
  433. <input id="init-time" type="datetime-local" step="1">
  434. </div>
  435. <button class="btn btn-primary" onclick="runPrediction('short')">短期预测</button>
  436. <button class="btn btn-ghost" onclick="runPrediction('medium')">中期预测</button>
  437. </div>
  438. <div class="result-box" id="result">等待请求……</div>
  439. <div class="notice">
  440. <strong>调用提示</strong>
  441. <span>接口会等待模型完成后再返回。请确保起报时间为上海时间,并且数据库和模型文件配置正确。</span>
  442. </div>
  443. </section>
  444. <div class="section-title">
  445. <h2>调用示例</h2>
  446. <p>可直接复制到终端执行</p>
  447. </div>
  448. <pre class="code-block">curl -G "http://127.0.0.1:8000/api/v1/power/short" \
  449. --data-urlencode "projs=JMJD01" \
  450. --data-urlencode "init_time=2026-11-29 08:00:00"
  451. curl -G "http://127.0.0.1:8000/api/v1/power/medium" \
  452. --data-urlencode "projs=JMJD01" \
  453. --data-urlencode "init_time=2026-11-29 08:00:00"</pre>
  454. <footer>
  455. <span>OuLiPower V1.0 · Short / Medium Term Forecast API</span>
  456. <span><a href="/docs">Swagger</a> · <a href="/redoc">ReDoc</a></span>
  457. </footer>
  458. </main>
  459. <script>
  460. const station = document.getElementById("station");
  461. const initTime = document.getElementById("init-time");
  462. const result = document.getElementById("result");
  463. function defaultDateTime() {
  464. const now = new Date();
  465. const pad = (n) => String(n).padStart(2, "0");
  466. return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}T08:00:00`;
  467. }
  468. initTime.value = defaultDateTime();
  469. function toApiTime(value) {
  470. return value.replace("T", " ") + (value.length === 16 ? ":00" : "");
  471. }
  472. async function runPrediction(period) {
  473. const params = new URLSearchParams({
  474. projs: station.value,
  475. init_time: toApiTime(initTime.value)
  476. });
  477. const url = `/api/v1/power/${period}?${params.toString()}`;
  478. result.textContent = `正在请求:${url}\n\n预测任务执行中,请稍候……`;
  479. try {
  480. const response = await fetch(url);
  481. const body = await response.json();
  482. result.textContent = JSON.stringify(body, null, 2);
  483. } catch (error) {
  484. result.textContent = `请求失败:\n${error}`;
  485. }
  486. }
  487. </script>
  488. </body>
  489. </html>