任务监控界面 完善 点击任务池 显示轨迹 路径功能,清空规划功能
This commit is contained in:
@@ -124,6 +124,9 @@ export default function MapEditorPage() {
|
||||
if (activeType === 'obstaclePoint') return obstaclePoints;
|
||||
return [];
|
||||
}, [activeType, returnPoints, restAreas, routePoints, obstaclePoints]);
|
||||
useEffect(() => {
|
||||
getSiteMapInfoFn()
|
||||
}, [activeType])
|
||||
|
||||
// 传给Cesium地图渲染的点位
|
||||
const drawingPoints = useMemo(() => {
|
||||
@@ -559,218 +562,7 @@ export default function MapEditorPage() {
|
||||
},
|
||||
});
|
||||
};
|
||||
// ========== 修改已配置返航点名称 ==========
|
||||
const handleUpdateReturnPointAlias = async (
|
||||
index: number,
|
||||
alias: string
|
||||
) => {
|
||||
console.log('[MapEditor] 修改返航点名称:', index, alias);
|
||||
const updated = returnPointConfigList.map((p: any, i: number) =>
|
||||
i === index ? { ...p, alias } : p
|
||||
);
|
||||
|
||||
// 同时更新已配置列表和编辑列表,保证二者一致
|
||||
setReturnPointConfigList(updated);
|
||||
setReturnPoints(prev => prev.map((p, i) => i === index ? { ...p, name: alias } : p));
|
||||
|
||||
const payload: any = {
|
||||
restPoints: updated.map((p: any) => ({
|
||||
alias: p.alias || '',
|
||||
position: p.position,
|
||||
bindDeviceId: p.bindDeviceId || null,
|
||||
})),
|
||||
siteId: stationId,
|
||||
orgId: currentStation?.orgId,
|
||||
};
|
||||
|
||||
if (siteMapInfoId != null) {
|
||||
payload.id = siteMapInfoId;
|
||||
}
|
||||
|
||||
try {
|
||||
const res: any = await saveSiteMapInfo(payload);
|
||||
|
||||
if (res?.code === 200) {
|
||||
messageApi.success('返航点名称修改成功');
|
||||
setOverlayRefreshKey(k => k + 1);
|
||||
getSiteMapInfoFn();
|
||||
} else {
|
||||
messageApi.error(res?.msg || '返航点名称修改失败');
|
||||
getSiteMapInfoFn();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('更新返航点名称失败:', error);
|
||||
messageApi.error('返航点名称修改失败');
|
||||
getSiteMapInfoFn();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// ========== 修改已配置障碍物点名称 ==========
|
||||
const handleUpdateObstacleAlias = async (
|
||||
item: any,
|
||||
alias: string
|
||||
) => {
|
||||
const updated = obstaclePointConfigList.map((point: any) =>
|
||||
String(point.id) === String(item.id)
|
||||
? { ...point, alias: alias, name: alias }
|
||||
: point
|
||||
);
|
||||
|
||||
setObstaclePointConfigList(updated);
|
||||
setObstaclePoints(updated); // 同时更新编辑中的列表,触发地图重绘
|
||||
|
||||
const payload: any = {
|
||||
tempObstaclePoints: updated.map((point: any) => ({
|
||||
position: {
|
||||
lat: Number(point.lat ?? point.position?.lat ?? 0),
|
||||
lng: Number(
|
||||
point.lon ??
|
||||
point.position?.lng ??
|
||||
point.position?.lon ??
|
||||
0
|
||||
),
|
||||
},
|
||||
radius: Number(point.radius) || 0,
|
||||
size_x: Number(point.size_x) || 0,
|
||||
size_y: Number(point.size_y) || 0,
|
||||
shapeType: point.shapeType || 'rect',
|
||||
alias: point.alias || point.name || '',
|
||||
source: 'platform'
|
||||
})),
|
||||
siteId: stationId,
|
||||
orgId: currentStation?.orgId,
|
||||
};
|
||||
|
||||
if (siteMapInfoId != null) {
|
||||
payload.id = siteMapInfoId;
|
||||
}
|
||||
|
||||
try {
|
||||
const res: any = await saveSiteMapInfo(payload);
|
||||
|
||||
if (res?.code === 200) {
|
||||
messageApi.success('障碍物点名称修改成功');
|
||||
setOverlayRefreshKey(k => k + 1);
|
||||
getSiteMapInfoFn();
|
||||
} else {
|
||||
messageApi.error(res?.msg || '障碍物点名称修改失败');
|
||||
getSiteMapInfoFn();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('更新障碍物点名称失败:', error);
|
||||
messageApi.error('障碍物点名称修改失败');
|
||||
getSiteMapInfoFn();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// ========== 修改已配置分区名称 ==========
|
||||
const handleUpdateRegionName = async (
|
||||
item: any,
|
||||
regionName: string
|
||||
) => {
|
||||
// 更新列表显示
|
||||
setRegionList(prev =>
|
||||
prev.map((region: any) =>
|
||||
String(region.id) === String(item.id)
|
||||
? { ...region, regionName }
|
||||
: region
|
||||
)
|
||||
);
|
||||
|
||||
const payload: any = {
|
||||
...item,
|
||||
id: item.id,
|
||||
regionName,
|
||||
siteId: item.siteId ?? stationId,
|
||||
type: item.type || 'region',
|
||||
scope: item.scope || [],
|
||||
status: item.status ?? 1,
|
||||
defaultRoute: item.defaultRoute ?? null,
|
||||
bindRoutes: item.bindRoutes || [],
|
||||
};
|
||||
|
||||
try {
|
||||
const res: any = await saveRegion(payload);
|
||||
|
||||
if (res?.code === 200) {
|
||||
messageApi.success('分区名称修改成功');
|
||||
setOverlayRefreshKey(k => k + 1);
|
||||
|
||||
const r: any = await getStationRegions({ siteId: stationId });
|
||||
if (r?.code === 200) {
|
||||
const list = r.data || r.rows || [];
|
||||
setRegionList(Array.isArray(list) ? list : []);
|
||||
}
|
||||
} else {
|
||||
messageApi.error(res?.msg || '分区名称修改失败');
|
||||
|
||||
// 保存失败时恢复服务端数据
|
||||
const r: any = await getStationRegions({ siteId: stationId });
|
||||
if (r?.code === 200) {
|
||||
const list = r.data || r.rows || [];
|
||||
setRegionList(Array.isArray(list) ? list : []);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('更新分区名称失败:', error);
|
||||
messageApi.error('分区名称修改失败');
|
||||
}
|
||||
};
|
||||
// ========== 修改已配置返航点的绑定设备 ==========
|
||||
const handleUpdateReturnPointBind = (index: number, bindDeviceId: string | undefined) => {
|
||||
const updated = returnPointConfigList.map((p: any, i: number) =>
|
||||
i === index ? { ...p, bindDeviceId: bindDeviceId || null } : p
|
||||
);
|
||||
setReturnPointConfigList(updated);
|
||||
setReturnPoints(prev => prev.map((p, i) => i === index ? { ...p, deviceId: bindDeviceId || undefined } : p));
|
||||
|
||||
const restPoints = updated.map((p: any) => ({
|
||||
alias: p.alias,
|
||||
position: p.position,
|
||||
bindDeviceId: p.bindDeviceId || null,
|
||||
}));
|
||||
const idArr = restPoints.map(item => item.bindDeviceId);
|
||||
const repeatIds: string[] = [];
|
||||
const seen = new Set();
|
||||
|
||||
for (const id of idArr) {
|
||||
if (seen.has(id)) {
|
||||
repeatIds.push(id);
|
||||
} else {
|
||||
seen.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (repeatIds.length > 0) {
|
||||
// 去重展示重复id
|
||||
const dupSet = [...new Set(repeatIds)];
|
||||
messageApi.warning(t('devices.mapEditor.duplicateBindDevice'));
|
||||
return;
|
||||
}
|
||||
|
||||
const payload: any = {
|
||||
restPoints,
|
||||
siteId: stationId,
|
||||
orgId: currentStation?.orgId,
|
||||
};
|
||||
if (siteMapInfoId != null) payload.id = siteMapInfoId;
|
||||
|
||||
saveSiteMapInfo(payload).then((res: any) => {
|
||||
if (res?.code === 200) {
|
||||
messageApi.success(t('devices.mapEditor.bindUpdateSuccess'));
|
||||
setOverlayRefreshKey(k => k + 1);
|
||||
// 刷新以获取最新 id
|
||||
getSiteMapInfoFn();
|
||||
} else {
|
||||
messageApi.error(res?.msg || t('common.saveFail'));
|
||||
}
|
||||
}).catch((e: any) => {
|
||||
console.error(e);
|
||||
messageApi.error(t('common.saveFail'));
|
||||
});
|
||||
};
|
||||
|
||||
const handleObstacleRadiusChange = async (
|
||||
index: number,
|
||||
@@ -906,54 +698,6 @@ export default function MapEditorPage() {
|
||||
}
|
||||
},
|
||||
});
|
||||
}; // 修改已配置障碍物点的尺寸
|
||||
const handleUpdateObstacleDimensions = async (
|
||||
item: any,
|
||||
dimensions: { radius?: number; size_x?: number; size_y?: number; shapeType?: 'circle' | 'rect' }
|
||||
) => {
|
||||
try {
|
||||
// 保留其他已配置障碍物点的数据,只修改当前项
|
||||
const tempObstaclePoints = obstaclePointConfigList.map(
|
||||
(point: any) => {
|
||||
const isTarget = String(point.id) === String(item.id);
|
||||
return {
|
||||
position: {
|
||||
lat: Number(point.position?.lat ?? point.lat ?? 0),
|
||||
lng: Number(point.position?.lng ?? point.position?.lon ?? point.lon ?? 0),
|
||||
},
|
||||
radius: isTarget ? (dimensions.radius ?? point.radius) : Number(point.radius),
|
||||
size_x: isTarget ? (dimensions.size_x ?? point.size_x) : Number(point.size_x),
|
||||
size_y: isTarget ? (dimensions.size_y ?? point.size_y) : Number(point.size_y),
|
||||
shapeType: isTarget ? (dimensions.shapeType ?? point.shapeType) : (point.shapeType || 'rect'),
|
||||
alias: point.alias ?? point.name ?? '',
|
||||
source: 'platform'
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
const payload: any = {
|
||||
tempObstaclePoints,
|
||||
siteId: stationId,
|
||||
orgId: currentStation?.orgId,
|
||||
};
|
||||
|
||||
if (siteMapInfoId != null) {
|
||||
payload.id = siteMapInfoId;
|
||||
}
|
||||
|
||||
const res: any = await saveSiteMapInfo(payload);
|
||||
|
||||
if (res?.code === 200) {
|
||||
messageApi.success('障碍物点修改成功');
|
||||
getSiteMapInfoFn();
|
||||
setOverlayRefreshKey(k => k + 1);
|
||||
} else {
|
||||
messageApi.error(res?.msg || '障碍物点修改失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[MapEditor] update obstacle dimensions failed:', error);
|
||||
messageApi.error('障碍物点修改失败');
|
||||
}
|
||||
};
|
||||
|
||||
// ========== 删除预设路径 ==========
|
||||
|
||||
@@ -66,7 +66,7 @@ type MapEditorViewProps = {
|
||||
};
|
||||
|
||||
export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
{ selectedRobotSn, embedded = false, extraMapProps, activeType: propsActiveType, onActiveTypeChange, onSave },
|
||||
{ selectedRobotSn, embedded = false, extraMapProps, activeType: propsActiveType, onActiveTypeChange, onSave, },
|
||||
ref
|
||||
) {
|
||||
const { t } = useTranslation();
|
||||
@@ -234,6 +234,8 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
loadDevices();
|
||||
}, [stationId]);
|
||||
|
||||
|
||||
|
||||
const getSiteMapInfoFn = () => {
|
||||
const reqId = ++siteMapRequestIdRef.current;
|
||||
getSiteMapInfo({ siteId: stationId }).then((res: any) => {
|
||||
@@ -296,6 +298,10 @@ export const MapEditorView = React.forwardRef(function MapEditorView(
|
||||
});
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getSiteMapInfoFn()
|
||||
}, [activeType, extraMapProps?.refreshNum])
|
||||
|
||||
|
||||
// 加载已配置的区域列表(分区)和站点地图信息(返航点),以及预设路径
|
||||
useEffect(() => {
|
||||
|
||||
@@ -32,9 +32,9 @@ export interface FeatureConfig {
|
||||
const FEATURES: FeatureConfig[] = [
|
||||
{ key: 'controlMode', icon: <ShieldAlert className="w-6 h-6" />, activeColor: '#0dab2d', inactiveColor: '#94a3b8' },
|
||||
|
||||
{ key: 'obstacleAvoidance', icon: <Siren className="w-6 h-6" />, activeColor: '#3b82f6', inactiveColor: '#94a3b8' },
|
||||
{ key: 'lowBatteryReturn', icon: <BatteryWarning className="w-6 h-6" />, activeColor: '#f59e0b', inactiveColor: '#94a3b8' },
|
||||
{ key: 'tiltProtection', icon: <MoveVertical className="w-6 h-6" />, activeColor: '#10b981', inactiveColor: '#94a3b8' },
|
||||
//{ key: 'obstacleAvoidance', icon: <Siren className="w-6 h-6" />, activeColor: '#3b82f6', inactiveColor: '#94a3b8' },
|
||||
//{ key: 'lowBatteryReturn', icon: <BatteryWarning className="w-6 h-6" />, activeColor: '#f59e0b', inactiveColor: '#94a3b8' },
|
||||
//{ 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' },
|
||||
];
|
||||
|
||||
@@ -75,6 +75,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
const [routeMode, setRouteMode] = useState('');
|
||||
const [clearNavLine, setClearNavLine] = useState(0);
|
||||
const [clearPlanLine, setClearPlanLine] = useState(0);
|
||||
const [num, setNum] = useState(0);// 触发重新渲染 传递给 组件 获取返航列表或者障碍物
|
||||
|
||||
const [routeSearch, setRouteSearch] = useState('');
|
||||
const [routeList, setRouteList] = useState([]);
|
||||
@@ -235,6 +236,8 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
fetchTaskList();
|
||||
fetchTaskHistoryList();
|
||||
fetchTaskPoolList();
|
||||
setNum((prev) => prev + 1); // 触发重新渲染 传递给 组件 获取返航列表或者障碍物
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -732,6 +735,8 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
fetchTaskPoolList();
|
||||
fetchTaskHistoryList();
|
||||
fetchConsecutiveTaskList();
|
||||
setNum((prev) => prev + 1); // 触发重新渲染 传递给 组件 获取返航列表或者障碍物
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1724,7 +1729,8 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
|
||||
focusOverlay,
|
||||
focusLocation,
|
||||
detectReportInfo,
|
||||
execute
|
||||
execute,
|
||||
refreshNum: num
|
||||
}}
|
||||
onSave={() => fetchRouteList()}
|
||||
/>
|
||||
|
||||
@@ -159,10 +159,12 @@ export default class DeviceController {
|
||||
if (msg.status == "FINISH") {
|
||||
console.log('task finish');
|
||||
this.onIsFinished?.(msg);
|
||||
}
|
||||
if (msg.status == "EXECUTING" || msg.status == "PAUSE" || msg.status == "CANCELLED" || msg.status == "FAILED") {
|
||||
} else {
|
||||
this.onIsExecuting?.(true);
|
||||
|
||||
}
|
||||
//if (msg.status == "EXECUTING" || msg.status == "PAUSE" || msg.status == "CANCELLED" || msg.status == "FAILED") {
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
@@ -517,10 +519,10 @@ export default class DeviceController {
|
||||
|
||||
if (msg.status == "FINISH") {
|
||||
console.log('task finish');
|
||||
this.onIsFinished?.(true);
|
||||
}
|
||||
if (msg.status == "EXECUTING" || msg.status == "PAUSE") {
|
||||
this.onIsFinished?.(msg);
|
||||
} else {
|
||||
this.onIsExecuting?.(true);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -18,7 +18,8 @@ import {
|
||||
FullscreenOutlined,
|
||||
RobotOutlined,
|
||||
RocketOutlined,
|
||||
WarningOutlined
|
||||
WarningOutlined,
|
||||
ClearOutlined
|
||||
} from '@ant-design/icons';
|
||||
import { UniversalLineChart, UniversalPieChart } from '../components/recharts';
|
||||
import CesiumMap from '../components/Map';
|
||||
@@ -26,16 +27,30 @@ import { useSelector } from 'react-redux';
|
||||
import { RootState } from '../store';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import dayjs from 'dayjs';
|
||||
import { getRobotTaskList, getSiteDevice, getDeviceTastPool, getSiteDeviceTaskHistory, } from '../api/device';
|
||||
import { getRobotTaskList, getSiteDevice, getDeviceTastPool, getSiteDeviceTaskHistory, getRouteByTask, getSingleRouteList, getTaskPath } from '../api/device';
|
||||
import { getAlarmList, getAlarmStatistics } from '../api/alarmApi';
|
||||
import { alarmTypeMap } from '@/constants.js';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import DeviceController from '../components/devices/DeviceController';
|
||||
import VideoPlayer from '../components/VideoPlayer';
|
||||
import { log } from 'console';
|
||||
import utils from '../lib/utils';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
|
||||
// 任务池状态展示:文案 + 标签色
|
||||
const TASK_STATUS_MAP: Record<string, { text: string; color: string }> = {
|
||||
NEW: { text: '待执行', color: 'gold' },
|
||||
EXECUTING: { text: '执行中', color: 'blue' },
|
||||
PAUSE: { text: '已暂停', color: 'orange' },
|
||||
FINISH: { text: '已完成', color: 'green' },
|
||||
FINISHED: { text: '已完成', color: 'green' },
|
||||
FAILED: { text: '失败', color: 'red' },
|
||||
CANCELLED: { text: '已取消', color: 'default' },
|
||||
};
|
||||
const getTaskStatusStyle = (status?: string) =>
|
||||
TASK_STATUS_MAP[String(status || '').toUpperCase()] || { text: status || '--', color: 'default' };
|
||||
|
||||
// 浅色主题卡片组件
|
||||
const MonitorCard: React.FC<{ title: string; icon: React.ReactNode; children: React.ReactNode; extra?: React.ReactNode; height?: number | string; bodyOverflow?: string }> = ({ title, icon, children, extra, height, bodyOverflow = 'auto' }) => (
|
||||
<Card
|
||||
@@ -85,6 +100,11 @@ const TaskMonitorPage: React.FC = () => {
|
||||
const [focusLocation, setFocusLocation] = useState<any>(null);
|
||||
const [messageApi, contextHolder] = message.useMessage();
|
||||
const [taskPoolList, setTaskPoolList] = useState([]);
|
||||
// 点击任务池条目后在地图上展示的路线
|
||||
const [selectedTaskId, setSelectedTaskId] = useState<any>(null);
|
||||
const [polyPoints, setPolyPoints] = useState<any[]>([]);
|
||||
const [routeMode, setRouteMode] = useState('');
|
||||
const [points, setPoints] = useState<any[]>([]);
|
||||
|
||||
|
||||
const controllerRef = useRef<DeviceController | null>(null);
|
||||
@@ -137,6 +157,39 @@ const TaskMonitorPage: React.FC = () => {
|
||||
controller.closeMapPush();
|
||||
};
|
||||
}, [userInfo, stationId]);
|
||||
const fetchRouteDetail = async (id) => {
|
||||
try {
|
||||
const params = {
|
||||
taskId: id,
|
||||
}
|
||||
|
||||
const res = await getTaskPath(params)
|
||||
//const res = await getSingleRouteList({ id: selectedPathWork.id });
|
||||
|
||||
if (res?.code === 200 && res?.data) {
|
||||
let pathPoints = [];
|
||||
|
||||
try {
|
||||
// 尝试解析 JSON
|
||||
pathPoints = res.data || [];
|
||||
} catch (err) {
|
||||
console.error('解析路线数据失败:', err);
|
||||
}
|
||||
|
||||
if (pathPoints.length === 0) {
|
||||
utils.message.warning(t('devices.route2'));
|
||||
}
|
||||
|
||||
setPoints(pathPoints);
|
||||
|
||||
} else {
|
||||
setPoints([]);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取路线详情失败:', err);
|
||||
setPoints([]);
|
||||
}
|
||||
};
|
||||
|
||||
// 获取基础数据
|
||||
const fetchData = async () => {
|
||||
@@ -168,7 +221,17 @@ const TaskMonitorPage: React.FC = () => {
|
||||
if (alarmStatRes.code === 200) setAlarmStats(alarmStatRes.data || null);
|
||||
if (deviceRes.code === 200) setDevices(deviceRes.rows || []);
|
||||
if (taskHistoreList.code == 200) setTaskHistoryLisy(taskHistoreList.rows || []);
|
||||
if (taskpoollist.code == 200) setTaskPoolList(taskpoollist.rows || []);
|
||||
if (taskpoollist.code == 200) {
|
||||
const poolRows = taskpoollist.rows || [];
|
||||
setTaskPoolList(poolRows);
|
||||
// 任务池中已不存在当前点击的任务(已完成 / 被撤销等)时,清空地图上的规划路线与实时轨迹
|
||||
if (selectedTaskId != null && !poolRows.some((t: any) => String(t?.id ?? t?.taskId) === String(selectedTaskId))) {
|
||||
setSelectedTaskId(null);
|
||||
setPolyPoints([]);
|
||||
setRouteMode('');
|
||||
setPoints([]);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Fetch monitoring data failed', err);
|
||||
} finally {
|
||||
@@ -345,6 +408,61 @@ const TaskMonitorPage: React.FC = () => {
|
||||
})).filter(d => d.value > 0);
|
||||
}, [alarmList]);
|
||||
|
||||
// 清空规划路线 / 区域,并取消任务选中态
|
||||
const clearTaskRoute = () => {
|
||||
setSelectedTaskId(null);
|
||||
setPolyPoints([]);
|
||||
setRouteMode('');
|
||||
setPoints([]);
|
||||
|
||||
};
|
||||
|
||||
// 清空实时轨迹
|
||||
const clearRealtimeTrack = () => {
|
||||
setPoints([]);
|
||||
};
|
||||
|
||||
// 点击任务池条目:与任务界面一致,展示该任务的路线(区域由地图按场站分区自动叠加)
|
||||
const handleTaskPoolClick = async (task: any) => {
|
||||
const taskId = task?.id ?? task?.taskId;
|
||||
if (!taskId) return;
|
||||
// 再次点击已选中的任务则清除路线
|
||||
if (String(selectedTaskId) === String(taskId)) {
|
||||
clearTaskRoute();
|
||||
return;
|
||||
}
|
||||
setSelectedTaskId(taskId);
|
||||
try {
|
||||
let path: any[] = [];
|
||||
let mode = '';
|
||||
const res: any = await getRouteByTask({ taskId });
|
||||
fetchRouteDetail(taskId)
|
||||
if (res?.code === 200 && res?.data) {
|
||||
path = res.data.jsonData?.path || [];
|
||||
mode = res.data.mode || '';
|
||||
}
|
||||
//// 任务接口没有返回路线时,用任务绑定的预设路线兜底
|
||||
//if (!path.length && task?.routeId) {
|
||||
// const routeRes: any = await getSingleRouteList({ id: task.routeId });
|
||||
// if (routeRes?.code === 200 && routeRes?.data) {
|
||||
// path = routeRes.data.jsonData?.path || [];
|
||||
// mode = routeRes.data.mode || '';
|
||||
// }
|
||||
//}
|
||||
const mapPoints = (path || [])
|
||||
.map((pt: any) => ({
|
||||
lng: Number(pt.lng ?? pt.lon ?? pt.longitude ?? pt[0]),
|
||||
lat: Number(pt.lat ?? pt.latitude ?? pt[1]),
|
||||
}))
|
||||
.filter((pt: any) => !isNaN(pt.lng) && !isNaN(pt.lat) && pt.lng !== 0 && pt.lat !== 0);
|
||||
|
||||
setPolyPoints(mapPoints);
|
||||
setRouteMode(mode || '');
|
||||
} catch (err) {
|
||||
console.error('[TaskMonitor] 加载任务路线失败', err);
|
||||
}
|
||||
};
|
||||
|
||||
const columnHeight = 'calc(100vh - 52px)';
|
||||
|
||||
return (
|
||||
@@ -386,20 +504,41 @@ const TaskMonitorPage: React.FC = () => {
|
||||
))}
|
||||
</Row>
|
||||
<div style={{ marginTop: 16 }}>
|
||||
{taskPoolList.slice(0, 2).map((task, idx) => (
|
||||
<div key={idx} style={{ background: '#f8faff', padding: '10px 12px', borderRadius: 8, marginBottom: 8, border: '1px solid #e6f7ff' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', fontSize: 13, marginBottom: 4 }}>
|
||||
<span style={{ fontWeight: 500, color: '#262626' }}>{task.workName}</span>
|
||||
{/*<span style={{ color: '#1890ff', fontWeight: 600 }}>{task.progress}%</span>*/}
|
||||
{taskPoolList.slice(0, 2).map((task, idx) => {
|
||||
const isSelected = String(selectedTaskId) === String(task?.id ?? task?.taskId);
|
||||
return (
|
||||
<div
|
||||
key={idx}
|
||||
onClick={() => handleTaskPoolClick(task)}
|
||||
style={{
|
||||
background: isSelected ? '#e6f4ff' : '#f8faff',
|
||||
border: `1px solid ${isSelected ? '#91caff' : '#e6f7ff'}`,
|
||||
padding: '10px 12px',
|
||||
borderRadius: 8,
|
||||
marginBottom: 8,
|
||||
cursor: 'pointer',
|
||||
transition: 'all 0.2s ease',
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 8, fontSize: 13, marginBottom: 4 }}>
|
||||
<span style={{ fontWeight: 500, color: '#262626', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{task.workName}</span>
|
||||
<Tag color={getTaskStatusStyle(task.taskStaus).color} style={{ margin: 0, fontSize: 10, borderRadius: 4 }}>
|
||||
{task.taskStausTranslate || getTaskStatusStyle(task.taskStaus).text}
|
||||
</Tag>
|
||||
</div>
|
||||
<div style={{ fontSize: 11, color: '#597a96', marginTop: 2, display: 'flex', alignItems: 'center', gap: 4 }}>
|
||||
<RobotOutlined style={{ fontSize: 11 }} />
|
||||
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{task.deviceAlias || task.deviceName || devices.find(d => d.serialNumber === (task.deviceSn || task.deviceId))?.deviceAlias || task.deviceId || '--'}
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ fontSize: 11, color: '#8c8c8c', marginTop: 4, display: 'inline-flex', alignItems: 'center', gap: 4 }}>
|
||||
<Clock size={10} />
|
||||
<span>{dayjs(task.createTime).format('YY-MM-DD HH:mm:ss')} 下发</span>
|
||||
</div>
|
||||
</div>
|
||||
{/*<Progress percent={task.progress} size="small" showInfo={false} strokeColor="#1890ff" />*/}
|
||||
<div style={{ fontSize: 11, color: '#8c8c8c', marginTop: 4, display: 'inline-flex', alignItems: 'center', gap: 4 }}>
|
||||
<Clock size={10} />
|
||||
<span>{dayjs(task.createTime).format('YY-MM-DD HH:mm:ss')} 下发</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
))}
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</MonitorCard>
|
||||
|
||||
@@ -522,8 +661,17 @@ const TaskMonitorPage: React.FC = () => {
|
||||
}}>
|
||||
<CesiumMap ref={mapRef} from="taskMonitor" mapLayer={currentStation?.siteMapName} focusLocation={focusLocation}
|
||||
devices={mapDevices}
|
||||
polyPoints={polyPoints}
|
||||
routeMode={routeMode}
|
||||
points={points}
|
||||
/>
|
||||
|
||||
{/* 地图叠加操作:清空实时轨迹 / 清空规划区域 */}
|
||||
<div style={{ position: 'absolute', top: 12, right: 12, display: 'flex', gap: 8, zIndex: 10 }}>
|
||||
{/*<Button size="small" icon={<ClearOutlined />} onClick={clearRealtimeTrack} >清空实时轨迹</Button>*/}
|
||||
<Button size="small" icon={<ClearOutlined />} onClick={clearTaskRoute} >清空规划区域</Button>
|
||||
</div>
|
||||
|
||||
{/* 选中车辆的信息浮窗;不接管地图内部交互,只叠加展示详情 */}
|
||||
{selectedDevice && (
|
||||
<div className="vehicle-map-popup" role="dialog" aria-label="车辆详情">
|
||||
@@ -549,7 +697,7 @@ const TaskMonitorPage: React.FC = () => {
|
||||
|
||||
|
||||
{/* 地图上的图例 */}
|
||||
<div style={{ position: 'absolute', bottom: 20, left: 20, display: 'flex', gap: 12, zIndex: 10 }}>
|
||||
{/*<div style={{ position: 'absolute', bottom: 20, left: 20, display: 'flex', gap: 12, zIndex: 10 }}>
|
||||
{[
|
||||
{ label: '巡逻车辆', color: '#1890ff' },
|
||||
{ label: '作业车辆', color: '#52c41a' },
|
||||
@@ -560,7 +708,7 @@ const TaskMonitorPage: React.FC = () => {
|
||||
<span style={{ color: '#595959' }}>{item.label}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>*/}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user