有和机器人总览界面
This commit is contained in:
@@ -1115,35 +1115,60 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
}, [markedPoints]);
|
||||
|
||||
function resolveDeviceStatus(device) {
|
||||
const fsRaw = device?.feStatus;
|
||||
const stRaw = device?.status;
|
||||
//if (device?.onlineStatus == 0) return 'offline';
|
||||
if (stRaw !== undefined && stRaw !== null && stRaw !== '') {
|
||||
const st = Number(stRaw);
|
||||
if (st === 1) return 'working';
|
||||
if (st === 2) return 'idle';
|
||||
if (st === 3) return 'offline';
|
||||
}
|
||||
const fsRaw = device?.color;
|
||||
return fsRaw === 'red' ? 'offline' : fsRaw === 'green' ? 'working' : fsRaw === 'blue' ? 'idle' : 'idle';
|
||||
////if (device?.onlineStatus == 0) return 'offline';
|
||||
//if (stRaw !== undefined && stRaw !== null && stRaw !== '') {
|
||||
// const st = Number(stRaw);
|
||||
// if (st === 1) return 'working';
|
||||
// if (st === 2) return 'idle';
|
||||
// if (st === 3) return 'offline';
|
||||
//}
|
||||
|
||||
// feStatus:0=离线,1=工作中,2=空闲
|
||||
if (fsRaw !== undefined && fsRaw !== null && fsRaw !== '') {
|
||||
const fs = Number(fsRaw);
|
||||
if (fs === 0) return 'offline';
|
||||
if (fs === 1) return 'working';
|
||||
if (fs === 2) return 'idle';
|
||||
}
|
||||
//// feStatus:0=离线,1=工作中,2=空闲
|
||||
//if (fsRaw !== undefined && fsRaw !== null && fsRaw !== '') {
|
||||
// const fs = Number(fsRaw);
|
||||
// if (fs === 0) return 'offline';
|
||||
// if (fs === 1) return 'working';
|
||||
// if (fs === 2) return 'idle';
|
||||
//}
|
||||
|
||||
// status:1=工作中,2=空闲,3=离线
|
||||
if (stRaw !== undefined && stRaw !== null && stRaw !== '') {
|
||||
const st = Number(stRaw);
|
||||
if (st === 1) return 'working';
|
||||
if (st === 2) return 'idle';
|
||||
if (st === 3) return 'offline';
|
||||
}
|
||||
//// status:1=工作中,2=空闲,3=离线
|
||||
//if (stRaw !== undefined && stRaw !== null && stRaw !== '') {
|
||||
// const st = Number(stRaw);
|
||||
// if (st === 1) return 'working';
|
||||
// if (st === 2) return 'idle';
|
||||
// if (st === 3) return 'offline';
|
||||
//}
|
||||
|
||||
return 'idle';
|
||||
}
|
||||
|
||||
// 设备状态视觉统一:工作中蓝 / 空闲绿 / 离线红(底层光圈与悬浮提示共用同一套颜色)
|
||||
const DEVICE_STATUS_COLORS = {
|
||||
working: '#1677ff',
|
||||
idle: '#52c41a',
|
||||
offline: '#ff4d4f',
|
||||
};
|
||||
|
||||
// 设备类型归一化:统一读 deviceType(I=巡检 / M=割草机 / U=无人机),兼容旧 type 字段
|
||||
function getDeviceKind(device) {
|
||||
const dt = String(device?.deviceType || '').toUpperCase();
|
||||
if (dt === 'U') return 'drone';
|
||||
if (dt === 'M') return 'mower';
|
||||
if (dt === 'I') return 'inspection';
|
||||
// 兼容旧 type 字段值
|
||||
const legacy = String(device?.type || '').toLowerCase();
|
||||
if (legacy === 'plane' || legacy === 'drone' || legacy === 'drone-inspect') return 'drone';
|
||||
if (legacy === 'mower') return 'mower';
|
||||
if (legacy === 'robot') return 'inspection';
|
||||
if (legacy === 'camera') return 'camera';
|
||||
return 'unknown';
|
||||
}
|
||||
const isDroneDevice = (d) => getDeviceKind(d) === 'drone';
|
||||
const isMowerDevice = (d) => getDeviceKind(d) === 'mower';
|
||||
const isInspectionDevice = (d) => getDeviceKind(d) === 'inspection';
|
||||
const isCameraDevice = (d) => getDeviceKind(d) === 'camera';
|
||||
|
||||
// 光圈颜色:工作中蓝(#1677ff)/ 空闲绿(#52c41a)/ 离线红(#ff4d4f)
|
||||
function getDeviceHaloColor(device) {
|
||||
const state = resolveDeviceStatus(device);
|
||||
@@ -1173,10 +1198,11 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
|
||||
if (robot) {
|
||||
const stateKey = resolveDeviceStatus(robot);
|
||||
// 与底层光圈颜色保持一致:工作中蓝 / 空闲绿 / 离线红
|
||||
const statusMap = {
|
||||
working: { text: t('common.working'), color: '#0a40df' },
|
||||
idle: { text: t('devices.idle'), color: '#12c60e' },
|
||||
offline: { text: t('devices.offline'), color: '#f01212' }
|
||||
working: { text: t('common.working'), color: DEVICE_STATUS_COLORS.working },
|
||||
idle: { text: t('devices.idle'), color: DEVICE_STATUS_COLORS.idle },
|
||||
offline: { text: t('devices.offline'), color: DEVICE_STATUS_COLORS.offline }
|
||||
};
|
||||
const status = statusMap[stateKey] || statusMap.idle;
|
||||
let deviceValuesHTML = '';
|
||||
@@ -1204,10 +1230,11 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
${deviceValuesHTML ? `<div style="margin-top:8px;"><strong>${t('devices.deviceData')}:</strong>${deviceValuesHTML}</div>` : ''}
|
||||
<div>${t('systemSetting.longitude')}:${lonStr}</div>
|
||||
<div>${t('systemSetting.latitude')}:${latStr}</div>
|
||||
<div>${t('systemSetting.status')}:
|
||||
<span style="display:inline-block;width:8px;height:8px;border-radius:50%;background:${status.color};margin-right:4px;"></span>
|
||||
<span style="color:${status.color};font-weight:bold">${status.text}</span>
|
||||
</div>`;
|
||||
`;
|
||||
//<div>${t('systemSetting.status')}:
|
||||
// <span style="display:inline-block;width:8px;height:8px;border-radius:50%;background:${status.color};margin-right:4px;"></span>
|
||||
// <span style="color:${status.color};font-weight:bold">${status.text}</span>
|
||||
//</div>
|
||||
} else {
|
||||
tooltip.innerHTML = `
|
||||
<div style = "font-weight:600;margin-bottom:4px;" >📍 ${t('systemSetting.longitude')}:${lonStr}</div >
|
||||
@@ -2796,33 +2823,21 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
|
||||
if (isIOT) {
|
||||
|
||||
image = device?.type === "camera" ? cameraImg : iotImg;
|
||||
image = isCameraDevice(device) ? cameraImg : iotImg;
|
||||
|
||||
width = device?.type === "camera" ? 40 : 20;
|
||||
height = device?.type === "camera" ? 40 : 20;
|
||||
width = isCameraDevice(device) ? 40 : 20;
|
||||
height = isCameraDevice(device) ? 40 : 20;
|
||||
|
||||
} else {
|
||||
|
||||
image =
|
||||
device?.type === "plane" ? planeImg : // 飞机
|
||||
device?.type === "drone" ? planeImg : // 无人机
|
||||
device?.type === "mower" ? carImg : // 割草
|
||||
device?.type === "robot" ? carImg : // 巡检
|
||||
carImg; // 默认车
|
||||
isDroneDevice(device) ? planeImg : // 无人机/飞机
|
||||
isMowerDevice(device) ? carImg : // 割草机
|
||||
carImg; // 巡检/默认车
|
||||
|
||||
width =
|
||||
device?.type === "plane" ||
|
||||
device?.type === "drone" ||
|
||||
device?.type === "drone-inspect"
|
||||
? 30
|
||||
: carsize;
|
||||
width = isDroneDevice(device) ? 30 : carsize;
|
||||
|
||||
height =
|
||||
device?.type === "plane" ||
|
||||
device?.type === "drone" ||
|
||||
device?.type === "drone-inspect"
|
||||
? 30
|
||||
: carsize;
|
||||
height = isDroneDevice(device) ? 30 : carsize;
|
||||
|
||||
}
|
||||
|
||||
@@ -2887,12 +2902,8 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
// 尺寸可根据设备类型微调:车辆类稍大,IOT/相机类稍小
|
||||
let haloSize = 0.8;
|
||||
if (isIOT) {
|
||||
haloSize = device?.type === "camera" ? 0.8 : 0.8;
|
||||
} else if (
|
||||
device?.type === "plane" ||
|
||||
device?.type === "drone" ||
|
||||
device?.type === "drone-inspect"
|
||||
) {
|
||||
haloSize = isCameraDevice(device) ? 0.8 : 0.8;
|
||||
} else if (isDroneDevice(device)) {
|
||||
haloSize = 0.1;
|
||||
} else {
|
||||
haloSize = 0.8;
|
||||
@@ -2925,12 +2936,8 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
let haloSize = 40;
|
||||
|
||||
if (isIOT) {
|
||||
haloSize = device?.type === "camera" ? 35 : 28;
|
||||
} else if (
|
||||
device?.type === "plane" ||
|
||||
device?.type === "drone" ||
|
||||
device?.type === "drone-inspect"
|
||||
) {
|
||||
haloSize = isCameraDevice(device) ? 35 : 28;
|
||||
} else if (isDroneDevice(device)) {
|
||||
haloSize = 42;
|
||||
} else {
|
||||
haloSize = 38;
|
||||
@@ -3252,7 +3259,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
// =============================
|
||||
// 判断是否是无人机模式
|
||||
// =============================
|
||||
const isDroneMode = realtimeType === 'plane' || realtimeType === 'drone' || devices.some(d => d.type === 'plane' || d.type === 'drone');
|
||||
const isDroneMode = realtimeType === 'plane' || realtimeType === 'drone' || devices.some(d => isDroneDevice(d));
|
||||
|
||||
// =============================
|
||||
// 判断实时数据是否合法
|
||||
@@ -3401,7 +3408,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
const position = Cesium.Cartesian3.fromDegrees(lon, lat, 1);
|
||||
|
||||
// 实时光圈颜色:优先取设备状态色,缺省蓝色(工作)
|
||||
const rtHaloColor = devices?.[0] ? getDeviceHaloColor(devices[0]) : Cesium.Color.fromCssColorString('#1677ff');
|
||||
const rtHaloColor = Cesium.Color.fromCssColorString('#19cd08');
|
||||
|
||||
// ====================================
|
||||
// 无人机模式:保持原来的逻辑
|
||||
|
||||
Reference in New Issue
Block a user