根据不同账号 显示的首页优化 规划界面 悬浮显示 状态信息 全局急停状态统一 割刀 根据新方案对接 两个状态 任务路线 显示为 抽拉式一行一个 xbox组件优化数据发送,重构数据

This commit is contained in:
mmc
2026-11-14 18:23:27 +08:00
parent f057e0b72c
commit 831e1086d3
12 changed files with 566 additions and 382 deletions

View File

@@ -425,14 +425,13 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
if (!viewer || !Cesium) return;
console.log(message, "障碍物信息")
const payload = message;
const objects = Array.isArray(payload)
? payload
: Array.isArray(payload?.objects)
? payload.objects
: [];
console.log(objects, "障碍物信息2222")
console.log(objects, "障碍物信息")
// 全量替换:先把地图上所有 live-obstacle 实体按 id 前缀全部移除
// 不依赖 liveObstacleEntities Map(避免历史孤儿实体残留)
const toRemove = [];
@@ -825,6 +824,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
// 特点:多层扩散动画光圈,独立一套 id
// ============================================================
function ensureRealtimeHalo(viewer, position, color, size = 100, haloId = 'realtime_car_halo') {
return;
const haloBaseId = haloId;
const RING_COUNT = 3;
const MIN_SIZE = 100;
@@ -1377,6 +1377,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
function resolveDeviceStatus(device) {
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 !== '') {
@@ -1466,6 +1467,42 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
offline: { text: t('devices.offline'), color: DEVICE_STATUS_COLORS.offline }
};
const status = statusMap[stateKey] || statusMap.idle;
// 控制模式 / 系统模式 / 定位状态 文案映射(与任务规划页保持一致)
const controlModeMap = {
'0': t('devices.controlOff'),
'1': t('devices.localCpntrol'),
'2': t('devices.autoTask'),
'3': t('devices.remoteControl')
};
const systemModeMap = {
'2': t('devices.autoTask'),
'3': t('devices.remoteControl')
};
const fixStatusMap = {
no_fix: t('devices.noFix'),
single: t('devices.single'),
dgnss: t('devices.dgnss'),
ins: t('devices.ins'),
rtk_fixed: t('devices.rtkFixed'),
rtk_float: t('devices.rtkFloat'),
single_no_heading: t('devices.singleNoHeading'),
dgnss_no_heading: t('devices.dgnssNoHeading'),
rtk_fixed_no_heading: t('devices.rtkFixedNoHeading'),
rtk_float_no_heading: t('devices.rtkFloatNoHeading')
};
// 以下状态行仅在设备携带对应字段时展示,普通标记点的悬浮提示不受影响
const hasWorkStatus = robot.color !== undefined || robot.status !== undefined || robot.feStatus !== undefined;
const controlModeText = robot.controlMode !== undefined && robot.controlMode !== null && robot.controlMode !== ''
? (controlModeMap[String(robot.controlMode)] || '-')
: '';
const systemModeText = robot.sm !== undefined && robot.sm !== null && robot.sm !== ''
? (systemModeMap[String(robot.sm)] || '-')
: '';
const fixStatusText = robot.fix_status ? (fixStatusMap[robot.fix_status] || String(robot.fix_status)) : '';
const batteryRaw = robot.battery !== undefined && robot.battery !== null
? robot.battery
: (robot.batteryLevel !== undefined ? robot.batteryLevel : undefined);
const batteryText = batteryRaw !== undefined && batteryRaw !== null && batteryRaw !== '' ? Number(batteryRaw) + '%' : '';
let deviceValuesHTML = '';
if (robot.devicevalue && robot.devicevalue.length > 0) {
deviceValuesHTML = robot.devicevalue.map((device) => `
@@ -1489,13 +1526,13 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
</span>
` : ''}</div >
${deviceValuesHTML ? `<div style="margin-top:8px;"><strong>${t('devices.deviceData')}:</strong>${deviceValuesHTML}</div>` : ''}
${hasWorkStatus ? `<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>` : ''}
${controlModeText ? `<div>${t('devices.controlMode')}${controlModeText}</div>` : ''}
${systemModeText ? `<div>${t('devices.systemMode')}:${systemModeText}</div>` : ''}
${batteryText ? `<div>${t('devices.rtBattery')}:${batteryText}</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>
} else {
tooltip.innerHTML = `
<div style = "font-weight:600;margin-bottom:4px;" >📍 ${t('systemSetting.longitude')}:${lonStr}</div >
@@ -3187,6 +3224,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
const haloId = `${id}_halo`;
const haloColor = getDeviceHaloColor(device);
if (isRealtimeMode) {
// 一机一光圈:实时模式下移除设备光圈,避免原位置残留
viewer.entities.removeById(haloId);
@@ -3532,6 +3570,18 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
realtimePosition.lat &&
!isNaN(Number(realtimePosition.lon)) &&
!isNaN(Number(realtimePosition.lat));
const rtHaloColor = realtimePosition?.status == "online" ? Cesium.Color.fromCssColorString('#19cd08') : Cesium.Color.fromCssColorString('#ef340b');
// =============================
// 判断是否需要飞行
// =============================
const needFlight = hasRealtime && !hasFlownRef.current && !realtimeHiddenRef.current;
// =============================
// 判断是否需要隐藏
// =============================
// ====================================
// 情况1:没有实时数据 -> 清理所有 realtime
@@ -3669,7 +3719,6 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
const position = Cesium.Cartesian3.fromDegrees(lon, lat, 1);
// 实时光圈颜色:优先取设备状态色,缺省蓝色(工作)
const rtHaloColor = Cesium.Color.fromCssColorString('#19cd08');
// ====================================
// 无人机模式:保持原来的逻辑
@@ -3940,7 +3989,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
realtimeCarEntityRef.current.billboard.rotation = rotation;
// 实时光圈跟随机器移动,原光随动不残留
ensureRealtimeHalo(viewer, position, rtHaloColor, 38);
//ensureRealtimeHalo(viewer, position, rtHaloColor, 38);
}
// 机器人模式只在导航模式下显示额外的实时轨迹线
@@ -4149,112 +4198,110 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
</div>
)}
{/* 图例:返航点 / 分区 */}
{(stationOverlay.returnPoints.length > 0 || stationOverlay.regions.length > 0 || stationOverlay.tempObstaclePoints.length > 0) && (
<div
<div
style={{
position: "absolute",
right: 12,
top: 12,
zIndex: 20,
background: "rgba(255,255,255,0.92)",
borderRadius: 6,
padding: "8px 10px",
fontSize: 12,
color: "#333",
lineHeight: "18px",
boxShadow: "0 2px 8px rgba(0,0,0,0.12)",
}}
>
<div style={{ fontWeight: 600, marginBottom: 6 }}>{t('devices.mapEditor.legend')}</div>
<div style={{
display: "flex",
alignItems: "center",
gap: 6,
padding: "2px 4px",
borderRadius: 4,
fontWeight: legendHighlight === "returnPoint" ? 600 : 400,
color: legendHighlight === "returnPoint" ? "#165DFF" : "#333",
background: legendHighlight === "returnPoint" ? "#e8f3ff" : "transparent",
}}>
<span style={{
display: "inline-block",
width: 10,
height: 10,
background: "#165DFF",
borderRadius: "50% 50% 50% 0",
transform: "rotate(-45deg)",
}} />
<span>{t('devices.mapEditor.returnPoint')}</span>
</div>
<div style={{
display: "flex",
alignItems: "center",
gap: 6,
marginTop: 4,
padding: "2px 4px",
borderRadius: 4,
fontWeight: legendHighlight === "region" ? 600 : 400,
color: legendHighlight === "region" ? "#13C2C2" : "#333",
background: legendHighlight === "region" ? "rgba(19,194,194,0.12)" : "transparent",
}}>
<span style={{
display: "inline-block",
width: 12,
height: 10,
border: "1px solid #13C2C2",
background: "rgba(19,194,194,0.18)",
}} />
<span>{t('devices.mapEditor.restArea')}</span>
</div>
<div style={{
display: "flex",
alignItems: "center",
gap: 6,
marginTop: 4,
padding: "2px 4px",
borderRadius: 4,
fontWeight: legendHighlight === "obstaclePoint" ? 600 : 400,
color: legendHighlight === "obstaclePoint" ? "#13C2C2" : "#333",
background: legendHighlight === "obstaclePoint" ? "rgba(19,194,194,0.12)" : "transparent",
}}>
<span
style={{
display: 'inline-block',
width: 12,
height: 12,
border: '2px solid #F5222D',
borderRadius: '50%',
background: 'rgba(245,34,45,0.18)',
boxSizing: 'border-box',
}}
/>
<span>{t('devices.mapEditor.obstacle')}</span>
</div>
<button
onClick={handleFlyToDevice}
style={{
position: "absolute",
right: 12,
top: 12,
zIndex: 20,
background: "rgba(255,255,255,0.92)",
borderRadius: 6,
padding: "8px 10px",
fontSize: 12,
color: "#333",
lineHeight: "18px",
boxShadow: "0 2px 8px rgba(0,0,0,0.12)",
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
gap: '8px',
padding: '4px 8px',
color: '#fff',
fontSize: '14px',
fontWeight: 500,
background: 'linear-gradient(135deg, #409eff 0%, #1677ff 100%)',
border: 'none',
borderRadius: '8px',
boxShadow: '0 3px 10px rgba(22, 119, 255, 0.25)',
cursor: 'pointer',
transition: 'all 0.2s ease',
}}
>
<div style={{ fontWeight: 600, marginBottom: 6 }}>{t('devices.mapEditor.legend')}</div>
<div style={{
display: "flex",
alignItems: "center",
gap: 6,
padding: "2px 4px",
borderRadius: 4,
fontWeight: legendHighlight === "returnPoint" ? 600 : 400,
color: legendHighlight === "returnPoint" ? "#165DFF" : "#333",
background: legendHighlight === "returnPoint" ? "#e8f3ff" : "transparent",
}}>
<span style={{
display: "inline-block",
width: 10,
height: 10,
background: "#165DFF",
borderRadius: "50% 50% 50% 0",
transform: "rotate(-45deg)",
}} />
<span>{t('devices.mapEditor.returnPoint')}</span>
</div>
<div style={{
display: "flex",
alignItems: "center",
gap: 6,
marginTop: 4,
padding: "2px 4px",
borderRadius: 4,
fontWeight: legendHighlight === "region" ? 600 : 400,
color: legendHighlight === "region" ? "#13C2C2" : "#333",
background: legendHighlight === "region" ? "rgba(19,194,194,0.12)" : "transparent",
}}>
<span style={{
display: "inline-block",
width: 12,
height: 10,
border: "1px solid #13C2C2",
background: "rgba(19,194,194,0.18)",
}} />
<span>{t('devices.mapEditor.restArea')}</span>
</div>
<div style={{
display: "flex",
alignItems: "center",
gap: 6,
marginTop: 4,
padding: "2px 4px",
borderRadius: 4,
fontWeight: legendHighlight === "obstaclePoint" ? 600 : 400,
color: legendHighlight === "obstaclePoint" ? "#13C2C2" : "#333",
background: legendHighlight === "obstaclePoint" ? "rgba(19,194,194,0.12)" : "transparent",
}}>
<span
style={{
display: 'inline-block',
width: 12,
height: 12,
border: '2px solid #F5222D',
borderRadius: '50%',
background: 'rgba(245,34,45,0.18)',
boxSizing: 'border-box',
}}
/>
<span>{t('devices.mapEditor.obstacle')}</span>
</div>
<button
onClick={handleFlyToDevice}
style={{
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
gap: '8px',
padding: '4px 8px',
color: '#fff',
fontSize: '14px',
fontWeight: 500,
background: 'linear-gradient(135deg, #409eff 0%, #1677ff 100%)',
border: 'none',
borderRadius: '8px',
boxShadow: '0 3px 10px rgba(22, 119, 255, 0.25)',
cursor: 'pointer',
transition: 'all 0.2s ease',
}}
>
<span style={{ fontSize: '18px', lineHeight: 1 }}>⌖</span>
<span>{t('devices.mapEditor.location')}</span>
</button>
</div>
)}
<span style={{ fontSize: '18px', lineHeight: 1 }}>⌖</span>
<span>{t('devices.mapEditor.location')}</span>
</button>
</div>
</div>
);