更新:1.查询岗位时添加时间段筛选,2.查询岗位不准确的问题。
This commit is contained in:
@@ -30,6 +30,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -505,14 +509,14 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
// 岗位薪资范围与用户期望薪资范围有交集
|
||||
// 条件:岗位最小薪资 <= 用户最大薪资 AND 岗位最大薪资 >= 用户最小薪资
|
||||
if(Objects.nonNull(userMinSalary) && Objects.nonNull(userMaxSalary)){
|
||||
wrapper.and(x->x.le(ESJobDocument::getMinSalary,userMaxSalary)
|
||||
.ge(ESJobDocument::getMaxSalary,userMinSalary));
|
||||
wrapper.and(x->x.le(ESJobDocument::getMaxSalary,userMaxSalary)
|
||||
.ge(ESJobDocument::getMinSalary,userMinSalary));
|
||||
} else if(Objects.nonNull(userMinSalary)){
|
||||
// 只有最小薪资:岗位最大薪资 >= 用户最小薪资
|
||||
wrapper.and(x->x.ge(ESJobDocument::getMaxSalary,userMinSalary));
|
||||
wrapper.and(x->x.ge(ESJobDocument::getMinSalary,userMinSalary));
|
||||
} else if(Objects.nonNull(userMaxSalary)){
|
||||
// 只有最大薪资:岗位最小薪资 <= 用户最大薪资
|
||||
wrapper.and(x->x.le(ESJobDocument::getMinSalary,userMaxSalary));
|
||||
wrapper.and(x->x.le(ESJobDocument::getMaxSalary,userMaxSalary));
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getExperience())){
|
||||
Integer maxValue = StringUtil.findMaxValue(esJobSearch.getExperience());
|
||||
@@ -520,9 +524,7 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getJobCategory())){
|
||||
String targetValue = esJobSearch.getJobCategory();
|
||||
wrapper.and(x -> x.match(ESJobDocument::getJobTitle, targetValue)
|
||||
.or()
|
||||
.match(ESJobDocument::getDescription, targetValue));
|
||||
wrapper.and(x -> x.eq(ESJobDocument::getJobCategory, targetValue));
|
||||
}
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getScale())){
|
||||
Integer maxValue = StringUtil.findMaxValue(esJobSearch.getScale());
|
||||
@@ -559,6 +561,17 @@ public class ESJobSearchImpl implements IESJobSearchService
|
||||
if(!StringUtil.isEmptyOrNull(esJobSearch.getJobLocation())){
|
||||
wrapper.and(x->x.like(ESJobDocument::getJobLocation,esJobSearch.getJobLocation()));
|
||||
}
|
||||
//按时间段来查询数据
|
||||
if(esJobSearch.getStartDate() != null){
|
||||
Date startDateTime = esJobSearch.getStartDate();
|
||||
String formattedStartDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startDateTime);
|
||||
wrapper.and(x->x.ge(ESJobDocument::getPostingDate, formattedStartDate));
|
||||
}
|
||||
if(esJobSearch.getEndDate() != null){
|
||||
Date endDateTime = esJobSearch.getEndDate();
|
||||
String formattedEndDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(endDateTime);
|
||||
wrapper.and(x->x.le(ESJobDocument::getPostingDate, formattedEndDate));
|
||||
}
|
||||
if(Objects.nonNull(esJobSearch.getOrder())){
|
||||
wrapper.orderByDesc(ESJobDocument::getPostingDate);
|
||||
if(esJobSearch.getOrder()==1){
|
||||
|
||||
Reference in New Issue
Block a user