From 96c2cf1e21dab5211239e772cc3a287c0eb4729b Mon Sep 17 00:00:00 2001 From: wzy-warehouse <18135009705@163.com> Date: Tue, 5 May 2026 17:09:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=99=8D=E9=9B=A8=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/api.ts | 15 +++++++ src/api/meteorology.ts | 14 +++++++ .../rain-earthquake/RightButtonComponent.vue | 2 +- src/config/config.json | 3 +- src/hooks/rain-earthquake/useRightHandle.ts | 21 +++++++++- src/hooks/rainstorm/useRainDisasterChain.ts | 40 +++++++++++++------ src/types/rainstorm/RainfallGridRequest.ts | 10 +++++ src/types/rainstorm/RainfallGridResponse.ts | 30 ++++++++++++++ 8 files changed, 120 insertions(+), 15 deletions(-) create mode 100644 src/api/meteorology.ts create mode 100644 src/types/rainstorm/RainfallGridRequest.ts create mode 100644 src/types/rainstorm/RainfallGridResponse.ts diff --git a/src/api/api.ts b/src/api/api.ts index ddeca55..190b4c5 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -55,6 +55,9 @@ import type { XianSchool } from '@/types/base/XianSchool'; import type { XianBridge } from '@/types/base/XianBridge.ts'; import type { XianReservoirList } from '@/types/base/XianReservoirList'; import type { XianSubwayStations } from '@/types/base/XianSubwayStations'; +import type { RainfallGridRequest } from '@/types/rainstorm/RainfallGridRequest'; +import type { RainfallGridResponse } from '@/types/rainstorm/RainfallGridResponse'; +import { getRainfallGrid } from './meteorology'; /** * API接口统一导出对象 @@ -277,4 +280,16 @@ export const $api = { ): Promise> => getSubwayStationsPointDetailById(id), }, + + // 气象信息 + meteorology: { + /** + * 获取网格天气信息 + * @param request - 请求参数 + * @returns 网格天气信息 + */ + getRainfallGrid: ( + request: RainfallGridRequest + ): Promise> => getRainfallGrid(request), + }, }; diff --git a/src/api/meteorology.ts b/src/api/meteorology.ts new file mode 100644 index 0000000..574ae7f --- /dev/null +++ b/src/api/meteorology.ts @@ -0,0 +1,14 @@ +import type { ApiResponse } from '@/types/ApiResponse'; +import type { RainfallGridRequest } from '@/types/rainstorm/RainfallGridRequest'; +import type { RainfallGridResponse } from '@/types/rainstorm/RainfallGridResponse'; +import httpInstance from '@/utils/request/http'; + +/** + * 获取降雨栅格数据 + * @returns 降雨栅格数据 + */ +export const getRainfallGrid = ( + request: RainfallGridRequest +): Promise> => { + return httpInstance.post('/algorithm-api/rainfall/grid', request); +}; diff --git a/src/component/rain-earthquake/RightButtonComponent.vue b/src/component/rain-earthquake/RightButtonComponent.vue index 886a6c5..bd44376 100644 --- a/src/component/rain-earthquake/RightButtonComponent.vue +++ b/src/component/rain-earthquake/RightButtonComponent.vue @@ -47,7 +47,7 @@ // 如果找到了选中的按钮,设置选中状态,同时执行回调函数 if (lastSelectedIndex !== -1) { useButtonSelectedIdStore().rightButtonSelectedId = lastSelectedIndex; - props.buttonList[lastSelectedIndex].callback(); + props.buttonList[lastSelectedIndex].callback(true); } }); diff --git a/src/config/config.json b/src/config/config.json index 63a4daf..bc42eed 100644 --- a/src/config/config.json +++ b/src/config/config.json @@ -2,7 +2,8 @@ "backendBaseUrl": "__BACKEND_BASE_URL__", "apiBaseUrl": "/api", "noEncryptUrls": [ - "/crypto/sm2/public-key" + "/crypto/sm2/public-key", + "/algorithm-api/rainfall/grid" ], "tdMapToken": [ "fc6cb1139b8eed4f79439130eb34eb00", diff --git a/src/hooks/rain-earthquake/useRightHandle.ts b/src/hooks/rain-earthquake/useRightHandle.ts index 38c9d74..042528a 100644 --- a/src/hooks/rain-earthquake/useRightHandle.ts +++ b/src/hooks/rain-earthquake/useRightHandle.ts @@ -2,8 +2,27 @@ import { useStatusStore } from '@/stores/useStatusStore.ts'; import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils.ts'; import config from '@/config/config.json'; import { useButtonSelectedIdStore } from '@/stores/useButtonSelectedIdStore'; +import { $api } from '@/api/api'; export const useRightHandle = () => { + /** + * 暴雨模拟 + * @param status - 状态 + */ + const rainstormSimulation = (status: unknown) => { + if (status as boolean) { + // 获取降雨栅格 + $api.meteorology + .getRainfallGrid({ + startTime: '2025-08-20T00:00:00', + endTime: '2025-08-20T00:00:00', + }) + .then((res) => { + console.log(res); + }); + } + }; + /** * 重置场景 */ @@ -22,5 +41,5 @@ export const useRightHandle = () => { ); }; - return { resetScene, resetView }; + return { rainstormSimulation, resetScene, resetView }; }; diff --git a/src/hooks/rainstorm/useRainDisasterChain.ts b/src/hooks/rainstorm/useRainDisasterChain.ts index e490bdb..3e3b7a0 100644 --- a/src/hooks/rainstorm/useRainDisasterChain.ts +++ b/src/hooks/rainstorm/useRainDisasterChain.ts @@ -166,9 +166,8 @@ export const useRainDisasterChain = () => { const rightButtonInfo = [ { name: '暴雨模拟', - callback: () => { - console.log('暴雨模拟'); - }, + callback: (status: unknown) => + useRightHandle().rainstormSimulation(status), selected: true, }, { @@ -222,7 +221,10 @@ export const useRainDisasterChain = () => { callback: layerControl.clickLandslideHiddenPoint, link: landslideIcon, category: ControlPanelCategory.DISASTER_HAZARD, - count: () => resourceStore.getResourceCount(LoadingResource.LANDSLIDE_HIDDEN_POINT), + count: () => + resourceStore.getResourceCount( + LoadingResource.LANDSLIDE_HIDDEN_POINT + ), }, { name: '泥石流隐患点', @@ -231,7 +233,10 @@ export const useRainDisasterChain = () => { callback: layerControl.clickDebrisFlowHiddenPoint, link: debrisFlowIcon, category: ControlPanelCategory.DISASTER_HAZARD, - count: () => resourceStore.getResourceCount(LoadingResource.DEBRIS_FLOW_HIDDEN_POINT), + count: () => + resourceStore.getResourceCount( + LoadingResource.DEBRIS_FLOW_HIDDEN_POINT + ), }, { name: '内涝隐患点', @@ -240,7 +245,10 @@ export const useRainDisasterChain = () => { callback: layerControl.clickWaterLoggingHiddenPoint, link: waterLoggingIcon, category: ControlPanelCategory.DISASTER_HAZARD, - count: () => resourceStore.getResourceCount(LoadingResource.WATER_LOGGING_HIDDEN_POINT), + count: () => + resourceStore.getResourceCount( + LoadingResource.WATER_LOGGING_HIDDEN_POINT + ), }, { name: '山洪隐患点', @@ -249,7 +257,10 @@ export const useRainDisasterChain = () => { callback: layerControl.clickFlashFloodHiddenPoint, link: flashFloodIcon, category: ControlPanelCategory.DISASTER_HAZARD, - count: () => resourceStore.getResourceCount(LoadingResource.FLASH_FLOOD_HIDDEN_POINT), + count: () => + resourceStore.getResourceCount( + LoadingResource.FLASH_FLOOD_HIDDEN_POINT + ), }, { name: '风险点', @@ -277,7 +288,8 @@ export const useRainDisasterChain = () => { callback: layerControl.clickDangerousSource, link: dangerousSourceIcon, category: ControlPanelCategory.INFRASTRUCTURE, - count: () => resourceStore.getResourceCount(LoadingResource.DANGEROUS_SOURCE), + count: () => + resourceStore.getResourceCount(LoadingResource.DANGEROUS_SOURCE), }, { name: '避难所', @@ -286,7 +298,8 @@ export const useRainDisasterChain = () => { callback: layerControl.clickEmergencyShelter, link: emergencyShelterIcon, category: ControlPanelCategory.INFRASTRUCTURE, - count: () => resourceStore.getResourceCount(LoadingResource.EMERGENCY_SHELTER), + count: () => + resourceStore.getResourceCount(LoadingResource.EMERGENCY_SHELTER), }, { name: '消防站', @@ -295,7 +308,8 @@ export const useRainDisasterChain = () => { callback: layerControl.clickFireStation, link: firefighterIcon, category: ControlPanelCategory.INFRASTRUCTURE, - count: () => resourceStore.getResourceCount(LoadingResource.FIRE_STATION), + count: () => + resourceStore.getResourceCount(LoadingResource.FIRE_STATION), }, { name: '储备点', @@ -304,7 +318,8 @@ export const useRainDisasterChain = () => { callback: layerControl.clickStorePoints, link: storePointsIcon, category: ControlPanelCategory.INFRASTRUCTURE, - count: () => resourceStore.getResourceCount(LoadingResource.STORE_POINTS), + count: () => + resourceStore.getResourceCount(LoadingResource.STORE_POINTS), }, { name: '学校', @@ -340,7 +355,8 @@ export const useRainDisasterChain = () => { callback: layerControl.clickSubwayStation, link: subwayIcon, category: ControlPanelCategory.INFRASTRUCTURE, - count: () => resourceStore.getResourceCount(LoadingResource.SUBWAY_STATION), + count: () => + resourceStore.getResourceCount(LoadingResource.SUBWAY_STATION), }, { name: '人口网格', diff --git a/src/types/rainstorm/RainfallGridRequest.ts b/src/types/rainstorm/RainfallGridRequest.ts new file mode 100644 index 0000000..233f248 --- /dev/null +++ b/src/types/rainstorm/RainfallGridRequest.ts @@ -0,0 +1,10 @@ +export interface RainfallGridRequest { + // 开始时间,默认为当前时间 + startTime?: string; + // 结束时间,默认为当前时间 + endTime?: string; + // 区域id,默认为1 + districtId?: number; + // 分辨率,默认为0.01,最小为0,最大为1 + resolution?: number; +} diff --git a/src/types/rainstorm/RainfallGridResponse.ts b/src/types/rainstorm/RainfallGridResponse.ts new file mode 100644 index 0000000..3c3bbd8 --- /dev/null +++ b/src/types/rainstorm/RainfallGridResponse.ts @@ -0,0 +1,30 @@ +interface RainfallFeature { + type: 'Feature'; + geometry: { + type: 'Polygon'; + coordinates: number[][][]; + }; + properties: { + rainfall: number; + color: string; + }; +} + +export interface RainfallGridResponse { + code: number; + message: string; + data: { + type: 'FeatureCollection'; + features: RainfallFeature[]; + metadata: { + resolution: number; + grid_size: number[]; + bounds: { + min_lon: number; + max_lon: number; + min_lat: number; + max_lat: number; + }; + }; + } | null; +}