Parcourir la source

[0917] 光伏电场累计报表

taosj il y a 3 semaines
Parent
commit
2b6493e673

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

@@ -0,0 +1,21 @@
+import request from '@/utils/request'
+
+// 查询光伏电场累计报表
+export function queryPvPlantCumulativeReport(query) {
+  return request({
+    url: '/data/pvPlantCumulativeReport',
+    method: 'post',
+    data: query
+  })
+}
+
+// 导出光伏电场累计报表
+export function exportPvPlantCumulativeReport(query) {
+  return request({
+    url: '/data/pvPlantCumulativeReport/export',
+    method: 'post',
+    data: query,
+    responseType: 'blob',
+    timeout: 120000
+  })
+}

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

@@ -221,6 +221,24 @@ const electricityRoutes = [
         name: 'UltraShorTermForecastYearlyReport',
         component: () => import('@/views/ufo/datareport/ultraShortTermForecastYearlyReport.vue'),
         meta: {title: '超短期预测年报', icon: 'FileTextOutlined'}
+      },
+      {
+        path: 'datareport/pv-plant-cumulative-daily',
+        name: 'PvPlantCumulativeDailyReport',
+        component: () => import('@/views/ufo/datareport/pvPlantCumulativeDailyReport.vue'),
+        meta: {title: '光伏电场累计日报', icon: 'FileTextOutlined'}
+      },
+      {
+        path: 'datareport/pv-plant-cumulative-monthly',
+        name: 'PvPlantCumulativeMonthlyReport',
+        component: () => import('@/views/ufo/datareport/pvPlantCumulativeMonthlyReport.vue'),
+        meta: {title: '光伏电场累计月报', icon: 'FileTextOutlined'}
+      },
+      {
+        path: 'datareport/pv-plant-cumulative-yearly',
+        name: 'PvPlantCumulativeYearlyReport',
+        component: () => import('@/views/ufo/datareport/pvPlantCumulativeYearlyReport.vue'),
+        meta: {title: '光伏电场累计年报', icon: 'FileTextOutlined'}
       }
     ]
   }

+ 164 - 0
forecast-backend-vue/src/views/ufo/datareport/pvPlantCumulativeDailyReport.vue

