From 1ef3af98acebc40d86c22ca0c6c02a87e6515a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E5=BC=BA=E5=BC=BA?= <787203167@qq.com> Date: Fri, 2 Sep 2022 16:18:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A6=85=E9=81=93?= =?UTF-8?q?=E5=B7=B2=E7=9F=A5bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jero-web/src/components/search/index.vue | 47 ++++++++++--------- .../views/regulatoryEarlyWarning/index.vue | 44 +++++++++-------- 2 files changed, 50 insertions(+), 41 deletions(-) diff --git a/jero-web/src/components/search/index.vue b/jero-web/src/components/search/index.vue index cf5a34acc..6184eda9e 100644 --- a/jero-web/src/components/search/index.vue +++ b/jero-web/src/components/search/index.vue @@ -191,7 +191,7 @@ searchQuery() { if (this.isDefault) { let startTime = moment(new Date()).format('YYYY-MM-DD') - let endTime = this.haflYear() + let endTime = this.getNowdate() if (this.queryParam['WarnTime'].length == 0) { this.queryParam['WarnTime'] = [startTime, endTime] } @@ -203,7 +203,8 @@ this.queryParam = {} if (this.isDefault) { let startTime = moment(new Date()).format('YYYY-MM-DD') - let endTime = this.haflYear() + let endTime = this.getNowdate() + console.log(endTime) this.queryParam['WarnTime'] = [startTime, endTime] this.queryParam = { ...this.queryParam } } @@ -225,26 +226,30 @@ } }) }, - haflYear() { - // 先获取当前时间 - var curDate = (new Date()).getTime() - // 将半年的时间单位换算成毫秒 - var halfYear = 365 / 2 * 24 * 3600 * 1000 - // 半年前的时间(毫秒单位) - var pastResult = curDate + halfYear - // 日期函数,定义起点为半年前 - var pastDate = new Date(pastResult) - var pastYear = pastDate.getFullYear() - var pastMonth = pastDate.getMonth() + 1 - var pastDay = pastDate.getDate() - if (pastMonth >= 1 && pastMonth <= 9) { - pastMonth = '0' + pastMonth + getNowdate(){ + var date_now = new Date()//获取当前时间 + var year = date_now.getFullYear()//获取当前时间的年份 + var month = date_now.getMonth()//获取当前时间的月份 + var day = date_now.getDate()//获取当前时间的日 + var days = new Date(year,month,0)//将获取到的年月赋值给days + days = days.getDate()//获取当前年月的日 + var year2 = year + var month2 = parseInt(month+7)//获取当前月份的1一个月以后的月份 + if(month2 > 12){ + year2 = parseInt(year2) + 1 + month2 = parseInt(month2) % 12 + }//考虑到12月要是获取一个月以后,就是一月,年份需要加一 ,一年没有13月,所以%12,取得来年1月 + var day2 = day + var days2 = new Date(year2,month2,0) + days2 = days2.getDate() + if(day2>days2){ + day2 = days2 + }//获取了当前年份的日和6个月以后的日,为的就是判断如果前一个月是有31号,后一个月没有,就将一个月以后的日期取到,赋值给day2 + if(month2 < 10){ + month2 = '0' + month2 } - if (pastDay >= 0 && pastDay <= 9) { - pastDay = '0' + pastDay - } - var endDate = pastYear + '-' + pastMonth + '-' + (pastDay + 1) - return endDate + var time = year2 + '-' + month2 + '-' + day2 + return time }, dateChange(item) { this.queryParam[item] = moment(this.queryParam[item]).format('YYYY-MM-DD') diff --git a/jero-web/src/views/regulatoryEarlyWarning/index.vue b/jero-web/src/views/regulatoryEarlyWarning/index.vue index 1629ad194..5920517da 100644 --- a/jero-web/src/views/regulatoryEarlyWarning/index.vue +++ b/jero-web/src/views/regulatoryEarlyWarning/index.vue @@ -273,32 +273,36 @@ }, clearSelected() { let startTime = moment(new Date()).format('YYYY-MM-DD') - let endTime = this.haflYear() + let endTime = this.getNowdate() this.searchParmes['WarnTime'] = [startTime, endTime] this.searchParmes = { ...this.searchParmes } this.pageNo = 1 this.getList() }, - haflYear() { - // 先获取当前时间 - var curDate = (new Date()).getTime() - // 将半年的时间单位换算成毫秒 - var halfYear = 365 / 2 * 24 * 3600 * 1000 - // 半年前的时间(毫秒单位) - var pastResult = curDate + halfYear - // 日期函数,定义起点为半年前 - var pastDate = new Date(pastResult) - var pastYear = pastDate.getFullYear() - var pastMonth = pastDate.getMonth() + 1 - var pastDay = pastDate.getDate() - if (pastMonth >= 1 && pastMonth <= 9) { - pastMonth = '0' + pastMonth + getNowdate(){ + var date_now = new Date()//获取当前时间 + var year = date_now.getFullYear()//获取当前时间的年份 + var month = date_now.getMonth()//获取当前时间的月份 + var day = date_now.getDate()//获取当前时间的日 + var days = new Date(year,month,0)//将获取到的年月赋值给days + days = days.getDate()//获取当前年月的日 + var year2 = year + var month2 = parseInt(month+7)//获取当前月份的1一个月以后的月份 + if(month2 > 12){ + year2 = parseInt(year2) + 1 + month2 = parseInt(month2) % 12 + }//考虑到12月要是获取一个月以后,就是一月,年份需要加一 ,一年没有13月,所以%12,取得来年1月 + var day2 = day + var days2 = new Date(year2,month2,0) + days2 = days2.getDate() + if(day2>days2){ + day2 = days2 + }//获取了当前年份的日和6个月以后的日,为的就是判断如果前一个月是有31号,后一个月没有,就将一个月以后的日期取到,赋值给day2 + if(month2 < 10){ + month2 = '0' + month2 } - if (pastDay >= 0 && pastDay <= 9) { - pastDay = '0' + pastDay - } - var endDate = pastYear + '-' + pastMonth + '-' + (pastDay + 1) - return endDate + var time = year2 + '-' + month2 + '-' + day2 + return time }, pageOnChange(page) { this.pageNo = page From a206eeb968a0c76fc5c445e7b7219dfe9f19f1ed Mon Sep 17 00:00:00 2001 From: liyawei Date: Fri, 2 Sep 2022 16:39:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E4=B8=AD=E5=BF=83-?= =?UTF-8?q?=E5=85=A8=E9=83=A8-=E6=8E=92=E5=BA=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DocumentSearchServiceImpl.java | 27 ++++++++++++++----- .../LawsMonthlyReportSearchServiceImpl.java | 7 +++-- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/DocumentSearchServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/DocumentSearchServiceImpl.java index 7211ba4ba..06b4cfcaa 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/DocumentSearchServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/DocumentSearchServiceImpl.java @@ -555,15 +555,15 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { Map map31 = new HashMap<>(); Map map41 = new HashMap<>(); if("serial_number".equals(field)){ - map31.put("boost",1); + map31.put("boost",10); }else if("title".equals(field)){ - map31.put("boost",1); + map31.put("boost",10); }else if("file_text".equals(field)){ map31.put("boost",0.01); }else if("content".equals(field)){ map31.put("boost",0.01); }else if("file_name".equals(field)){ - map31.put("boost",1); + map31.put("boost",10); } map31.put("value", selectValue); map21.put(field + ".keyword", map31); @@ -575,15 +575,15 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { Map map32 = new HashMap<>(); Map map42 = new HashMap<>(); if("serial_number".equals(field)){ - map32.put("boost",1); + map32.put("boost",10); }else if("title".equals(field)){ - map32.put("boost",1); + map32.put("boost",10); }else if("file_text".equals(field)){ map32.put("boost",0.01); }else if("content".equals(field)){ map32.put("boost",0.01); }else if("file_name".equals(field)){ - map32.put("boost",1); + map32.put("boost",10); } map32.put("query", selectValue); map22.put(field, map32); @@ -593,8 +593,21 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { // match分词匹配查询 // 情况举例:用户可能他知道开头的前缀几个字,知道中间的几个字 Map map23 = new HashMap<>(); + Map map33 = new HashMap<>(); Map map43 = new HashMap<>(); - map23.put(field, selectValue); + if("serial_number".equals(field)){ + map33.put("boost",10); + }else if("title".equals(field)){ + map33.put("boost",10); + }else if("file_text".equals(field)){ + map33.put("boost",0.01); + }else if("content".equals(field)){ + map33.put("boost",0.01); + }else if("file_name".equals(field)){ + map33.put("boost",10); + } + map33.put("query", selectValue); + map23.put(field, map33); map43.put("match", map23); queryMapJson.add(map43); diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/LawsMonthlyReportSearchServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/LawsMonthlyReportSearchServiceImpl.java index 179f3e0b5..960f55799 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/LawsMonthlyReportSearchServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/LawsMonthlyReportSearchServiceImpl.java @@ -251,7 +251,7 @@ public class LawsMonthlyReportSearchServiceImpl implements ILawsMonthlyReportSea if("title".equals(field)){ map31.put("boost",10); }else if("content".equals(field)){ - map31.put("boost",2); + map31.put("boost",0.01); } map31.put("value", selectValue); map21.put(field + ".keyword", map31); @@ -265,7 +265,7 @@ public class LawsMonthlyReportSearchServiceImpl implements ILawsMonthlyReportSea if("title".equals(field)){ map32.put("boost",10); }else if("content".equals(field)){ - map32.put("boost",2); + map32.put("boost",0.01); } map32.put("query", selectValue); map22.put(field, map32); @@ -280,11 +280,10 @@ public class LawsMonthlyReportSearchServiceImpl implements ILawsMonthlyReportSea if("title".equals(field)){ map33.put("boost",10); }else if("content".equals(field)){ - map33.put("boost",2); + map33.put("boost",0.01); } map33.put("query", selectValue); map23.put(field, map33); - map23.put(field, selectValue); map43.put("match", map23); queryMapJson.add(map43); From f95f64736799cb2954fc4ea23cd6fc473e8d5c78 Mon Sep 17 00:00:00 2001 From: liyawei Date: Fri, 2 Sep 2022 16:51:10 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E4=B8=AD=E5=BF=83-?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E7=9F=A5=E8=AF=86=E5=BA=93-=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DocumentSearchServiceImpl.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/DocumentSearchServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/DocumentSearchServiceImpl.java index 06b4cfcaa..8b96ccbf8 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/DocumentSearchServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/searchcenter/service/impl/DocumentSearchServiceImpl.java @@ -1532,7 +1532,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { Map map31 = new HashMap<>(); Map map41 = new HashMap<>(); if("title".equals(field)){ - map31.put("boost",1); + map31.put("boost",10); }else if("content".equals(field)){ map31.put("boost",0.01); } @@ -1546,7 +1546,7 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { Map map32 = new HashMap<>(); Map map42 = new HashMap<>(); if("title".equals(field)){ - map32.put("boost",1); + map32.put("boost",10); }else if("content".equals(field)){ map32.put("boost",0.01); } @@ -1558,8 +1558,15 @@ public class DocumentSearchServiceImpl implements IDocumentSearchService { // match分词匹配查询 // 情况举例:用户可能他知道开头的前缀几个字,知道中间的几个字 Map map23 = new HashMap<>(); + Map map33 = new HashMap<>(); Map map43 = new HashMap<>(); - map23.put(field, selectValue); + if("title".equals(field)){ + map33.put("boost",10); + }else if("content".equals(field)){ + map33.put("boost",0.01); + } + map33.put("query", selectValue); + map23.put(field, map33); map43.put("match", map23); queryMapJson.add(map43);