修改5
This commit is contained in:
@@ -62,17 +62,23 @@ class MatchService
|
||||
// 3. 计算匹配度
|
||||
$results = [];
|
||||
foreach ($filteredPositions as $position) {
|
||||
$score = $this->calculateMatchScore($position, $resume);
|
||||
|
||||
if ($filterZero && $score == 0) {
|
||||
continue; // 过滤0分岗位
|
||||
try {
|
||||
$score = $this->calculateMatchScore($position, $resume);
|
||||
|
||||
if ($filterZero && $score == 0) {
|
||||
continue; // 过滤0分岗位
|
||||
}
|
||||
|
||||
$results[] = [
|
||||
'position_id' => $position['id'],
|
||||
'match_score' => $score,
|
||||
'position' => $position
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
// 如果计算出错,记录错误但继续处理其他岗位
|
||||
error_log("计算匹配度失败 - 岗位ID: {$position['id']}, 错误: " . $e->getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
$results[] = [
|
||||
'position_id' => $position['id'],
|
||||
'match_score' => $score,
|
||||
'position' => $position
|
||||
];
|
||||
}
|
||||
|
||||
// 4. 按匹配度降序排序
|
||||
@@ -291,8 +297,9 @@ class MatchService
|
||||
}
|
||||
|
||||
// 3. 年龄要求(硬性)
|
||||
if (!empty($positionRequire['年龄要求'])) {
|
||||
$ageCheck = $this->checkAge($positionRequire['年龄要求'], $resume);
|
||||
$ageRequire = $positionRequire['年龄要求'] ?? '';
|
||||
if (!empty($ageRequire) && trim($ageRequire) !== '' && trim($ageRequire) !== '无' && trim($ageRequire) !== '不限制') {
|
||||
$ageCheck = $this->checkAge($ageRequire, $resume);
|
||||
$result['details']['年龄要求'] = $ageCheck;
|
||||
if (!$ageCheck['passed']) {
|
||||
$result['passed'] = false;
|
||||
@@ -313,9 +320,10 @@ class MatchService
|
||||
}
|
||||
|
||||
// 5. 性别要求(硬性,如果明确要求)
|
||||
$otherConditions = $positionRequire['其他资格条件'] ?? '';
|
||||
if (preg_match('/适合(男|女)性/u', $otherConditions, $matches)) {
|
||||
$genderCheck = $this->checkGender($matches[1], $resume);
|
||||
// 优先检查 sex_require 字段
|
||||
$sexRequire = $positionRequire['性别要求'] ?? '';
|
||||
if (!empty($sexRequire) && $sexRequire !== '不限制' && $sexRequire !== '无') {
|
||||
$genderCheck = $this->checkGender($sexRequire, $resume);
|
||||
$result['details']['性别要求'] = $genderCheck;
|
||||
if (!$genderCheck['passed']) {
|
||||
$result['passed'] = false;
|
||||
@@ -323,6 +331,19 @@ class MatchService
|
||||
}
|
||||
}
|
||||
|
||||
// 如果 sex_require 字段没有明确要求,再检查其他资格条件
|
||||
if (empty($sexRequire) || $sexRequire === '不限制' || $sexRequire === '无') {
|
||||
$otherConditions = $positionRequire['其他资格条件'] ?? '';
|
||||
if (preg_match('/适合(男|女)性/u', $otherConditions, $matches)) {
|
||||
$genderCheck = $this->checkGender($matches[1], $resume);
|
||||
$result['details']['性别要求'] = $genderCheck;
|
||||
if (!$genderCheck['passed']) {
|
||||
$result['passed'] = false;
|
||||
$result['rejection_reasons'][] = $genderCheck['reason'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user