From 2a531f9e32e269ab100d29d9f13afece8a6a3226 Mon Sep 17 00:00:00 2001 From: mmc <1556375442@qq.com> Date: Tue, 25 Aug 2026 16:54:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E6=89=93=E7=82=B9=E5=92=8C?= =?UTF-8?q?=E6=B8=85=E9=99=A4=20=E6=89=93=E7=82=B9=E6=A0=87=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env.js | 8 +++-- src/components/Map.jsx | 10 ++++--- src/components/devices/DeviceOverviewPage.tsx | 4 +-- src/components/devices/DeviceStatusPage.tsx | 30 +++++++++++++++++-- src/locales/en/index.ts | 3 +- src/locales/zh/index.ts | 1 + 6 files changed, 44 insertions(+), 12 deletions(-) diff --git a/env.js b/env.js index 8715ca4..ff63e87 100644 --- a/env.js +++ b/env.js @@ -9,7 +9,9 @@ const currentEnv = import.meta.env?.MODE || process.env.NODE_ENV; // 环境配置映射 const envConfig = { [ENV.DEV]: { - baseURL: 'http://1.95.137.212:8081',//http://192.168.2.56:8081 + //baseURL: 'http://1.95.137.212:8081',//http://192.168.2.56:8081 + baseURL: 'http://192.168.2.249:8081',//http://192.168.2.56:8081 + ////baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081 //WS_URL: 'ws://192.168.2.59:9002/ws/', //mqtt_url: "ws://1.95.137.212:8083/mqtt", @@ -17,8 +19,10 @@ const envConfig = { //baseURL: 'http://1.95.137.212:8081',//http://192.168.2.56:8081 //baseURL: 'http://192.168.2.62:8081',//http://192.168.2.56:8081 + WS_URL: 'ws://192.168.2.249:9002/ws/', + //baseURL: 'https://serviceri.satabot.com', - WS_URL: 'ws://1.95.137.212:9002/ws/', + //WS_URL: 'ws://1.95.137.212:9002/ws/', //WS_URL: 'ws://192.168.2.62:9002/ws/', mqtt_url: "ws://1.95.137.212:8083/mqtt", geoserver_url: "http://1.95.137.212:7900/geoserver" diff --git a/src/components/Map.jsx b/src/components/Map.jsx index 22eeb1d..c6a734b 100644 --- a/src/components/Map.jsx +++ b/src/components/Map.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef, useState, useMemo, useImperativeHandle, forwardRef, useCallback } from 'react'; +import React, { useEffect, useRef, useState, useMemo, useImperativeHandle, forwardRef, useCallback } from 'react'; import carImg from '../assets/images/carplane.png'; import inspectImg from "../assets/images/inspectCar.png" import planeImg from '../assets/images/planeicon.png'; @@ -27,7 +27,7 @@ const CYAN_GLOW_COLOR = new window.Cesium.Color( ); window.Cesium.Ion.defaultAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJmNjk0NjI1MC0wZGYyLTQ1YzItYjJmZi0wY2M5ODEwODllYzIiLCJpZCI6Mzk3MTQxLCJpYXQiOjE3NzI1MjkwMjV9.U6qmakhDgXJVXwLFyWzSxAUOFZRrDkIsRUPP6CCdnKg"; -const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, finishPoint, drawRealTime, realtimePosition, realtimeType, pathPoints = [], devices = [], onCameraClick, focusLocation, points = [], markedPoints = [], onPathChange, from, onClearDraw }, ref) => { +const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, finishPoint, drawRealTime, realtimePosition, realtimeType, pathPoints = [], devices = [], onCameraClick, focusLocation, points = [], markedPoints = [], onPathChange, from, onClearDraw, onMarkPoint }, ref) => { const containerRef = useRef(null); const viewerRef = useRef(null); const tooltipRef = useRef(null); @@ -153,6 +153,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, } }); } + console.log(newPoints, "newPoints") onPathChange && onPathChange(newPoints); }; @@ -1416,8 +1417,8 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, }, window.Cesium.ScreenSpaceEventType.LEFT_CLICK); handler.setInputAction((movement) => { - //if (from !== "device-control") - return; + if (from !== "deviceStatus") + return; const cartesian = viewer.camera.pickEllipsoid(movement.position, viewer.scene.globe.ellipsoid); if (!cartesian) return; const cartographic = window.Cesium.Cartographic.fromCartesian(cartesian); @@ -1427,6 +1428,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, const newPoints = [...drawPoints, newPoint]; setDrawPoints(newPoints); updateDrawPath(newPoints); + onMarkPoint?.({ lon, lat }); }, window.Cesium.ScreenSpaceEventType.LEFT_CLICK); if (onClearDraw) { diff --git a/src/components/devices/DeviceOverviewPage.tsx b/src/components/devices/DeviceOverviewPage.tsx index bb42016..2af36f1 100644 --- a/src/components/devices/DeviceOverviewPage.tsx +++ b/src/components/devices/DeviceOverviewPage.tsx @@ -750,8 +750,8 @@ export default function DeviceOverviewPage() { String(option?.label || "").toLowerCase().includes(input.toLowerCase()) } options={[ - { label: devices.robot, options: devices.map(item => ({ value: item.device_sn || item.serialNumber, label: item.deviceAlias || item.deviceName || '未知设备' })) }, - { label: constants.uav, options: planedevices.map(item => ({ value: item.device_sn, label: item.drone_callsign || item.callsign || '未知设备' })) }, + { label: {t('devices.robot')}, options: devices.map(item => ({ value: item.device_sn || item.serialNumber, label: item.deviceAlias || item.deviceName || '未知设备' })) }, + { label: {t('constants.uav')}, options: planedevices.map(item => ({ value: item.device_sn, label: item.drone_callsign || item.callsign || '未知设备' })) }, ]} /> diff --git a/src/components/devices/DeviceStatusPage.tsx b/src/components/devices/DeviceStatusPage.tsx index 353cab2..46867a8 100644 --- a/src/components/devices/DeviceStatusPage.tsx +++ b/src/components/devices/DeviceStatusPage.tsx @@ -123,7 +123,8 @@ export default function DeviceStatusPage() { const [isSaveModalVisible, setIsSaveModalVisible] = useState(false); // 保存模态框可见性 const [plotName, setPlotName] = useState(''); // 地块名称 const [isSaving, setIsSaving] = useState(false); // 是否正在保存 - const mapRef = useRef(null); // 地图 ref + const mapRef = useRef(null); + const clearDrawRef = useRef<(() => void) | null>(null); // 地图 ref const location = useLocation(); const queryParams = new URLSearchParams(location.search); @@ -658,13 +659,34 @@ export default function DeviceStatusPage() { messageApi.success(t('devices.pointMarked', { count: markedPoints.length + 1 })); }; + // Map click to add marked point + const handleMapMarkPoint = (point) => { + setMarkedPoints([...markedPoints, { lon: Number(point.lon), lat: Number(point.lat) }]); + messageApi.success(t('devices.pointMarked', { count: markedPoints.length + 1 })); + }; + // 清空标记点 const handleClearPoints = () => { setMarkedPoints([]); setCompleteFlag(false); setSavePath(null); + clearDrawRef.current?.(); }; + const getPathPoints = (coords) => { + console.log("getPathPoints", coords) + //setPathPoints(coords); + if (!coords || coords.length === 0) return; + const newWps = coords.map((p, i) => ({ + id: i + 1, + lon: p.lon.toFixed(6), + lat: p.lat.toFixed(6), + })); + console.log("newWps", newWps) + //setWaypoints(newWps); + }; + + // 完成功能 - 调用路径规划接口 const handleSave = async () => { if (!plotName.trim()) { @@ -1034,11 +1056,13 @@ export default function DeviceStatusPage() { markedPoints={markedPoints} realtimePosition={realtimePosition} realtimeType={realtimeType} + onPathChange={getPathPoints} + drawRealTime={true} finishPoint={arrivedPoint} ifClearNavLine={clearNavLine} ifClearPlanLine={clearPlanLine} - from="deviceStatus" + from="deviceStatus" onMarkPoint={handleMapMarkPoint} onClearDraw={(fn) => { clearDrawRef.current = fn; }} /> @@ -1324,7 +1348,7 @@ export default function DeviceStatusPage() { finishPoint={arrivedPoint} ifClearNavLine={clearNavLine} ifClearPlanLine={clearPlanLine} - from="deviceStatus" + from="deviceStatus" onMarkPoint={handleMapMarkPoint} onClearDraw={(fn) => { clearDrawRef.current = fn; }} /> diff --git a/src/locales/en/index.ts b/src/locales/en/index.ts index 28a8346..4d1bd6c 100644 --- a/src/locales/en/index.ts +++ b/src/locales/en/index.ts @@ -241,6 +241,7 @@ const en = { }, devices: { deviceManagement: 'Device Management', + distributable: 'Distributable', deviceOverview: 'Device Overview', deviceStatus: 'Device Status', waylineTask: 'Wayline Tasks', @@ -1290,7 +1291,7 @@ const en = { noneControl: 'None Control jurisdiction', fixed2ControlFixed2: 'Fixed2 Control 请求 超时 Fixed2', - controlFailed:"请求被拒绝", + controlFailed: "controlFailed", }, video: { onlineVideo: 'Online Video', diff --git a/src/locales/zh/index.ts b/src/locales/zh/index.ts index 988a256..cf63c37 100644 --- a/src/locales/zh/index.ts +++ b/src/locales/zh/index.ts @@ -244,6 +244,7 @@ const zh = { }, devices: { deviceManagement: '设备管理', + distributable: '可调度', deviceOverview: '设备总览', deviceStatus: '设备状态', waylineTask: '航线任务',