This commit is contained in:
张成
2026-02-28 13:51:17 +08:00
parent 58c9d64e55
commit 0483d6d023
7 changed files with 76 additions and 234 deletions

View File

@@ -655,71 +655,6 @@ class JobFilterService {
return null;
}
/**
* 过滤职位列表(基于文本匹配)
* @param {Array} jobs - 职位列表
* @param {object} filterRules - 过滤规则
* @param {object} resumeInfo - 简历信息(可选)
* @param {number} jobTypeId - 职位类型ID可选
* @param {object} options - 选项
* @param {boolean} options.autoSave - 是否自动保存评分结果到数据库默认false
* @returns {Promise<Array>} 过滤后的职位列表(带匹配分数)
*/
async filterJobs(jobs, filterRules = {}, resumeInfo = {}, jobTypeId = null, options = {}) {
const {
minScore = 60, // 最低匹配分数
excludeOutsourcing = true, // 是否排除外包
excludeKeywords = [] // 额外排除关键词
} = filterRules;
const { autoSave = false } = options;
// 获取职位类型配置
const { excludeKeywords: typeExcludeKeywords } = await this.getJobTypeConfig(jobTypeId);
const allExcludeKeywords = [...typeExcludeKeywords, ...excludeKeywords];
const results = [];
for (const job of jobs) {
const jobData = job.toJSON ? job.toJSON() : job;
// 分析匹配度(如果 autoSave 为 true 且 job 有 id则自动保存
const analysisOptions = autoSave && jobData.id ? {
jobPostingId: jobData.id,
autoSave: true
} : {};
const analysis = await this.analyzeJobMatch(jobData, resumeInfo, jobTypeId, analysisOptions);
results.push({
...jobData,
matchScore: analysis.overallScore,
matchAnalysis: analysis
});
}
return results
.filter(job => {
// 1. 最低分数过滤
if (job.matchScore < minScore) {
return false;
}
// 2. 外包过滤
if (excludeOutsourcing && job.matchAnalysis.isOutsourcing) {
return false;
}
// 3. 排除关键词过滤
const jobText = this.buildJobText(job);
if (allExcludeKeywords.some(kw => jobText.includes(kw.toLowerCase()))) {
return false;
}
return true;
})
.sort((a, b) => b.matchScore - a.matchScore); // 按匹配分数降序排序
}
/**
* 根据自定义权重配置计算职位评分
* @param {Object} jobData - 职位数据