1
This commit is contained in:
@@ -144,7 +144,7 @@ class JobManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多条件搜索职位列表(新指令)
|
* 多条件搜索职位列表(新指令,使用新的MQTT action)
|
||||||
* @param {string} sn_code - 设备SN码
|
* @param {string} sn_code - 设备SN码
|
||||||
* @param {object} mqttClient - MQTT客户端
|
* @param {object} mqttClient - MQTT客户端
|
||||||
* @param {object} params - 搜索参数
|
* @param {object} params - 搜索参数
|
||||||
@@ -249,7 +249,7 @@ class JobManager {
|
|||||||
|
|
||||||
console.log(`[工作管理] 开始搜索并投递职位,设备: ${sn_code}, 关键词: ${keyword}`);
|
console.log(`[工作管理] 开始搜索并投递职位,设备: ${sn_code}, 关键词: ${keyword}`);
|
||||||
|
|
||||||
// 1. 先执行搜索
|
// 1. 先执行搜索(使用search_jobs_with_params,新的搜索指令)
|
||||||
const searchResult = await this.search_jobs_with_params(sn_code, mqttClient, {
|
const searchResult = await this.search_jobs_with_params(sn_code, mqttClient, {
|
||||||
keyword,
|
keyword,
|
||||||
platform,
|
platform,
|
||||||
@@ -360,15 +360,16 @@ class JobManager {
|
|||||||
console.warn(`[工作管理] 解析职位原始数据失败:`, e);
|
console.warn(`[工作管理] 解析职位原始数据失败:`, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 执行投递
|
// 执行投递(使用新的deliver_resume_search action)
|
||||||
const deliverResult = await this.applyJob(sn_code, mqttClient, {
|
const deliverResult = await this.deliver_resume(sn_code, mqttClient, {
|
||||||
jobId: jobData.jobId,
|
jobId: jobData.jobId,
|
||||||
encryptBossId: jobData.encryptBossId || '',
|
encryptBossId: jobData.encryptBossId || '',
|
||||||
securityId: securityId,
|
securityId: securityId,
|
||||||
brandName: jobData.companyName || '',
|
brandName: jobData.companyName || '',
|
||||||
jobTitle: jobData.jobTitle || '',
|
jobTitle: jobData.jobTitle || '',
|
||||||
companyName: jobData.companyName || '',
|
companyName: jobData.companyName || '',
|
||||||
platform: platform
|
platform: platform,
|
||||||
|
action: 'deliver_resume_search' // 搜索并投递使用新的action
|
||||||
});
|
});
|
||||||
|
|
||||||
if (deliverResult && deliverResult.success) {
|
if (deliverResult && deliverResult.success) {
|
||||||
@@ -394,14 +395,99 @@ class JobManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取岗位列表
|
* 获取岗位列表(支持多条件搜索)
|
||||||
* @param {string} sn_code - 设备SN码
|
* @param {string} sn_code - 设备SN码
|
||||||
* @param {object} mqttClient - MQTT客户端
|
* @param {object} mqttClient - MQTT客户端
|
||||||
* @param {object} params - 参数
|
* @param {object} params - 参数
|
||||||
* @returns {Promise<object>} 岗位列表
|
* @returns {Promise<object>} 岗位列表
|
||||||
*/
|
*/
|
||||||
async get_job_list(sn_code, mqttClient, params = {}) {
|
async get_job_list(sn_code, mqttClient, params = {}) {
|
||||||
const { keyword = '前端', platform = 'boss', pageCount = 3 } = params;
|
const {
|
||||||
|
keyword = '前端',
|
||||||
|
platform = 'boss',
|
||||||
|
pageCount = 3,
|
||||||
|
city = '',
|
||||||
|
cityName = '',
|
||||||
|
salary = '',
|
||||||
|
experience = '',
|
||||||
|
education = '',
|
||||||
|
industry = '',
|
||||||
|
companySize = '',
|
||||||
|
financingStage = '',
|
||||||
|
page = 1,
|
||||||
|
pageSize = 20
|
||||||
|
} = params;
|
||||||
|
|
||||||
|
// 判断是否是多条件搜索(如果包含多条件参数,使用多条件搜索逻辑)
|
||||||
|
const hasMultiParams = city || cityName || salary || experience || education ||
|
||||||
|
industry || companySize || financingStage || page || pageSize;
|
||||||
|
|
||||||
|
if (hasMultiParams) {
|
||||||
|
// 使用多条件搜索逻辑
|
||||||
|
console.log(`[工作管理] 开始多条件搜索设备 ${sn_code} 的职位,关键词: ${keyword}, 城市: ${cityName || city}`);
|
||||||
|
|
||||||
|
// 构建完整的搜索参数对象
|
||||||
|
const searchData = {
|
||||||
|
keyword,
|
||||||
|
pageCount
|
||||||
|
};
|
||||||
|
|
||||||
|
// 添加可选搜索条件
|
||||||
|
if (city) searchData.city = city;
|
||||||
|
if (cityName) searchData.cityName = cityName;
|
||||||
|
if (salary) searchData.salary = salary;
|
||||||
|
if (experience) searchData.experience = experience;
|
||||||
|
if (education) searchData.education = education;
|
||||||
|
if (industry) searchData.industry = industry;
|
||||||
|
if (companySize) searchData.companySize = companySize;
|
||||||
|
if (financingStage) searchData.financingStage = financingStage;
|
||||||
|
if (page) searchData.page = page;
|
||||||
|
if (pageSize) searchData.pageSize = pageSize;
|
||||||
|
|
||||||
|
// 通过MQTT指令获取岗位列表(保持action不变,前端已使用)
|
||||||
|
const response = await mqttClient.publishAndWait(sn_code, {
|
||||||
|
platform,
|
||||||
|
action: "get_job_list", // 保持与原有get_job_list相同的action,前端已使用
|
||||||
|
data: searchData
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response || response.code !== 200) {
|
||||||
|
console.error(`[工作管理] 多条件搜索职位失败:`, response);
|
||||||
|
throw new Error('多条件搜索职位失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理职位列表数据
|
||||||
|
let jobs = [];
|
||||||
|
if (Array.isArray(response.data)) {
|
||||||
|
for (const item of response.data) {
|
||||||
|
if (item.data?.zpData?.jobList && Array.isArray(item.data.zpData.jobList)) {
|
||||||
|
jobs = jobs.concat(item.data.zpData.jobList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (response.data?.data?.zpData?.jobList) {
|
||||||
|
jobs = response.data.data.zpData.jobList || [];
|
||||||
|
} else if (response.data?.zpData?.jobList) {
|
||||||
|
jobs = response.data.zpData.jobList || [];
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[工作管理] 成功获取岗位数据,共 ${jobs.length} 个岗位`);
|
||||||
|
|
||||||
|
// 保存职位到数据库
|
||||||
|
try {
|
||||||
|
await this.saveJobsToDatabase(sn_code, platform, keyword, jobs);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`[工作管理] 保存职位到数据库失败:`, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
jobs: jobs,
|
||||||
|
keyword: keyword,
|
||||||
|
platform: platform,
|
||||||
|
count: jobs.length
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 简单搜索逻辑(保持原有逻辑)
|
||||||
console.log(`[工作管理] 开始获取设备 ${sn_code} 的岗位列表,关键词: ${keyword}`);
|
console.log(`[工作管理] 开始获取设备 ${sn_code} 的岗位列表,关键词: ${keyword}`);
|
||||||
|
|
||||||
// 通过MQTT指令获取岗位列表
|
// 通过MQTT指令获取岗位列表
|
||||||
@@ -570,10 +656,11 @@ class JobManager {
|
|||||||
* @param {string} params.brandName - 公司名称(可选)
|
* @param {string} params.brandName - 公司名称(可选)
|
||||||
* @param {string} params.jobTitle - 职位标题(可选)
|
* @param {string} params.jobTitle - 职位标题(可选)
|
||||||
* @param {string} params.companyName - 公司名称(可选)
|
* @param {string} params.companyName - 公司名称(可选)
|
||||||
|
* @param {string} params.action - MQTT Action(默认:deliver_resume,可选:deliver_resume_search)
|
||||||
* @returns {Promise<object>} 投递结果
|
* @returns {Promise<object>} 投递结果
|
||||||
*/
|
*/
|
||||||
async applyJob(sn_code, mqttClient, params = {}) {
|
async deliver_resume(sn_code, mqttClient, params = {}) {
|
||||||
const { platform = 'boss', jobId, encryptBossId, securityId, brandName, jobTitle, companyName } = params;
|
const { platform = 'boss', jobId, encryptBossId, securityId, brandName, jobTitle, companyName, action = 'deliver_resume' } = params;
|
||||||
|
|
||||||
if (!jobId) {
|
if (!jobId) {
|
||||||
throw new Error('jobId 参数不能为空,请指定要投递的职位ID');
|
throw new Error('jobId 参数不能为空,请指定要投递的职位ID');
|
||||||
@@ -651,10 +738,10 @@ class JobManager {
|
|||||||
|
|
||||||
console.log(`[工作管理] 投递职位: ${jobData.jobTitle} @ ${jobData.companyName}`);
|
console.log(`[工作管理] 投递职位: ${jobData.jobTitle} @ ${jobData.companyName}`);
|
||||||
|
|
||||||
// 通过MQTT指令投递简历
|
// 通过MQTT指令投递简历(支持自定义action)
|
||||||
const response = await mqttClient.publishAndWait(sn_code, {
|
const response = await mqttClient.publishAndWait(sn_code, {
|
||||||
platform,
|
platform,
|
||||||
action: "deliver_resume",
|
action: action, // 使用传入的action参数,默认为"deliver_resume"
|
||||||
data: {
|
data: {
|
||||||
encryptJobId: jobData.jobId,
|
encryptJobId: jobData.jobId,
|
||||||
securityId: jobData.securityId || securityId || '',
|
securityId: jobData.securityId || securityId || '',
|
||||||
|
|||||||
@@ -230,12 +230,41 @@ class CommandManager {
|
|||||||
|
|
||||||
// 构建指令执行 Promise
|
// 构建指令执行 Promise
|
||||||
const command_promise = (async () => {
|
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]) {
|
if (command_type && jobManager[method_name]) {
|
||||||
return await jobManager[method_name](sn_code, mqttClient, command_params);
|
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);
|
return await jobManager[command_type](sn_code, mqttClient, command_params);
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`未知的指令类型: ${command_type} (尝试的方法名: ${method_name})`);
|
throw new Error(`未知的指令类型: ${command_type} (尝试的方法名: ${method_name}, 映射方法: ${mappedMethod})`);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ class DeviceWorkStatusNotifier {
|
|||||||
return `投递职位: ${parsedParams.jobTitle} @ ${companyName}`;
|
return `投递职位: ${parsedParams.jobTitle} @ ${companyName}`;
|
||||||
} else if (parsedParams.jobTitle) {
|
} else if (parsedParams.jobTitle) {
|
||||||
return `投递职位: ${parsedParams.jobTitle}`;
|
return `投递职位: ${parsedParams.jobTitle}`;
|
||||||
} else if (commandType === 'applyJob' || commandName.includes('投递')) {
|
} else if (commandType === 'deliver_resume' || commandName.includes('投递')) {
|
||||||
return '投递简历';
|
return '投递简历';
|
||||||
} else if (commandType === 'searchJobs' || commandName.includes('搜索')) {
|
} else if (commandType === 'searchJobs' || commandName.includes('搜索')) {
|
||||||
return `搜索职位: ${parsedParams.keyword || ''}`;
|
return `搜索职位: ${parsedParams.keyword || ''}`;
|
||||||
|
|||||||
@@ -474,7 +474,7 @@ class TaskHandlers {
|
|||||||
for (const jobData of jobsToDeliver) {
|
for (const jobData of jobsToDeliver) {
|
||||||
console.log(`[任务处理器] 准备投递职位: ${jobData.jobTitle} @ ${jobData.companyName}, 评分: ${jobData.matchScore}`, jobData.scoreDetails);
|
console.log(`[任务处理器] 准备投递职位: ${jobData.jobTitle} @ ${jobData.companyName}, 评分: ${jobData.matchScore}`, jobData.scoreDetails);
|
||||||
deliverCommands.push({
|
deliverCommands.push({
|
||||||
command_type: 'applyJob',
|
command_type: 'deliver_resume', // 与MQTT Action保持一致
|
||||||
command_name: `投递简历 - ${jobData.jobTitle} @ ${jobData.companyName} (评分:${jobData.matchScore})`,
|
command_name: `投递简历 - ${jobData.jobTitle} @ ${jobData.companyName} (评分:${jobData.matchScore})`,
|
||||||
command_params: JSON.stringify({
|
command_params: JSON.stringify({
|
||||||
sn_code: sn_code,
|
sn_code: sn_code,
|
||||||
@@ -660,11 +660,11 @@ class TaskHandlers {
|
|||||||
sequence: 1
|
sequence: 1
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// 使用多条件搜索指令
|
// 使用多条件搜索指令(新的指令类型,使用新的MQTT action)
|
||||||
searchCommand = {
|
searchCommand = {
|
||||||
command_type: 'search_jobs_with_params',
|
command_type: 'search_jobs_with_params', // 新的指令类型
|
||||||
command_name: '多条件搜索职位列表',
|
command_name: '多条件搜索职位列表',
|
||||||
command_params: JSON.stringify(searchCommandParams),
|
command_params: JSON.stringify(searchCommandParams), // 包含多条件参数
|
||||||
priority: config.getTaskPriority('search_jobs_with_params') || 5,
|
priority: config.getTaskPriority('search_jobs_with_params') || 5,
|
||||||
sequence: 1
|
sequence: 1
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user