From 3502be64782391f18ad3e7131a047792f415193c Mon Sep 17 00:00:00 2001 From: chenshaohua <635616957@qq.com> Date: Thu, 18 Jun 2026 13:12:56 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2=E6=8B=9B?= =?UTF-8?q?=E8=81=98=E4=BC=9A=E6=97=A5=E6=9C=9F=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98=202.=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2es=E4=B8=8D?= =?UTF-8?q?=E5=87=BA=E6=9D=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cms/service/impl/ESJobSearchImpl.java | 35 ++++++++++++++----- .../mapper/rc/PublicJobFairMapper.xml | 2 +- 2 files changed, 28 insertions(+), 9 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 92850c0..543ffe8 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 @@ -488,12 +488,33 @@ public class ESJobSearchImpl implements IESJobSearchService private LambdaEsQueryWrapper getWrapper(ESJobSearch esJobSearch,List jobIds){ LambdaEsQueryWrapper wrapper = new LambdaEsQueryWrapper<>(); - if(!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){ + /*if(!StringUtil.isEmptyOrNull(esJobSearch.getJobTitle())){ for (String keyWord:esJobSearch.getJobTitle().split(",")) { wrapper.and(a -> a.match(ESJobDocument::getJobTitle, keyWord, 5.0f) ); } + }*/ + //优化岗位名称查询,只有命中岗位名称或者分类就行 + String titleStr = esJobSearch.getJobTitle(); + String cateStr = esJobSearch.getJobCategory(); + if (!StringUtil.isEmptyOrNull(titleStr) || !StringUtil.isEmptyOrNull(cateStr)) { + wrapper.and(sub -> { + boolean first = true; + sub.or(); + if (!StringUtil.isEmptyOrNull(titleStr)) { + String[] words = titleStr.split(","); + for (String w : words) { + if (!first) sub.or(); + sub.match(ESJobDocument::getJobTitle, w, 5.0f); + first = false; + } + } + if (!StringUtil.isEmptyOrNull(cateStr)) { + if (!first) sub.or(); + sub.eq(ESJobDocument::getJobCategory, cateStr); + } + }); } if(esJobSearch.getLongitude()!=null){ @@ -523,10 +544,10 @@ public class ESJobSearchImpl implements IESJobSearchService Integer maxValue = StringUtil.findMaxValue(esJobSearch.getExperience()); wrapper.and(x->x.eq(ESJobDocument::getExperience_int,maxValue)); } - if(!StringUtil.isEmptyOrNull(esJobSearch.getJobCategory())){ - String targetValue = esJobSearch.getJobCategory(); - wrapper.and(x -> x.eq(ESJobDocument::getJobCategory, targetValue)); - } +// if(!StringUtil.isEmptyOrNull(esJobSearch.getJobCategory())){ +// String targetValue = esJobSearch.getJobCategory(); +// wrapper.and(x -> x.eq(ESJobDocument::getJobCategory, targetValue)); +// } if(!StringUtil.isEmptyOrNull(esJobSearch.getScale())){ Integer maxValue = StringUtil.findMaxValue(esJobSearch.getScale()); wrapper.and(x->x.le(ESJobDocument::getScale,maxValue)); @@ -550,9 +571,6 @@ public class ESJobSearchImpl implements IESJobSearchService if(!StringUtil.isEmptyOrNull(esJobSearch.getCode())){ wrapper.and(x->x.eq(ESJobDocument::getCode,esJobSearch.getCode())); } - if(!StringUtil.isEmptyOrNull(esJobSearch.getType())){ - wrapper.and(x->x.eq(ESJobDocument::getType,esJobSearch.getType())); - } if(esJobSearch.getJobId()!=null){ wrapper.and(x->x.eq(ESJobDocument::getJobId,esJobSearch.getJobId())); } @@ -917,6 +935,7 @@ public class ESJobSearchImpl implements IESJobSearchService relaxConditions.add(() -> newSearch.setMaxSalary(null)); relaxConditions.add(() -> newSearch.setMinSalary(null)); relaxConditions.add(() -> newSearch.setEducation(null)); + relaxConditions.add(()-> newSearch.setJobCategory(null)); relaxConditions.add(()-> newSearch.setJobTitle(null)); // 保存所有查询到的文档 List allDocuments = new ArrayList<>(esJobDocuments); diff --git a/ruoyi-bussiness/src/main/resources/mapper/rc/PublicJobFairMapper.xml b/ruoyi-bussiness/src/main/resources/mapper/rc/PublicJobFairMapper.xml index a04a8ec..c26adbe 100644 --- a/ruoyi-bussiness/src/main/resources/mapper/rc/PublicJobFairMapper.xml +++ b/ruoyi-bussiness/src/main/resources/mapper/rc/PublicJobFairMapper.xml @@ -257,7 +257,7 @@ generate_series( DATE_TRUNC('day', f.job_fair_start_time), DATE_TRUNC('day', f.job_fair_end_time), - '1 day'::interval + make_interval(days => 1) ) AS d(date) WHERE f.del_flag = '0' ORDER BY date