|
|
@@ -0,0 +1,169 @@
|
|
|
+<template>
|
|
|
+ <div class="shor-term-forecast-yearly-page">
|
|
|
+ <a-card :bordered="false">
|
|
|
+ <a-row :gutter="[12, 12]" align="middle">
|
|
|
+ <a-col :xs="24" :md="6">
|
|
|
+ <StationSelector v-model:value="query.stationId" :options="stationOptions" :multiple="false" />
|
|
|
+ </a-col>
|
|
|
+ <a-col :xs="24" :md="5">
|
|
|
+ <a-year-picker
|
|
|
+ v-model:value="query.startTime"
|
|
|
+ format="YYYY"
|
|
|
+ placeholder="起始时间"
|
|
|
+ class="full-control"
|
|
|
+ />
|
|
|
+ </a-col>
|
|
|
+ <a-col :xs="24" :md="5">
|
|
|
+ <a-year-picker
|
|
|
+ v-model:value="query.endTime"
|
|
|
+ format="YYYY"
|
|
|
+ placeholder="截止时间"
|
|
|
+ class="full-control"
|
|
|
+ />
|
|
|
+ </a-col>
|
|
|
+ <a-col :xs="24" :md="8">
|
|
|
+ <a-space>
|
|
|
+ <a-button type="primary" :loading="loading" :disabled="!queryValid" @click="handleQuery">确认</a-button>
|
|
|
+ <a-button :loading="exporting" :disabled="!queryValid" @click="handleExport">导出</a-button>
|
|
|
+ </a-space>
|
|
|
+ </a-col>
|
|
|
+ </a-row>
|
|
|
+ </a-card>
|
|
|
+
|
|
|
+ <a-card title="数据详情" :bordered="false" style="margin-top: 16px">
|
|
|
+ <BusinessDataTable
|
|
|
+ :columns="tableColumns"
|
|
|
+ :data-source="tableRows"
|
|
|
+ :pagination="{ pageSize: 10 }"
|
|
|
+ :scroll-x="'max-content'"
|
|
|
+ />
|
|
|
+ </a-card>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup name="shorTermForecastYearlyReport">
|
|
|
+import { computed, onMounted, reactive, ref } from 'vue';
|
|
|
+import { message } from 'ant-design-vue';
|
|
|
+import dayjs from 'dayjs';
|
|
|
+import { saveAs } from 'file-saver';
|
|
|
+import { blobValidate } from '@/utils/bearjia';
|
|
|
+import { listStation } from '@/api/config/station';
|
|
|
+import { queryShortTermForecastReport, exportShortTermForecastReport } from '@/api/power/shortTermForecastReport';
|
|
|
+import BusinessDataTable from '../components/BusinessDataTable.vue';
|
|
|
+import StationSelector from '../components/StationSelector.vue';
|
|
|
+import { normalizeRows } from '../components/dataAdapter';
|
|
|
+
|
|
|
+const loading = ref(false);
|
|
|
+const exporting = ref(false);
|
|
|
+const stationOptions = ref([]);
|
|
|
+const tableRows = ref([]);
|
|
|
+
|
|
|
+const query = reactive({
|
|
|
+ stationId: undefined,
|
|
|
+ startTime: dayjs(),
|
|
|
+ endTime: dayjs(),
|
|
|
+});
|
|
|
+
|
|
|
+const tableColumns = [
|
|
|
+ { title: '时间', dataIndex: 'time' },
|
|
|
+ { title: '开机容量(MW)', dataIndex: 'operatingCapacity' },
|
|
|
+ { title: '实发功率(MW)', dataIndex: 'actualPower' },
|
|
|
+ { title: '预测功率(MW)', dataIndex: 'forecastPower' },
|
|
|
+ { title: '均方根差', dataIndex: 'rootMeanSquareError' },
|
|
|
+ { title: '平均绝对误差', dataIndex: 'meanAbsoluteError' },
|
|
|
+ { title: '相关性系数', dataIndex: 'correlationCoefficientR' },
|
|
|
+ { title: '最大误差合格率(%)', dataIndex: 'maximumErrorPassRate' },
|
|
|
+];
|
|
|
+
|
|
|
+const queryValid = computed(() => {
|
|
|
+ if (!query.stationId) return false;
|
|
|
+ if (!query.startTime || !query.endTime) return false;
|
|
|
+ return true;
|
|
|
+});
|
|
|
+
|
|
|
+const buildParams = () => {
|
|
|
+ const start = dayjs(query.startTime);
|
|
|
+ const end = dayjs(query.endTime);
|
|
|
+ return {
|
|
|
+ type: 'yearly',
|
|
|
+ entityId: String(query.stationId),
|
|
|
+ startTime: start.startOf('year').format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ endTime: end.endOf('year').format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ };
|
|
|
+};
|
|
|
+
|
|
|
+const handleQuery = async () => {
|
|
|
+ if (!query.stationId) {
|
|
|
+ message.warning('请先选择场站');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!queryValid.value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ loading.value = true;
|
|
|
+ try {
|
|
|
+ const res = await queryShortTermForecastReport(buildParams());
|
|
|
+ tableRows.value = normalizeRows(res);
|
|
|
+ } finally {
|
|
|
+ loading.value = false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const handleExport = async () => {
|
|
|
+ if (!query.stationId) {
|
|
|
+ message.warning('请先选择场站');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!queryValid.value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ exporting.value = true;
|
|
|
+ try {
|
|
|
+ const res = await exportShortTermForecastReport(buildParams());
|
|
|
+ const isFile = await blobValidate(res);
|
|
|
+ if (isFile) {
|
|
|
+ const start = dayjs(query.startTime).format('YYYY');
|
|
|
+ const end = dayjs(query.endTime).format('YYYY');
|
|
|
+ saveAs(new Blob([res]), `短期预测年报-${start}-${end}.xlsx`);
|
|
|
+ message.success('导出成功');
|
|
|
+ } else {
|
|
|
+ const text = await res.text();
|
|
|
+ let msg = '导出失败';
|
|
|
+ try { msg = JSON.parse(text)?.msg || msg; } catch (e) { /* ignore */ }
|
|
|
+ message.error(msg);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ exporting.value = false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+async function loadStationOptions() {
|
|
|
+ try {
|
|
|
+ const res = await listStation({ pageNum: 1, pageSize: 500 });
|
|
|
+ const rows = normalizeRows(res);
|
|
|
+ stationOptions.value = rows.map((item, index) => ({
|
|
|
+ label: item.stationName || item.name || item.entityName || item.siteName || '未知场站',
|
|
|
+ value: item.id || item.stationId || item.entityId || `station-${index + 1}`,
|
|
|
+ }));
|
|
|
+ if (!query.stationId && stationOptions.value.length) {
|
|
|
+ query.stationId = stationOptions.value[0].value;
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ /* ignore */
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(async () => {
|
|
|
+ await loadStationOptions();
|
|
|
+ await handleQuery();
|
|
|
+});
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.shor-term-forecast-yearly-page {
|
|
|
+ padding: 16px;
|
|
|
+}
|
|
|
+.full-control {
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
+</style>
|