From 5529fc060540c0ab63d9a61097658469446ac57d Mon Sep 17 00:00:00 2001 From: chenshaohua <635616957@qq.com> Date: Tue, 2 Jun 2026 11:43:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9es=E6=8C=89=E7=85=A7=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E6=97=B6=E9=97=B4=E5=80=92=E5=8F=99=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=EF=BC=8C=E5=8F=91=E5=B8=83=E6=97=B6=E9=97=B4=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E6=94=BE=E6=9C=80=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/cms/service/impl/ESJobSearchImpl.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ESJobSearchImpl.java b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ESJobSearchImpl.java index 9a69b4d..7b7b3d1 100644 --- a/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ESJobSearchImpl.java +++ b/ruoyi-bussiness/src/main/java/com/ruoyi/cms/service/impl/ESJobSearchImpl.java @@ -24,16 +24,15 @@ import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper; import org.dromara.easyes.core.conditions.update.LambdaEsUpdateWrapper; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.unit.DistanceUnit; +import org.elasticsearch.search.sort.SortBuilders; +import org.elasticsearch.search.sort.SortOrder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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; @@ -573,7 +572,7 @@ public class ESJobSearchImpl implements IESJobSearchService wrapper.and(x->x.le(ESJobDocument::getPostingDate, formattedEndDate)); } if(Objects.nonNull(esJobSearch.getOrder())){ - wrapper.orderByDesc(ESJobDocument::getPostingDate); + wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last")); if(esJobSearch.getOrder()==1){ wrapper.orderByDesc(ESJobDocument::getIsHot); } @@ -582,7 +581,7 @@ public class ESJobSearchImpl implements IESJobSearchService } }else{ //默认按照发布时间倒叙 - wrapper.orderByDesc(ESJobDocument::getPostingDate); + wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last")); } //企业用户排除es去除jobIds boolean isCompanyUser = StringUtil.IS_COMPANY_USER.equals(esJobSearch.getUserType()); @@ -651,7 +650,7 @@ public class ESJobSearchImpl implements IESJobSearchService wrapper.and(a->a.eq(ESJobDocument::getType,jobQuery.getType().trim())); } if(Objects.nonNull(jobQuery.getOrder())){ - wrapper.orderByDesc(ESJobDocument::getPostingDate); + wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last")); if (jobQuery.getOrder()==1){ wrapper.orderByDesc(ESJobDocument::getIsHot); wrapper.orderByDesc(ESJobDocument::getApplyNum); @@ -659,7 +658,7 @@ public class ESJobSearchImpl implements IESJobSearchService } }else{ //默认按照发布时间倒叙 - wrapper.orderByDesc(ESJobDocument::getPostingDate); + wrapper.sort(SortBuilders.fieldSort("postingDate").order(SortOrder.DESC).missing("_last")); } EsPageInfo esJobDocumentEsPageInfo = esJobDocumentMapper.pageQuery(wrapper, pageNum, pageSize); return esJobDocumentEsPageInfo;