diff --git a/client-api/src/main/java/org/jiayunet/service/JobService.java b/client-api/src/main/java/org/jiayunet/service/JobService.java
index f9bf592..3619438 100644
--- a/client-api/src/main/java/org/jiayunet/service/JobService.java
+++ b/client-api/src/main/java/org/jiayunet/service/JobService.java
@@ -614,7 +614,7 @@ public class JobService {
/**
* 求职助手岗位推荐
- *
1. 查求职意向构造筛选条件(无意向则不设条件) 2. 排除已推荐的+已投递的 3. 取前35条候选 4. AI精筛返回8-10个
+ * 1. 查求职意向构造筛选条件(无意向则不设条件) 2. 排除已推荐的+已投递的 3. 取2000条候选池 4. 随机取100条 5. AI精筛返回8-10个
*/
public JobAgentRecommendDto recommendJobs(JobAgentRecommendParam param, Long userId) {
StopWatch sw = new StopWatch("recommendJobs");
@@ -627,12 +627,13 @@ public class JobService {
// 2. 构造查询参数
JobQueryParam queryParam = new JobQueryParam();
queryParam.setPageNum(1);
- queryParam.setPageSize(100);
+ queryParam.setPageSize(2000);
if (intention != null) {
queryParam.setCategoryIds(intention.getCategoryIds());
queryParam.setRegionCodes(intention.getRegionCodes());
queryParam.setIndustryIds(intention.getIndustryIds());
queryParam.setEmploymentType(intention.getEmploymentType());
+ queryParam.setRecruitCategory(intention.getRecruitCategory());
}
// 3. 合并排除列表:入参传的 + 已投递/待投递的
@@ -646,7 +647,7 @@ public class JobService {
applications.forEach(a -> excludeIds.add(a.getJobId()));
queryParam.setExcludeJobIds(excludeIds);
- // 4. 查询候选岗位(完整列表数据)
+ // 4. 查询候选池(2000条)
sw.start("查候选岗位");
PageResult candidates = listJobs(queryParam, userId);
sw.stop();
@@ -657,27 +658,34 @@ public class JobService {
return dto;
}
- // 5. 批量查岗位详情(title + description + requirement)
+ // 5. 随机取100条作为AI候选
+ List candidateList = new ArrayList<>(candidates.getList());
+ Collections.shuffle(candidateList);
+ if (candidateList.size() > 100) {
+ candidateList = candidateList.subList(0, 100);
+ }
+
+ // 6. 批量查岗位详情(title + description + requirement)
sw.start("查岗位详情");
- List candidateJobIds = candidates.getList().stream().map(JobDto::getId).collect(Collectors.toList());
+ List candidateJobIds = candidateList.stream().map(JobDto::getId).collect(Collectors.toList());
List jobDetails = jobMapper.selectList(new LambdaQueryWrapper().in(Job::getId, candidateJobIds).select(Job::getId, Job::getTitle, Job::getDescription, Job::getRequirement));
Map jobDetailMap = jobDetails.stream().collect(Collectors.toMap(Job::getId, j -> j));
sw.stop();
- // 6. 构造别名映射(短序号 → 真实ID)和候选岗位映射
+ // 7. 构造别名映射(短序号 → 真实ID)和候选岗位映射
Map aliasToRealId = new HashMap<>();
Map candidateMap = new HashMap<>();
int seq = 1;
- for (JobDto dto : candidates.getList()) {
+ for (JobDto dto : candidateList) {
aliasToRealId.put(seq, dto.getId());
candidateMap.put(dto.getId(), dto);
seq++;
}
- // 7. 构造AI输入(用短序号替代19位雪花ID,减少token消耗)
+ // 8. 构造AI输入(用短序号替代19位雪花ID,减少token消耗)
StringBuilder jobInfo = new StringBuilder();
seq = 1;
- for (JobDto dto : candidates.getList()) {
+ for (JobDto dto : candidateList) {
Job detail = jobDetailMap.get(dto.getId());
jobInfo.append("ID:").append(seq++)
.append("\n标题:").append(dto.getTitle())
@@ -695,7 +703,7 @@ public class JobService {
"只返回JSON,不要其他内容。";
String userMessage = "【用户偏好(仅供参考)】\n" + preferenceInfo + "\n\n【候选岗位】\n" + jobInfo;
- // 8. 调用AI
+ // 9. 调用AI
sw.start("AI调用");
String aiResponse = aiChatAbility.chat("job-recommend", systemPrompt, userMessage);
String json = AiResponseCleanTool.clean(aiResponse);
@@ -703,7 +711,7 @@ public class JobService {
log.info("recommendJobs耗时统计:\n{}", sw.prettyPrint());
- // 9. 解析AI返回,别名映射回真实ID,过滤出选中的岗位
+ // 10. 解析AI返回,别名映射回真实ID,过滤出选中的岗位
try {
JsonNode root = HttpTool.objectMapper.readTree(json);
String summary = root.path("summary").asText("为你精选了合适的岗位");