模拟障碍物 继续作业 连续作业 初始化
This commit is contained in:
@@ -456,23 +456,7 @@ export default function DeviceStatusPage() {
|
||||
|
||||
|
||||
|
||||
// 开关切换回调
|
||||
|
||||
const handleChange = (checked: boolean) => {
|
||||
|
||||
setIsLoopMode(checked);
|
||||
|
||||
if (checked) {
|
||||
|
||||
console.log('当前作业方式:回字');
|
||||
|
||||
} else {
|
||||
|
||||
console.log('当前作业方式:单点');
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1016,32 +1000,33 @@ export default function DeviceStatusPage() {
|
||||
|
||||
}, [device, wsDeviceInfo, isUAV, locationInfo]);
|
||||
|
||||
// 统一在线状态判断:优先实时数据,兜底接口数据
|
||||
const isDeviceOnline = useMemo(() => {
|
||||
// 1. 优先检查实时数据源(WebSocket 推送的 wsDeviceInfo / locationInfo)
|
||||
const hasWsData = wsDeviceInfo && Object.keys(wsDeviceInfo).length > 0;
|
||||
const hasLocData = locationInfo && Object.keys(locationInfo).length > 0;
|
||||
|
||||
if (hasWsData || hasLocData) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 2. 检查 runningStatus 里是否有有效经纬度或实时状态字段
|
||||
const runningLon = runningStatus?.longitude;
|
||||
const runningLat = runningStatus?.latitude;
|
||||
const hasValidCoords = runningLon !== undefined && runningLon !== null && runningLon !== 0
|
||||
&& runningLat !== undefined && runningLat !== null && runningLat !== 0;
|
||||
|
||||
const hasFeStatus = runningStatus?.feStatus !== 3;
|
||||
const hasStatusField = runningStatus?.status !== 0;
|
||||
|
||||
if (hasValidCoords || hasFeStatus || hasStatusField) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 3. 兜底用接口返回的 onlineStatus
|
||||
return device?.onlineStatus === 1;
|
||||
}, [device, wsDeviceInfo, locationInfo, runningStatus]);
|
||||
// 统一在线状态判断:优先实时数据,兜底接口数据
|
||||
const isDeviceOnline = useMemo(() => {
|
||||
// 1. 优先检查实时数据源(WebSocket 推送的 wsDeviceInfo / locationInfo)
|
||||
const hasWsData = wsDeviceInfo && Object.keys(wsDeviceInfo).length > 0;
|
||||
const hasLocData = locationInfo && Object.keys(locationInfo).length > 0;
|
||||
|
||||
if (hasWsData || hasLocData) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//// 2. 检查 runningStatus 里是否有有效经纬度或实时状态字段
|
||||
//const runningLon = runningStatus?.longitude;
|
||||
//const runningLat = runningStatus?.latitude;
|
||||
//const hasValidCoords = runningLon !== undefined && runningLon !== null && runningLon !== 0
|
||||
// && runningLat !== undefined && runningLat !== null && runningLat !== 0;
|
||||
|
||||
//const hasFeStatus = runningStatus?.feStatus !== 3;
|
||||
//const hasStatusField = runningStatus?.status !== 0;
|
||||
|
||||
//if (hasValidCoords || hasFeStatus || hasStatusField) {
|
||||
// return true;
|
||||
//}
|
||||
|
||||
// 3. 兜底用接口返回的 onlineStatus
|
||||
return device?.onlineStatus == 1;
|
||||
}, [device, wsDeviceInfo, locationInfo,]);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ import { MowerAllView } from './mowerAllView.jsx';
|
||||
import { useWebRTCPlayer } from '../useWebRTCStream.js';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { getStationRegions } from '@/api/stationManage/index.js';
|
||||
import { Reorder } from 'motion/react';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const { RangePicker } = DatePicker;
|
||||
@@ -73,7 +74,7 @@ export default function RobotTaskPage() {
|
||||
const { modal } = App.useApp();
|
||||
const [polyPoints, setPolyPoints] = useState([]);
|
||||
const [detectReportInfo, setDeportInfo] = useState<any>(null);
|
||||
|
||||
const [selectedDeviceMap, setSelectedDeviceMap] = useState<Record<string, string>>({});
|
||||
|
||||
|
||||
|
||||
@@ -896,7 +897,10 @@ export default function RobotTaskPage() {
|
||||
utils.message.error(t('devices.fixed2ResumeTaskFixed2AbnormalFixed2'));
|
||||
}
|
||||
};
|
||||
|
||||
const handleContinueWord = (record: any, selectSn: string) => {
|
||||
console.log('当前行选中设备sn:', selectSn, record);
|
||||
// 你的原有业务逻辑
|
||||
};
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
@@ -1156,7 +1160,7 @@ export default function RobotTaskPage() {
|
||||
{
|
||||
title: t('devices.device'),
|
||||
dataIndex: 'deviceId',
|
||||
width: 320,
|
||||
width: 220,
|
||||
},
|
||||
{
|
||||
title: t('roles.status'),
|
||||
@@ -1189,6 +1193,49 @@ export default function RobotTaskPage() {
|
||||
title: t('common.createTime'),
|
||||
dataIndex: 'createTime',
|
||||
width: 170,
|
||||
}, {
|
||||
title: t('common.operation'),
|
||||
width: 170,
|
||||
|
||||
render: (_text, record) => {
|
||||
// 哪些状态显示【继续作业】:FINISH 完成 / FAILED 失败 / CANCEL 取消
|
||||
const showContinueBtn = ['FAILED', 'CANCELED'].includes(record.taskStaus);
|
||||
|
||||
if (!showContinueBtn) return null;
|
||||
const currentSn = selectedDeviceMap[record.taskId] ?? record.serialNumber;
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
||||
<Select
|
||||
placeholder={t('devices.taskSelectRobot')}
|
||||
value={currentSn}
|
||||
onChange={(val) => {
|
||||
setSelectedDeviceMap(prev => ({
|
||||
...prev,
|
||||
[record.taskId]: val
|
||||
}));
|
||||
}}
|
||||
szie="small"
|
||||
style={{ flex: 1, minWidth: 100 }}
|
||||
options={(devices || []).map(item => ({
|
||||
value: item.serialNumber,
|
||||
label: `${item.deviceAlias || item.deviceName} (${item.serialNumber})`
|
||||
}))}
|
||||
/>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
const chooseSn = selectedDeviceMap[record.taskId] ?? record.serialNumber;
|
||||
handleContinueWord(record, chooseSn);
|
||||
}}
|
||||
>
|
||||
{t('devices.continueWork')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
);
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
@@ -1256,6 +1303,21 @@ export default function RobotTaskPage() {
|
||||
return (routeList || []).filter(rt => ids.has(rt.id));
|
||||
}, [regionList, dispatchRegionIds, routeList]);
|
||||
|
||||
// 选中的路径对象列表(用于拖拽排序显示)
|
||||
const selectedRouteObjects = useMemo(() => {
|
||||
// 根据 dispatchRouteIds 的顺序返回路径对象
|
||||
return dispatchRouteIds
|
||||
.map(id => routeList.find(r => r.id === id))
|
||||
.filter(Boolean);
|
||||
}, [dispatchRouteIds, routeList]);
|
||||
|
||||
// 监听路径顺序变化并打印
|
||||
useEffect(() => {
|
||||
if (dispatchRouteIds.length > 0) {
|
||||
console.log('当前已选路径 ID 顺序:', dispatchRouteIds);
|
||||
}
|
||||
}, [dispatchRouteIds]);
|
||||
|
||||
// 定时任务:周/月选项
|
||||
const weekDays = [
|
||||
{ label: t('devices.wdSun'), value: 'SUNDAY' },
|
||||
@@ -2162,136 +2224,211 @@ export default function RobotTaskPage() {
|
||||
)}
|
||||
</div>
|
||||
{dispatchRegionIds.length > 0 && (
|
||||
<div>
|
||||
<div style={{ fontWeight: 600, marginBottom: 8 }}>{t('devices.taskSelectRoute')}</div>
|
||||
{regionAvailableRoutes.length === 0 ? (
|
||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={t('devices.noRouteInRegion')} />
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
||||
<div>
|
||||
<div style={{ fontWeight: 600, marginBottom: 8 }}>{t('devices.taskSelectRoute')}</div>
|
||||
{regionAvailableRoutes.length === 0 ? (
|
||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={t('devices.noRouteInRegion')} />
|
||||
) : (
|
||||
<div
|
||||
style={{
|
||||
width: '100%',
|
||||
boxSizing: 'border-box',
|
||||
padding: 8,
|
||||
border: '1px solid #e6edf5',
|
||||
borderRadius: 6,
|
||||
background: '#fff',
|
||||
}}
|
||||
>
|
||||
{/* 顶部提示文字 */}
|
||||
<div
|
||||
style={{
|
||||
marginBottom: 8,
|
||||
color: '#8c9bb0',
|
||||
fontSize: 11,
|
||||
lineHeight: '16px',
|
||||
}}
|
||||
>
|
||||
选择需要执行任务的路线(可多选)
|
||||
</div>
|
||||
|
||||
{/* 路线选择卡片 */}
|
||||
<div
|
||||
style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: 'repeat(4, minmax(0, 1fr))',
|
||||
gap: 8,
|
||||
width: '100%',
|
||||
}}
|
||||
>
|
||||
{regionAvailableRoutes.map((route, index) => {
|
||||
const checked = dispatchRouteIds.includes(route.id);
|
||||
|
||||
const regionColors = [
|
||||
'#1677ff',
|
||||
'#13b879',
|
||||
'#fa8c16',
|
||||
'#a33cff',
|
||||
];
|
||||
|
||||
const color = regionColors[index % regionColors.length];
|
||||
|
||||
return (
|
||||
<Tag.CheckableTag
|
||||
key={route.id}
|
||||
checked={checked}
|
||||
onChange={nextChecked => {
|
||||
setDispatchRouteIds(prev =>
|
||||
nextChecked
|
||||
? [...prev, route.id]
|
||||
: prev.filter(id => id !== route.id)
|
||||
);
|
||||
|
||||
if (nextChecked) {
|
||||
flyToRoute(route.id);
|
||||
}
|
||||
}}
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 5,
|
||||
width: '100%',
|
||||
minWidth: 0,
|
||||
height: 40,
|
||||
boxSizing: 'border-box',
|
||||
margin: 0,
|
||||
padding: '0 8px',
|
||||
color: '#344054',
|
||||
background: '#fff',
|
||||
border: '1px solid #dce5f2',
|
||||
borderRadius: 4,
|
||||
fontSize: 12,
|
||||
lineHeight: 'normal',
|
||||
cursor: 'pointer',
|
||||
overflow: 'hidden',
|
||||
}}
|
||||
>
|
||||
{/* 自定义复选框 */}
|
||||
<span
|
||||
style={{
|
||||
display: 'inline-flex',
|
||||
flex: '0 0 12px',
|
||||
width: 12,
|
||||
height: 12,
|
||||
boxSizing: 'border-box',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
border: `1px solid ${checked ? color : '#cbd5e1'}`,
|
||||
borderRadius: 3,
|
||||
background: checked ? color : '#fff',
|
||||
color: '#fff',
|
||||
fontSize: 10,
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
{checked ? '✓' : ''}
|
||||
</span>
|
||||
|
||||
{/* 路线定位图标 */}
|
||||
<EnvironmentFilled
|
||||
style={{
|
||||
flex: '0 0 auto',
|
||||
color,
|
||||
fontSize: 13,
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* 路线名称 */}
|
||||
<span
|
||||
style={{
|
||||
flex: 1,
|
||||
minWidth: 0,
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
color: '#344054',
|
||||
}}
|
||||
>
|
||||
{route.workName || route.name}
|
||||
</span>
|
||||
</Tag.CheckableTag>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 已选路径顺序调节 */}
|
||||
{dispatchRouteIds.length > 1 && (
|
||||
<div
|
||||
style={{
|
||||
width: '100%',
|
||||
boxSizing: 'border-box',
|
||||
padding: 8,
|
||||
border: '1px solid #e6edf5',
|
||||
borderRadius: 6,
|
||||
background: '#fff',
|
||||
padding: '12px',
|
||||
background: '#f8faff',
|
||||
border: '1px dashed #d6e4ff',
|
||||
borderRadius: 8,
|
||||
}}
|
||||
>
|
||||
{/* 顶部提示文字 */}
|
||||
<div
|
||||
style={{
|
||||
marginBottom: 8,
|
||||
color: '#8c9bb0',
|
||||
fontSize: 11,
|
||||
lineHeight: '16px',
|
||||
}}
|
||||
>
|
||||
选择需要执行任务的路线(可多选)
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 12 }}>
|
||||
<TrendingUp size={16} style={{ color: '#1677ff' }} />
|
||||
<span style={{ fontWeight: 600, fontSize: 13, color: '#1d2129' }}>调节执行顺序 (拖拽排序)</span>
|
||||
<Tooltip title="机器人将按照下方列表从上到下的顺序依次执行路径任务">
|
||||
<AlertCircle size={14} style={{ color: '#86909c', cursor: 'help' }} />
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
{/* 路线选择卡片 */}
|
||||
<div
|
||||
style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: 'repeat(4, minmax(0, 1fr))',
|
||||
gap: 8,
|
||||
width: '100%',
|
||||
}}
|
||||
<Reorder.Group
|
||||
axis="y"
|
||||
values={dispatchRouteIds}
|
||||
onReorder={setDispatchRouteIds}
|
||||
style={{ listStyle: 'none', padding: 0, margin: 0, display: 'flex', flexDirection: 'column', gap: 8 }}
|
||||
>
|
||||
{regionAvailableRoutes.map((route, index) => {
|
||||
const checked = dispatchRouteIds.includes(route.id);
|
||||
|
||||
const regionColors = [
|
||||
'#1677ff',
|
||||
'#13b879',
|
||||
'#fa8c16',
|
||||
'#a33cff',
|
||||
];
|
||||
|
||||
const color = regionColors[index % regionColors.length];
|
||||
|
||||
return (
|
||||
<Tag.CheckableTag
|
||||
key={route.id}
|
||||
checked={checked}
|
||||
onChange={nextChecked => {
|
||||
setDispatchRouteIds(prev =>
|
||||
nextChecked
|
||||
? [...prev, route.id]
|
||||
: prev.filter(id => id !== route.id)
|
||||
);
|
||||
|
||||
if (nextChecked) {
|
||||
flyToRoute(route.id);
|
||||
}
|
||||
}}
|
||||
{selectedRouteObjects.map((route, idx) => (
|
||||
<Reorder.Item
|
||||
key={route.id}
|
||||
value={route.id}
|
||||
style={{
|
||||
cursor: 'grab',
|
||||
background: '#fff',
|
||||
border: '1px solid #e6edf5',
|
||||
borderRadius: 6,
|
||||
padding: '8px 12px',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 12,
|
||||
boxShadow: '0 2px 4px rgba(0,0,0,0.02)',
|
||||
}}
|
||||
whileDrag={{
|
||||
scale: 1.02,
|
||||
boxShadow: '0 8px 16px rgba(0,0,0,0.1)',
|
||||
cursor: 'grabbing',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
width: 20,
|
||||
height: 20,
|
||||
background: '#1677ff',
|
||||
color: '#fff',
|
||||
borderRadius: '50%',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 5,
|
||||
width: '100%',
|
||||
minWidth: 0,
|
||||
height: 40,
|
||||
boxSizing: 'border-box',
|
||||
margin: 0,
|
||||
padding: '0 8px',
|
||||
color: '#344054',
|
||||
background: '#fff',
|
||||
border: '1px solid #dce5f2',
|
||||
borderRadius: 4,
|
||||
fontSize: 12,
|
||||
lineHeight: 'normal',
|
||||
cursor: 'pointer',
|
||||
overflow: 'hidden',
|
||||
justifyContent: 'center',
|
||||
fontSize: 11,
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
{/* 自定义复选框 */}
|
||||
<span
|
||||
style={{
|
||||
display: 'inline-flex',
|
||||
flex: '0 0 12px',
|
||||
width: 12,
|
||||
height: 12,
|
||||
boxSizing: 'border-box',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
border: `1px solid ${checked ? color : '#cbd5e1'}`,
|
||||
borderRadius: 3,
|
||||
background: checked ? color : '#fff',
|
||||
color: '#fff',
|
||||
fontSize: 10,
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
{checked ? '✓' : ''}
|
||||
</span>
|
||||
|
||||
{/* 路线定位图标 */}
|
||||
<EnvironmentFilled
|
||||
style={{
|
||||
flex: '0 0 auto',
|
||||
color,
|
||||
fontSize: 13,
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* 路线名称 */}
|
||||
<span
|
||||
style={{
|
||||
flex: 1,
|
||||
minWidth: 0,
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
color: '#344054',
|
||||
}}
|
||||
>
|
||||
{route.workName || route.name}
|
||||
</span>
|
||||
</Tag.CheckableTag>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{idx + 1}
|
||||
</div>
|
||||
<span style={{ flex: 1, fontSize: 13, fontWeight: 500, color: '#344054' }}>
|
||||
{route.workName || route.name}
|
||||
</span>
|
||||
<div style={{ color: '#bfbfbf' }}>
|
||||
<LayoutGrid size={14} />
|
||||
</div>
|
||||
</Reorder.Item>
|
||||
))}
|
||||
</Reorder.Group>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user