急停 发送的模式切换 接收障碍物信息 纵览界面 返航和任务表格数据 优化 状态界面加入人员跟随和 系统模式 还未对接系统模式 任务监控界面加入障碍物
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user