急停 发送的模式切换 接收障碍物信息 纵览界面 返航和任务表格数据 优化 状态界面加入人员跟随和 系统模式 还未对接系统模式 任务监控界面加入障碍物
This commit is contained in:
@@ -540,6 +540,17 @@ export function modeChage(params) {
|
||||
})
|
||||
}
|
||||
|
||||
///iot/host/eStopChange
|
||||
|
||||
export function eStopChange(params) {
|
||||
return request({
|
||||
url: '/iot/host/eStopChange',
|
||||
method: 'get',
|
||||
params,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -256,6 +256,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
);
|
||||
|
||||
const liveObstacleEntities = new Map();
|
||||
const liveObstacleLastTsRef = useRef(0);
|
||||
|
||||
// ==============================
|
||||
// 统一相机飞行调度器
|
||||
@@ -396,39 +397,119 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
}, [baseMapType, tiandituUnavailable]);
|
||||
|
||||
|
||||
|
||||
const computeDistanceScale = () => {
|
||||
const viewer = viewerRef.current;
|
||||
const MIN_SCALE = 0.35;
|
||||
const MAX_SCALE = 2.5;
|
||||
const REF_HEIGHT = 50; // 相机高度 50m 时 scale = 1(基准尺寸)
|
||||
const h = viewer.camera.positionCartographic?.height ?? REF_HEIGHT;
|
||||
let s = REF_HEIGHT / Math.max(h, 1); // 反比
|
||||
if (s < MIN_SCALE) s = MIN_SCALE;
|
||||
if (s > MAX_SCALE) s = MAX_SCALE;
|
||||
return s;
|
||||
};
|
||||
function updateLiveObstacleBoxes(
|
||||
message,
|
||||
) {
|
||||
const viewer = viewerRef.current;
|
||||
//for (const [, entity] of liveObstacleEntities) {
|
||||
// viewer.entities.remove(entity);
|
||||
//}
|
||||
//liveObstacleEntities.clear();
|
||||
|
||||
|
||||
// 让 billboard / label 图标随相机高度(地图远近)动态缩放
|
||||
// 经验映射:相机越高(地图越远)scale 越小,相机越低(地图越近)scale 越大
|
||||
// 相机高度 20m → scale 1.5;50m → 1.0;200m → 0.5;上限/下限 clamp
|
||||
|
||||
|
||||
if (!viewer || !Cesium) return;
|
||||
|
||||
console.log(message, "障碍物信息")
|
||||
const payload = message;
|
||||
const objects = Array.isArray(payload) ? payload : (payload?.objects ?? []);
|
||||
const objects = Array.isArray(payload)
|
||||
? payload
|
||||
: Array.isArray(payload?.objects)
|
||||
? payload.objects
|
||||
: [];
|
||||
console.log(objects, "障碍物信息2222")
|
||||
// 全量替换:先把地图上所有 live-obstacle 实体按 id 前缀全部移除
|
||||
// 不依赖 liveObstacleEntities Map(避免历史孤儿实体残留)
|
||||
const toRemove = [];
|
||||
viewer.entities.values.forEach((ent) => {
|
||||
if (ent && ent.id && String(ent.id).startsWith('live-obstacle-')) {
|
||||
toRemove.push(ent);
|
||||
}
|
||||
});
|
||||
toRemove.forEach((ent) => viewer.entities.remove(ent));
|
||||
liveObstacleEntities.clear();
|
||||
|
||||
if (objects.length === 0) return;
|
||||
if (objects.length === 0) {
|
||||
console.log("没有障碍物")
|
||||
viewer.scene.requestRender();
|
||||
return;
|
||||
}
|
||||
|
||||
// 记录第一个有效障碍物的位置,用于视角跳转
|
||||
let firstPos = null;
|
||||
|
||||
objects.forEach((obj, index) => {
|
||||
console.log(obj, "障碍物信息1111")
|
||||
const lat = Number(obj.latitude ?? obj.lat);
|
||||
const lon = Number(obj.longitude ?? obj.lng ?? obj.lon);
|
||||
const dis = obj?.distance;
|
||||
|
||||
// 根据类型设置默认尺寸和颜色
|
||||
const type = (obj.class_name ?? obj.name ?? '').toLowerCase();
|
||||
const isPerson = type.includes('person') || type.includes('行人') || type.includes('人');
|
||||
const isVehicle = type.includes('car') || type.includes('车辆') || type.includes('车') || type.includes('truck');
|
||||
const isFence = type.includes('fence') || type.includes('围挡') || type.includes('障碍');
|
||||
// 优先按 class_id 判定类型;未提供时再 fallback 到 class_name 字符串
|
||||
const CLASS_ID_MAP = {
|
||||
0: 'bus',
|
||||
1: 'car',
|
||||
2: 'motorcycle',
|
||||
3: 'person',
|
||||
4: 'truck',
|
||||
};
|
||||
const classIdRaw = obj.class_id ?? obj.classId ?? obj.class;
|
||||
const parsedClassId = Number(classIdRaw);
|
||||
const kindByClassId = Number.isInteger(parsedClassId) && CLASS_ID_MAP[parsedClassId]
|
||||
? CLASS_ID_MAP[parsedClassId]
|
||||
: null;
|
||||
const rawName = (obj.class_name ?? obj.name ?? '').toLowerCase();
|
||||
const kindByName = rawName.includes('person') || rawName.includes('行人') || rawName.includes('人') ? 'person'
|
||||
: rawName.includes('motorcycle') || rawName.includes('摩托车') || rawName.includes('电驴') ? 'motorcycle'
|
||||
: rawName.includes('bus') || rawName.includes('公交') || rawName.includes('大巴') ? 'bus'
|
||||
: rawName.includes('truck') || rawName.includes('货车') || rawName.includes('卡车') ? 'truck'
|
||||
: rawName.includes('car') || rawName.includes('车辆') || rawName.includes('车') ? 'car'
|
||||
: rawName.includes('fence') || rawName.includes('围挡') || rawName.includes('障碍') ? 'fence'
|
||||
: 'unknown';
|
||||
|
||||
const sx = Number(obj.size_x ?? obj.sizeX ?? (isPerson ? 0.6 : isVehicle ? 1.8 : 1.2));
|
||||
const sy = Number(obj.size_y ?? obj.sizeY ?? (isPerson ? 0.6 : isVehicle ? 4.2 : 1.2));
|
||||
const sz = Number(obj.size_z ?? obj.sizeZ ?? (isPerson ? 1.7 : isVehicle ? 1.5 : 1.5));
|
||||
const obstacleKind = kindByClassId || kindByName;
|
||||
const isPerson = obstacleKind === 'person';
|
||||
const isVehicle = ['car', 'truck', 'bus', 'motorcycle'].includes(obstacleKind);
|
||||
const isFence = obstacleKind === 'fence';
|
||||
|
||||
// 尺寸兜底:过滤 NaN / 负数 / 0,避免 Cesium BoxOutlineGeometry 抛 DeveloperError
|
||||
const safeSize = (val, fallback) => {
|
||||
const n = Number(val);
|
||||
return Number.isFinite(n) && n > 0 ? n : fallback;
|
||||
};
|
||||
// 不同类别的默认尺寸(长 x 宽 x 高,单位米)
|
||||
const KIND_DEFAULT_SIZE = {
|
||||
person: { sx: 0.6, sy: 0.6, sz: 1.7 },
|
||||
motorcycle: { sx: 0.8, sy: 2.2, sz: 1.6 },
|
||||
car: { sx: 1.8, sy: 4.5, sz: 1.5 },
|
||||
truck: { sx: 2.5, sy: 7.0, sz: 3.0 },
|
||||
bus: { sx: 2.6, sy: 10.0, sz: 3.2 },
|
||||
fence: { sx: 1.2, sy: 1.2, sz: 1.5 },
|
||||
unknown: { sx: 1.2, sy: 1.2, sz: 1.5 },
|
||||
};
|
||||
const defaults = KIND_DEFAULT_SIZE[obstacleKind] || KIND_DEFAULT_SIZE.unknown;
|
||||
const sx = safeSize(obj.size_x ?? obj.sizeX, defaults.sx);
|
||||
const sy = safeSize(obj.size_y ?? obj.sizeY, defaults.sy);
|
||||
const sz = safeSize(obj.size_z ?? obj.sizeZ, defaults.sz);
|
||||
|
||||
if (!Number.isFinite(lat) || !Number.isFinite(lon)) return;
|
||||
|
||||
const id = `live-obstacle-${obj.track_id ?? obj.id ?? index}`;
|
||||
const id = `live-obstacle-${index}`;
|
||||
|
||||
const position = Cesium.Cartesian3.fromDegrees(lon, lat, sz / 2);
|
||||
|
||||
if (!firstPos) firstPos = { lon, lat };
|
||||
@@ -438,21 +519,21 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(Number(obj.angle ?? obj.yaw ?? 0)), 0, 0)
|
||||
);
|
||||
|
||||
// 设置视觉差异
|
||||
let boxColor = Cesium.Color.RED;
|
||||
let typeEmoji = '⚠️';
|
||||
let iconImage = null; // 用于存储图标
|
||||
|
||||
if (isPerson) {
|
||||
boxColor = Cesium.Color.YELLOW;
|
||||
typeEmoji = '🚶';
|
||||
iconImage = 'https://img.icons8.com/color/96/walking--v1.png'; // 行人图标
|
||||
} else if (isVehicle) {
|
||||
boxColor = Cesium.Color.CYAN;
|
||||
typeEmoji = '🚗';
|
||||
iconImage = 'https://img.icons8.com/color/96/car--v1.png'; // 车辆图标
|
||||
}
|
||||
const labelText = `${typeEmoji} ${obj.class_name ?? '障碍物'} #${obj.track_id ?? obj.id ?? index} (${sx.toFixed(1)}x${sy.toFixed(1)}m)`;
|
||||
// 不同类别的颜色、图标和文字
|
||||
const KIND_STYLE = {
|
||||
person: { color: Cesium.Color.YELLOW, emoji: '🚶', label: '行人', icon: 'https://img.icons8.com/color/96/walking--v1.png', width: 24 },
|
||||
motorcycle: { color: Cesium.Color.ORANGE, emoji: '🛵', label: '摩托车', icon: 'https://img.icons8.com/color/96/motorcycle--v1.png', width: 28 },
|
||||
car: { color: Cesium.Color.CYAN, emoji: '🚗', label: '小车', icon: 'https://img.icons8.com/color/96/car--v1.png', width: 32 },
|
||||
truck: { color: Cesium.Color.LIME, emoji: '🚚', label: '货车', icon: 'https://img.icons8.com/color/96/delivery-truck--v1.png', width: 36 },
|
||||
bus: { color: Cesium.Color.VIOLET, emoji: '🚌', label: '公交', icon: 'https://img.icons8.com/color/96/bus--v1.png', width: 36 },
|
||||
unknown: { color: Cesium.Color.RED, emoji: '⚠️', label: '障碍物', icon: null, width: 32 },
|
||||
};
|
||||
const style = KIND_STYLE[obstacleKind] || KIND_STYLE.unknown;
|
||||
const boxColor = style.color;
|
||||
const typeEmoji = style.emoji;
|
||||
const iconImage = style.icon;
|
||||
const labelText = `${typeEmoji} ${style.label} (${sx.toFixed(1)}x${sy.toFixed(1)}m) ${dis ? `\n距离: ${dis.toFixed(1)}m` : ''}`;
|
||||
const billboardSize = style.width;
|
||||
|
||||
let entity = viewer.entities.getById(id);
|
||||
|
||||
@@ -462,30 +543,32 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
position,
|
||||
orientation,
|
||||
// 外部包围盒,显示物理占用空间
|
||||
box: {
|
||||
dimensions: new Cesium.Cartesian3(sx, sy, sz),
|
||||
material: boxColor.withAlpha(0.2),
|
||||
outline: true,
|
||||
outlineColor: boxColor,
|
||||
outlineWidth: 1,
|
||||
},
|
||||
//box: {
|
||||
// dimensions: new Cesium.Cartesian3(sx, sy, sz),
|
||||
// material: boxColor.withAlpha(0.2),
|
||||
// outline: true,
|
||||
// outlineColor: boxColor,
|
||||
// outlineWidth: 1,
|
||||
//},
|
||||
// 内部图标,直观显示物体类型
|
||||
billboard: iconImage ? {
|
||||
image: iconImage,
|
||||
width: isPerson ? 24 : 32,
|
||||
height: isPerson ? 24 : 32,
|
||||
width: billboardSize,
|
||||
height: billboardSize,
|
||||
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND,
|
||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
scale: new Cesium.CallbackProperty(computeDistanceScale, false),
|
||||
} : undefined,
|
||||
label: {
|
||||
text: labelText,
|
||||
font: 'bold 14px sans-serif',
|
||||
fillColor: Cesium.Color.WHITE,
|
||||
showBackground: true,
|
||||
backgroundColor: boxColor.withAlpha(0.85),
|
||||
pixelOffset: new Cesium.Cartesian2(0, -40),
|
||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
},
|
||||
//label: {
|
||||
// text: labelText,
|
||||
// font: 'bold 14px sans-serif',
|
||||
// fillColor: Cesium.Color.WHITE,
|
||||
// showBackground: true,
|
||||
// backgroundColor: boxColor.withAlpha(0.85),
|
||||
// pixelOffset: new Cesium.Cartesian2(0, -40),
|
||||
// disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
// //scale: new Cesium.CallbackProperty(computeDistanceScale, false),
|
||||
//},
|
||||
});
|
||||
} else {
|
||||
entity.position = position;
|
||||
@@ -497,27 +580,29 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
}
|
||||
if (entity.billboard && iconImage) {
|
||||
entity.billboard.image = iconImage;
|
||||
entity.billboard.scale = new Cesium.CallbackProperty(computeDistanceScale, false);
|
||||
}
|
||||
if (entity.label) {
|
||||
entity.label.text = labelText;
|
||||
entity.label.backgroundColor = boxColor.withAlpha(0.85);
|
||||
entity.label.scale = new Cesium.CallbackProperty(computeDistanceScale, false);
|
||||
}
|
||||
}
|
||||
liveObstacleEntities.set(id, entity);
|
||||
});
|
||||
|
||||
// 自动跳转到第一个障碍物
|
||||
if (firstPos) {
|
||||
flyToView(viewer, 100, {
|
||||
destination: Cesium.Cartesian3.fromDegrees(firstPos.lon, firstPos.lat, 60),
|
||||
orientation: {
|
||||
heading: Cesium.Math.toRadians(0),
|
||||
pitch: Cesium.Math.toRadians(-40),
|
||||
roll: 0
|
||||
},
|
||||
duration: 2.0
|
||||
}, 'live-obstacle-jump');
|
||||
}
|
||||
//if (firstPos) {
|
||||
// flyToView(viewer, 100, {
|
||||
// destination: Cesium.Cartesian3.fromDegrees(firstPos.lon, firstPos.lat, 60),
|
||||
// orientation: {
|
||||
// heading: Cesium.Math.toRadians(0),
|
||||
// pitch: Cesium.Math.toRadians(-40),
|
||||
// roll: 0
|
||||
// },
|
||||
// duration: 2.0
|
||||
// }, 'live-obstacle-jump');
|
||||
//}
|
||||
viewer.scene.requestRender();
|
||||
}
|
||||
|
||||
@@ -567,10 +652,79 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
|
||||
// return () => clearTimeout(timer);
|
||||
//}, [stationId]);
|
||||
//useEffect(() => {
|
||||
// const viewer = viewerRef.current;
|
||||
// if (!viewer || !Cesium) return;
|
||||
|
||||
// let count = 0;
|
||||
|
||||
// const mockTimer = setInterval(() => {
|
||||
// count++;
|
||||
|
||||
// let mockMsg;
|
||||
|
||||
// // 奇数次:模拟有障碍物
|
||||
// if (count % 2 === 1) {
|
||||
// mockMsg = {
|
||||
// objects: [
|
||||
// {
|
||||
// track_id: "obs-v-001",
|
||||
// latitude: 31.2989,
|
||||
// longitude: 120.5853,
|
||||
// size_x: 1.8,
|
||||
// size_y: 4.2,
|
||||
// size_z: 1.5,
|
||||
// angle: 30,
|
||||
// class_name: "车辆",
|
||||
// distance: 15.5
|
||||
// },
|
||||
// {
|
||||
// track_id: "obs-p-002",
|
||||
// latitude: 31.2992,
|
||||
// longitude: 120.5856,
|
||||
// size_x: 0.6,
|
||||
// size_y: 0.6,
|
||||
// size_z: 1.7,
|
||||
// angle: 0,
|
||||
// class_name: "行人",
|
||||
// distance: 8.2
|
||||
// },
|
||||
// {
|
||||
// track_id: "obs-t-003",
|
||||
// latitude: 31.2987,
|
||||
// longitude: 120.5850,
|
||||
// size_x: 2.5,
|
||||
// size_y: 7.0,
|
||||
// size_z: 3.0,
|
||||
// angle: 90,
|
||||
// class_name: "货车",
|
||||
// distance: 22.6
|
||||
// }
|
||||
// ]
|
||||
// };
|
||||
|
||||
// console.log("模拟发送:有障碍物", mockMsg);
|
||||
// } else {
|
||||
// // 偶数次:模拟没有障碍物
|
||||
// mockMsg = {
|
||||
// objects: []
|
||||
// };
|
||||
|
||||
// console.log("模拟发送:没有障碍物");
|
||||
// }
|
||||
|
||||
// updateLiveObstacleBoxes(mockMsg);
|
||||
|
||||
// }, 3000); // 每隔3秒发送一次
|
||||
|
||||
// return () => {
|
||||
// clearInterval(mockTimer);
|
||||
// };
|
||||
|
||||
//}, [stationId]);
|
||||
|
||||
const handleDetectFn = (res) => {
|
||||
if (!res) return;
|
||||
liveObstacleLastTsRef.current = Date.now();
|
||||
updateLiveObstacleBoxes(res);
|
||||
};
|
||||
|
||||
@@ -648,7 +802,6 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
};
|
||||
|
||||
|
||||
|
||||
const clearDrawingPath = () => {
|
||||
const viewer = viewerRef.current;
|
||||
if (!viewer) return;
|
||||
@@ -724,6 +877,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
pixelOffset: new Cesium.Cartesian2(0, 0),
|
||||
color: ringColor,
|
||||
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||
scale: new Cesium.CallbackProperty(computeDistanceScale, false),
|
||||
heightReference: Cesium.HeightReference.NONE,
|
||||
},
|
||||
});
|
||||
@@ -3891,6 +4045,28 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
|
||||
handleDetectFn(detectReportInfo)
|
||||
}, [detectReportInfo])
|
||||
|
||||
// // 超时兜底:2s 没收到新的障碍物消息,自动清掉(防止上游停推时残留)
|
||||
useEffect(() => {
|
||||
const TIMEOUT = 2000;
|
||||
const timer = setInterval(() => {
|
||||
const now = Date.now();
|
||||
if (liveObstacleLastTsRef.current > 0 && now - liveObstacleLastTsRef.current > TIMEOUT) {
|
||||
const v = viewerRef.current;
|
||||
if (!v || !v.scene) return;
|
||||
// 按 id 前缀扫掉所有 live-obstacle 实体(不依赖 Map 记录)
|
||||
const toRemove = [];
|
||||
v.entities.values.forEach((ent) => {
|
||||
if (ent && ent.id && String(ent.id).startsWith('live-obstacle-')) toRemove.push(ent);
|
||||
});
|
||||
toRemove.forEach((ent) => v.entities.remove(ent));
|
||||
liveObstacleEntities.clear();
|
||||
liveObstacleLastTsRef.current = 0;
|
||||
v.scene.requestRender();
|
||||
}
|
||||
}, 500);
|
||||
return () => clearInterval(timer);
|
||||
}, []);
|
||||
|
||||
// 暴露 ref 方法
|
||||
useImperativeHandle(ref, () => ({
|
||||
captureScreenshot,
|
||||
|
||||
@@ -43,6 +43,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { sendEmergencyStop } from './emergencyStopControl';
|
||||
import AlarmLevelTag from '../AlarmLevelTag.tsx';
|
||||
import { getDeviceTastPool } from '@/api/device.ts';
|
||||
import { backToRestPointCommand } from '@/api/mapEdit';
|
||||
|
||||
const { Content } = Layout;
|
||||
const { Text, Title } = Typography;
|
||||
@@ -174,6 +175,90 @@ export default function DeviceOverviewPage() {
|
||||
|
||||
}
|
||||
|
||||
const getRealtimeColor = (status: any) => {
|
||||
const s = Number(status);
|
||||
if (s === 1) return 'green';
|
||||
if (s === 2) return 'blue';
|
||||
return 'red';
|
||||
};
|
||||
const mapDevices = useMemo(() => {
|
||||
const base = [...devices];
|
||||
const knownKeys = new Set();
|
||||
base.forEach((d: any) => {
|
||||
const k = d?.serialNumber ?? d?.device_sn ?? d?.id;
|
||||
if (k != null && k !== '') knownKeys.add(String(k));
|
||||
});
|
||||
// mapPush 推的是 { [设备id]: 实时记录 },同时兼容数组结构
|
||||
const rtList: any[] = Array.isArray(realtimeMap) ? realtimeMap : Object.values(realtimeMap || {});
|
||||
const extras = rtList
|
||||
.filter((rt: any) =>
|
||||
Number.isFinite(Number(rt.lng)) &&
|
||||
Number.isFinite(Number(rt.lat)) &&
|
||||
!(Number(rt.lng) === 0 && Number(rt.lat) === 0) &&
|
||||
!knownKeys.has(String(rt.id))
|
||||
)
|
||||
.map((rt: any) => ({
|
||||
id: rt?.id,
|
||||
name: rt?.name || rt?.alias || `设备-${String(rt?.id).slice(-4)}`,
|
||||
serialNumber: rt?.id,
|
||||
status: rt?.status,
|
||||
color: getRealtimeColor(rt?.status),
|
||||
longitude: rt?.lng,
|
||||
latitude: rt?.lat,
|
||||
heading: rt?.yaw,
|
||||
batteryLevel: rt?.battery,
|
||||
updateTime: rt?.updateTime,
|
||||
feStatus: rt?.feStatus,
|
||||
taskId: rt?.t,
|
||||
isRealtimeOnly: true,
|
||||
// 同步写入 locationMessage / lastRunningStatus,确保 Map.jsx 设备渲染 useEffect 能读到实时坐标
|
||||
locationMessage: { longitude: rt?.lng, latitude: rt?.lat, heading: rt?.yaw, batteryLevel: rt?.battery },
|
||||
lastRunningStatus: { longitude: rt?.lng, latitude: rt?.lat, heading: rt?.yaw, batteryLevel: rt?.battery },
|
||||
raw: { ...rt },
|
||||
}));
|
||||
// 关键:把静态列表中已有设备的位置/状态用实时数据覆盖,
|
||||
// 否则 base 里的设备永远只有接口返回的旧坐标,地图实体不会实时动
|
||||
const rtMapDict: any = Array.isArray(realtimeMap)
|
||||
? realtimeMap.reduce((acc: any, r: any, i: number) => { acc[String(r?.id ?? i)] = r; return acc; }, {})
|
||||
: (realtimeMap || {});
|
||||
const baseOverridden = base.map((d) => {
|
||||
const k = String(d?.serialNumber ?? d?.device_sn ?? d?.id ?? "");
|
||||
const rt = rtMapDict[k];
|
||||
if (!rt) return { ...d, color: 'red' };
|
||||
return {
|
||||
...d,
|
||||
longitude: rt.lng ?? d.longitude,
|
||||
latitude: rt.lat ?? d.latitude,
|
||||
heading: rt.yaw ?? d.heading,
|
||||
batteryLevel: rt.battery ?? d.batteryLevel,
|
||||
feStatus: rt.feStatus ?? d.feStatus,
|
||||
status: rt.status ?? d.status,
|
||||
color: getRealtimeColor(rt.status),
|
||||
hasAlarm: !!rt.hasAlarm,
|
||||
taskId: rt.t ?? rt.taskId ?? d.taskId,
|
||||
updateTime: rt.updateTime ?? d.updateTime,
|
||||
locationMessage: {
|
||||
longitude: rt.lng ?? d.locationMessage?.longitude,
|
||||
latitude: rt.lat ?? d.locationMessage?.latitude,
|
||||
heading: rt.yaw ?? d.locationMessage?.heading,
|
||||
batteryLevel: rt.battery ?? d.locationMessage?.batteryLevel,
|
||||
},
|
||||
lastRunningStatus: {
|
||||
longitude: rt.lng ?? d.lastRunningStatus?.longitude,
|
||||
latitude: rt.lat ?? d.lastRunningStatus?.latitude,
|
||||
heading: rt.yaw ?? d.lastRunningStatus?.heading,
|
||||
batteryLevel: rt.battery ?? d.lastRunningStatus?.batteryLevel,
|
||||
},
|
||||
};
|
||||
});
|
||||
const all = [...baseOverridden, ...extras];
|
||||
|
||||
return all.filter((d: any) =>
|
||||
(d?.lastRunningStatus?.latitude && d?.lastRunningStatus?.longitude) ||
|
||||
(d?.locationMessage?.latitude && d?.locationMessage?.longitude) ||
|
||||
(d?.longitude && d?.latitude)
|
||||
);
|
||||
}, [devices, realtimeMap]);
|
||||
|
||||
// 打开编辑弹窗
|
||||
const openEditRobotModal = (record) => {
|
||||
@@ -593,6 +678,22 @@ export default function DeviceOverviewPage() {
|
||||
},
|
||||
];
|
||||
}, [devices, planedevices, realtimeMap, taskStats]);
|
||||
const handleAutoBack = () => {
|
||||
const payload = {
|
||||
deviceId: selectedDevice?.serialNumber,
|
||||
orgId: currentStation?.orgId,
|
||||
siteId: stationId,
|
||||
}
|
||||
backToRestPointCommand(payload).then(res => {
|
||||
if (res.code == 200) {
|
||||
message.success(t('devices.fixed2ReturnHomeFixed2CommandIssuedFixed2'));
|
||||
} else {
|
||||
message.error(t('devices.fixed2ReturnHomeFixed2CommandIssuedFixed2Failed'));
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error('返回休息点失败', err);
|
||||
})
|
||||
}
|
||||
|
||||
// 设备调度列表
|
||||
const dynamicScheduleList = useMemo(() => {
|
||||
@@ -624,7 +725,7 @@ export default function DeviceOverviewPage() {
|
||||
const handleRecharge = () => message.info(t('devices.commandIssuedFixed2'));
|
||||
// 急停:点击时直接下发 button7(绕过控制权限校验),并提示已触发
|
||||
const handleEmergencyStop = () => {
|
||||
sendEmergencyStop(userInfo);
|
||||
sendEmergencyStop(selectedDevice?.serialNumber || "");
|
||||
message.error(t('devices.s73'));
|
||||
};
|
||||
|
||||
@@ -713,7 +814,7 @@ export default function DeviceOverviewPage() {
|
||||
<Col xs={24} lg={14}>
|
||||
<Card title={<><EnvironmentOutlined />{t('devices.fixed2Equipment')}</>} extra={<Button type="text" icon={<SettingOutlined />} />} variant="borderless" style={{ borderRadius: 8, marginBottom: 8 }} styles={{ body: { padding: 0 } }}>
|
||||
<div style={{ width: '100%', height: 350, borderRadius: 8, position: 'relative', overflow: 'hidden' }}>
|
||||
<div style={{ position: 'absolute', zIndex: 11, top: 12, left: 12, background: 'rgba(255,255,255,0.95)', borderRadius: 6, padding: 8 }}>
|
||||
{/*<div style={{ position: 'absolute', zIndex: 11, top: 12, left: 12, background: 'rgba(255,255,255,0.95)', borderRadius: 6, padding: 8 }}>
|
||||
<div style={{ fontSize: 11, fontWeight: 60, marginBottom: 4 }}>{t('devices.s22')}</div>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 4, fontSize: 10 }}>
|
||||
<div><span style={{ color: '#1890ff' }}>———</span>{t('devices.fixed2Inspection')}</div>
|
||||
@@ -724,8 +825,8 @@ export default function DeviceOverviewPage() {
|
||||
<div><span style={{ color: '#1890ff' }}>●</span>{t('devices.chargePointFixed2')}</div>
|
||||
<div><span style={{ color: '#ff4d4f' }}>■</span>{t('devices.s9')}</div>
|
||||
</div>
|
||||
</div>
|
||||
<CesiumMap devices={devicesAll} mapLayer={currentStation?.siteMapName} />
|
||||
</div>*/}
|
||||
<CesiumMap devices={mapDevices} mapLayer={currentStation?.siteMapName} />
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -831,24 +932,57 @@ export default function DeviceOverviewPage() {
|
||||
dataSource={taskList}
|
||||
scroll={{ x: 'max-content' }}
|
||||
columns={[
|
||||
{ title: t('common.createTime'), dataIndex: 'time', width: 90, render: (v) => <span style={{ fontSize: 13 }}>{v}</span> },
|
||||
{ title: t('devices.deviceId'), dataIndex: 'device', width: 100, render: (v) => <span style={{ fontSize: 13 }}>{v}</span> },
|
||||
{ title: t('common.createTime'), dataIndex: 'startTime', width: 90, render: (v) => <span style={{ fontSize: 13 }}>{v}</span> },
|
||||
{ title: t('devices.deviceId'), dataIndex: 'deviceId', width: 100, render: (v) => <span style={{ fontSize: 13 }}>{v}</span> },
|
||||
|
||||
{
|
||||
title: t('devices.deviceType'),
|
||||
dataIndex: 'type',
|
||||
width: 70,
|
||||
render: (v) => {
|
||||
let c = '#52c41a';
|
||||
let text = ''
|
||||
if (v === 'I') { c = '#fa8c16'; text = t('devices.robot') }
|
||||
if (v === 'M') { c = '#1890ff'; text = t('devices.mower') }
|
||||
if (v === 'U') { c = '#1890ff'; text = t('devices.uav') }
|
||||
return (
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
|
||||
<span style={{ width: 10, height: 10, borderRadius: 2, background: c }} />
|
||||
<span style={{ fontSize: 13 }}>{text}</span>
|
||||
</div>
|
||||
);
|
||||
title: t('devices.executionPlan'),
|
||||
width: 280,
|
||||
render: (_, record) => {
|
||||
const rule = record.deviceTaskPlanRules || {};
|
||||
const { type, startDate, dayTime, days, dayOfMonth } = rule;
|
||||
|
||||
// 周映射
|
||||
const weekMap = {
|
||||
SUNDAY: t('devices.sun'),
|
||||
MONDAY: t('devices.mon'),
|
||||
TUESDAY: t('devices.tue'),
|
||||
WEDNESDAY: t('devices.wed'),
|
||||
THURSDAY: t('devices.thu'),
|
||||
FRIDAY: t('devices.fri'),
|
||||
SATURDAY: t('devices.sat')
|
||||
};
|
||||
|
||||
switch (type) {
|
||||
case 'DAY':
|
||||
return t('devices.planByDay', { startDate: startDate || '', dayTime: dayTime || '' });
|
||||
case 'WEEK':
|
||||
const weekText = (days || []).map(d => weekMap[d]).join('、');
|
||||
return t('devices.planByWeek', { weekText, dayTime: dayTime || '' });
|
||||
case 'MONTH':
|
||||
const monthText = (dayOfMonth || []).map(d => t('devices.daySuffix', { day: d })).join('、');
|
||||
return t('devices.planByMonth', { monthText, dayTime: dayTime || '' });
|
||||
default:
|
||||
return t('devices.unknownPlan');
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: t('roles.status'),
|
||||
dataIndex: 'taskStaus',
|
||||
width: 100,
|
||||
render: (status, record) => {
|
||||
console.log('status', status, record);
|
||||
const statusMap = {
|
||||
'NEW': { color: 'default', text: t('devices.statusNew') },
|
||||
'EXECUTING': { color: 'processing', text: t('workOrder.inProgress') },
|
||||
'PAUSE': { color: 'warning', text: t('devices.statusPaused') },
|
||||
'FINISH': { color: 'success', text: t('devices.statusFinished') },
|
||||
'FAILED': { color: 'error', text: t('devices.statusFailed') },
|
||||
"CANCELING": { color: 'warning', text: t('devices.statusCanceling') },
|
||||
};
|
||||
const item = statusMap[status] || { color: 'default', text: record.taskStausTranslate || t('constants.locationUnknown') };
|
||||
return <Tag color={item.color}>{record.taskStausTranslate}</Tag>;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1022,9 +1156,11 @@ export default function DeviceOverviewPage() {
|
||||
|
||||
<div style={{ display: 'flex', justifyContent: "space-between", flexWrap: 'wrap', gap: 6 }}>
|
||||
<Button type="primary" style={{ borderRadius: 8, flex: 1 }} onClick={handleStart}>{t('devices.s23')}</Button>
|
||||
<Button style={{ borderRadius: 8, flex: 1 }} onClick={handlePause}>{t('video.pause')}</Button>
|
||||
<Button type="primary" style={{ borderRadius: 8, flex: 1 }} onClick={handleReturn}>{t('devices.returnHome')}</Button>
|
||||
<Button style={{ flex: 1, background: '#52c41a', borderColor: '#52c41a', color: "#fff", borderRadius: 8, }} onClick={handleRecharge}>{t('devices.s24')}</Button>
|
||||
{/*<Button style={{ borderRadius: 8, flex: 1 }} onClick={handlePause}>{t('video.pause')}</Button>*/}
|
||||
<Button type="primary" style={{ borderRadius: 8, flex: 1 }} onClick={handleAutoBack}>{t('devices.returnHome')}</Button>
|
||||
{/*<Button style={{ flex: 1, background: '#52c41a', borderColor: '#52c41a', color: "#fff", borderRadius: 8, }} onClick={handleRecharge}>{t('devices.s24')}</Button>*/}
|
||||
<Button danger style={{ flex: 1, borderRadius: 8 }} onClick={handleEmergencyStop}>{t('devices.s29')}</Button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</Col>
|
||||
@@ -1125,8 +1261,7 @@ export default function DeviceOverviewPage() {
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
|
||||
<Button size="large" style={{ flex: 1, borderRadius: 8 }}>{t('devices.switchManual')}</Button>
|
||||
<Button danger size="large" style={{ flex: 1, borderRadius: 8 }} onClick={handleEmergencyStop}>{t('devices.s29')}</Button>
|
||||
{/*<Button size="large" style={{ flex: 1, borderRadius: 8 }}>{t('devices.switchManual')}</Button>*/}
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
@@ -560,7 +560,6 @@ export default function DeviceStatusPage() {
|
||||
};
|
||||
const handleDetectionReport = (res) => {
|
||||
console.log("获取障碍物信息", res)
|
||||
|
||||
setDeportInfo(res);
|
||||
}
|
||||
useEffect(() => {
|
||||
@@ -679,6 +678,7 @@ export default function DeviceStatusPage() {
|
||||
longitude: lng,
|
||||
latitude: lat,
|
||||
name: device?.deviceAlias || device?.callsign || device?.deviceName || t('devices.device'),
|
||||
color: "red",
|
||||
type: isUAV
|
||||
? 'drone'
|
||||
: device?.productName?.includes(t('constants.mower'))
|
||||
@@ -686,17 +686,17 @@ export default function DeviceStatusPage() {
|
||||
: 'robot',
|
||||
};
|
||||
}, [device, isUAV, runningStatus, uavState, currentDroneData]);
|
||||
const handleControlMode = () => {
|
||||
const handleControlMode = (controlMode: number) => {
|
||||
if (!selectedSn) {
|
||||
messageApi.error(t('devices.selectDevice'));
|
||||
return;
|
||||
}
|
||||
console.log(runningStatus, "现在的控制controlmode")
|
||||
if (runningStatus?.control_mode == 3) {
|
||||
//console.log(runningStatus,controlMode, "现在的控制controlmode")
|
||||
if (controlMode == 3 && runningStatus?.control_mode == 3) {
|
||||
return;
|
||||
}
|
||||
const data = {
|
||||
controlMode: 3,
|
||||
controlMode: controlMode,
|
||||
deviceId: selectedSn
|
||||
}
|
||||
modeChage(data).then(res => {
|
||||
@@ -1242,6 +1242,27 @@ export default function DeviceStatusPage() {
|
||||
: '-'
|
||||
}
|
||||
/>
|
||||
<ConsoleRow
|
||||
icon={<DashboardOutlined />}
|
||||
label={t('devices.systemMode')}
|
||||
value={
|
||||
(runningStatus?.system_mode ?? runningStatus?.systemMode) !== undefined
|
||||
? (() => {
|
||||
const mode = runningStatus?.system_mode ?? runningStatus?.systemMode;
|
||||
switch (mode) {
|
||||
case '2':
|
||||
case 2:
|
||||
return t('devices.autoTask');
|
||||
case '3':
|
||||
case 3:
|
||||
return t('devices.remoteControl');
|
||||
default:
|
||||
return "-";
|
||||
}
|
||||
})()
|
||||
: '-'
|
||||
}
|
||||
/>
|
||||
<ConsoleRow icon={<DashboardOutlined />} label={t('devices.forwardSpeed')} value={(runningStatus?.linear_speed ?? runningStatus?.linearSpeed) !== undefined ? Number(runningStatus?.linear_speed ?? runningStatus?.linearSpeed).toFixed(2) + ' m/s' : '-'} />
|
||||
<ConsoleRow icon={<DashboardOutlined />} label={t('devices.turnSpeed')} value={(runningStatus?.angular_speed ?? runningStatus?.angularSpeed) !== undefined ? Number(runningStatus?.angular_speed ?? runningStatus?.angularSpeed).toFixed(2) + ' rad/s' : '-'} />
|
||||
<ConsoleRow icon={<DashboardOutlined />} label={t('devices.rtLeftMotor')} value={(runningStatus?.left_motor_current ?? runningStatus?.leftCurrent) !== undefined ? Number(runningStatus?.left_motor_current ?? runningStatus?.leftCurrent).toFixed(2) + 'A' : '-'} />
|
||||
@@ -1405,10 +1426,10 @@ export default function DeviceStatusPage() {
|
||||
bodyStyle={{ padding: 10, display: 'flex', alignItems: 'center', gap: 10, overflow: 'hidden' }}
|
||||
>
|
||||
<div style={{ width: 300, flexShrink: 0, transform: 'scale(0.82)', transformOrigin: 'left center' }}>
|
||||
<XboxController onGamepadUpdate={handleGamepadUpdate} onConnectionChange={setIsGamepadConnected} />
|
||||
<XboxController onGamepadUpdate={handleGamepadUpdate} onConnectionChange={setIsGamepadConnected} deviceId={selectedSn} />
|
||||
</div>
|
||||
<div style={{ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 6, overflow: 'auto' }}>
|
||||
{[{ k: t('devices.gamepad.leftStick'), v: t('devices.gamepad.leftStickDesc') }, { k: t('devices.gamepad.rightStick'), v: t('devices.gamepad.rightStickDesc') }, { k: t('devices.gamepad.aKey'), v: t('devices.gamepad.aKeyDesc') }, { k: t('devices.gamepad.bKey'), v: t('devices.gamepad.bKeyDesc') }, { k: t('devices.gamepad.xKey'), v: t('devices.gamepad.xKeyDesc') }, { k: t('devices.gamepad.yKey'), v: t('devices.gamepad.yKeyDesc') }, { k: "LB", v: t("devices.gamepad.lbDesc") }, { k: "RB", v: t("devices.gamepad.rbDesc") }].map((item) => (
|
||||
{[{ k: t('devices.gamepad.leftStick'), v: t('devices.gamepad.leftStickDesc') }, { k: t('devices.gamepad.rightStick'), v: t('devices.gamepad.rightStickDesc') }, { k: t('devices.gamepad.aKey'), v: t('devices.gamepad.aKeyDesc') }, { k: t('devices.gamepad.bKey'), v: t('devices.gamepad.bKeyDesc') }, { k: t('devices.gamepad.xKey'), v: t('devices.gamepad.xKeyDesc') }, { k: t('devices.gamepad.yKey'), v: t('devices.gamepad.yKeyDesc') }, { k: "LB", v: t("devices.gamepad.lbDesc") }, { k: "RB", v: t("devices.gamepad.rbDesc") }, { k: "Stop", v: t("devices.gamepad.Stop") }].map((item) => (
|
||||
<div key={item.k} style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 12 }}>
|
||||
<span style={{ minWidth: 52, color: '#8c8c8c', whiteSpace: 'nowrap' }}>{item.k}</span>
|
||||
<span style={{ color: '#262626' }}>{item.v}</span>
|
||||
@@ -1427,7 +1448,7 @@ export default function DeviceStatusPage() {
|
||||
<DPadControl
|
||||
onGamepadUpdate={(state) => { if (blockIfGamepadConnected()) return; handleGamepadUpdate(state); }}
|
||||
onSpeedChange={() => { }}
|
||||
onEmergencyStop={() => sendEmergencyStop(userInfo)}
|
||||
onEmergencyStop={() => sendEmergencyStop(selectedSn)}
|
||||
/>
|
||||
</div>
|
||||
<div style={{ width: '100%', display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
@@ -1454,11 +1475,12 @@ export default function DeviceStatusPage() {
|
||||
>
|
||||
<RobotFeatureButtons
|
||||
showEmergencyStop={false}
|
||||
deviceId={selectedSn}
|
||||
activeFeatures={['response', 'obstacleAvoidance', 'lowBatteryReturn', 'tiltProtection', "findCar"]}
|
||||
onToggle={(feature, enabled) => { console.log('[DeviceStatusPage] Feature toggled: ' + feature + ' = ' + enabled); }}
|
||||
sendFindCar={() => handleFindCar()}
|
||||
sendAutoBack={() => handleAutoBack()}
|
||||
sendControlMode={() => handleControlMode()}
|
||||
sendControlMode={(data) => handleControlMode(data)}
|
||||
controlMode={runningStatus?.controlMode}
|
||||
/>
|
||||
</ConsolePanel>
|
||||
|
||||
@@ -19,7 +19,8 @@ export type RobotFeature =
|
||||
| 'tiltProtection'
|
||||
| 'findCar'
|
||||
| 'autoback'
|
||||
| 'controlMode';
|
||||
| 'controlMode'
|
||||
| 'personFollow';
|
||||
|
||||
export interface FeatureConfig {
|
||||
key: RobotFeature;
|
||||
@@ -37,6 +38,7 @@ const FEATURES: FeatureConfig[] = [
|
||||
//{ key: 'tiltProtection', icon: <MoveVertical className="w-6 h-6" />, activeColor: '#10b981', inactiveColor: '#94a3b8' },
|
||||
{ key: 'autoback', icon: <Zap className="w-6 h-6" />, activeColor: '#22c55e', inactiveColor: '#94a3b8' },
|
||||
{ key: 'findCar', icon: <ShieldAlert className="w-6 h-6" />, activeColor: '#ef4444', inactiveColor: '#94a3b8' },
|
||||
{ key: 'personFollow', icon: <MoveVertical className="w-6 h-6" />, activeColor: '#10b981', inactiveColor: '#94a3b8' },
|
||||
];
|
||||
|
||||
// 急停方块
|
||||
@@ -55,6 +57,7 @@ interface RobotFeatureButtonsProps {
|
||||
sendFindCar?: () => void;
|
||||
sendAutoBack?: () => void;
|
||||
sendControlMode?: () => void;
|
||||
deviceId?: string;
|
||||
controlMode?: number | string;
|
||||
}
|
||||
|
||||
@@ -66,7 +69,8 @@ const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
|
||||
sendFindCar,
|
||||
sendAutoBack,
|
||||
sendControlMode,
|
||||
controlMode
|
||||
controlMode,
|
||||
deviceId
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
@@ -75,10 +79,11 @@ const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
|
||||
const [flashKey, setFlashKey] = useState<RobotFeature | null>(null);
|
||||
|
||||
// 一次性触发,不toggle的按钮列表
|
||||
const oneShotKeys: RobotFeature[] = ['emergencyStop', 'findCar', 'autoback', 'controlMode'];
|
||||
const oneShotKeys: RobotFeature[] = ['emergencyStop', 'findCar', 'autoback', 'controlMode', 'personFollow'];
|
||||
|
||||
const list = showEmergencyStop ? [EMERGENCY, ...FEATURES] : FEATURES;
|
||||
|
||||
|
||||
const handleClick = (feature: RobotFeature) => {
|
||||
// 触发按压反馈
|
||||
setFlashKey(feature);
|
||||
@@ -89,7 +94,7 @@ const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
|
||||
// 一次性按钮:只发指令,不切换active状态
|
||||
if (oneShotKeys.includes(feature)) {
|
||||
if (feature === 'emergencyStop') {
|
||||
sendEmergencyStop(userInfo);
|
||||
sendEmergencyStop(deviceId || "");
|
||||
onToggle?.(feature, true);
|
||||
return;
|
||||
}
|
||||
@@ -100,8 +105,12 @@ const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
|
||||
sendAutoBack?.();
|
||||
}
|
||||
if (feature === 'controlMode') {
|
||||
sendControlMode?.();
|
||||
sendControlMode?.(3);
|
||||
}
|
||||
if (
|
||||
feature === 'personFollow'
|
||||
) sendControlMode?.(4);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ import { getStationRegions } from '@/api/stationManage';
|
||||
import { Reorder } from 'motion/react';
|
||||
import { MapEditorView } from './MapEditorView';
|
||||
import type { ViewStats } from './WayLineView';
|
||||
import { backToRestPointCommand } from '@/api/mapEdit';
|
||||
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const { RangePicker } = DatePicker;
|
||||
@@ -61,7 +63,6 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
|
||||
// 设备数据
|
||||
const [devices, setDevices] = useState([]);
|
||||
const [deleteLoading, setDeleteLoading] = useState(false);
|
||||
|
||||
|
||||
|
||||
@@ -430,10 +431,11 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
if (!rt) return null;
|
||||
return {
|
||||
...rt,
|
||||
longitude: rt.lng,
|
||||
latitude: rt.lat,
|
||||
fix_status: rt.fixStatus,
|
||||
controlMode: rt.controlMode ?? targetRobot?.lastRunningStatus?.controlMode,
|
||||
longitude: rt?.lng,
|
||||
latitude: rt?.lat,
|
||||
fix_status: rt?.fixStatus,
|
||||
controlMode: rt?.controlMode ?? targetRobot?.lastRunningStatus?.controlMode,
|
||||
sm: rt?.sm,
|
||||
};
|
||||
}, [realtimeMap, targetRobot]);
|
||||
|
||||
@@ -1361,6 +1363,23 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
return (routeList || []).filter(rt => ids.has(rt.id));
|
||||
}, [regionList, dispatchRegionIds, routeList]);
|
||||
|
||||
const handleAutoBack = () => {
|
||||
const payload = {
|
||||
deviceId: selectedMachineSn,
|
||||
orgId: currentStation?.orgId,
|
||||
siteId: stationId,
|
||||
}
|
||||
backToRestPointCommand(payload).then(res => {
|
||||
if (res.code == 200) {
|
||||
messageApi.success(t('devices.fixed2ReturnHomeFixed2CommandIssuedFixed2'));
|
||||
} else {
|
||||
messageApi.error(res.msg || t('devices.fixed2ReturnHomeFixed2CommandIssuedFixed2Failed2'));
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error('返回休息点失败', err);
|
||||
})
|
||||
}
|
||||
|
||||
// 选中的路径对象列表(用于拖拽排序显示)
|
||||
const selectedRouteObjects = useMemo(() => {
|
||||
// 根据 dispatchRouteIds 的顺序返回路径对象
|
||||
@@ -1801,6 +1820,39 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
})()}
|
||||
</span>
|
||||
|
||||
<span>
|
||||
{t('devices.systemMode')}
|
||||
{(() => {
|
||||
const mode = robotRealtimePosition?.sm || robotRealtimePosition?.sm;
|
||||
|
||||
const modeConfig: Record<string, { label: string; color: string }> = {
|
||||
|
||||
'2': {
|
||||
label: t('devices.autoTask'),
|
||||
color: '#9eff9e',
|
||||
},
|
||||
'3': {
|
||||
label: t('devices.remoteControl'),
|
||||
color: '#9eff9e',
|
||||
},
|
||||
};
|
||||
|
||||
const config =
|
||||
mode !== undefined && mode !== null
|
||||
? modeConfig[String(mode)]
|
||||
: undefined;
|
||||
|
||||
return config ? (
|
||||
<span style={{ color: config.color }}>{config.label}</span>
|
||||
) : (
|
||||
<span style={{ color: '#999999' }}>
|
||||
-
|
||||
</span>
|
||||
);
|
||||
})()}
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1855,6 +1907,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
}}
|
||||
onMouseEnter={e => e.currentTarget.style.background = 'rgba(255,255,255,0.3)'}
|
||||
onMouseLeave={e => e.currentTarget.style.background = 'rgba(255,255,255,0.18)'}
|
||||
onClick={handleAutoBack}
|
||||
>
|
||||
<EnvironmentOutlined />
|
||||
{t('devices.features.autoback')}
|
||||
@@ -2810,7 +2863,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
</div>
|
||||
<Button onClick={handleDispatchCancel}>{t('common.cancel')}</Button>
|
||||
|
||||
<Button type="primary" style={{ flex: 1 }} loading={dispatchLoading} onClick={handleDispatchTask}>
|
||||
<Button type="primary" style={{ flex: 1 }} loading={dispatchLoading} onClick={handleDispatchTask} disabled={dispatchLoading}>
|
||||
{dispatchMode === 'immediate' ? t('devices.taskExecuteNow') : t('devices.taskSaveSchedule')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -352,8 +352,11 @@
|
||||
robotRouteMonitor: 'Robot Path Planning & Monitoring',
|
||||
clearRealtimeTrack: 'Clear Track',
|
||||
clearPlanRoute: 'Clear Planned Route',
|
||||
controlMode: 'Control Mode:',
|
||||
controlMode: 'RemoteControlStatus',
|
||||
personFollow: 'Person Follow',
|
||||
localMode: 'Local',
|
||||
systemMode: 'System Mode',
|
||||
|
||||
remoteMode: 'Remote',
|
||||
heading: 'Heading:',
|
||||
initialized: 'Initialized',
|
||||
@@ -679,6 +682,8 @@
|
||||
lbDesc: 'Ignition',
|
||||
rbKey: 'RB',
|
||||
rbDesc: 'Shut Down',
|
||||
Stop: "Emergency Stop",
|
||||
|
||||
},
|
||||
steer: {
|
||||
ignition: 'Ignition',
|
||||
@@ -703,6 +708,7 @@
|
||||
findCar: 'Find Car',
|
||||
autoback: 'Auto Back',
|
||||
controlMode: 'Control Mode Switch',
|
||||
personFollow: 'Person Follow',
|
||||
},
|
||||
dpad: {
|
||||
title: 'Direction Control',
|
||||
@@ -1560,7 +1566,8 @@
|
||||
|
||||
fixed2TaskSuspended22: 'Fixed2 Task Suspended2 已启动',
|
||||
|
||||
fixed2ReturnHomeFixed2CommandIssuedFixed2: 'Fixed2 Return Home Fixed2 Command Issued Fixed2',
|
||||
fixed2ReturnHomeFixed2CommandIssuedFixed2: 'Return Home Command Issued ',
|
||||
fixed2ReturnHomeFixed2CommandIssuedFixed2Failed: 'Return Home Command Issued Failed ',
|
||||
|
||||
commandIssuedFixed2: '回充 Command Issued Fixed2',
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ const zh = {
|
||||
thu: '周四',
|
||||
fri: '周五',
|
||||
sat: '周六',
|
||||
planByDay: '按天 | 开始日期{{startDate}} {{dayTime}}',
|
||||
planByDay: '按天 | 开始时间{{startDate}} {{dayTime}}',
|
||||
planByWeek: '按周 | {{weekText}} {{dayTime}}',
|
||||
planByMonth: '按月 | {{monthText}} {{dayTime}}',
|
||||
daySuffix: '{{day}}日',
|
||||
@@ -375,7 +375,7 @@ const zh = {
|
||||
robotRouteMonitor: '机器人路径规划与监控',
|
||||
clearRealtimeTrack: '清空实时轨迹',
|
||||
clearPlanRoute: '清空规划区域',
|
||||
controlMode: '控制模式:',
|
||||
controlMode: '遥控器状态:',
|
||||
localMode: '本地',
|
||||
remoteMode: '远程',
|
||||
heading: '航向:',
|
||||
@@ -714,6 +714,7 @@ const zh = {
|
||||
lbDesc: '点火',
|
||||
rbKey: 'RB 键',
|
||||
rbDesc: '熄火',
|
||||
Stop: "急停",
|
||||
},
|
||||
steer: {
|
||||
ignition: '点火',
|
||||
@@ -738,6 +739,7 @@ const zh = {
|
||||
findCar: '寻车',
|
||||
autoback: '返航',
|
||||
controlMode: '控制模式切换',
|
||||
personFollow: '智能跟随',
|
||||
|
||||
|
||||
},
|
||||
@@ -988,6 +990,7 @@ const zh = {
|
||||
rtLeftTemp: '左电机温度',
|
||||
rtMainTemp: '芯片温度',
|
||||
rtMode: '控制模式',
|
||||
systemMode: '系统模式',
|
||||
rtPitchAngle: '俯仰角度',
|
||||
rtRollAngle: '翻滚角度',
|
||||
rtPositioning: '定位',
|
||||
@@ -1400,6 +1403,9 @@ const zh = {
|
||||
fixed2TaskSuspended22: '任务已启动',
|
||||
|
||||
fixed2ReturnHomeFixed2CommandIssuedFixed2: '返航指令已下发',
|
||||
fixed2ReturnHomeFixed2CommandIssuedFixed2Failed2: '返航指令下发失败',
|
||||
|
||||
|
||||
|
||||
commandIssuedFixed2: '回充指令已下发',
|
||||
|
||||
|
||||
@@ -1485,6 +1485,7 @@ const RealTimeMonitorPage = () => {
|
||||
console.log('[RTMonitor Feature]', feature, enabled);
|
||||
}}
|
||||
controlMode={pickRealtimeRecord(realtimeMap, selectedDevice)?.controlMode}
|
||||
deviceId={selectedDevice?.serialNumber}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
|
||||
@@ -105,6 +105,8 @@ const TaskMonitorPage: React.FC = () => {
|
||||
const [polyPoints, setPolyPoints] = useState<any[]>([]);
|
||||
const [routeMode, setRouteMode] = useState('');
|
||||
const [points, setPoints] = useState<any[]>([]);
|
||||
const [detectReportInfo, setDeportInfo] = useState<any>(null);
|
||||
|
||||
|
||||
|
||||
const controllerRef = useRef<DeviceController | null>(null);
|
||||
@@ -119,6 +121,9 @@ const TaskMonitorPage: React.FC = () => {
|
||||
}
|
||||
return null;
|
||||
};
|
||||
const handleDetectionReport = (res) => {
|
||||
setDeportInfo(res);
|
||||
}
|
||||
|
||||
// 电量优先取实时数据,实时没有时回退到设备结构里的 lastRunningStatus / locationMessage
|
||||
const getDeviceBattery = (device: any): number | undefined => {
|
||||
@@ -152,6 +157,8 @@ const TaskMonitorPage: React.FC = () => {
|
||||
controller.onIsExecuting = refreshData;
|
||||
controller.deviceStatusChangedMsg = refreshData;
|
||||
controller.initMapPush((rtMap: any) => setRealtimeMap(rtMap || {}));
|
||||
controller.onDetectionReport = handleDetectionReport;
|
||||
|
||||
controllerRef.current = controller;
|
||||
return () => {
|
||||
controller.closeMapPush();
|
||||
@@ -669,10 +676,11 @@ const TaskMonitorPage: React.FC = () => {
|
||||
polyPoints={polyPoints}
|
||||
routeMode={routeMode}
|
||||
points={points}
|
||||
detectReportInfo={detectReportInfo}
|
||||
/>
|
||||
|
||||
{/* 地图叠加操作:清空实时轨迹 / 清空规划区域 */}
|
||||
<div style={{ position: 'absolute', top: 12, right: 12, display: 'flex', gap: 8, zIndex: 10 }}>
|
||||
<div style={{ position: 'absolute', top: 12, right: 112, display: 'flex', gap: 8, zIndex: 10 }}>
|
||||
{/*<Button size="small" icon={<ClearOutlined />} onClick={clearRealtimeTrack} >清空实时轨迹</Button>*/}
|
||||
<Button size="small" icon={<ClearOutlined />} onClick={clearTaskRoute} >清空规划区域</Button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user