This commit is contained in:
张成
2026-02-28 14:15:49 +08:00
parent 0483d6d023
commit e44ffba1ef
4 changed files with 79 additions and 16 deletions

View File

@@ -394,6 +394,29 @@ class JobManager {
};
}
/**
* 获取期望 tab 列表(投递用标签,如 推荐、前端开发工程师)
* @param {string} sn_code - 设备SN码
* @param {object} mqttClient - MQTT客户端
* @param {object} params - 参数 { platform }
* @returns {Promise<Array<{ index: number, text: string }>>} tab 列表
*/
async get_job_listings(sn_code, mqttClient, params = {}) {
const { platform = 'boss' } = params;
const response = await mqttClient.publishAndWait(sn_code, {
platform,
action: 'get_job_listings',
data: {}
});
if (!response || response.code !== 200) {
console.error(`[工作管理] 获取 job_listings 失败:`, response);
throw new Error(response?.message || '获取 job_listings 失败');
}
const list = Array.isArray(response.data) ? response.data : [];
console.log(`[工作管理] 获取 job_listings 成功,共 ${list.length} 个 tab`);
return list;
}
/**
* 获取岗位列表(支持多条件搜索)
* @param {string} sn_code - 设备SN码

View File

@@ -60,10 +60,11 @@ class ActiveHandler extends BaseHandler {
}
// 4. 创建活跃指令
const actionNameMap = { view_jobs: '浏览职位', browse_jobs: '浏览职位', refresh_resume: '刷新简历', check_notifications: '查看通知' };
const actions = activeStrategy.actions || ['view_jobs'];
const activeCommands = actions.map(action => ({
command_type: `active_${action}`,
command_name: `active_${action}`,
command_name: actionNameMap[action] || `活跃-${action}`,
command_params: JSON.stringify({
sn_code,
platform: platform || accountConfig.platform_type || 'boss',

View File

@@ -81,12 +81,17 @@ class DeliverHandler extends BaseHandler {
}
}
// 5. 获取职位类型配置
const jobTypeConfig = await this.getJobTypeConfig(accountConfig.job_type_id);
// 5. 获取职位类型配置(同时下发 get_job_listings 并保存到 resume_info.job_listings
const jobTypeConfig = await this.getJobTypeConfig(accountConfig.job_type_id, {
sn_code,
platform,
taskId: task.id,
mqttClient: this.mqttClient
});
// 6. 搜索职位列表(从 resume_info 取 deliver_tab_label 作为 tabLabel 下发给 get_job_list 切换期望 tab
// 6. 下发 get_job_list 拉取职位列表tabLabel 切换期望 tabjob_type_id 随指令下发供设备使用
const tabLabel = resume.deliver_tab_label || '';
await this.searchJobs(sn_code, platform, keyword || accountConfig.keyword, pageCount, task.id, tabLabel);
await this.getJobList(sn_code, platform, pageCount, task.id, tabLabel, accountConfig.job_type_id);
// 7. 从数据库获取待投递职位
const pendingJobs = await this.getPendingJobs(sn_code, platform, actualMaxCount * 3);
@@ -202,7 +207,7 @@ class DeliverHandler extends BaseHandler {
try {
await command.executeCommands(taskId, [{
command_type: 'get_online_resume',
command_name: 'get_online_resume',
command_name: '获取在线简历',
command_params: JSON.stringify({ sn_code, platform }),
priority: config.getTaskPriority('get_resume') || 5
}], this.mqttClient);
@@ -221,11 +226,42 @@ class DeliverHandler extends BaseHandler {
}
/**
* 获取职位类型配置
* 获取职位类型配置;若传入 options先下发 get_job_listings 获取 tab 列表并写入 resume_info.job_listings
* @param {number} jobTypeId - 职位类型 ID
* @param {object} options - 可选 { sn_code, platform, taskId, mqttClient },用于下发 get_job_listings 并保存
*/
async getJobTypeConfig(jobTypeId) {
if (!jobTypeId) return null;
async getJobTypeConfig(jobTypeId, options = {}) {
const { sn_code, platform = 'boss', taskId, mqttClient } = options;
if (sn_code && taskId && mqttClient) {
try {
const getListingsCommand = {
command_type: 'get_job_listings',
command_name: '获取投递标签列表',
command_params: JSON.stringify({ sn_code, platform }),
priority: config.getTaskPriority('auto_deliver') || 7
};
const ret = await command.executeCommands(taskId, [getListingsCommand], mqttClient);
const firstResult = ret.results && ret.results[0];
const list = firstResult && firstResult.result && Array.isArray(firstResult.result)
? firstResult.result
: [];
const job_listings = list.map((item) => (item && item.text != null ? String(item.text).trim() : '')).filter(Boolean);
if (job_listings.length > 0) {
const resume_info = db.getModel('resume_info');
const [updated] = await resume_info.update(
{ job_listings },
{ where: { sn_code, platform } }
);
if (updated) {
console.log(`[自动投递] job_listings 已保存,共 ${job_listings.length}`);
}
}
} catch (err) {
console.warn(`[自动投递] 下发 get_job_listings 或保存失败:`, err.message);
}
}
if (!jobTypeId) return null;
try {
const job_types = db.getModel('job_types');
const jobType = await job_types.findByPk(jobTypeId);
@@ -237,24 +273,27 @@ class DeliverHandler extends BaseHandler {
}
/**
* 搜索职位列表
* 下发 get_job_list 命令拉取职位列表
* @param {string} tabLabel - 投递用期望标签文案,对应 resume_info.deliver_tab_labelget_job_list 会按此选择 tab
* @param {number} jobTypeId - 职位类型 ID随指令下发供设备使用
*/
async searchJobs(sn_code, platform, keyword, pageCount, taskId, tabLabel = '') {
async getJobList(sn_code, platform, pageCount, taskId, tabLabel = '', jobTypeId = null) {
const params = {
sn_code,
keyword,
platform,
pageCount
};
if (tabLabel != null && String(tabLabel).trim() !== '') {
params.tabLabel = String(tabLabel).trim();
}
if (jobTypeId != null && jobTypeId !== '') {
params.job_type_id = jobTypeId;
}
const getJobListCommand = {
command_type: 'get_job_list',
command_name: 'get_job_list',
command_name: '获取职位列表',
command_params: JSON.stringify(params),
priority: config.getTaskPriority('search_jobs') || 5
priority: config.getTaskPriority('auto_deliver') || 7
};
await command.executeCommands(taskId, [getJobListCommand], this.mqttClient);
@@ -343,7 +382,7 @@ class DeliverHandler extends BaseHandler {
createDeliverCommands(jobs, sn_code, platform) {
return jobs.map(job => ({
command_type: 'deliver_resume',
command_name: 'deliver_resume',
command_name: '投递简历',
command_params: JSON.stringify({
sn_code,
platform,

View File

@@ -87,7 +87,7 @@ class SearchHandler extends BaseHandler {
const searchCommand = {
command_type: 'get_job_list',
command_name: 'get_job_list',
command_name: '获取职位列表',
command_params: JSON.stringify(commandParams),
priority: config.getTaskPriority('search_jobs') || 8
};