Browse Source

[0917] 光伏气象资源数据报表

taosj 5 days ago
parent
commit
d28f7f8a10

+ 21 - 0
forecast-backend-vue/src/api/data/pvMeteorologicalResourceData.js

@@ -0,0 +1,21 @@
+import request from '@/utils/request'
+
+// 查询光伏气象资源数据
+export function queryPvMeteorologicalResourceData(query) {
+  return request({
+    url: '/data/pvMeteorologicalResourceData',
+    method: 'post',
+    data: query
+  })
+}
+
+// 导出光伏气象资源数据
+export function exportPvMeteorologicalResourceData(query) {
+  return request({
+    url: '/data/pvMeteorologicalResourceData/export',
+    method: 'post',
+    data: query,
+    responseType: 'blob',
+    timeout: 120000
+  })
+}

+ 6 - 0
forecast-backend-vue/src/router/electricity.js

@@ -239,6 +239,12 @@ const electricityRoutes = [
         name: 'PvPlantCumulativeYearlyReport',
         component: () => import('@/views/ufo/datareport/pvPlantCumulativeYearlyReport.vue'),
         meta: {title: '光伏电场累计年报', icon: 'FileTextOutlined'}
+      },
+      {
+        path: 'datareport/pv-meteorological-resource-data',
+        name: 'PvMeteorologicalResourceDataReport',
+        component: () => import('@/views/ufo/datareport/pvMeteorologicalResourceDataReport.vue'),
+        meta: {title: '光伏气象资源数据报表', icon: 'FileTextOutlined'}
       }
     ]
   }

+ 157 - 0
forecast-backend-vue/src/views/ufo/datareport/pvMeteorologicalResourceDataReport.vue

@@ -0,0 +1,157 @@
+<template>
+  <div class="pv-meteorological-resource-data-report-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-date-picker
+            v-model:value="query.startTime"
+            format="YYYY-MM-DD"
+            value-format="YYYY-MM-DD"
+            placeholder="起始时间"
+            class="full-control"
+          />
+        </a-col>
+        <a-col :xs="24" :md="5">
+          <a-date-picker
+            v-model:value="query.endTime"
+            format="YYYY-MM-DD"
+            value-format="YYYY-MM-DD"
+            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="pvMeteorologicalResourceDataReport">
+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 { queryPvMeteorologicalResourceData, exportPvMeteorologicalResourceData } from '@/api/data/pvMeteorologicalResourceData';
+import BusinessDataTable from '../electricity/components/BusinessDataTable.vue';
+import StationSelector from '../electricity/components/StationSelector.vue';
+import { normalizeRows, toStationOptions } from '../electricity/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', width: 120 },
+  { title: '总辐照度(W/m²)', dataIndex: 'totalIrradiation', width: 160 },
+  { title: '组件温度(℃)', dataIndex: 'boardTemperature', width: 130 },
+  { title: '风速(m/s)', dataIndex: 'windSpeed', width: 110 },
+  { title: '风向(度)', dataIndex: 'windDirection', width: 100 },
+  { title: '温度(℃)', dataIndex: 'temperature', width: 110 },
+  { title: '湿度(%RH)', dataIndex: 'humidity', width: 110 },
+  { title: '气压(hPa)', dataIndex: 'pressure', width: 120 }
+];
+
+const queryValid = computed(() => {
+  if (!query.startTime || !query.endTime) return false;
+  const start = dayjs(query.startTime);
+  const end = dayjs(query.endTime);
+  if (!start.isValid() || !end.isValid()) return false;
+  return !end.isBefore(start);
+});
+
+const loadStationOptions = async () => {
+  const res = await listStation({ pageNum: 1, pageSize: 500 });
+  stationOptions.value = toStationOptions(normalizeRows(res));
+  if (!query.stationId && stationOptions.value.length) {
+    query.stationId = stationOptions.value[0].value;
+  }
+};
+
+const buildParams = () => ({
+  entityId: query.stationId,
+  startTime: dayjs(query.startTime).format('YYYY-MM-DD'),
+  endTime: dayjs(query.endTime).format('YYYY-MM-DD')
+});
+
+const handleQuery = async () => {
+  if (!query.stationId) {
+    message.warning('请先选择场站');
+    return;
+  }
+  if (!queryValid.value) return;
+
+  loading.value = true;
+  try {
+    const res = await queryPvMeteorologicalResourceData(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 exportPvMeteorologicalResourceData(buildParams());
+    const isFile = await blobValidate(res);
+    if (isFile) {
+      const name = `光伏气象资源数据-${dayjs(query.startTime).format('YYYYMMDD')}-${dayjs(query.endTime).format('YYYYMMDD')}.xlsx`;
+      saveAs(new Blob([res]), name);
+      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;
+  }
+};
+
+onMounted(async () => {
+  await loadStationOptions();
+  await handleQuery();
+});
+</script>
+
+<style lang="less" scoped>
+.pv-meteorological-resource-data-report-page {
+  padding: 16px;
+}
+.full-control {
+  width: 100%;
+}
+</style>

+ 8 - 0
release_note/2026.09.17/20260917_dp.sql

@@ -41,3 +41,11 @@ INSERT INTO "public"."sys_menu" ("menu_id", "menu_name", "parent_id", "order_num
 INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 2101);
 INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 2102);
 INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 2103);
+
+-- =============================================================================
+-- 任务编号 2026091402  增加"光伏气象资源数据报表"功能
+-- =============================================================================
+
+INSERT INTO "public"."sys_menu" ("menu_id", "menu_name", "parent_id", "order_num", "path", "component", "query", "route_name", "is_frame", "is_cache", "menu_type", "visible", "status", "perms", "icon", "create_by", "create_time", "update_by", "update_time", "remark") VALUES (2111, '光伏气象资源数据报表', 2016, 12, 'pv-meteorological-resource-data', 'ufo/datareport/pvMeteorologicalResourceDataReport', '', 'PvMeteorologicalResourceDataReport', 1, 0, 'C', '0', '0', 'data:pvMeteorologicalResourceData:list', 'file-text', 'admin', '2026-09-14 00:00:00', '', NULL, '光伏气象资源数据报表页面');
+
+INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 2111);