修改地图 测试
This commit is contained in:
@@ -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 carImg from '../assets/images/carplane.png';
|
||||||
import planeImg from '../assets/images/planeicon.png';
|
import planeImg from '../assets/images/planeicon.png';
|
||||||
import cameraImg from '../assets/images/camera.png';
|
import cameraImg from '../assets/images/camera.png';
|
||||||
@@ -214,13 +214,14 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
baseLayerPicker: true,
|
baseLayerPicker: true,
|
||||||
geocoder: false,
|
geocoder: false,
|
||||||
homeButton: false,
|
homeButton: false,
|
||||||
sceneModePicker: false,
|
sceneModePicker: true,
|
||||||
navigationHelpButton: false,
|
navigationHelpButton: false,
|
||||||
fullscreenButton: false,
|
fullscreenButton: false,
|
||||||
infoBox: false,
|
infoBox: false,
|
||||||
|
terrain: Cesium.Terrain.fromWorldTerrain(),
|
||||||
imageryProvider: new Cesium.UrlTemplateImageryProvider({
|
imageryProvider: new Cesium.UrlTemplateImageryProvider({
|
||||||
url: "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
|
url: "https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}",
|
||||||
fileExtension: "jpg"
|
credit: "Google Maps"
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
viewer.resolutionScale = 2.0;
|
viewer.resolutionScale = 2.0;
|
||||||
@@ -3596,6 +3597,32 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
|||||||
duration,
|
duration,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
setMapType: (type) => {
|
||||||
|
const viewer = viewerRef.current;
|
||||||
|
if (!viewer) return;
|
||||||
|
viewer.imageryLayers.removeAll();
|
||||||
|
let url = "";
|
||||||
|
if (type === 'google-satellite') {
|
||||||
|
url = "https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}";
|
||||||
|
} else if (type === 'google-streets') {
|
||||||
|
url = "https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}";
|
||||||
|
} else {
|
||||||
|
url = "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}";
|
||||||
|
}
|
||||||
|
viewer.imageryLayers.addImageryProvider(new Cesium.UrlTemplateImageryProvider({
|
||||||
|
url: url,
|
||||||
|
credit: "Map Data"
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
toggle3D: (is3D) => {
|
||||||
|
const viewer = viewerRef.current;
|
||||||
|
if (!viewer) return;
|
||||||
|
if (is3D) {
|
||||||
|
viewer.scene.mode = Cesium.SceneMode.SCENE3D;
|
||||||
|
} else {
|
||||||
|
viewer.scene.mode = Cesium.SceneMode.SCENE2D;
|
||||||
|
}
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import AgoraTextTest from '../AgoraRtc.tsx';
|
|||||||
import { useWebRTCPlayer } from '../useWebRTCStream.tsx';
|
import { useWebRTCPlayer } from '../useWebRTCStream.tsx';
|
||||||
import VideoPlayer from '../VideoPlayer.tsx';
|
import VideoPlayer from '../VideoPlayer.tsx';
|
||||||
|
|
||||||
|
import DeviceController from './DeviceController';
|
||||||
import AgrtcRoomRobot from '../AgrtcRoomRobot';
|
import AgrtcRoomRobot from '../AgrtcRoomRobot';
|
||||||
import CesiumMap from '../Map.jsx';
|
import CesiumMap from '../Map.jsx';
|
||||||
import DeviceParamModal from './DeviceParamModal';
|
import DeviceParamModal from './DeviceParamModal';
|
||||||
@@ -60,6 +61,9 @@ export default function DeviceOverviewPage() {
|
|||||||
const [taskStats, setTaskStats] = useState({ completed: 12, total: 15 });
|
const [taskStats, setTaskStats] = useState({ completed: 12, total: 15 });
|
||||||
const [deviceStatistics, setDeviceStatistics] = useState(null);
|
const [deviceStatistics, setDeviceStatistics] = useState(null);
|
||||||
const [currentSelectedRobot, setCurrentSelectedRobot] = useState(null);
|
const [currentSelectedRobot, setCurrentSelectedRobot] = useState(null);
|
||||||
|
const [realtimeMap, setRealtimeMap] = useState<any>({});
|
||||||
|
const controllerRef = useRef<DeviceController | null>(null);
|
||||||
|
const [messageApi, contextHolder] = message.useMessage();
|
||||||
|
|
||||||
// 编辑机器人弹窗相关
|
// 编辑机器人弹窗相关
|
||||||
const [editRobotModalOpen, setEditRobotModalOpen] = useState(false);
|
const [editRobotModalOpen, setEditRobotModalOpen] = useState(false);
|
||||||
@@ -184,6 +188,16 @@ export default function DeviceOverviewPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!userInfo || !stationId) return;
|
||||||
|
const controller = new DeviceController(userInfo, messageApi, stationId);
|
||||||
|
controller.initMapPush((rtMap: any) => setRealtimeMap(rtMap || {}));
|
||||||
|
controllerRef.current = controller;
|
||||||
|
return () => {
|
||||||
|
if (controllerRef.current) controllerRef.current.closeMapPush();
|
||||||
|
};
|
||||||
|
}, [userInfo, stationId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchAllData();
|
fetchAllData();
|
||||||
}, [stationId]);
|
}, [stationId]);
|
||||||
@@ -280,16 +294,25 @@ export default function DeviceOverviewPage() {
|
|||||||
return { ...selectedDevice };
|
return { ...selectedDevice };
|
||||||
}, [selectedDevice]); // 只有切设备才变 → 视频不闪
|
}, [selectedDevice]); // 只有切设备才变 → 视频不闪
|
||||||
|
|
||||||
// ======================== UI显示用(MQTT实时更新)========================
|
// ======================== UI显示用(MQTT/WS实时更新)========================
|
||||||
const realtimeDevice = useMemo(() => {
|
const realtimeDevice = useMemo(() => {
|
||||||
if (!selectedDevice) return null;
|
if (!selectedDevice) return null;
|
||||||
|
const sn = selectedDevice.device_sn || selectedDevice.serialNumber;
|
||||||
|
const wsData = realtimeMap[sn] || {};
|
||||||
|
setDeviceStatistics(wsData || {})
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...selectedDevice,
|
...selectedDevice,
|
||||||
...uavState,
|
...uavState,
|
||||||
...persistentHostData,
|
...persistentHostData,
|
||||||
...persistentDroneData,
|
...persistentDroneData,
|
||||||
|
...wsData,
|
||||||
|
// 统一字段名
|
||||||
|
capacity_percent: wsData.battery_level || persistentDroneData?.capacity_percent || selectedDevice.capacity_percent || 100
|
||||||
};
|
};
|
||||||
}, [selectedDevice, uavState, persistentHostData, persistentDroneData?.wind_speed]);
|
|
||||||
|
}, [selectedDevice, uavState, persistentHostData, persistentDroneData, realtimeMap]);
|
||||||
|
|
||||||
// MQTT消息处理
|
// MQTT消息处理
|
||||||
const handleMqttMessage = useCallback((topic, message) => {
|
const handleMqttMessage = useCallback((topic, message) => {
|
||||||
@@ -454,19 +477,25 @@ export default function DeviceOverviewPage() {
|
|||||||
//feStatus; 1任务中 / 2空闲
|
//feStatus; 1任务中 / 2空闲
|
||||||
const dynamicTopCards = useMemo(() => {
|
const dynamicTopCards = useMemo(() => {
|
||||||
const totalDrones = planedevices?.length || 0;
|
const totalDrones = planedevices?.length || 0;
|
||||||
const onlineDrones = planedevices?.filter(d => d.onlineStatus === 1).length || 0;
|
const onlineDrones = planedevices?.filter(d => {
|
||||||
const totalRobots = 1;
|
const rt = realtimeMap[d.device_sn];
|
||||||
//const totalRobots = devicesAll?.filter(d => d.productName?.includes(t('constants.inspection'))).length || 0;
|
return rt ? rt.status !== 'OFFLINE' : d.onlineStatus === 1;
|
||||||
|
}).length || 0;
|
||||||
//key 0 有任务 1 无任务
|
const totalRobots = devices?.filter(d => !d.gateway_sn).length || 0;
|
||||||
const activeRobots = 0;
|
const onlineRobots = devices?.filter(d => {
|
||||||
const totalMowers = 1;
|
if (d.gateway_sn) return false;
|
||||||
//const totalMowers = devicesAll?.filter(d => d.productName?.includes(t('constants.mower'))).length || 0;
|
const rt = realtimeMap[d.serialNumber];
|
||||||
const activeMowers = devices?.filter(d => d.feStatus == 1).length || 0; // 作业中状态数量
|
return rt ? rt.status !== 'OFFLINE' : d.onlineStatus === 1;
|
||||||
const washDroneStandby = planedevices?.[0]?.modeStatistics?.["0"] || 0;
|
}).length || 0;
|
||||||
//key 设备状态:{"0":"空闲中","1":"现场调试","2":"远程调试","3":"固件升级中","4":"作业中"}
|
|
||||||
|
|
||||||
|
|
||||||
|
const activeMowers = devices?.filter(d => {
|
||||||
|
const rt = realtimeMap[d.serialNumber];
|
||||||
|
return rt ? rt.status === 'EXECUTING' : d.feStatus == 1;
|
||||||
|
}).length || 0;
|
||||||
|
const washDroneStandby = planedevices?.filter(d => {
|
||||||
|
const rt = realtimeMap[d.device_sn];
|
||||||
|
return rt ? rt.status === 'IDLE' : true; // 简化逻辑
|
||||||
|
}).length || 0;
|
||||||
|
|
||||||
// 今日任务执行统计
|
// 今日任务执行统计
|
||||||
const completedTasks = taskStats.completed;
|
const completedTasks = taskStats.completed;
|
||||||
@@ -485,15 +514,15 @@ export default function DeviceOverviewPage() {
|
|||||||
{
|
{
|
||||||
title: t('home.inspectionRobot'),
|
title: t('home.inspectionRobot'),
|
||||||
icon: <RobotOutlined style={{ color: '#13c2c2', fontSize: 24 }} />,
|
icon: <RobotOutlined style={{ color: '#13c2c2', fontSize: 24 }} />,
|
||||||
value: `${totalRobots} ${t('devices.UnitsRobot')}`,
|
value: `${onlineRobots} / ${totalRobots}`,
|
||||||
sub: `${t('devices.executing')} ${activeRobots}`,
|
sub: `${t('devices.online')} ${onlineRobots}`,
|
||||||
color: '#13c2c2',
|
color: '#13c2c2',
|
||||||
iconBg: '#E6FFFA'
|
iconBg: '#E6FFFA'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t('devices.mowingRobot'),
|
title: t('devices.mowingRobot'),
|
||||||
icon: <CarOutlined style={{ color: '#722ED1', fontSize: 24 }} />,
|
icon: <CarOutlined style={{ color: '#722ED1', fontSize: 24 }} />,
|
||||||
value: `${totalMowers} ${t('devices.UnitsRobot')}`,
|
value: `${totalRobots} ${t('devices.UnitsRobot')}`,
|
||||||
sub: `${t('devices.executing')} ${activeMowers}`,
|
sub: `${t('devices.executing')} ${activeMowers}`,
|
||||||
color: '#722ED1',
|
color: '#722ED1',
|
||||||
iconBg: '#F9F0FF'
|
iconBg: '#F9F0FF'
|
||||||
@@ -506,14 +535,6 @@ export default function DeviceOverviewPage() {
|
|||||||
color: '#eb2f96',
|
color: '#eb2f96',
|
||||||
iconBg: '#FFF1F3'
|
iconBg: '#FFF1F3'
|
||||||
},
|
},
|
||||||
//{
|
|
||||||
// title: t('devices.fixed2DeviceBatteryFixed2'),
|
|
||||||
// icon: <ThunderboltOutlined style={{ color: '#52c41a', fontSize: 24 }} />,
|
|
||||||
// value: `${finalAvgBattery}%`,
|
|
||||||
// sub: '',
|
|
||||||
// color: '#52c41a',
|
|
||||||
// iconBg: '#E8FFEA'
|
|
||||||
//},
|
|
||||||
{
|
{
|
||||||
title: t('devices.todayTaskExecute'),
|
title: t('devices.todayTaskExecute'),
|
||||||
icon: <CheckCircleOutlined style={{ color: '#2f54eb', fontSize: 24 }} />,
|
icon: <CheckCircleOutlined style={{ color: '#2f54eb', fontSize: 24 }} />,
|
||||||
@@ -523,24 +544,31 @@ export default function DeviceOverviewPage() {
|
|||||||
iconBg: '#E8F3FF'
|
iconBg: '#E8F3FF'
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}, [devicesAll, planedevices, persistentDroneData, uavState, taskStats]);
|
}, [devices, planedevices, realtimeMap, taskStats]);
|
||||||
|
|
||||||
// 设备调度列表
|
// 设备调度列表
|
||||||
const dynamicScheduleList = useMemo(() => {
|
const dynamicScheduleList = useMemo(() => {
|
||||||
return devicesAll?.map((d, index) => ({
|
return devicesAll?.map((d, index) => {
|
||||||
...d,
|
const sn = d.serialNumber || d.device_sn;
|
||||||
id: d.deviceId || index,
|
const rt = realtimeMap[sn] || {};
|
||||||
name: d.deviceAlias || d.deviceName || d.callsign || '未知设备',
|
const online = rt.status !== undefined ? (rt.status !== 'OFFLINE' ? 1 : 0) : d.onlineStatus;
|
||||||
type: d.deviceType || "割草机",
|
|
||||||
status: d.onlineStatus === 1 ? t('devices.online') : t('devices.offline'),
|
|
||||||
mode: d.feStatus == 1 ? '作业中' : d.feStatus == 2 ? t('devices.idle') : d.mode_code == 0 ? t('devices.idle') : d.mode_code == 1 ? '现场调试' : d.mode_code == 2 ? '远程调试' : d.mode_code == 3 ? '固件升级中' : '作业中',
|
|
||||||
capacity_percent: d.capacity_percent || 100,
|
|
||||||
position: d.position || '站内',
|
|
||||||
task: d.status === 4 ? '待命' : '作业中',
|
|
||||||
comm: d.rssi ? `${d.rssi}dBm` : '良好',
|
|
||||||
|
|
||||||
})) || [];
|
return {
|
||||||
}, [devicesAll]);
|
...d,
|
||||||
|
id: d.deviceId || index,
|
||||||
|
name: d.deviceAlias || d.deviceName || d.callsign || '未知设备',
|
||||||
|
type: d.deviceType || "割草机",
|
||||||
|
status: online === 1 ? t('devices.online') : t('devices.offline'),
|
||||||
|
onlineStatus: online,
|
||||||
|
mode: rt.status === 'EXECUTING' ? '作业中' : rt.status === 'IDLE' ? t('devices.idle') : (d.feStatus == 1 ? '作业中' : d.feStatus == 2 ? t('devices.idle') : '离线'),
|
||||||
|
capacity_percent: rt.battery || d.capacity_percent || 100,
|
||||||
|
position: rt.position || d.position || '站内',
|
||||||
|
task: rt.currentTaskName || d.task || (d.status === 4 ? '待命' : '作业中'),
|
||||||
|
comm: rt.rssi ? `${rt.rssi}dBm` : (d.rssi ? `${d.rssi}dBm` : '良好'),
|
||||||
|
work_area: rt.work_area || 0
|
||||||
|
};
|
||||||
|
}) || [];
|
||||||
|
}, [devicesAll, realtimeMap]);
|
||||||
|
|
||||||
const handleStart = () => message.success(t('devices.fixed2TaskSuspended22'));
|
const handleStart = () => message.success(t('devices.fixed2TaskSuspended22'));
|
||||||
const handlePause = () => message.info(t('devices.taskPaused'));
|
const handlePause = () => message.info(t('devices.taskPaused'));
|
||||||
@@ -653,7 +681,7 @@ export default function DeviceOverviewPage() {
|
|||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card title={<><SettingOutlined />{t('devices.fixed2EquipmentListFixed2')}</>} variant="borderless" style={{ borderRadius: 8, marginBottom: 8 }}>
|
<Card title={<><SettingOutlined />{t('devices.fixed2EquipmentListFixed2')}</>} extra={<Button type="text" icon={<ReloadOutlined />} onClick={fetchAllData} />} variant="borderless" style={{ borderRadius: 8, marginBottom: 8 }}>
|
||||||
<Table rowKey={(record) => record.id || record.serialNumber || record.device_sn} size="small" pagination={false}
|
<Table rowKey={(record) => record.id || record.serialNumber || record.device_sn} size="small" pagination={false}
|
||||||
columns={[
|
columns={[
|
||||||
{ title: t('devices.fixed2EquipmentFixed2NameFixed2'), dataIndex: 'name', width: 180 },
|
{ title: t('devices.fixed2EquipmentFixed2NameFixed2'), dataIndex: 'name', width: 180 },
|
||||||
@@ -693,8 +721,9 @@ export default function DeviceOverviewPage() {
|
|||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
}, { title: t('aiAnalysis.location'), dataIndex: 'position', width: 90 },
|
}, { title: t('aiAnalysis.location'), dataIndex: 'position', width: 90 },
|
||||||
|
//{ title: '累计作业面积', dataIndex: 'work_area', width: 110, render: v => `${Number(v || 0).toFixed(2)} ㎡` },
|
||||||
//{ title: t('devices.fixed2CurrentFixed2TaskSuspended2Fixed2'), dataIndex: 'task', width: 100 },
|
//{ title: t('devices.fixed2CurrentFixed2TaskSuspended2Fixed2'), dataIndex: 'task', width: 100 },
|
||||||
{ title: t('devices.statusFixed2'), dataIndex: 'comm', width: 100, render: v => <Badge status={v.includes('-') ? 'warning' : 'success'} text={v} /> },
|
{ title: t('devices.statusFixed2'), dataIndex: 'comm', width: 100, render: v => <Badge status={v && v.includes('-') ? 'warning' : 'success'} text={v} /> },
|
||||||
{
|
{
|
||||||
title: t('roles.actions'),
|
title: t('roles.actions'),
|
||||||
key: 'action',
|
key: 'action',
|
||||||
|
|||||||
@@ -1522,7 +1522,7 @@ export default function DeviceStatusPage() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
console.log(realtimePosition?.controlMode, "现在的控制controlmode")
|
console.log(realtimePosition?.controlMode, "现在的控制controlmode")
|
||||||
if (realtimePosition?.controlMode != 3 || realtimePosition?.control_mode != 3) {
|
if (realtimePosition?.controlMode && (realtimePosition?.controlMode != 3 || realtimePosition?.control_mode != 3)) {
|
||||||
|
|
||||||
messageApi.warning(t('devices.noRemoteControl'));
|
messageApi.warning(t('devices.noRemoteControl'));
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ const TaskMonitorPage: React.FC = () => {
|
|||||||
const [messageApi, contextHolder] = message.useMessage();
|
const [messageApi, contextHolder] = message.useMessage();
|
||||||
|
|
||||||
const controllerRef = useRef<DeviceController | null>(null);
|
const controllerRef = useRef<DeviceController | null>(null);
|
||||||
|
const mapRef = useRef<any>(null);
|
||||||
|
|
||||||
// 初始化实时数据控制器
|
// 初始化实时数据控制器
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -414,7 +415,7 @@ const TaskMonitorPage: React.FC = () => {
|
|||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
border: '1px solid #f0f0f0'
|
border: '1px solid #f0f0f0'
|
||||||
}}>
|
}}>
|
||||||
<CesiumMap from="taskMonitor" mapLayer={currentStation?.siteMapName} focusLocation={focusLocation}
|
<CesiumMap ref={mapRef} from="taskMonitor" mapLayer={currentStation?.siteMapName} focusLocation={focusLocation}
|
||||||
devices={mapDevices}
|
devices={mapDevices}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -452,7 +453,16 @@ const TaskMonitorPage: React.FC = () => {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div style={{ position: 'absolute', bottom: 20, right: 20, display: 'flex', gap: 8, zIndex: 10 }}>
|
||||||
|
<Button size="small" style={{ borderRadius: 4 }} icon={<MapIcon size={14} />} onClick={() => {
|
||||||
|
mapRef.current?.setMapType('google-satellite');
|
||||||
|
mapRef.current?.toggle3D(true);
|
||||||
|
}}>卫星全景</Button>
|
||||||
|
<Button size="small" style={{ borderRadius: 4 }} icon={<LayoutGrid size={14} />} onClick={() => {
|
||||||
|
mapRef.current?.setMapType('google-streets');
|
||||||
|
mapRef.current?.toggle3D(false);
|
||||||
|
}}>2D普通</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
@@ -475,7 +485,14 @@ const TaskMonitorPage: React.FC = () => {
|
|||||||
const lon = Number(pos.longitude ?? pos.lng);
|
const lon = Number(pos.longitude ?? pos.lng);
|
||||||
const lat = Number(pos.latitude ?? pos.lat);
|
const lat = Number(pos.latitude ?? pos.lat);
|
||||||
if (Number.isFinite(lon) && Number.isFinite(lat)) {
|
if (Number.isFinite(lon) && Number.isFinite(lat)) {
|
||||||
setFocusLocation({ lon, lat, type: item.deviceType === 'UAV' ? 'drone' : 'robot', });
|
setFocusLocation({
|
||||||
|
lon,
|
||||||
|
lat,
|
||||||
|
type: item.deviceType === 'UAV' ? 'drone' : 'robot',
|
||||||
|
height: 1000, // 增加高度以实现飞入效果
|
||||||
|
heading: 0,
|
||||||
|
pitch: -45
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
aria-pressed={selectedDeviceSerial === item.serialNumber}
|
aria-pressed={selectedDeviceSerial === item.serialNumber}
|
||||||
|
|||||||
Reference in New Issue
Block a user