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})`);
}
})();

View File

@@ -214,7 +214,7 @@ class DeviceWorkStatusNotifier {
return `投递职位: ${parsedParams.jobTitle} @ ${companyName}`;
} else if (parsedParams.jobTitle) {
return `投递职位: ${parsedParams.jobTitle}`;
} else if (commandType === 'applyJob' || commandName.includes('投递')) {
} else if (commandType === 'deliver_resume' || commandName.includes('投递')) {
return '投递简历';
} else if (commandType === 'searchJobs' || commandName.includes('搜索')) {
return `搜索职位: ${parsedParams.keyword || ''}`;

View File

@@ -474,7 +474,7 @@ class TaskHandlers {
for (const jobData of jobsToDeliver) {
console.log(`[任务处理器] 准备投递职位: ${jobData.jobTitle} @ ${jobData.companyName}, 评分: ${jobData.matchScore}`, jobData.scoreDetails);
deliverCommands.push({
command_type: 'applyJob',
command_type: 'deliver_resume', // 与MQTT Action保持一致
command_name: `投递简历 - ${jobData.jobTitle} @ ${jobData.companyName} (评分:${jobData.matchScore})`,
command_params: JSON.stringify({
sn_code: sn_code,
@@ -660,11 +660,11 @@ class TaskHandlers {
sequence: 1
};
} else {
// 使用多条件搜索指令
// 使用多条件搜索指令新的指令类型使用新的MQTT action
searchCommand = {
command_type: 'search_jobs_with_params',
command_type: 'search_jobs_with_params', // 新的指令类型
command_name: '多条件搜索职位列表',
command_params: JSON.stringify(searchCommandParams),
command_params: JSON.stringify(searchCommandParams), // 包含多条件参数
priority: config.getTaskPriority('search_jobs_with_params') || 5,
sequence: 1
};