更新:1.查询岗位时添加时间段筛选,2.查询岗位不准确的问题。

This commit is contained in:
chenyanchang
2026-06-01 19:50:00 +08:00
parent 6462112d28
commit e27bc97cf2
3 changed files with 29 additions and 8 deletions

View File

@@ -60,7 +60,7 @@ public class ESJobDocument
@ApiModelProperty("工作地点区县字典代码")
private Integer jobLocationAreaCode;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("发布时间")
private Date postingDate;

View File

@@ -1,10 +1,12 @@
package com.ruoyi.cms.domain.query;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.cms.domain.Job;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
@@ -55,4 +57,10 @@ public class ESJobSearch extends Job
/*** 用户角色app角色0企业1求职者2网格员 3内部政府人员*/
private String userType;
//开始时间
private Date startDate;
//结束时间
private Date endDate;
}

View File

@@ -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){