@@ -0,0 +1,164 @@
+<template>
+  <div class="pv-plant-cumulative-daily-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="pvPlantCumulativeDailyReport">
+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 { queryPvPlantCumulativeReport, exportPvPlantCumulativeReport } from '@/api/data/pvPlantCumulativeReport';
+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(),
+  type: 'daily'
+});
+
+const tableColumns = [
+  { title: '时间', dataIndex: 'time', width: 120 },
+  { title: '平均辐照度(W/m²)', dataIndex: 'avgIrradiance', width: 160 },
+  { title: '最大辐照度(W/m²)', dataIndex: 'maxIrradiance', width: 160 },
+  { title: '累计辐照量(MJ/㎡)', dataIndex: 'totalIrradiation', width: 140 },
+  { title: '并网功率最大对应时间', dataIndex: 'gridMaxPowerTime', width: 170 },
+  { title: '并网功率最大值(MW)', dataIndex: 'gridMaxPowder', width: 150 },
+  { title: '实际发电量(万千瓦时)', dataIndex: 'actualPower', width: 160 },
+  { title: '理论发电量(万千瓦时)', dataIndex: 'theoreticalPower', width: 160 },
+  { title: '有效利用小时数', dataIndex: 'validHours', width: 130 },
+  { title: '累计日照小时数', dataIndex: 'totalHours', width: 120 },
+  { title: '平均风速(m/s)', dataIndex: 'avgWindSpeed', width: 120 },
+  { title: '平均温度(℃)', dataIndex: 'avgTemperature', width: 120 },
+  { title: '组件平均温度(℃)', dataIndex: 'avgBoardTemperature', width: 150 }
+];
+
+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 = () => ({
+  type: query.type,
+  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 queryPvPlantCumulativeReport(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 exportPvPlantCumulativeReport(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-plant-cumulative-daily-page {
+  padding: 16px;
+}
+.full-control {
+  width: 100%;
+}
+</style>

+ 162 - 0
forecast-backend-vue/src/views/ufo/datareport/pvPlantCumulativeMonthlyReport.vue

@@ -0,0 +1,162 @@
+<template>
+  <div class="pv-plant-cumulative-monthly-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-month-picker
+            v-model:value="query.startTime"
+            format="YYYY-MM"
+            placeholder="起始时间"
+            class="full-control"
+          />
+        </a-col>
+        <a-col :xs="24" :md="5">
+          <a-month-picker
+            v-model:value="query.endTime"
+            format="YYYY-MM"
+            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="pvPlantCumulativeMonthlyReport">
+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 { queryPvPlantCumulativeReport, exportPvPlantCumulativeReport } from '@/api/data/pvPlantCumulativeReport';
+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().startOf('month'),
+  endTime: dayjs().startOf('month'),
+  type: 'monthly'
+});
+
+const tableColumns = [
+  { title: '时间', dataIndex: 'time', width: 120 },
+  { title: '平均辐照度(W/m²)', dataIndex: 'avgIrradiance', width: 160 },
+  { title: '最大辐照度(W/m²)', dataIndex: 'maxIrradiance', width: 160 },
+  { title: '累计辐照量(MJ/㎡)', dataIndex: 'totalIrradiation', width: 140 },
+  { title: '并网功率最大对应时间', dataIndex: 'gridMaxPowerTime', width: 170 },
+  { title: '并网功率最大值(MW)', dataIndex: 'gridMaxPowder', width: 150 },
+  { title: '实际发电量(万千瓦时)', dataIndex: 'actualPower', width: 160 },
+  { title: '理论发电量(万千瓦时)', dataIndex: 'theoreticalPower', width: 160 },
+  { title: '有效利用小时数', dataIndex: 'validHours', width: 130 },
+  { title: '累计日照小时数', dataIndex: 'totalHours', width: 120 },
+  { title: '平均风速(m/s)', dataIndex: 'avgWindSpeed', width: 120 },
+  { title: '平均温度(℃)', dataIndex: 'avgTemperature', width: 120 },
+  { title: '组件平均温度(℃)', dataIndex: 'avgBoardTemperature', width: 150 }
+];
+
+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 = () => ({
+  type: query.type,
+  entityId: query.stationId,
+  startTime: dayjs(query.startTime).format('YYYY-MM') + '-01',
+  endTime: dayjs(query.endTime).endOf('month').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 queryPvPlantCumulativeReport(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 exportPvPlantCumulativeReport(buildParams());
+    const isFile = await blobValidate(res);
+    if (isFile) {
+      const name = `光伏电场累计月报-${dayjs(query.startTime).format('YYYYMM')}-${dayjs(query.endTime).format('YYYYMM')}.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-plant-cumulative-monthly-page {
+  padding: 16px;
+}
+.full-control {
+  width: 100%;
+}
+</style>

+ 162 - 0
forecast-backend-vue/src/views/ufo/datareport/pvPlantCumulativeYearlyReport.vue

@@ -0,0 +1,162 @@
+<template>
+  <div class="pv-plant-cumulative-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="pvPlantCumulativeYearlyReport">
+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 { queryPvPlantCumulativeReport, exportPvPlantCumulativeReport } from '@/api/data/pvPlantCumulativeReport';
+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().startOf('year'),
+  endTime: dayjs().startOf('year'),
+  type: 'yearly'
+});
+
+const tableColumns = [
+  { title: '时间', dataIndex: 'time', width: 120 },
+  { title: '平均辐照度(W/m²)', dataIndex: 'avgIrradiance', width: 160 },
+  { title: '最大辐照度(W/m²)', dataIndex: 'maxIrradiance', width: 160 },
+  { title: '累计辐照量(MJ/㎡)', dataIndex: 'totalIrradiation', width: 140 },
+  { title: '并网功率最大对应时间', dataIndex: 'gridMaxPowerTime', width: 170 },
+  { title: '并网功率最大值(MW)', dataIndex: 'gridMaxPowder', width: 150 },
+  { title: '实际发电量(万千瓦时)', dataIndex: 'actualPower', width: 160 },
+  { title: '理论发电量(万千瓦时)', dataIndex: 'theoreticalPower', width: 160 },
+  { title: '有效利用小时数', dataIndex: 'validHours', width: 130 },
+  { title: '累计日照小时数', dataIndex: 'totalHours', width: 120 },
+  { title: '平均风速(m/s)', dataIndex: 'avgWindSpeed', width: 120 },
+  { title: '平均温度(℃)', dataIndex: 'avgTemperature', width: 120 },
+  { title: '组件平均温度(℃)', dataIndex: 'avgBoardTemperature', width: 150 }
+];
+
+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 = () => ({
+  type: query.type,
+  entityId: query.stationId,
+  startTime: dayjs(query.startTime).startOf('year').format('YYYY-MM-DD HH:mm:ss'),
+  endTime: dayjs(query.endTime).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 queryPvPlantCumulativeReport(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 exportPvPlantCumulativeReport(buildParams());
+    const isFile = await blobValidate(res);
+    if (isFile) {
+      const name = `光伏电场累计年报-${dayjs(query.startTime).format('YYYY')}-${dayjs(query.endTime).format('YYYY')}.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-plant-cumulative-yearly-page {
+  padding: 16px;
+}
+.full-control {
+  width: 100%;
+}
+</style>

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

@@ -29,3 +29,15 @@ INSERT INTO "public"."sys_menu" ("menu_id", "menu_name", "parent_id", "order_num
 INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 2091);
 INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 2092);
 INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 2093);
+
+-- =============================================================================
+-- 任务编号 2026091401  增加"光伏电场累计报表"功能
+-- =============================================================================
+
+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 (2101, '光伏电场累计日报', 2016, 9, 'pv-plant-cumulative-daily', 'ufo/datareport/pvPlantCumulativeDailyReport', '', 'PvPlantCumulativeDailyReport', 1, 0, 'C', '0', '0', 'data:pvPlantCumulativeReport:daily', 'file-text', 'admin', '2026-09-14 00:00:00', '', NULL, '光伏电场累计日报页面');
+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 (2102, '光伏电场累计月报', 2016, 10, 'pv-plant-cumulative-monthly', 'ufo/datareport/pvPlantCumulativeMonthlyReport', '', 'PvPlantCumulativeMonthlyReport', 1, 0, 'C', '0', '0', 'data:pvPlantCumulativeReport:monthly', 'file-text', 'admin', '2026-09-14 00:00:00', '', NULL, '光伏电场累计月报页面');
+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 (2103, '光伏电场累计年报', 2016, 11, 'pv-plant-cumulative-yearly', 'ufo/datareport/pvPlantCumulativeYearlyReport', '', 'PvPlantCumulativeYearlyReport', 1, 0, 'C', '0', '0', 'data:pvPlantCumulativeReport:yearly', 'file-text', 'admin', '2026-09-14 00:00:00', '', NULL, '光伏电场累计年报页面');
+
+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);