From dc000ffc6a4acf4c3013c78380c24eddebd20c5a Mon Sep 17 00:00:00 2001 From: mmc <1556375442@qq.com> Date: Wed, 2 Sep 2026 10:45:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=BA=E7=AB=99=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SystemSetting/StationManage.tsx | 41 +++++++++++++++++++ src/lib/geoServer.ts | 35 ++++++++++++++++ src/locales/en/index.ts | 2 + src/locales/zh/index.ts | 2 + 4 files changed, 80 insertions(+) create mode 100644 src/lib/geoServer.ts diff --git a/src/components/SystemSetting/StationManage.tsx b/src/components/SystemSetting/StationManage.tsx index 71d0306..a54f3cd 100644 --- a/src/components/SystemSetting/StationManage.tsx +++ b/src/components/SystemSetting/StationManage.tsx @@ -12,6 +12,7 @@ import { getStationRegions, saveRegion, deleteRegion } from '../../api/stationManage'; import { getOrgList } from '../../api/organization'; +import { fetchPublishedLayers } from '../../lib/geoServer'; import { useSelector } from 'react-redux'; import { RootState } from '../../store'; import { useTranslation } from 'react-i18next'; @@ -26,6 +27,9 @@ export default function StationManage() { // 组织列表 const [orgList, setOrgList] = useState([]); + // 发布图层列表(来自 GeoServer WMS) + const [layerList, setLayerList] = useState<{ name: string; title: string }[]>([]); + const [layerLoading, setLayerLoading] = useState(false); // 🔥 选中的组织ID(用于筛选) const [selectedOrgId, setSelectedOrgId] = useState(undefined); @@ -71,6 +75,15 @@ export default function StationManage() { }); }; + // ====================== 获取发布图层列表 ====================== + const getLayerData = () => { + setLayerLoading(true); + fetchPublishedLayers() + .then(layers => setLayerList(layers || [])) + .catch(() => setLayerList([])) + .finally(() => setLayerLoading(false)); + }; + // ====================== 获取场站列表 ====================== const getStationData = () => { const params = { @@ -131,6 +144,7 @@ export default function StationManage() { // ====================== 新增 / 编辑 场站 ====================== const handleAdd = () => { + getLayerData(); form.resetFields(); setEditRecord(null); // 默认全部推送关闭 @@ -145,6 +159,7 @@ export default function StationManage() { }; const handleEdit = (record) => { + getLayerData(); setEditRecord(record); // 后端数字转布尔给Switch form.setFieldsValue({ @@ -246,6 +261,15 @@ export default function StationManage() { // ====================== 表格列 ====================== const columns = [ { title: t('systemSetting.siteName'), dataIndex: 'siteName' }, + { + title: t('systemSetting.mappingLayer'), + dataIndex: 'site_map_name', + render: (value) => value ? ( + {value} + ) : ( + — + ) + }, { title: t('systemSetting.belongingOrg'), dataIndex: 'orgId', @@ -363,6 +387,23 @@ export default function StationManage() { + + + + {t('systemSetting.s3')} diff --git a/src/lib/geoServer.ts b/src/lib/geoServer.ts new file mode 100644 index 0000000..723c05e --- /dev/null +++ b/src/lib/geoServer.ts @@ -0,0 +1,35 @@ +import envConfig from '../../env'; + +// 获取发布图层列表 +// 通过 GetCapabilities 解析 WMS 发布的所有图层(workspace:layer) +export function fetchPublishedLayers(): Promise<{ name: string; title: string }[]> { + const baseUrl = envConfig.geoserver_url; + const getCapabilitiesUrl = `${baseUrl}/wms?service=WMS&version=1.1.1&request=GetCapabilities`; + + return fetch(getCapabilitiesUrl) + .then(response => response.text()) + .then(xmlText => { + const parser = new DOMParser(); + const xmlDoc = parser.parseFromString(xmlText, 'text/xml'); + const layerElements = xmlDoc.getElementsByTagName('Layer'); + const uniqueLayerNames = new Set(); + const publishedLayers: { name: string; title: string }[] = []; + + for (let i = 0; i < layerElements.length; i++) { + const layer = layerElements[i]; + const nameElement = layer.getElementsByTagName('Name')[0]; + const titleElement = layer.getElementsByTagName('Title')[0]; + if (nameElement && nameElement.textContent) { + const layerName = nameElement.textContent; + if (layerName.includes(':') && !uniqueLayerNames.has(layerName)) { + uniqueLayerNames.add(layerName); + publishedLayers.push({ + name: layerName, + title: titleElement ? titleElement.textContent : layerName + }); + } + } + } + return publishedLayers; + }); +} \ No newline at end of file diff --git a/src/locales/en/index.ts b/src/locales/en/index.ts index 122f0fd..c00af5a 100644 --- a/src/locales/en/index.ts +++ b/src/locales/en/index.ts @@ -3069,6 +3069,8 @@ const en = { s412: 'Auto Backup', s110: 'Boundary Drawing', + mappingLayer: 'Mapped Layer', + mappingLayerPlaceholder: 'Select a published layer to map', fixed2Camera2: 'Total Cameras', diff --git a/src/locales/zh/index.ts b/src/locales/zh/index.ts index 656fd40..392c224 100644 --- a/src/locales/zh/index.ts +++ b/src/locales/zh/index.ts @@ -3104,6 +3104,8 @@ const zh = { s412: '自动备份', s110: '边界绘制', + mappingLayer: '映射图层', + mappingLayerPlaceholder: '请选择要映射的发布图层', fixed2Camera2: '摄像头总数',