修改去掉推荐注释的放宽条件

This commit is contained in:
sh
2026-07-17 20:18:45 +08:00
parent a2b0c27963
commit 163bbabcea

View File

@@ -264,50 +264,50 @@ public class ESJobSearchImpl implements IESJobSearchService
List<ESJobDocument> esJobDocuments = esJobDocumentMapper.selectList(wrapper); List<ESJobDocument> esJobDocuments = esJobDocumentMapper.selectList(wrapper);
// if (!isCompanyUser &&esJobDocuments.size() < esJobSearch.getPageSize()) { if (!isCompanyUser &&esJobDocuments.size() < esJobSearch.getPageSize()) {
// // 定义要逐步放宽的搜索条件字段 // 定义要逐步放宽的搜索条件字段
// List<Runnable> relaxConditions = new ArrayList<>(); List<Runnable> relaxConditions = new ArrayList<>();
// relaxConditions.add(() -> newSearch.setArea(null)); relaxConditions.add(() -> newSearch.setArea(null));
// relaxConditions.add(() -> newSearch.setExperience(null)); relaxConditions.add(() -> newSearch.setExperience(null));
// relaxConditions.add(() -> newSearch.setMaxSalary(null)); relaxConditions.add(() -> newSearch.setMaxSalary(null));
// relaxConditions.add(() -> newSearch.setMinSalary(null)); relaxConditions.add(() -> newSearch.setMinSalary(null));
// relaxConditions.add(() -> newSearch.setEducation(null)); relaxConditions.add(() -> newSearch.setEducation(null));
// relaxConditions.add(()-> newSearch.setJobTitle(null)); relaxConditions.add(()-> newSearch.setJobTitle(null));
// // 保存所有查询到的文档 // 保存所有查询到的文档
// List<ESJobDocument> allDocuments = new ArrayList<>(esJobDocuments); List<ESJobDocument> allDocuments = new ArrayList<>(esJobDocuments);
//
// // 记录已经放宽的条件数量 // 记录已经放宽的条件数量
// int relaxedConditions = 0; int relaxedConditions = 0;
//
// // 继续放宽条件直到满足分页或所有条件都已放宽 // 继续放宽条件直到满足分页或所有条件都已放宽
// while (allDocuments.size() < esJobSearch.getPageSize() while (allDocuments.size() < esJobSearch.getPageSize()
// && relaxedConditions < relaxConditions.size()) { && relaxedConditions < relaxConditions.size()) {
// // 放宽下一个条件 // 放宽下一个条件
// relaxConditions.get(relaxedConditions).run(); relaxConditions.get(relaxedConditions).run();
// relaxedConditions++; relaxedConditions++;
//
// // 查询新增的文档(不包含之前已经查询到的) // 查询新增的文档(不包含之前已经查询到的)
// wrapper = getWrapper(newSearch, jobIds); wrapper = getWrapper(newSearch, jobIds);
// wrapper.limit(esJobSearch.getPageSize() - allDocuments.size()); wrapper.limit(esJobSearch.getPageSize() - allDocuments.size());
// if (!allDocuments.isEmpty()) { if (!allDocuments.isEmpty()) {
// // 排除已经查询到的文档ID // 排除已经查询到的文档ID
// Set<String> existingIds = allDocuments.stream() Set<String> existingIds = allDocuments.stream()
// .map(ESJobDocument::getId) .map(ESJobDocument::getId)
// .collect(Collectors.toSet()); .collect(Collectors.toSet());
// wrapper.not().in(ESJobDocument::getId, existingIds); wrapper.not().in(ESJobDocument::getId, existingIds);
// } }
//
// List<ESJobDocument> newDocuments = esJobDocumentMapper.selectList(wrapper); List<ESJobDocument> newDocuments = esJobDocumentMapper.selectList(wrapper);
// allDocuments.addAll(newDocuments); allDocuments.addAll(newDocuments);
// } }
//
// // 如果总数超过分页大小,截取所需数量 // 如果总数超过分页大小,截取所需数量
// if (allDocuments.size() > esJobSearch.getPageSize()) { if (allDocuments.size() > esJobSearch.getPageSize()) {
// esJobDocuments = allDocuments.subList(0, esJobSearch.getPageSize()); esJobDocuments = allDocuments.subList(0, esJobSearch.getPageSize());
// } else { } else {
// esJobDocuments = allDocuments; esJobDocuments = allDocuments;
// } }
// } }
return esJobDocuments; return esJobDocuments;
} }
@@ -926,50 +926,50 @@ public class ESJobSearchImpl implements IESJobSearchService
wrapper.limit(esJobSearch.getPageSize()); wrapper.limit(esJobSearch.getPageSize());
List<ESJobDocument> esJobDocuments = esJobDocumentMapper.selectList(wrapper); List<ESJobDocument> esJobDocuments = esJobDocumentMapper.selectList(wrapper);
// if (esJobDocuments.size() < esJobSearch.getPageSize()) { if (esJobDocuments.size() < esJobSearch.getPageSize()) {
// // 定义要逐步放宽的搜索条件字段 // 定义要逐步放宽的搜索条件字段
// List<Runnable> relaxConditions = new ArrayList<>(); List<Runnable> relaxConditions = new ArrayList<>();
// relaxConditions.add(() -> newSearch.setArea(null)); relaxConditions.add(() -> newSearch.setArea(null));
// relaxConditions.add(() -> newSearch.setExperience(null)); relaxConditions.add(() -> newSearch.setExperience(null));
// relaxConditions.add(() -> newSearch.setMaxSalary(null)); relaxConditions.add(() -> newSearch.setMaxSalary(null));
// relaxConditions.add(() -> newSearch.setMinSalary(null)); relaxConditions.add(() -> newSearch.setMinSalary(null));
// relaxConditions.add(() -> newSearch.setEducation(null)); relaxConditions.add(() -> newSearch.setEducation(null));
// relaxConditions.add(()-> newSearch.setJobTitle(null)); relaxConditions.add(()-> newSearch.setJobTitle(null));
// // 保存所有查询到的文档 // 保存所有查询到的文档
// List<ESJobDocument> allDocuments = new ArrayList<>(esJobDocuments); List<ESJobDocument> allDocuments = new ArrayList<>(esJobDocuments);
//
// // 记录已经放宽的条件数量 // 记录已经放宽的条件数量
// int relaxedConditions = 0; int relaxedConditions = 0;
//
// // 继续放宽条件直到满足分页或所有条件都已放宽 // 继续放宽条件直到满足分页或所有条件都已放宽
// while (allDocuments.size() < esJobSearch.getPageSize() while (allDocuments.size() < esJobSearch.getPageSize()
// && relaxedConditions < relaxConditions.size()) { && relaxedConditions < relaxConditions.size()) {
// // 放宽下一个条件 // 放宽下一个条件
// relaxConditions.get(relaxedConditions).run(); relaxConditions.get(relaxedConditions).run();
// relaxedConditions++; relaxedConditions++;
//
// // 查询新增的文档(不包含之前已经查询到的) // 查询新增的文档(不包含之前已经查询到的)
// wrapper = getWrapper(newSearch, jobIds); wrapper = getWrapper(newSearch, jobIds);
// wrapper.limit(esJobSearch.getPageSize() - allDocuments.size()); wrapper.limit(esJobSearch.getPageSize() - allDocuments.size());
// if (!allDocuments.isEmpty()) { if (!allDocuments.isEmpty()) {
// // 排除已经查询到的文档ID // 排除已经查询到的文档ID
// Set<String> existingIds = allDocuments.stream() Set<String> existingIds = allDocuments.stream()
// .map(ESJobDocument::getId) .map(ESJobDocument::getId)
// .collect(Collectors.toSet()); .collect(Collectors.toSet());
// wrapper.not().in(ESJobDocument::getId, existingIds); wrapper.not().in(ESJobDocument::getId, existingIds);
// } }
//
// List<ESJobDocument> newDocuments = esJobDocumentMapper.selectList(wrapper); List<ESJobDocument> newDocuments = esJobDocumentMapper.selectList(wrapper);
// allDocuments.addAll(newDocuments); allDocuments.addAll(newDocuments);
// } }
//
// // 如果总数超过分页大小,截取所需数量 // 如果总数超过分页大小,截取所需数量
// if (allDocuments.size() > esJobSearch.getPageSize()) { if (allDocuments.size() > esJobSearch.getPageSize()) {
// esJobDocuments = allDocuments.subList(0, esJobSearch.getPageSize()); esJobDocuments = allDocuments.subList(0, esJobSearch.getPageSize());
// } else { } else {
// esJobDocuments = allDocuments; esJobDocuments = allDocuments;
// } }
// } }
return esJobDocuments; return esJobDocuments;
} }