1
This commit is contained in:
@@ -78,8 +78,10 @@ class DeviceWorkStatusNotifier {
|
||||
};
|
||||
|
||||
// 如果有当前执行的指令,优先显示指令状态
|
||||
if (options.currentCommand) {
|
||||
const cmd = options.currentCommand;
|
||||
// 优先从 options 中获取,如果没有则从 taskStatusSummary 中获取
|
||||
const currentCommand = options.currentCommand || taskStatusSummary.currentCommand;
|
||||
if (currentCommand) {
|
||||
const cmd = currentCommand;
|
||||
workStatus.currentActivity = {
|
||||
type: 'command',
|
||||
id: cmd.command_id || cmd.id,
|
||||
@@ -87,8 +89,8 @@ class DeviceWorkStatusNotifier {
|
||||
description: this._formatCommandDescription(cmd),
|
||||
status: 'running',
|
||||
progress: cmd.progress || 0,
|
||||
currentStep: cmd.currentStep || '',
|
||||
startTime: cmd.startTime || new Date().toISOString()
|
||||
currentStep: cmd.currentStep || cmd.current_step || '',
|
||||
startTime: cmd.startTime || cmd.start_time || new Date().toISOString()
|
||||
};
|
||||
}
|
||||
// 如果有当前执行的任务,显示任务状态
|
||||
@@ -146,8 +148,16 @@ class DeviceWorkStatusNotifier {
|
||||
|
||||
await mqttClient.publish(topic, message);
|
||||
|
||||
// 输出日志
|
||||
console.log(`[设备工作状态] 已推送到 ${sn_code}: ${workStatus.displayText}`);
|
||||
// 输出详细日志
|
||||
if (workStatus.currentActivity) {
|
||||
const activity = workStatus.currentActivity;
|
||||
const activityInfo = activity.type === 'command'
|
||||
? `指令[${activity.name}]`
|
||||
: `任务[${activity.name}]`;
|
||||
console.log(`[设备工作状态] 已推送到 ${sn_code}: ${activityInfo} - ${workStatus.displayText}`);
|
||||
} else {
|
||||
console.log(`[设备工作状态] 已推送到 ${sn_code}: ${workStatus.displayText}`);
|
||||
}
|
||||
} catch (error) {
|
||||
// 通知失败不影响任务执行,只记录日志
|
||||
console.warn(`[设备工作状态] 推送失败:`, error.message);
|
||||
@@ -232,7 +242,15 @@ class DeviceWorkStatusNotifier {
|
||||
const statusText = activity.status === 'running' ? '执行中' :
|
||||
activity.status === 'completed' ? '已完成' :
|
||||
activity.status === 'failed' ? '失败' : '未知';
|
||||
parts.push(`${typeText}: ${activity.description || activity.name} (${statusText}, 进度: ${activity.progress}%)`);
|
||||
|
||||
// 构建详细描述:包含指令/任务名称和描述
|
||||
let activityDesc = activity.description || activity.name;
|
||||
if (activity.type === 'command' && activity.currentStep) {
|
||||
// 对于指令,如果有当前步骤信息,追加到描述中
|
||||
activityDesc = `${activityDesc} - ${activity.currentStep}`;
|
||||
}
|
||||
|
||||
parts.push(`${typeText}: ${activityDesc} (${statusText}${activity.progress > 0 ? `, 进度: ${activity.progress}%` : ''})`);
|
||||
} else {
|
||||
parts.push('当前活动: 无');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user