Compare commits

..

2 Commits

Author SHA1 Message Date
张成
e3d14dd637 1 2026-04-08 13:30:50 +08:00
张成
ca8bbcd9cd 1 2026-04-08 13:29:22 +08:00
8 changed files with 177 additions and 19 deletions

View File

@@ -496,7 +496,7 @@ module.exports = {
/**
* 仅保存投递标签:标签列表(来自 get_job_listings+ 当前选中的标签
* 更新 resume_info 的 job_listings、deliver_tab_label不碰其他配置
* 更新 resume_info 的 job_listings、deliver_tab_label并同步 pla_account.keyword与推荐/期望职位一致)
*/
'POST /user/deliver-tab-label/save': async (ctx) => {
try {
@@ -533,6 +533,10 @@ module.exports = {
isActive: true
});
}
const keywordSync = label.trim().slice(0, 50);
await pla_account.update({ keyword: keywordSync }, { where: { id: user.id } });
return ctx.success({ message: '投递标签已保存', job_listings: list, deliver_tab_label: label });
} catch (error) {
console.error('[保存投递标签失败]', error);
@@ -603,6 +607,13 @@ module.exports = {
isActive: true
});
}
if (deliver_tab_label !== undefined) {
const keywordSync = (deliver_tab_label != null ? String(deliver_tab_label) : '')
.trim()
.slice(0, 50);
await pla_account.update({ keyword: keywordSync }, { where: { id: user.id } });
}
}
if (Object.keys(updateData).length === 0 && deliver_tab_label === undefined && job_listings === undefined) {

View File

@@ -426,7 +426,7 @@ class JobManager {
*/
async get_job_list(sn_code, mqttClient, params = {}) {
const {
keyword = '前端',
keyword: paramKeyword = '',
platform = 'boss',
pageCount = 3,
city = '',
@@ -438,22 +438,60 @@ class JobManager {
companySize = '',
financingStage = '',
page = 1,
pageSize = 20
pageSize = 20,
tabLabel,
tabIndex,
job_type_id
} = params;
// 判断是否是多条件搜索(如果包含多条件参数,使用多条件搜索逻辑
const hasMultiParams = city || cityName || salary || experience || education ||
industry || companySize || financingStage || page || pageSize;
// 推荐列表实际按期望 tab 拉取,入库 keyword 应与「职位来源」一致:显式 keyword > deliver_tab_label > 空(不再默认「前端」
let keyword = paramKeyword != null && String(paramKeyword).trim() !== ''
? String(paramKeyword).trim()
: '';
if (!keyword && tabLabel != null && String(tabLabel).trim() !== '') {
keyword = String(tabLabel).trim();
}
// 仅当调用方显式传入筛选/分页字段时才走多条件分支(避免 page/pageSize 默认值把简单拉列表永远判成「多条件」)
const hasMultiParams = Boolean(
(params.city != null && params.city !== '') ||
(params.cityName != null && params.cityName !== '') ||
(params.salary != null && params.salary !== '') ||
(params.experience != null && params.experience !== '') ||
(params.education != null && params.education !== '') ||
(params.industry != null && params.industry !== '') ||
(params.companySize != null && params.companySize !== '') ||
(params.financingStage != null && params.financingStage !== '') ||
params.page !== undefined ||
params.pageSize !== undefined
);
/** 期望 tab 与职位类型需原样带给设备端 get_job_list否则不会切换 .c-expect-select 标签 */
const appendExpectTabToData = (data) => {
if (tabLabel != null && String(tabLabel).trim() !== '') {
data.tabLabel = String(tabLabel).trim();
}
if (tabIndex !== undefined && tabIndex !== null && String(tabIndex).trim() !== '') {
const ti = Number(tabIndex);
if (!Number.isNaN(ti)) {
data.tabIndex = ti;
}
}
if (job_type_id != null && job_type_id !== '') {
data.job_type_id = job_type_id;
}
return data;
};
if (hasMultiParams) {
// 使用多条件搜索逻辑
console.log(`[工作管理] 开始多条件搜索设备 ${sn_code} 的职位,关键词: ${keyword}, 城市: ${cityName || city}`);
// 构建完整的搜索参数对象
const searchData = {
const searchData = appendExpectTabToData({
keyword,
pageCount
};
});
// 添加可选搜索条件
if (city) searchData.city = city;
@@ -513,11 +551,11 @@ class JobManager {
// 简单搜索逻辑(保持原有逻辑)
console.log(`[工作管理] 开始获取设备 ${sn_code} 的岗位列表,关键词: ${keyword}`);
// 通过MQTT指令获取岗位列表
// 通过MQTT指令获取岗位列表(须带上 tabLabel/tabIndex与 schedule/deliver 下发一致)
const response = await mqttClient.publishAndWait(sn_code, {
platform,
action: "get_job_list",
data: { keyword, pageCount }
data: appendExpectTabToData({ keyword, pageCount })
});
if (!response || response.code !== 200) {

View File

@@ -91,7 +91,15 @@ class DeliverHandler extends BaseHandler {
// 6. 下发 get_job_list 拉取职位列表tabLabel 切换期望 tabjob_type_id 随指令下发供设备使用)
const tabLabel = resume.deliver_tab_label || '';
await this.getJobList(sn_code, platform, pageCount, task.id, tabLabel, accountConfig.job_type_id);
await this.getJobList(
sn_code,
platform,
pageCount,
task.id,
tabLabel,
accountConfig.job_type_id,
accountConfig.keyword
);
// 7. 从数据库获取待投递职位
const pendingJobs = await this.getPendingJobs(sn_code, platform, actualMaxCount * 3);
@@ -277,14 +285,20 @@ class DeliverHandler extends BaseHandler {
* @param {string} tabLabel - 投递用期望标签文案,对应 resume_info.deliver_tab_labelget_job_list 会按此选择 tab
* @param {number} jobTypeId - 职位类型 ID随指令下发供设备使用
*/
async getJobList(sn_code, platform, pageCount, taskId, tabLabel = '', jobTypeId = null) {
async getJobList(sn_code, platform, pageCount, taskId, tabLabel = '', jobTypeId = null, accountKeyword = '') {
const label = tabLabel != null && String(tabLabel).trim() !== '' ? String(tabLabel).trim() : '';
const accKw = accountKeyword != null && String(accountKeyword).trim() !== '' ? String(accountKeyword).trim() : '';
// 与 jobManager 一致:优先期望职位文案,其次账户搜索词,用于 job_postings.keyword
const keyword = label || accKw;
const params = {
sn_code,
platform,
pageCount
pageCount,
keyword
};
if (tabLabel != null && String(tabLabel).trim() !== '') {
params.tabLabel = String(tabLabel).trim();
if (label) {
params.tabLabel = label;
}
if (jobTypeId != null && jobTypeId !== '') {
params.job_type_id = jobTypeId;

View File

@@ -77,9 +77,14 @@ class SearchHandler extends BaseHandler {
console.warn('[自动搜索] 读取 resume_info.deliver_tab_label 失败:', e.message);
}
let listKeyword = (keyword && String(keyword).trim()) || (accountConfig.keyword && String(accountConfig.keyword).trim()) || '';
if (!listKeyword && tabLabel) {
listKeyword = tabLabel;
}
const commandParams = {
sn_code,
keyword: keyword || accountConfig.keyword || '',
keyword: listKeyword,
platform: platformType,
pageCount: pageCount || searchConfig.page_count || 3
};

View File

@@ -40,7 +40,7 @@ module.exports = (db) => {
defaultValue: ''
},
keyword: {
comment: '关键词',
comment: '搜索/推荐职位关键词;保存投递期望标签时会与 resume_info.deliver_tab_label 同步',
type: Sequelize.STRING(50),
allowNull: false,
defaultValue: ''

View File

@@ -486,7 +486,7 @@ class PlaAccountService {
finalParams.keyword = account.keyword;
}
// get_job_list 从 resume_info 取 deliver_tab_label 作为 tabLabel 参数
// get_job_list 从 resume_info 取 deliver_tab_label 作为 tabLabel;入库 keyword 优先用期望职位而非写死
if (commandTypeSnake === 'get_job_list') {
try {
const resume_info = db.getModel('resume_info');
@@ -496,7 +496,11 @@ class PlaAccountService {
attributes: ['deliver_tab_label']
});
if (resume && resume.deliver_tab_label) {
finalParams.tabLabel = String(resume.deliver_tab_label).trim();
const tab = String(resume.deliver_tab_label).trim();
finalParams.tabLabel = tab;
if (!finalParams.keyword || String(finalParams.keyword).trim() === '') {
finalParams.keyword = tab;
}
}
} catch (e) {
console.warn('[pla_account_service] 读取 resume_info.deliver_tab_label 失败:', e.message);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long