任务进度完成 修改 辅助线 高度 总览界面逻辑优化 cotrolmode提醒优化 大唐项目删减

This commit is contained in:
mmc
2026-11-19 09:40:36 +08:00
parent 75ed862801
commit b967138b80
16 changed files with 296 additions and 86 deletions

View File

@@ -75,7 +75,6 @@ export default function App() {
if (systemNameItem?.paramValue) {
dispatch(setSettingField({ systemName: systemNameItem.paramValue }));
}
console.log('[System] global config loaded:', globalArr);
}
})
.catch((err: any) => {

View File

@@ -420,7 +420,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
: Array.isArray(payload?.objects)
? payload.objects
: [];
console.log(objects, "障碍物信息")
//console.log(objects, "障碍物信息")
// 全量替换:先把地图上所有 live-obstacle 实体按 id 前缀全部移除
// 不依赖 liveObstacleEntities Map(避免历史孤儿实体残留)
const toRemove = [];
@@ -433,7 +433,6 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
liveObstacleEntities.clear();
if (objects.length === 0) {
console.log("没有障碍物")
viewer.scene.requestRender();
return;
}
@@ -442,7 +441,6 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
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;
@@ -1481,6 +1479,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
};
// 以下状态行仅在设备携带对应字段时展示,普通标记点的悬浮提示不受影响
const hasWorkStatus = robot.color !== undefined || robot.status !== undefined || robot.feStatus !== undefined;
const progress = robot.progress !== undefined && robot.progress !== null && robot.progress !== '' ? robot.progress : '';
const controlModeText = robot.controlMode !== undefined && robot.controlMode !== null && robot.controlMode !== ''
? (controlModeMap[String(robot.controlMode)] || '-')
: '';
@@ -1519,6 +1518,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
${controlModeText ? `<div>${t('devices.controlMode')}${controlModeText}</div>` : ''}
${systemModeText ? `<div>${t('devices.systemMode')}:${systemModeText}</div>` : ''}
${batteryText ? `<div>${t('devices.rtBattery')}:${batteryText}</div>` : ''}
${progress ? `<div>${t('devices.taskProgress')}:${progress}%</div>` : ''}
<div>${t('systemSetting.longitude')}:${lonStr}</div>
<div>${t('systemSetting.latitude')}:${latStr}</div>
`;

View File

@@ -242,11 +242,11 @@ export default function AlarmCenterPage() {
dataIndex: 'alarmContent',
ellipsis: true
},
{
title: t('alerts.reportValue'),
dataIndex: 'timeValues',
ellipsis: true
},
//{
// title: t('alerts.reportValue'),
// dataIndex: 'timeValues',
// ellipsis: true
//},
{
title: t('devices.deviceName'),
dataIndex: 'deviceName',

View File

@@ -114,43 +114,43 @@ const CarReverseGuideLine: React.FC<GuideLineProps> = ({
const computeTurn = () => {
const v = linearSpeedRef.current;
const w = angularSpeedRef.current;
const hasRealtime =
typeof v === 'number' &&
Number.isFinite(v) &&
typeof w === 'number' &&
Number.isFinite(w);
// 统一用 steer 计算意图转向(-1 ~ +1)
const steerAngle = Math.max(-45, Math.min(45, steerRef.current));
const steerIntent = Math.tan((steerAngle * Math.PI) / 180);
// 没有实时数据 → 完全依赖方向盘意图
if (!hasRealtime) {
return steerIntent;
}
// 静止 / 极低速(机器人没真在动)→ 用方向盘意图
// 此时 curvature = w/v 不稳定(v≈0 会放大),而且用户拨动摇杆就是想让它转
if (Math.abs(v) < 0.05) {
return steerIntent;
}
// 真在跑 → 用实时曲率反映实际运动轨迹
// 低速时限制分母,避免曲率被放大到满量程
const speed = Math.max(Math.abs(v), 0.15);
// 曲率:ω / v,正值左转
const kappa = w / speed;
// 满量程曲率(约对应 1m 转弯半径)
const KAPPA_FULL_SCALE = 1.0;
const normalized = Math.max(
-1,
Math.min(1, kappa / KAPPA_FULL_SCALE)
);
// 左转为正 → 画面左侧为负偏移
return -normalized;
};
@@ -240,8 +240,8 @@ const CarReverseGuideLine: React.FC<GuideLineProps> = ({
// 前进、倒车都保持近端在下方
const y =
height * 0.12 +
progress * height * 0.76;
height * 0.25 +
progress * height * 0.5;
return {
x: centerX + sideOffset,
@@ -316,7 +316,7 @@ const CarReverseGuideLine: React.FC<GuideLineProps> = ({
const size =
height *
(0.075 + progress * 0.035);
(0.045 + progress * 0.020);
// 人字线整体跟随转向弯曲
const offset =
@@ -445,7 +445,7 @@ const CarReverseGuideLine: React.FC<GuideLineProps> = ({
const targetTurn = computeTurn();
turnRef.current +=
(targetTurn - turnRef.current) *
Math.min(1, delta * 8);
Math.min(1, delta * 8);
ctx.clearRect(0, 0, width, height);

View File

@@ -146,15 +146,24 @@ export default function DeviceOverviewPage() {
const res = await getDeviceTastPool(params);
if (res.code === 200) {
const list = res.rows || [];
list.map(item => {
const list = (res.rows || []).map(item => {
return {
time: dayjs(item.createTime).format('HH:mm:ss'),
color: item.taskStaus === 'EXECUTING' ? 'green' : 'blue',
text: item.workName || t('devices.unnamedTask'),
status: item.taskStaus === 'EXECUTING' ? t('devices.executing') : item.taskStaus === 'FAILED' ? t('devices.executeFail') : item.taskStaus === 'COMPLETED' ? t('devices.statusFinished') : item.taskStaus === 'CANCELED' ? t('devices.taskCanceled') : t('devices.taskStatusNew')
}
})
device: item.deviceAlias || item.serialNumber,
status: item.taskStaus === 'EXECUTING'
? t('devices.executing')
: item.taskStaus === 'FAILED'
? t('devices.executeFail')
: item.taskStaus === 'COMPLETED'
? t('devices.statusFinished')
: item.taskStaus === 'CANCELED'
? t('devices.taskCanceled')
: t('devices.taskStatusNew')
};
});
setTaskPoolList(list);
}
} catch (err) {
@@ -357,6 +366,8 @@ export default function DeviceOverviewPage() {
const incoming: any[] = Array.isArray(payload?.alarms) ? payload.alarms : [];
setAlarmList(incoming);
};
controller.onIsExecuting = fetchTaskPoolList;
controllerRef.current = controller;
return () => {
if (controllerRef.current) controllerRef.current.closeMapPush();
@@ -1181,11 +1192,11 @@ export default function DeviceOverviewPage() {
<Tag color={realtimeDevice.status == 1 || realtimeDevice.status == 2 ? "success" : "default"} size="small" className="device-overview-tag-flat">
{realtimeDevice.status == 1 || realtimeDevice.status == 2 ? t('devices.online') : t('devices.offline')}
</Tag>
<Button
{/*<Button
type="primary" size="small" ghost icon={<InfoCircleOutlined />}
className="device-overview-detail-btn"
onClick={() => onViewStatus(selectedDevice.device_sn || selectedDevice.serialNumber)}
>{t('common.detail')}</Button>
>{t('common.detail')}</Button>*/}
</div>
<div className="device-overview-stats-row">
@@ -1472,8 +1483,9 @@ export default function DeviceOverviewPage() {
{taskPoolList.length > 0 ? (
<Timeline mode="left">
{taskPoolList.map((item, idx) => (
<Timeline.Item key={idx} color={item.color} label={<div className="device-overview-timeline-label">{item.time}</div>}>
<div className="device-overview-text-13">{item.text}</div>
<div className="device-overview-text-13">{item.text} | {item.device}</div>
<div className="device-overview-timeline-label">{item.status}</div>
</Timeline.Item>
))}

View File

@@ -397,7 +397,6 @@ export default function DeviceStatusPage() {
// channel 字段:videoChannel / cameraChannel / agoraChannel / rtcChannel / channel
setCameraNum(Number.isFinite(n) && n >= 1 && n <= 4 ? n : 1);
console.log('[DSP] deviceRunParam res.data=', res.data);
} else {
setCameraNum(1);
}
@@ -451,7 +450,11 @@ export default function DeviceStatusPage() {
...locationInfo
};
}, [device, wsDeviceInfo, isUAV, locationInfo]);
const runningStatusRef = useRef(runningStatus);
useEffect(() => {
runningStatusRef.current = runningStatus;
}, [runningStatus]);
// 实时下发的急停状态同步到共享锁存状态:true=已急停,false=未急停
useEffect(() => {
syncEmergencyStop(runningStatus?.emergency_stop);
@@ -555,7 +558,7 @@ export default function DeviceStatusPage() {
mapRef.current?.flyToPosition?.(realtimePosition, { height: 300 });
};
const handleDetectionReport = (res) => {
console.log("获取障碍物信息", res)
//console.log("获取障碍物信息", res)
setDeportInfo(res);
}
useEffect(() => {
@@ -725,6 +728,8 @@ export default function DeviceStatusPage() {
// 避免点击页面其他区域、手柄轮询中性帧、失焦复位等无输入帧误触发提示
const controlWarnRef = useRef(0);
const handleGamepadUpdate = useCallback((state) => {
const currentStatus = runningStatusRef.current;
const hasInput =
//(Array.isArray(state?.buttons) && state.buttons.some((v: any) => v == true || v == 1)) ||
(Array.isArray(state?.axes) && state.axes.some((v: any) => Math.abs(Number(v) || 0) > 0.05));
@@ -738,18 +743,20 @@ export default function DeviceStatusPage() {
messageApi.warning("请获取控制权限");
warned = true;
}
console.log(runningStatus, "realtimePosition1111")
if (!(runningStatus?.control_mode == 3 || runningStatus?.systemMode == 3)) {
if ((currentStatus?.control_mode != 3 || currentStatus?.controlMode != 3) &&
currentStatus?.systemMode != 3) {
messageApi.warning(t('devices.switchControl'));
warned = true;
} else if (
runningStatus?.controlMode != 3 &&
runningStatus?.controlMode != 0 &&
runningStatus?.controlMode != null
) {
messageApi.warning(t('devices.noRemoteControl'));
warned = true;
}
//else if (
// runningStatus?.controlMode != 3 &&
// runningStatus?.controlMode != 0 &&
// runningStatus?.controlMode != null
//) {
// messageApi.warning(t('devices.noRemoteControl'));
// warned = true;
//}
if (warned) controlWarnRef.current = now;
}
}
@@ -777,7 +784,7 @@ export default function DeviceStatusPage() {
}
return true;
}, [isGamepadConnected, isControlled, t, messageApi]);
}, [isGamepadConnected, isControlled,]);
// 方向盘功能按钮:复用与手柄一致的遥控帧(指定位按下后短暂释放)
// 方向盘按键按下/释放帧(长按模式:onDown 每 100ms 调用一次;短按模式:sendSteerButton 一次性发送后 300ms 自动释放)
const sendSteerFrame = useCallback(
@@ -1362,7 +1369,13 @@ export default function DeviceStatusPage() {
<ConsoleRow icon={<DashboardOutlined />} label={t('devices.rtRightTemp')} value={(runningStatus?.right_motor_temperature ?? runningStatus?.rightMotorTemp) !== undefined ? formatTemperature(Number(runningStatus?.right_motor_temperature ?? runningStatus?.rightMotorTemp), 1).label : '-'} />
<ConsoleRow icon={<DashboardOutlined />} label={t('devices.rtMainTemp')} value={(runningStatus?.main_temperature ?? runningStatus?.chipTemp) !== undefined ? formatTemperature(Number(runningStatus?.main_temperature ?? runningStatus?.chipTemp), 1).label : '-'} />
{/*<ConsoleRow icon={<EnvironmentOutlined />} label={t('devices.motionStatus')} value={runningStatus?.motion === 'moving' ? t('devices.motionMoving') : runningStatus?.motion === 'stopped' ? t('devices.motionStopped') : runningStatus?.motion === 'blocked' ? t('devices.motionBlocked') : '-'} />*/}
<ConsoleRow icon={<EnvironmentOutlined />} label={t('devices.cutterSpedd')} value={runningStatus?.cutter_speed ?? "-"} />
<ConsoleRow
icon={<EnvironmentOutlined />}
label={t('devices.cutterSpedd')}
value={runningStatus?.cutter_speed != null
? `${runningStatus.cutter_speed} rpm`
: "-"}
/>
<ConsoleRow icon={<SafetyOutlined />} label={t('devices.rtEmergency')} value={runningStatus?.emergency_stop == "true" ? t('devices.estopTriggered') : runningStatus?.emergency_stop == "false" ? t('devices.estopNormal') : '-'} />
{/*<ConsoleRow icon={<DashboardOutlined />} label={t('devices.rtLeftMeasureRpm')} value={(runningStatus?.left_measured_rpm ?? runningStatus?.leftMeasureSpeed) !== undefined ? Number(runningStatus?.left_measured_rpm ?? runningStatus?.leftMeasureSpeed).toFixed(1) + 'rpm' : '-'} />*/}
{/*<ConsoleRow icon={<DashboardOutlined />} label={t('devices.rtRightMeasureRpm')} value={(runningStatus?.right_measured_rpm ?? runningStatus?.rightMeasureSpeed) !== undefined ? Number(runningStatus?.right_measured_rpm ?? runningStatus?.rightMeasureSpeed).toFixed(1) + 'rpm' : '-'} />*/}
@@ -1549,10 +1562,10 @@ export default function DeviceStatusPage() {
/>
</div>
<div style={{ width: '100%', display: 'flex', flexDirection: 'column', gap: 8 }}>
<div style={{ display: 'flex', gap: 8 }}>
{/*<div style={{ display: 'flex', gap: 8 }}>
<SteerButton icon={<PlayCircleOutlined />} label={t('devices.steer.ignition')} color="#22c55e" active={steerState.power === 'ignition'} onToggle={() => toggleSteerGroup('power', 'ignition')} />
<SteerButton icon={<PoweroffOutlined />} label={t('devices.steer.shutdown')} color="#ef4444" active={steerState.power === 'shutdown'} onToggle={() => toggleSteerGroup('power', 'shutdown')} />
</div>
</div>*/}
<div style={{ display: 'flex', gap: 8 }}>
<SteerButton icon={<ArrowUpOutlined />} label={t('devices.steer.chassisUp')} color="#3b82f6" active={steerState.chassis === 'up'} onToggle={() => toggleSteerGroup('chassis', 'up')} />
<SteerButton icon={<ArrowDownOutlined />} label={t('devices.steer.chassisDown')} color="#3b82f6" active={steerState.chassis === 'down'} onToggle={() => toggleSteerGroup('chassis', 'down')} />

View File

@@ -38,7 +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' },
//{ key: 'personFollow', icon: <MoveVertical className="w-6 h-6" />, activeColor: '#10b981', inactiveColor: '#94a3b8' },
];
// 急停方块

View File

@@ -192,14 +192,31 @@ export default function RobotTaskPage() {
const working = (robotStats.working || 0) + (droneStats.working || 0);
const finishCount = (robotStats.finishCount || 0) + (droneStats.finishCount || 0);
const finishCount = (robotStats.todayFinishCount || 0) + (droneStats.finishCount || 0);
const totalCount = (robotStats.totalCount || 0) + (droneStats.totalCount || 0);
const totalCount = (robotStats.todayTotalCount || 0) + (droneStats.totalCount || 0);
const completionRate = totalCount ? Math.round((finishCount / totalCount) * 100) : 0;
const yesterdayFinishCount = (robotStats.yesterdayFinishCount || 0);
const yesterdayTotalCount = (robotStats.yesterdayTotalCount || 0);
const yesterdayCompletionRate = yesterdayTotalCount ? Math.round((yesterdayFinishCount / yesterdayTotalCount) * 100) : 0;
const completionRateDiff = completionRate - yesterdayCompletionRate;
const completionRateTrendText = `${completionRateDiff > 0 ? '+' : ''}${completionRateDiff}%`;
const completionRateTrendColor = completionRateDiff >= 0 ? '#00B42A' : '#F53F3F';
const onlineRate = robotOnline.total ? Math.round((robotOnline.online / robotOnline.total) * 100) : 0;
const totalWorkArea = robotStats?.workArea ?? "0";
const todayAlarmCount = robotStats.todayAlarmCount || 0;
const yesterdayAlarmCount = robotStats.yesterdayAlarmCount || 0;
const alarmDiff = todayAlarmCount - yesterdayAlarmCount;
const alarmTrendColor = alarmDiff > 0
? '#F53F3F'
: alarmDiff < 0
? '#00B42A'
: '#86909C';
const alarmTrendText = `${alarmDiff > 0 ? '+' : ''}${alarmDiff}`; const totalWorkArea = robotStats?.workArea ?? "0";
return [
@@ -209,10 +226,17 @@ export default function RobotTaskPage() {
//{ title: t('devices.totalWorkArea'), value: totalWorkArea, unit: '㎡', trend: "", trendColor: '#00B42A', icon: <TrendingUp size={22} />, color: '#722ED1' },
{ title: t('devices.statCompletionRate'), value: completionRate, unit: '%', trend: t('devices.vsYesterday', { value: '+5%' }), trendColor: '#00B42A', icon: <CheckCircle2 size={22} />, color: '#00B42A' },
{ title: t('devices.statAlerts'), value: '0', unit: t('devices.unitTimes'), trend: t('devices.vsYesterday', { value: '-1' }), trendColor: '#00B42A', icon: <AlertCircle size={22} />, color: '#F53F3F' },
{ title: t('devices.statCompletionRate'), value: completionRate, unit: '%', trend: t('devices.vsYesterday', { value: completionRateTrendText }), trendColor: completionRateTrendColor, icon: <CheckCircle2 size={22} />, color: '#00B42A' },
{
title: t('devices.statAlerts'),
value: todayAlarmCount,
unit: t('devices.unitTimes'),
trend: t('devices.vsYesterday', { value: alarmTrendText }),
trendColor: alarmTrendColor,
icon: <AlertCircle size={22} />,
color: '#F53F3F'
},
{ title: t('devices.statOnlineRate'), value: `${onlineRate}`, unit: '%', desc: t('devices.good'), icon: <Satellite size={22} />, color: '#165DFF' },
] as { title: string; value: any; unit: string; desc?: string; trend?: string; trendColor?: string; icon: React.ReactElement; color: string }[];

View File

@@ -21,6 +21,7 @@ import { backToRestPointCommand } from '@/api/mapEdit';
import { sendEmergencyStop, subscribeEmergencyStop, syncEmergencyStop } from './emergencyStopControl';
import AgrtcRoomRobot from '../AgrtcRoomRobot.js';
import { deviceRunParamSelectByDeviceId } from '@/api/stationManage/index.js';
import { getAlarmList } from '@/api/alarmApi.js';
const { Text, Title } = Typography;
@@ -95,6 +96,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
const [executeModalVisible, setExecuteModalVisible] = useState(false);
const [selectedRouteForExecute, setSelectedRouteForExecute] = useState(null);
const [selectedRobotForExecute, setSelectedRobotForExecute] = useState(null);
const [alarmList, setAlarmList] = useState([])
const [runningPoolTask, setRunningPoolTask] = useState(null);//正在执行的任务
@@ -108,6 +110,8 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
// 任务池和历史任务数据
const [taskPoolList, setTaskPoolList] = useState([]);
const [taskHistoryList, setTaskHistoryList] = useState([]);
// 顶部今日/昨日统计专用数据:不受历史任务列表筛选条件影响
const [statsTaskHistoryList, setStatsTaskHistoryList] = useState([]);
// 当前激活的Tab
const [activeTab, setActiveTab] = useState('pool'); // 'task' for 任务列表, 'pool' for 任务池, 'history' for 历史任务
@@ -234,6 +238,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
setSelectedRouteForExecute(null);
fetchTaskList();
fetchTaskHistoryList();
fetchStatsTaskHistoryList();
fetchTaskPoolList();
setNum((prev) => prev + 1); // 触发重新渲染 传递给 组件 获取返航列表或者障碍物
@@ -329,6 +334,18 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
controller.deviceStatusChangedMsg = () => {
fetchAllData();
}
controller.onDeviceErrorPush = (payload: any) => {
const incoming: any[] = Array.isArray(payload?.alarms) ? payload.alarms : [];
setAlarmList((prev) => {
if (!incoming?.length) return prev;
const ids = new Set(incoming.map((a) => a?.id ?? a?.alarmNo));
// 新告警补 createTime(WS 推送可能没有该字段)
const now = new Date().toISOString();
const merged = incoming.map((a) => (a?.createTime ? a : { ...a, createTime: a?.alarmTime || now }));
return [...merged, ...prev.filter((a) => !ids.has(a?.id ?? a?.alarmNo))];
});
};
controller.onDetectionReport = handleDetectionReport;
@@ -434,7 +451,6 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
if (isSameDevice) return;
// 切换设备
console.log('🔄 检测到正在执行任务的新设备,开始连接', targetDevice);
//if (isFirstConnect.current) { isFirstConnect.current = false; controllerRef.current?.connectDevice(targetDevice); } else { controllerRef.current?.switchDevice(targetDevice); }
//setShowVideo(true);
@@ -474,7 +490,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
fix_status: rt?.fixStatus,
controlMode: rt?.controlMode ?? rt?.control_mode ?? targetRobot?.lastRunningStatus?.controlMode,
sm: rt?.sm,
e: rt?.emergencyStop,
progress: rt?.progress,
};
}, [realtimeMap, targetRobot]);
@@ -755,6 +771,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
fetchTaskList();
fetchTaskPoolList();
fetchTaskHistoryList();
fetchStatsTaskHistoryList();
});
}
@@ -776,11 +793,15 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
const handleRreshTask = (data) => {
fetchTaskList();
fetchTaskPoolList();
fetchTaskHistoryList();
fetchConsecutiveTaskList();
setNum((prev) => prev + 1); // 触发重新渲染 传递给 组件 获取返航列表或者障碍物
setTimeout(() => {
fetchTaskList();
fetchTaskPoolList();
fetchTaskHistoryList();
fetchStatsTaskHistoryList();
fetchConsecutiveTaskList();
setNum((prev) => prev + 1); // 触发重新渲染 传递给 组件 获取返航列表或者障碍物
}, 800)
}
@@ -823,6 +844,19 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
}
};
// 获取顶部统计专用历史数据(不应用历史列表筛选条件)
const fetchStatsTaskHistoryList = async () => {
console.log('fetchStatsTaskHistoryList')
if (!stationId) return;
try {
const params = { siteId: stationId, orgId: currentStation?.orgId, pageNum: 1, pageSize: 99999999 };
const res = await getSiteDeviceTaskHistory(params);
if (res.code == 200) setStatsTaskHistoryList(res.rows || []);
} catch (err) {
console.error('获取统计任务数据失败:', err);
}
};
// 获取历史任务数据
const fetchTaskHistoryList = async () => {
if (!stationId) return;
@@ -868,6 +902,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
utils.message.success(t('devices.fixed2TaskSuspended2Fixed2CancelledFixed2'));
fetchTaskPoolList();
fetchTaskHistoryList();
fetchStatsTaskHistoryList();
fetchConsecutiveTaskList();
setExecute(false);
//if (controllerRef.current) {
@@ -901,6 +936,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
utils.message.success(t('devices.taskPaused'));
fetchTaskPoolList();
fetchTaskHistoryList();
fetchStatsTaskHistoryList();
} else {
utils.message.error(res.msg || t('devices.pauseFailed'));
}
@@ -923,6 +959,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
utils.message.success(t('devices.taskResumed'));
fetchTaskPoolList();
fetchTaskHistoryList();
fetchStatsTaskHistoryList();
} else {
utils.message.error(res.msg || t('devices.resumeFailed'));
}
@@ -961,13 +998,16 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
}
}, [poolFilterForm, stationId]);
// 监听历史任务筛选条件变化
// 监听历史任务筛选条件变化(仅刷新列表,不刷新顶部统计)
useEffect(() => {
if (stationId) {
fetchTaskHistoryList();
}
if (stationId) fetchTaskHistoryList();
}, [historyFilterForm, stationId]);
// 顶部统计始终取未筛选的历史任务数据
useEffect(() => {
if (stationId) fetchStatsTaskHistoryList();
}, [stationId, currentStation?.orgId]);
const taskColumns = [
{
title: t('devices.taskName'),
@@ -1357,13 +1397,112 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
const { waitList, runList, finishList } = groupBoardData;
const { successfulTaskList } = historyData;
// 今日 / 昨日 任务完成统计(按 startTime 分总任务、endTime 分完成任务)
const { todayFinishCount, yesterdayFinishCount, todayTotalCount, yesterdayTotalCount } = useMemo(() => {
const todayKey = dayjs().format('YYYY-MM-DD');
const yesterdayKey = dayjs().subtract(1, 'day').format('YYYY-MM-DD');
// 时间可能是 ISO 字符串,也可能是 Java LocalDateTime 数组 [y,mo,d,h,mi,s]
const toDayKey = (v: any) => {
if (!v) return '';
if (Array.isArray(v)) {
const [y, mo, d] = v;
return y ? dayjs(new Date(y, mo - 1, d)).format('YYYY-MM-DD') : '';
}
const dt = dayjs(v);
return dt.isValid() ? dt.format('YYYY-MM-DD') : '';
};
let tf = 0, yf = 0, tt = 0, yt = 0;
for (const item of statsTaskHistoryList || []) {
const startTime = item?.startTime;
const status = item?.taskStaus;
if (!startTime) continue;
const startKey = toDayKey(startTime);
// 统计今日/昨日任务总数(按开始时间)
if (startKey === todayKey) tt++;
else if (startKey === yesterdayKey) yt++;
// 统计今日/昨日完成数(完成状态,按开始时间)
if (status === 'FINISH') {
if (startKey === todayKey) tf++;
else if (startKey === yesterdayKey) yf++;
}
}
return {
todayFinishCount: tf,
yesterdayFinishCount: yf,
todayTotalCount: tt,
yesterdayTotalCount: yt
};
}, [statsTaskHistoryList]);
const {
todayCompletionRate,
yesterdayCompletionRate,
completionRateDiff,
completionRateTrendText,
completionRateTrendColor
} = useMemo(() => {
const todayRate = todayTotalCount
? Math.round((todayFinishCount / todayTotalCount) * 100)
: 0;
const yesterdayRate = yesterdayTotalCount
? Math.round((yesterdayFinishCount / yesterdayTotalCount) * 100)
: 0;
const diff = todayRate - yesterdayRate;
return {
todayCompletionRate: todayRate,
yesterdayCompletionRate: yesterdayRate,
completionRateDiff: diff,
completionRateTrendText: `${diff > 0 ? '+' : ''}${diff}%`,
completionRateTrendColor:
diff > 0 ? '#00B42A' : diff < 0 ? '#F53F3F' : '#86909C'
};
}, [todayFinishCount, todayTotalCount, yesterdayFinishCount, yesterdayTotalCount]);
// 告警时间解析:兼容 ISO 字符串 与 Java LocalDateTime 数组 [y,mo,d,h,mi,s]
const parseAlarmDay = (v: any) => {
if (!v) return null;
if (Array.isArray(v)) {
const [y, mo, d] = v;
if (!y) return null;
return dayjs(new Date(y, mo - 1, d));
}
const dt = dayjs(v);
return dt.isValid() ? dt : null;
};
// 今日 / 昨日 告警数
const { todayAlarmCount, yesterdayAlarmCount } = useMemo(() => {
const today = dayjs().startOf('day');
const yesterday = dayjs().subtract(1, 'day').startOf('day');
let t = 0, y = 0;
for (const a of alarmList || []) {
const dt = parseAlarmDay(a?.createTime ?? a?.alarmTime);
if (!dt) continue;
if (dt.isSame(today, 'day')) t++;
else if (dt.isSame(yesterday, 'day')) y++;
}
return { todayAlarmCount: t, yesterdayAlarmCount: y };
}, [alarmList]);
const topCards = [
{ title: t('devices.statTodayPlan'), value: taskList.length, unit: t('devices.unitPlan'), desc: t('devices.statInProgress'), icon: <LayoutGrid size={22} />, color: '#165DFF' },
{ title: t('devices.statWorkingRobots'), value: taskPoolList?.filter(item => ['EXECUTING', 'PAUSE'].includes(item.taskStaus))?.length, unit: t('devices.unitRobot'), desc: t('devices.statWorking'), icon: <Car size={22} />, color: '#165DFF' },
{ title: t('devices.statTotalDistance'), value: '12.5', unit: 'km', trend: t('devices.vsYesterday', { value: '+1.2' }), trendColor: '#00B42A', icon: <TrendingUp size={22} />, color: '#722ED1' },
{ title: t('devices.statCompletionRate'), value: successfulTaskList.length ? Math.round((successfulTaskList.length / taskHistoryList.length) * 100) : 0, unit: '%', trend: t('devices.vsYesterday', { value: '+5%' }), trendColor: '#00B42A', icon: <CheckCircle2 size={22} />, color: '#00B42A' },
{ title: t('devices.statAlerts'), value: '0', unit: t('devices.unitTimes'), trend: t('devices.vsYesterday', { value: '-1' }), trendColor: '#00B42A', icon: <AlertCircle size={22} />, color: '#F53F3F' },
{ title: t('devices.statCompletionRate'), value: todayCompletionRate, unit: '%', trend: t('devices.vsYesterday', { value: completionRateTrendText }), trendColor: completionRateTrendColor, icon: <CheckCircle2 size={22} />, color: '#00B42A' },
{ title: t('devices.statAlerts'), value: todayAlarmCount, unit: t('devices.unitTimes'), trend: t('devices.vsYesterday', { value: (todayAlarmCount - yesterdayAlarmCount >= 0 ? '+' : '') + (todayAlarmCount - yesterdayAlarmCount) }), trendColor: todayAlarmCount - yesterdayAlarmCount > 0 ? '#F53F3F' : '#00B42A', icon: <AlertCircle size={22} />, color: '#F53F3F' },
{
title: t('devices.statOnlineRate'),
value: `${devices?.length ? Math.round((devices.filter(d => d.onlineStatus == 1).length / devices.length) * 100) : 0}`,
@@ -1399,7 +1538,6 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
if (res?.code === 200) {
const n = Number(res.data?.cameraNum);
setCameraNum(Number.isFinite(n) && n >= 1 && n <= 4 ? n : 1);
console.log('[DSP] deviceRunParam res.data=', res.data);
} else {
setCameraNum(1);
}
@@ -1408,6 +1546,18 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
});
return () => { cancelled = true; };
}, [selectedMachineSn]);
const fetchAlarmList = async () => {
try {
const res = await getAlarmList({ pageNum: 1, pageSize: 9999, siteId: stationId });
if (res.code === 200) {
setAlarmList(res.rows ?? []);
}
} catch (err) {
messageApi.error(t('common.loadFailed'));
} finally {
}
};
useEffect(() => {
const workingCount = taskPoolList?.filter(item =>
@@ -1419,15 +1569,16 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
working: workingCount,
finishCount: successfulTaskList.length,
totalCount: taskHistoryList.length,
...deviceStatistics,
todayAlarmCount,
yesterdayAlarmCount, todayFinishCount, yesterdayFinishCount, todayTotalCount, yesterdayTotalCount, ...deviceStatistics,
});
}, [
taskList.length,
taskPoolList,
successfulTaskList.length,
taskHistoryList.length,
deviceStatistics,
]);
deviceStatistics, yesterdayAlarmCount,
todayAlarmCount, todayFinishCount, yesterdayFinishCount, todayTotalCount, yesterdayTotalCount]);;
// ===== 分区列表 =====
useEffect(() => {
@@ -1436,6 +1587,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
const list = Array.isArray(res?.data) ? res.data : (Array.isArray(res?.rows) ? res.rows : []);
setRegionList(list);
}).catch(() => setRegionList([]));
fetchAlarmList();
}, [stationId]);
// 按区域下发时,选中区域的可用路径(bindRoutes + defaultRoute)
@@ -1628,6 +1780,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
fetchTaskList();
fetchTaskPoolList();
fetchTaskHistoryList();
fetchStatsTaskHistoryList();
}
} else if (dispatchMode === 'immediate' && dispatchSource == "region") {
try {
@@ -1644,6 +1797,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
fetchTaskList();
fetchTaskPoolList();
fetchTaskHistoryList();
fetchStatsTaskHistoryList();
fetchConsecutiveTaskList();
} else {
utils.message.error(res.msg || t("devices.createFailed"));
@@ -1694,6 +1848,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
fetchTaskList();
fetchTaskPoolList();
fetchTaskHistoryList();
fetchStatsTaskHistoryList();
}
}
} catch (err) {
@@ -2059,10 +2214,10 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
key: 'history',
label: t('devices.taskHistory'),
},
{
key: 'consecutive',
label: t('devices.taskConsecutive'),
}
//{
// key: 'consecutive',
// label: t('devices.taskConsecutive'),
//}
]}
tabBarExtraContent={
<Space size={8}>
@@ -2070,6 +2225,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
fetchTaskList();
fetchTaskPoolList();
fetchTaskHistoryList();
fetchStatsTaskHistoryList();
fetchConsecutiveTaskList();
}} />
@@ -2194,7 +2350,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
rowKey="id"
columns={taskPoolColumns}
dataSource={taskPoolList}
pagination={false}
//pagination={false}
scroll={{ x: 800, y: 150 }}
onRow={(record) => ({
onClick: () => handlePoolTaskClick(record),
@@ -2203,6 +2359,7 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
backgroundColor: record.id === runningPoolTask?.id ? '#e6f4ff' : 'transparent'
}
})}
pagination={{ pageSize: 10, showSizeChanger: false, showQuickJumper: true, showTotal: (total) => t('devices.mapEditor.totalCountWithUnit', { count: total }) }}
/>
</>
)}
@@ -2350,8 +2507,8 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, minmax(0, 1fr))', gap: 8 }}>
{([
{ type: 'returnPoint' as const, label: t('devices.mapEditor.returnPoint'), desc: t('devices.mapEditor.returnPointDesc'), icon: <Navigation size={18} color="#165DFF" /> },
{ type: 'restArea' as const, label: t('devices.mapEditor.restArea'), desc: t('devices.mapEditor.restAreaDesc'), icon: <MapPinned size={18} color="#13C2C2" /> },
{ type: 'obstaclePoint' as const, label: t('devices.mapEditor.obstaclePointLabel'), desc: t('devices.mapEditor.obstaclePointDesc'), icon: <MapPinned size={18} color="#FF7D00" /> },
//{ type: 'restArea' as const, label: t('devices.mapEditor.restArea'), desc: t('devices.mapEditor.restAreaDesc'), icon: <MapPinned size={18} color="#13C2C2" /> },
//{ type: 'obstaclePoint' as const, label: t('devices.mapEditor.obstaclePointLabel'), desc: t('devices.mapEditor.obstaclePointDesc'), icon: <MapPinned size={18} color="#FF7D00" /> },
{ type: 'routeGen' as const, label: t('devices.mapEditor.routeGen'), desc: t('devices.mapEditor.routeGenDesc'), icon: <Route size={18} color="#00B42A" /> },
]).map((item) => {
const selected = editorType === item.type;

View File

@@ -149,7 +149,7 @@ export default class DeviceController {
hasAlarm: !!it?.ha || !!it?.hasAlarm,
updateTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
controlMode: it?.cm ?? it?.controlMode,
progress: it?.p ?? it?.progress,
progress: Number(Number(it?.p ?? it?.progress ?? 0).toFixed(2)),
workName: it?.wk ?? null,
sm: it?.sm ?? null,
emergencyStop: it?.e

View File

@@ -41,7 +41,7 @@ export const sendEmergencyStop = async (deviceId: string) => {
deviceId,
eStop: newActive ? 1 : 0
});
if (res?.code == 200) {
if (res?.code == 200 && res?.data) {
active = newActive;
emit();
utils.message.success('急停状态切换成功');

View File

@@ -357,6 +357,7 @@ export const UniversalPieChart = ({
outerRadius={outerRadius}
paddingAngle={paddingAngle}
label={showLabel}
isAnimationActive={false}
>
{data.map((entry, index) => (
<Cell

View File

@@ -33,12 +33,12 @@ const TaskTypeRadio: React.FC<TaskTypeRadioProps> = ({
description: t('devices.taskTypeRadio.immediateDescription'),
icon: <LoginOutlined />,
},
{
value: 'scheduled',
title: t('devices.taskTypeRadio.scheduled'),
description: t('devices.taskTypeRadio.scheduledDescription'),
icon: <ClockCircleOutlined />,
},
//{
// value: 'scheduled',
// title: t('devices.taskTypeRadio.scheduled'),
// description: t('devices.taskTypeRadio.scheduledDescription'),
// icon: <ClockCircleOutlined />,
//},
];

View File

@@ -1560,6 +1560,8 @@
autoControl: 'autoControl',
manual: 'manual',
auto: 'auto',
taskProgress: 'taskProgress',

View File

@@ -274,6 +274,8 @@ const zh = {
deviceStatus: '设备状态',
waylineTask: '航线任务',
robotTask: '机器人任务',
taskProgress: '任务进度',
deviceName: '设备名称',
deviceType: '设备类型',
deviceModel: '设备型号',

View File

@@ -772,7 +772,7 @@ const TaskMonitorPage: React.FC = () => {
)}
<div className="vehicle-map-popup__row"><span>当前任务</span><strong>{selectedRealtime.workName || "无"}</strong></div>
{/*<div className="vehicle-map-popup__row"><span>设备类型</span><strong>{selectedDevice.deviceTypeName || selectedDevice.deviceType || '车辆'}</strong></div>*/}
<div className="vehicle-map-popup__row"><span>任务进度</span><strong>{selectedRealtime.progress ?? 0}%</strong></div>
<div className="vehicle-map-popup__row"><span>任务进度</span><strong>{selectedRealtime.progress}%</strong></div>
</div>
</div>
)}
@@ -914,7 +914,7 @@ const TaskMonitorPage: React.FC = () => {
{/* Progress 关键:minWidth:0,禁止撑出去 */}
<Progress
percent={rt.progress || 0}
percent={rt.progress}
size="small"
showInfo={false}
strokeColor="#52c41a"