Compare commits
2 Commits
820e437729
...
e3d14dd637
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3d14dd637 | ||
|
|
ca8bbcd9cd |
@@ -496,7 +496,7 @@ module.exports = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 仅保存投递标签:标签列表(来自 get_job_listings)+ 当前选中的标签
|
* 仅保存投递标签:标签列表(来自 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) => {
|
'POST /user/deliver-tab-label/save': async (ctx) => {
|
||||||
try {
|
try {
|
||||||
@@ -533,6 +533,10 @@ module.exports = {
|
|||||||
isActive: true
|
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 });
|
return ctx.success({ message: '投递标签已保存', job_listings: list, deliver_tab_label: label });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[保存投递标签失败]', error);
|
console.error('[保存投递标签失败]', error);
|
||||||
@@ -603,6 +607,13 @@ module.exports = {
|
|||||||
isActive: true
|
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) {
|
if (Object.keys(updateData).length === 0 && deliver_tab_label === undefined && job_listings === undefined) {
|
||||||
|
|||||||
@@ -426,7 +426,7 @@ class JobManager {
|
|||||||
*/
|
*/
|
||||||
async get_job_list(sn_code, mqttClient, params = {}) {
|
async get_job_list(sn_code, mqttClient, params = {}) {
|
||||||
const {
|
const {
|
||||||
keyword = '前端',
|
keyword: paramKeyword = '',
|
||||||
platform = 'boss',
|
platform = 'boss',
|
||||||
pageCount = 3,
|
pageCount = 3,
|
||||||
city = '',
|
city = '',
|
||||||
@@ -438,22 +438,60 @@ class JobManager {
|
|||||||
companySize = '',
|
companySize = '',
|
||||||
financingStage = '',
|
financingStage = '',
|
||||||
page = 1,
|
page = 1,
|
||||||
pageSize = 20
|
pageSize = 20,
|
||||||
|
tabLabel,
|
||||||
|
tabIndex,
|
||||||
|
job_type_id
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
// 判断是否是多条件搜索(如果包含多条件参数,使用多条件搜索逻辑)
|
// 推荐列表实际按期望 tab 拉取,入库 keyword 应与「职位来源」一致:显式 keyword > deliver_tab_label > 空(不再默认「前端」)
|
||||||
const hasMultiParams = city || cityName || salary || experience || education ||
|
let keyword = paramKeyword != null && String(paramKeyword).trim() !== ''
|
||||||
industry || companySize || financingStage || page || pageSize;
|
? 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) {
|
if (hasMultiParams) {
|
||||||
// 使用多条件搜索逻辑
|
// 使用多条件搜索逻辑
|
||||||
console.log(`[工作管理] 开始多条件搜索设备 ${sn_code} 的职位,关键词: ${keyword}, 城市: ${cityName || city}`);
|
console.log(`[工作管理] 开始多条件搜索设备 ${sn_code} 的职位,关键词: ${keyword}, 城市: ${cityName || city}`);
|
||||||
|
|
||||||
// 构建完整的搜索参数对象
|
// 构建完整的搜索参数对象
|
||||||
const searchData = {
|
const searchData = appendExpectTabToData({
|
||||||
keyword,
|
keyword,
|
||||||
pageCount
|
pageCount
|
||||||
};
|
});
|
||||||
|
|
||||||
// 添加可选搜索条件
|
// 添加可选搜索条件
|
||||||
if (city) searchData.city = city;
|
if (city) searchData.city = city;
|
||||||
@@ -513,11 +551,11 @@ class JobManager {
|
|||||||
// 简单搜索逻辑(保持原有逻辑)
|
// 简单搜索逻辑(保持原有逻辑)
|
||||||
console.log(`[工作管理] 开始获取设备 ${sn_code} 的岗位列表,关键词: ${keyword}`);
|
console.log(`[工作管理] 开始获取设备 ${sn_code} 的岗位列表,关键词: ${keyword}`);
|
||||||
|
|
||||||
// 通过MQTT指令获取岗位列表
|
// 通过MQTT指令获取岗位列表(须带上 tabLabel/tabIndex,与 schedule/deliver 下发一致)
|
||||||
const response = await mqttClient.publishAndWait(sn_code, {
|
const response = await mqttClient.publishAndWait(sn_code, {
|
||||||
platform,
|
platform,
|
||||||
action: "get_job_list",
|
action: "get_job_list",
|
||||||
data: { keyword, pageCount }
|
data: appendExpectTabToData({ keyword, pageCount })
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response || response.code !== 200) {
|
if (!response || response.code !== 200) {
|
||||||
|
|||||||
@@ -91,7 +91,15 @@ class DeliverHandler extends BaseHandler {
|
|||||||
|
|
||||||
// 6. 下发 get_job_list 拉取职位列表(tabLabel 切换期望 tab,job_type_id 随指令下发供设备使用)
|
// 6. 下发 get_job_list 拉取职位列表(tabLabel 切换期望 tab,job_type_id 随指令下发供设备使用)
|
||||||
const tabLabel = resume.deliver_tab_label || '';
|
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. 从数据库获取待投递职位
|
// 7. 从数据库获取待投递职位
|
||||||
const pendingJobs = await this.getPendingJobs(sn_code, platform, actualMaxCount * 3);
|
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_label,get_job_list 会按此选择 tab
|
* @param {string} tabLabel - 投递用期望标签文案,对应 resume_info.deliver_tab_label,get_job_list 会按此选择 tab
|
||||||
* @param {number} jobTypeId - 职位类型 ID,随指令下发供设备使用
|
* @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 = {
|
const params = {
|
||||||
sn_code,
|
sn_code,
|
||||||
platform,
|
platform,
|
||||||
pageCount
|
pageCount,
|
||||||
|
keyword
|
||||||
};
|
};
|
||||||
if (tabLabel != null && String(tabLabel).trim() !== '') {
|
if (label) {
|
||||||
params.tabLabel = String(tabLabel).trim();
|
params.tabLabel = label;
|
||||||
}
|
}
|
||||||
if (jobTypeId != null && jobTypeId !== '') {
|
if (jobTypeId != null && jobTypeId !== '') {
|
||||||
params.job_type_id = jobTypeId;
|
params.job_type_id = jobTypeId;
|
||||||
|
|||||||
@@ -77,9 +77,14 @@ class SearchHandler extends BaseHandler {
|
|||||||
console.warn('[自动搜索] 读取 resume_info.deliver_tab_label 失败:', e.message);
|
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 = {
|
const commandParams = {
|
||||||
sn_code,
|
sn_code,
|
||||||
keyword: keyword || accountConfig.keyword || '',
|
keyword: listKeyword,
|
||||||
platform: platformType,
|
platform: platformType,
|
||||||
pageCount: pageCount || searchConfig.page_count || 3
|
pageCount: pageCount || searchConfig.page_count || 3
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ module.exports = (db) => {
|
|||||||
defaultValue: ''
|
defaultValue: ''
|
||||||
},
|
},
|
||||||
keyword: {
|
keyword: {
|
||||||
comment: '关键词',
|
comment: '搜索/推荐职位关键词;保存投递期望标签时会与 resume_info.deliver_tab_label 同步',
|
||||||
type: Sequelize.STRING(50),
|
type: Sequelize.STRING(50),
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
defaultValue: ''
|
defaultValue: ''
|
||||||
|
|||||||
@@ -486,7 +486,7 @@ class PlaAccountService {
|
|||||||
finalParams.keyword = account.keyword;
|
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') {
|
if (commandTypeSnake === 'get_job_list') {
|
||||||
try {
|
try {
|
||||||
const resume_info = db.getModel('resume_info');
|
const resume_info = db.getModel('resume_info');
|
||||||
@@ -496,7 +496,11 @@ class PlaAccountService {
|
|||||||
attributes: ['deliver_tab_label']
|
attributes: ['deliver_tab_label']
|
||||||
});
|
});
|
||||||
if (resume && resume.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) {
|
} catch (e) {
|
||||||
console.warn('[pla_account_service] 读取 resume_info.deliver_tab_label 失败:', e.message);
|
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
Reference in New Issue
Block a user