This commit is contained in:
张成
2026-04-08 13:29:22 +08:00
parent 820e437729
commit ca8bbcd9cd
6 changed files with 164 additions and 17 deletions

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) {