1
This commit is contained in:
@@ -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 切换期望 tab,job_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_label,get_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,
|
||||
|
||||
Reference in New Issue
Block a user