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