去掉debug
This commit is contained in:
@@ -45,8 +45,6 @@ class MatchService
|
|||||||
// 1. 从数据库获取用户简历信息
|
// 1. 从数据库获取用户简历信息
|
||||||
$resume = $this->getUserResumeFromDb($userId);
|
$resume = $this->getUserResumeFromDb($userId);
|
||||||
if (empty($resume)) {
|
if (empty($resume)) {
|
||||||
// 记录调试信息
|
|
||||||
error_log("获取用户简历失败 - 用户ID: {$userId}");
|
|
||||||
return [
|
return [
|
||||||
'list' => [],
|
'list' => [],
|
||||||
'pagination' => [
|
'pagination' => [
|
||||||
@@ -54,10 +52,6 @@ class MatchService
|
|||||||
'page_size' => $pageSize,
|
'page_size' => $pageSize,
|
||||||
'total' => 0,
|
'total' => 0,
|
||||||
'total_pages' => 0
|
'total_pages' => 0
|
||||||
],
|
|
||||||
'debug' => [
|
|
||||||
'error' => '用户不存在或简历信息为空',
|
|
||||||
'user_id' => $userId
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -65,9 +59,6 @@ class MatchService
|
|||||||
// 2. 从数据库获取所有岗位
|
// 2. 从数据库获取所有岗位
|
||||||
$filteredPositions = $this->filterPositionsFromDb($resume);
|
$filteredPositions = $this->filterPositionsFromDb($resume);
|
||||||
|
|
||||||
// 记录调试信息
|
|
||||||
error_log("获取到岗位数量: " . count($filteredPositions) . ", 用户ID: {$userId}");
|
|
||||||
|
|
||||||
if (empty($filteredPositions)) {
|
if (empty($filteredPositions)) {
|
||||||
return [
|
return [
|
||||||
'list' => [],
|
'list' => [],
|
||||||
@@ -76,51 +67,15 @@ class MatchService
|
|||||||
'page_size' => $pageSize,
|
'page_size' => $pageSize,
|
||||||
'total' => 0,
|
'total' => 0,
|
||||||
'total_pages' => 0
|
'total_pages' => 0
|
||||||
],
|
|
||||||
'debug' => [
|
|
||||||
'error' => '未找到任何岗位',
|
|
||||||
'user_id' => $userId,
|
|
||||||
'positions_count' => 0
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 计算匹配度
|
// 3. 计算匹配度
|
||||||
$results = [];
|
$results = [];
|
||||||
$zeroScoreCount = 0;
|
|
||||||
$firstZeroScoreReason = null; // 记录第一个0分岗位的拒绝原因
|
|
||||||
foreach ($filteredPositions as $position) {
|
foreach ($filteredPositions as $position) {
|
||||||
try {
|
try {
|
||||||
// 检查硬性条件,获取详细的拒绝原因
|
$score = $this->calculateMatchScore($position, $resume);
|
||||||
$hardCheck = $this->checkHardRequirements($position, $resume);
|
|
||||||
$score = 0;
|
|
||||||
$rejectionInfo = null;
|
|
||||||
|
|
||||||
if ($hardCheck['passed']) {
|
|
||||||
// 硬性条件通过,计算软性条件分数
|
|
||||||
$softCheck = $this->calculateSoftRequirements($position, $resume);
|
|
||||||
$score = $softCheck['score'];
|
|
||||||
} else {
|
|
||||||
// 硬性条件不通过,记录拒绝原因
|
|
||||||
$score = 0;
|
|
||||||
$rejectionInfo = [
|
|
||||||
'rejection_reasons' => $hardCheck['rejection_reasons'],
|
|
||||||
'details' => $hardCheck['details']
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($score == 0) {
|
|
||||||
$zeroScoreCount++;
|
|
||||||
// 记录第一个0分岗位的拒绝原因
|
|
||||||
if ($firstZeroScoreReason === null && $rejectionInfo !== null) {
|
|
||||||
$firstZeroScoreReason = [
|
|
||||||
'position_id' => $position['id'] ?? 0,
|
|
||||||
'position_name' => $position['position_name'] ?? $position['name'] ?? '',
|
|
||||||
'rejection_reasons' => $rejectionInfo['rejection_reasons'],
|
|
||||||
'details' => $rejectionInfo['details']
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($filterZero && $score == 0) {
|
if ($filterZero && $score == 0) {
|
||||||
continue; // 过滤0分岗位
|
continue; // 过滤0分岗位
|
||||||
@@ -132,15 +87,11 @@ class MatchService
|
|||||||
'position' => $position
|
'position' => $position
|
||||||
];
|
];
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// 如果计算出错,记录错误但继续处理其他岗位
|
// 如果计算出错,继续处理其他岗位
|
||||||
error_log("计算匹配度失败 - 岗位ID: " . ($position['id'] ?? 'unknown') . ", 错误: " . $e->getMessage());
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 记录调试信息
|
|
||||||
error_log("匹配完成 - 总岗位数: " . count($filteredPositions) . ", 有效结果数: " . count($results) . ", 0分岗位数: {$zeroScoreCount}, filter_zero: " . ($filterZero ? 'true' : 'false'));
|
|
||||||
|
|
||||||
// 4. 按匹配度降序排序
|
// 4. 按匹配度降序排序
|
||||||
usort($results, function($a, $b) {
|
usort($results, function($a, $b) {
|
||||||
return $b['match_score'] - $a['match_score'];
|
return $b['match_score'] - $a['match_score'];
|
||||||
@@ -160,36 +111,6 @@ class MatchService
|
|||||||
'total' => $total,
|
'total' => $total,
|
||||||
'total_pages' => $totalPages,
|
'total_pages' => $totalPages,
|
||||||
'has_more' => $page < $totalPages
|
'has_more' => $page < $totalPages
|
||||||
],
|
|
||||||
'debug' => [
|
|
||||||
'total_positions' => count($filteredPositions),
|
|
||||||
'zero_score_count' => $zeroScoreCount,
|
|
||||||
'filter_zero' => $filterZero,
|
|
||||||
'result_count' => $total,
|
|
||||||
'resume_info' => [
|
|
||||||
'user_id' => $resume['user_id'] ?? 0,
|
|
||||||
'has_education' => !empty($resume['education']),
|
|
||||||
'education_count' => count($resume['education'] ?? []),
|
|
||||||
'birth_date' => $resume['birth_date'] ?? '',
|
|
||||||
'gender' => $resume['gender'] ?? '',
|
|
||||||
'education_details' => array_map(function($edu) {
|
|
||||||
return [
|
|
||||||
'education_level' => $edu['education_level'] ?? '',
|
|
||||||
'degree' => $edu['degree'] ?? '',
|
|
||||||
'majors_name' => $edu['majors_name'] ?? '',
|
|
||||||
'majors_code' => $edu['majors_code'] ?? '',
|
|
||||||
'majors_category' => $edu['majors_category'] ?? '',
|
|
||||||
'school_name' => $edu['school_name'] ?? '',
|
|
||||||
];
|
|
||||||
}, $resume['education'] ?? []),
|
|
||||||
'education_raw' => array_map(function($edu) {
|
|
||||||
// 返回原始数据的前几个字段用于调试(避免数据过大)
|
|
||||||
$raw = $edu['_raw'] ?? [];
|
|
||||||
// 只返回前15个字段
|
|
||||||
return array_slice($raw, 0, 15, true);
|
|
||||||
}, $resume['education'] ?? []),
|
|
||||||
],
|
|
||||||
'first_zero_reason' => $firstZeroScoreReason
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -214,12 +135,11 @@ class MatchService
|
|||||||
try {
|
try {
|
||||||
$user = Db::name('t_user')->where('id', $userId)->find();
|
$user = Db::name('t_user')->where('id', $userId)->find();
|
||||||
} catch (\Exception $e2) {
|
} catch (\Exception $e2) {
|
||||||
error_log("查询用户失败 - 用户ID: {$userId}, 错误: " . $e2->getMessage());
|
// 忽略错误
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($user)) {
|
if (empty($user)) {
|
||||||
error_log("用户不存在 - 用户ID: {$userId}");
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +228,6 @@ class MatchService
|
|||||||
->select()
|
->select()
|
||||||
->toArray();
|
->toArray();
|
||||||
if (!empty($majors)) {
|
if (!empty($majors)) {
|
||||||
error_log("成功从da_majors表查询到 " . count($majors) . " 条专业记录,使用字段: {$queryField}");
|
|
||||||
break; // 找到匹配的字段,退出循环
|
break; // 找到匹配的字段,退出循环
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -326,10 +245,24 @@ class MatchService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 尝试多种可能的名称字段
|
// 尝试多种可能的名称字段
|
||||||
$name = $major['major_name'] ?? $major['name'] ?? $major['title'] ?? $major['专业名称'] ?? '';
|
$name = $major['major_name']
|
||||||
|
?? $major['name']
|
||||||
|
?? $major['title']
|
||||||
|
?? $major['full_name']
|
||||||
|
?? $major['major_full_name']
|
||||||
|
?? $major['专业名称']
|
||||||
|
?? $major['专业名称全称']
|
||||||
|
?? '';
|
||||||
|
|
||||||
// 尝试多种可能的类别字段
|
// 尝试多种可能的类别字段
|
||||||
$category = $major['category_name'] ?? $major['category'] ?? $major['major_category'] ?? $major['专业类别'] ?? $major['学科类别'] ?? '';
|
$category = $major['category_name']
|
||||||
|
?? $major['category']
|
||||||
|
?? $major['category_full']
|
||||||
|
?? $major['major_category']
|
||||||
|
?? $major['major_category_name']
|
||||||
|
?? $major['专业类别']
|
||||||
|
?? $major['学科类别']
|
||||||
|
?? '';
|
||||||
|
|
||||||
$majorCodeMap[$code] = [
|
$majorCodeMap[$code] = [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
@@ -337,12 +270,9 @@ class MatchService
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
error_log("专业代码映射表构建完成,共 " . count($majorCodeMap) . " 条记录");
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
error_log("查询da_majors表失败: " . $e->getMessage());
|
// 忽略错误
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
error_log("未找到专业代码,无法查询da_majors表");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建简历数据结构
|
// 构建简历数据结构
|
||||||
@@ -386,7 +316,6 @@ class MatchService
|
|||||||
$majorName = $majorCodeMap[$codeValue]['name'] ?? '';
|
$majorName = $majorCodeMap[$codeValue]['name'] ?? '';
|
||||||
$education['major_category'] = $majorCodeMap[$codeValue]['category'] ?? '';
|
$education['major_category'] = $majorCodeMap[$codeValue]['category'] ?? '';
|
||||||
if (!empty($majorName)) {
|
if (!empty($majorName)) {
|
||||||
error_log("从majorCodeMap获取到专业名称: {$majorName}, 代码: {$codeValue}");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -411,8 +340,6 @@ class MatchService
|
|||||||
'majors_category' => $education['major_category'] ?? $education['专业类别'] ?? '',
|
'majors_category' => $education['major_category'] ?? $education['专业类别'] ?? '',
|
||||||
'school_name' => $education['school_name'] ?? $education['school'] ?? $education['学校名称'] ?? '',
|
'school_name' => $education['school_name'] ?? $education['school'] ?? $education['学校名称'] ?? '',
|
||||||
'graduation_date' => $education['graduation_date'] ?? $education['毕业时间'] ?? '',
|
'graduation_date' => $education['graduation_date'] ?? $education['毕业时间'] ?? '',
|
||||||
// 保存原始数据用于调试
|
|
||||||
'_raw' => $education
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,15 +365,12 @@ class MatchService
|
|||||||
// 尝试添加deleted_at条件
|
// 尝试添加deleted_at条件
|
||||||
$query->whereNull('deleted_at');
|
$query->whereNull('deleted_at');
|
||||||
$positions = $query->select()->toArray();
|
$positions = $query->select()->toArray();
|
||||||
error_log("从no_notice_position表获取到 " . count($positions) . " 个岗位(已排除deleted_at)");
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// 如果字段不存在或其他错误,查询所有记录
|
// 如果字段不存在或其他错误,查询所有记录
|
||||||
try {
|
try {
|
||||||
$query = Db::name('no_notice_position');
|
$query = Db::name('no_notice_position');
|
||||||
$positions = $query->select()->toArray();
|
$positions = $query->select()->toArray();
|
||||||
error_log("从no_notice_position表获取到 " . count($positions) . " 个岗位(无deleted_at字段)");
|
|
||||||
} catch (\Exception $e2) {
|
} catch (\Exception $e2) {
|
||||||
error_log("查询岗位失败: " . $e2->getMessage());
|
|
||||||
$positions = [];
|
$positions = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user