Browse Source

[0917] 辐照度累计值报表

taosj 1 week ago
parent
commit
7a6a704f0c

+ 1 - 1
forecast-backend-server/src/main/java/com/ufo/project/weather/service/impl/DataWeatherLocalServiceImpl.java

@@ -222,7 +222,7 @@ public class DataWeatherLocalServiceImpl implements IDataWeatherLocalService
     @Override
     public List<DataWeatherLocal> selectForCumulativeIrradiance(String stationId, String startTime, String endTime)
     {
-        Long startTs = parseDateToTimestamp(startTime);
+        Long startTs = parseDateToTimestamp(startTime + " 00:00:00");
         Long endTs = parseDateToTimestamp(endTime + " 23:59:59");
         return dataWeatherLocalMapper.selectDataWeatherLocalListByTimeRange(
                 Long.valueOf(stationId), startTs, endTs);

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

@@ -0,0 +1,21 @@
+import request from '@/utils/request'
+
+// 查询辐照度累计值报表
+export function queryCumulativeIrradiance(query) {
+  return request({
+    url: '/data/cumulativeIrradiance',
+    method: 'post',
+    data: query
+  })
+}
+
+// 导出辐照度累计值报表
+export function exportCumulativeIrradiance(query) {
+  return request({
+    url: '/data/cumulativeIrradiance/export',
+    method: 'post',
+    data: query,
+    responseType: 'blob',
+    timeout: 120000
+  })
+}

+ 144 - 0
forecast-backend-vue/src/views/ufo/electricity/datareport/cumulativeIrradianceDataReport.vue

@@ -0,0 +1,144 @@
+<template>
+  <div class="cumulative-irradiance-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="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="CumulativeIrradianceDataReport">
+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 { queryCumulativeIrradiance, exportCumulativeIrradiance } from '@/api/data/cumulativeIrradiance';
+import BusinessDataTable from '../components/BusinessDataTable.vue';
+import StationSelector from '../components/StationSelector.vue';
+import { normalizeRows, toStationOptions } from '../components/dataAdapter.js';
+
+const loading = ref(false);
+const exporting = ref(false);
+const stationOptions = ref([]);
+const tableRows = ref([]);
+
+const query = reactive({
+  stationId: undefined,
+  startTime: dayjs()
+});
+
+const tableColumns = [
+  { title: '时间', dataIndex: 'time', width: 120 },
+  { title: '总辐照度(W/㎡)', 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) return false;
+  return true;
+});
+
+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.startTime).format('YYYY-MM-DD')
+});
+
+const handleQuery = async () => {
+  if (!query.stationId) {
+    message.warning('请先选择场站');
+    return;
+  }
+  if (!queryValid.value) return;
+
+  loading.value = true;
+  try {
+    const res = await queryCumulativeIrradiance(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 exportCumulativeIrradiance(buildParams());
+    const isFile = await blobValidate(res);
+    if (isFile) {
+      const name = `辐照度累计值报表-${dayjs(query.startTime).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>
+.cumulative-irradiance-report-page {
+  padding: 16px;
+}
+.full-control {
+  width: 100%;
+}
+</style>

+ 10 - 1
release_note/2026.09.17/20260917_dp.sql

@@ -46,11 +46,20 @@ 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, '光伏气象资源数据报表', 2087, 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 "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, '光伏气象资源数据报表', 2087, 12, 'pv-meteorological-resource-data', 'ufo/electricity/datareport/pvMeteorologicalResourceDataReport', '', 'PvMeteorologicalResourceDataReport', 1, 0, 'C', '0', '0', 'data:pvMeteorologicalResourceData:list', 'HeatMapOutlined', 'admin', '2026-09-14 00:00:00', '', NULL, '光伏气象资源数据报表页面');
 
 INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 2111);
 
 
+-- =============================================================================
+-- 任务编号 2026091601  增加"辐照度累计值报表"功能
+-- =============================================================================
+
+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 (2121, '辐照度累计值报表', 2087, 13, 'cumulative-irradiance', 'ufo/electricity/datareport/cumulativeIrradianceDataReport', '', 'CumulativeIrradianceDataReport', 1, 0, 'C', '0', '0', 'data:cumulativeIrradiance:list', 'DotChartOutlined', 'admin', '2026-09-16 00:00:00', '', NULL, '辐照度累计值报表页面');
+
+INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 2121);
+
+
 -- 修复菜单名称
 update "public"."sys_menu" set menu_name = '湿度曲线图' where menu_name = '温度曲线图' and menu_id = 2074;
 update "public"."sys_menu" set menu_name = '气压曲线图' where menu_name = '湿度曲线图' and menu_id = 2075;