修改es开始时间和截至时间
This commit is contained in:
@@ -34,7 +34,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -605,15 +604,16 @@ public class ESJobSearchImpl implements IESJobSearchService
|
|||||||
wrapper.and(x->x.like(ESJobDocument::getCompanyName,esJobSearch.getCompanyName()));
|
wrapper.and(x->x.like(ESJobDocument::getCompanyName,esJobSearch.getCompanyName()));
|
||||||
}
|
}
|
||||||
//按时间段来查询数据
|
//按时间段来查询数据
|
||||||
if(esJobSearch.getStartDate() != null){
|
Date startDate = esJobSearch.getStartDate();
|
||||||
Date startDateTime = esJobSearch.getStartDate();
|
Date endDate = esJobSearch.getEndDate();
|
||||||
String formattedStartDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startDateTime);
|
if (Objects.nonNull(startDate) && Objects.nonNull(endDate)) {
|
||||||
wrapper.and(x->x.ge(ESJobDocument::getPostingDate, formattedStartDate));
|
String startStr = DateUtils.ES_DATE_FORMATTER.format(startDate.toInstant());
|
||||||
}
|
String endStr = DateUtils.ES_DATE_FORMATTER.format(endDate.toInstant());
|
||||||
if(esJobSearch.getEndDate() != null){
|
wrapper.between(ESJobDocument::getPostingDate, startStr, endStr);
|
||||||
Date endDateTime = esJobSearch.getEndDate();
|
} else if (Objects.nonNull(startDate)) {
|
||||||
String formattedEndDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(endDateTime);
|
wrapper.ge(ESJobDocument::getPostingDate, DateUtils.ES_DATE_FORMATTER.format(startDate.toInstant()));
|
||||||
wrapper.and(x->x.le(ESJobDocument::getPostingDate, formattedEndDate));
|
} else if (Objects.nonNull(endDate)) {
|
||||||
|
wrapper.le(ESJobDocument::getPostingDate, DateUtils.ES_DATE_FORMATTER.format(endDate.toInstant()));
|
||||||
}
|
}
|
||||||
// 先开启打分、优先按匹配分数排序(关键词前台命中越高越靠前)
|
// 先开启打分、优先按匹配分数排序(关键词前台命中越高越靠前)
|
||||||
wrapper.trackScores();
|
wrapper.trackScores();
|
||||||
@@ -721,8 +721,9 @@ public class ESJobSearchImpl implements IESJobSearchService
|
|||||||
Date startDate = jobQuery.getStartDate();
|
Date startDate = jobQuery.getStartDate();
|
||||||
Date endDate = jobQuery.getEndDate();
|
Date endDate = jobQuery.getEndDate();
|
||||||
if (Objects.nonNull(startDate) && Objects.nonNull(endDate)) {
|
if (Objects.nonNull(startDate) && Objects.nonNull(endDate)) {
|
||||||
wrapper.and(w -> w.ge(ESJobDocument::getPostingDate, DateUtils.ES_DATE_FORMATTER.format(startDate.toInstant()))
|
String startStr = DateUtils.ES_DATE_FORMATTER.format(startDate.toInstant());
|
||||||
.le(ESJobDocument::getPostingDate, DateUtils.ES_DATE_FORMATTER.format(endDate.toInstant())));
|
String endStr = DateUtils.ES_DATE_FORMATTER.format(endDate.toInstant());
|
||||||
|
wrapper.between(ESJobDocument::getPostingDate, startStr, endStr);
|
||||||
} else if (Objects.nonNull(startDate)) {
|
} else if (Objects.nonNull(startDate)) {
|
||||||
wrapper.ge(ESJobDocument::getPostingDate, DateUtils.ES_DATE_FORMATTER.format(startDate.toInstant()));
|
wrapper.ge(ESJobDocument::getPostingDate, DateUtils.ES_DATE_FORMATTER.format(startDate.toInstant()));
|
||||||
} else if (Objects.nonNull(endDate)) {
|
} else if (Objects.nonNull(endDate)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user