雷达图兜底处理
This commit is contained in:
@@ -253,11 +253,13 @@ public class JobCollectionServiceImpl extends ServiceImpl<JobCollectionMapper,Jo
|
||||
|
||||
// 3. 薪资匹配(用户期望 <= 岗位最大薪资,且不低于最小太多)
|
||||
Integer userMinSalary = parseSalary(user.getSalaryMin());
|
||||
if (userMinSalary != null && userMinSalary <= job.getMaxSalary()) {
|
||||
if (userMinSalary >= job.getMinSalary()) {
|
||||
matchScore += 1;
|
||||
} else if (userMinSalary >= job.getMinSalary() * 0.8) {
|
||||
matchScore += 0.5;
|
||||
if (userMinSalary != null && job.getMaxSalary() != null && job.getMinSalary() != null) {
|
||||
if (userMinSalary <= job.getMaxSalary()) {
|
||||
if (userMinSalary >= job.getMinSalary()) {
|
||||
matchScore += 1;
|
||||
} else if (userMinSalary >= job.getMinSalary() * 0.8) {
|
||||
matchScore += 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,14 +280,18 @@ public class JobCollectionServiceImpl extends ServiceImpl<JobCollectionMapper,Jo
|
||||
}
|
||||
|
||||
// 6. 技能/岗位匹配(简化:期望岗位是否包含该岗位关键词)
|
||||
boolean jobMatch = user.getJobTitle() != null &&
|
||||
user.getJobTitle().stream().anyMatch(title -> title.contains(job.getJobTitle()) || job.getJobTitle().contains(title));
|
||||
String jobTitleStr = job.getJobTitle();
|
||||
List<String> userJobTitles = user.getJobTitle();
|
||||
boolean jobMatch = jobTitleStr != null && userJobTitles != null && !userJobTitles.isEmpty() &&
|
||||
userJobTitles.stream().anyMatch(title -> title != null &&
|
||||
(title.contains(jobTitleStr) || jobTitleStr.contains(title)));
|
||||
if (jobMatch) {
|
||||
matchScore += 1;
|
||||
}
|
||||
|
||||
// 匹配度:0-6 → 映射为 0-100 分
|
||||
// 匹配度:0-6 → 映射为 0-100 分,兜底最低10分
|
||||
int finalScore = (int) Math.round((matchScore / (double) totalFactors) * 100);
|
||||
finalScore = Math.max(finalScore, 10); // 兜底最低10分
|
||||
userScores.add(new UserCompetitiveness(user, finalScore));
|
||||
}
|
||||
|
||||
@@ -295,12 +301,12 @@ public class JobCollectionServiceImpl extends ServiceImpl<JobCollectionMapper,Jo
|
||||
// ================== 计算雷达图数据(取平均值)==================
|
||||
RadarChart radarChart = new RadarChart();
|
||||
|
||||
double avgAgeScore = userScores.stream().mapToInt(u -> getAgeScore(DateUtils.stringToDateWithYmd(u.getUser().getBirthDate(),DateUtils.YYYY_MM_DD))).average().orElse(0);
|
||||
double avgExperienceScore = userScores.stream().mapToInt(u -> getExperienceScore(u.getUser().getExperience(), job.getExperience(), experienceRank)).average().orElse(0);
|
||||
double avgEducationScore = userScores.stream().mapToInt(u -> getEducationScore(u.getUser().getEducation(), job.getEducation(), educationRank)).average().orElse(0);
|
||||
double avgSkillScore = userScores.stream().mapToInt(u -> getSkillScore(u.getUser(), job)).average().orElse(0);
|
||||
double avgSalaryScore = userScores.stream().mapToInt(u -> getSalaryScore(u.getUser(), job)).average().orElse(0);
|
||||
double avgLocationScore = userScores.stream().mapToInt(u -> getLocationScore(u.getUser(), job)).average().orElse(0);
|
||||
double avgAgeScore = userScores.stream().mapToInt(u -> getAgeScore(DateUtils.stringToDateWithYmd(u.getUser().getBirthDate(),DateUtils.YYYY_MM_DD))).average().orElse(60);
|
||||
double avgExperienceScore = userScores.stream().mapToInt(u -> getExperienceScore(u.getUser().getExperience(), job.getExperience(), experienceRank)).average().orElse(60);
|
||||
double avgEducationScore = userScores.stream().mapToInt(u -> getEducationScore(u.getUser().getEducation(), job.getEducation(), educationRank)).average().orElse(60);
|
||||
double avgSkillScore = userScores.stream().mapToInt(u -> getSkillScore(u.getUser(), job)).average().orElse(60);
|
||||
double avgSalaryScore = userScores.stream().mapToInt(u -> getSalaryScore(u.getUser(), job)).average().orElse(60);
|
||||
double avgLocationScore = userScores.stream().mapToInt(u -> getLocationScore(u.getUser(), job)).average().orElse(60);
|
||||
|
||||
radarChart.setAge((int) avgAgeScore);
|
||||
radarChart.setExperience((int) avgExperienceScore);
|
||||
@@ -313,8 +319,8 @@ public class JobCollectionServiceImpl extends ServiceImpl<JobCollectionMapper,Jo
|
||||
CompetitivenessResponse response = new CompetitivenessResponse();
|
||||
response.setTotalApplicants(Math.toIntExact(applyCount));
|
||||
|
||||
// Top 用户的匹配分
|
||||
int topMatchScore = userScores.get(0).getScore();
|
||||
// Top 用户的匹配分(兜底处理)
|
||||
int topMatchScore = userScores.isEmpty() ? 10 : userScores.get(0).getScore();
|
||||
response.setMatchScore(topMatchScore);
|
||||
|
||||
// 排名(Top1)
|
||||
@@ -367,7 +373,8 @@ public class JobCollectionServiceImpl extends ServiceImpl<JobCollectionMapper,Jo
|
||||
private int getLocationScore(AppUser user, Job job) {
|
||||
String area = user.getArea();
|
||||
String loc = job.getJobLocation();
|
||||
if (area != null && (area.contains(loc) || loc.contains(area))) return 90;
|
||||
if (area == null || loc == null) return 60; // 兜底
|
||||
if (area.contains(loc) || loc.contains(area)) return 90;
|
||||
return 60;
|
||||
}
|
||||
private int getSkillScore(AppUser user, Job job) {
|
||||
|
||||
Reference in New Issue
Block a user