This commit is contained in:
张成
2025-12-29 21:07:52 +08:00
parent 8fa06435a9
commit 5035b9aa72
4 changed files with 134 additions and 18 deletions

View File

@@ -230,12 +230,41 @@ class CommandManager {
// 构建指令执行 Promise
const command_promise = (async () => {
// 指令类型映射表(内部指令类型 -> jobManager方法名
const commandMethodMap = {
// get_job_list 指令对应MQTT Action: "get_job_list"
'get_job_list': 'get_job_list',
'getJobList': 'get_job_list',
// search_jobs_with_params 指令对应MQTT Action: "search_job_list"
'search_jobs_with_params': 'search_jobs_with_params',
'searchJobsWithParams': 'search_jobs_with_params',
// search_and_deliver 指令内部调用search_jobs_with_params和deliver_resume
'search_and_deliver': 'search_and_deliver',
'searchAndDeliver': 'search_and_deliver',
// deliver_resume 指令对应MQTT Action: "deliver_resume"
'deliver_resume': 'deliver_resume',
'deliverResume': 'deliver_resume'
// search_jobs 指令对应MQTT Action: "search_jobs"
'search_jobs': 'search_jobs',
'searchJobs': 'search_jobs'
};
// 优先使用映射表
const mappedMethod = commandMethodMap[command_type] || commandMethodMap[method_name];
if (mappedMethod && jobManager[mappedMethod]) {
return await jobManager[mappedMethod](sn_code, mqttClient, command_params);
}
// 其次尝试转换后的方法名
if (command_type && jobManager[method_name]) {
return await jobManager[method_name](sn_code, mqttClient, command_params);
} else if (jobManager[command_type]) {
}
// 最后尝试原始指令类型
if (jobManager[command_type]) {
return await jobManager[command_type](sn_code, mqttClient, command_params);
} else {
throw new Error(`未知的指令类型: ${command_type} (尝试的方法名: ${method_name})`);
throw new Error(`未知的指令类型: ${command_type} (尝试的方法名: ${method_name}, 映射方法: ${mappedMethod})`);
}
})();