mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 19:06:49 +08:00
Merge branch 'master' of https://codeup.aliyun.com/648097ddb583fece2f059e59/boe/java-servers into zcwy-dev
This commit is contained in:
@@ -3,10 +3,7 @@ package com.xboe.module.elasticsearc;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -410,6 +407,7 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
|||||||
BoolQueryBuilder keywordQuery = QueryBuilders.boolQuery();
|
BoolQueryBuilder keywordQuery = QueryBuilders.boolQuery();
|
||||||
keywordQuery.should(QueryBuilders.wildcardQuery("name", "*"+words+"*").boost(9f));
|
keywordQuery.should(QueryBuilders.wildcardQuery("name", "*"+words+"*").boost(9f));
|
||||||
keywordQuery.should(QueryBuilders.wildcardQuery("teacher", "*"+words+"*").boost(7f));
|
keywordQuery.should(QueryBuilders.wildcardQuery("teacher", "*"+words+"*").boost(7f));
|
||||||
|
keywordQuery.should(QueryBuilders.wildcardQuery("keywords", "*"+words+"*").boost(9f));
|
||||||
//keywordQuery.should(QueryBuilders.queryStringQuery(words).field("name", 9f));//用此方法无法查询出有转义符的处理
|
//keywordQuery.should(QueryBuilders.queryStringQuery(words).field("name", 9f));//用此方法无法查询出有转义符的处理
|
||||||
//keywordQuery.should(QueryBuilders.queryStringQuery(words).field("teacher", 8f));
|
//keywordQuery.should(QueryBuilders.queryStringQuery(words).field("teacher", 8f));
|
||||||
|
|
||||||
@@ -426,7 +424,7 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
|||||||
//// //其它是教师,教师也是 like查询, 它只是2位权重
|
//// //其它是教师,教师也是 like查询, 它只是2位权重
|
||||||
//// boolQuery.should(QueryBuilders.queryStringQuery(params.getKeywords()).field("teacher", 5f));
|
//// boolQuery.should(QueryBuilders.queryStringQuery(params.getKeywords()).field("teacher", 5f));
|
||||||
//// //关键词查询
|
//// //关键词查询
|
||||||
//// boolQuery.should(QueryBuilders.queryStringQuery(params.getKeywords()).field("keywords", 3f));
|
// boolQuery.should(QueryBuilders.queryStringQuery(params.getKeywords()).field("keywords", 10f));
|
||||||
////
|
////
|
||||||
//// //boolQuery.should(QueryBuilders.fuzzyQuery("keywords",params.getKeywords()).boost(3f));
|
//// //boolQuery.should(QueryBuilders.fuzzyQuery("keywords",params.getKeywords()).boost(3f));
|
||||||
//// //分词查询,权重是1,默念
|
//// //分词查询,权重是1,默念
|
||||||
@@ -437,7 +435,7 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
|||||||
// //其它是教师,教师也是 like查询, 它只是5权重
|
// //其它是教师,教师也是 like查询, 它只是5权重
|
||||||
// //keywordQuery.should(QueryBuilders.queryStringQuery(params.getKeywords()).field("teacher", 5f));
|
// //keywordQuery.should(QueryBuilders.queryStringQuery(params.getKeywords()).field("teacher", 5f));
|
||||||
// //关键词查询 like查询, 它只是3权重
|
// //关键词查询 like查询, 它只是3权重
|
||||||
// //keywordQuery.should(QueryBuilders.queryStringQuery(params.getKeywords()).field("keywords", 3f));
|
// keywordQuery.should(QueryBuilders.queryStringQuery(params.getKeywords()).field("keywords", 3f));
|
||||||
//
|
//
|
||||||
// //boolQuery.should(QueryBuilders.fuzzyQuery("keywords",params.getKeywords()).boost(3f));
|
// //boolQuery.should(QueryBuilders.fuzzyQuery("keywords",params.getKeywords()).boost(3f));
|
||||||
// //分词查询,权重是1,
|
// //分词查询,权重是1,
|
||||||
@@ -613,7 +611,7 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//排序
|
//排序
|
||||||
if(StringUtils.isBlank(paras.getKeywords())) {
|
if(StringUtils.isBlank(paras.getKeywords()) && paras.getOrderType()!=3) {
|
||||||
sourceBuilder.sort("isTop",SortOrder.DESC);
|
sourceBuilder.sort("isTop",SortOrder.DESC);
|
||||||
//sourceBuilder.sort("topTime",SortOrder.DESC);
|
//sourceBuilder.sort("topTime",SortOrder.DESC);
|
||||||
}
|
}
|
||||||
@@ -639,10 +637,10 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
|||||||
HighlightBuilder.Field nameHighlight=new HighlightBuilder.Field("name");
|
HighlightBuilder.Field nameHighlight=new HighlightBuilder.Field("name");
|
||||||
HighlightBuilder.Field summaryHighlight=new HighlightBuilder.Field("summary");
|
HighlightBuilder.Field summaryHighlight=new HighlightBuilder.Field("summary");
|
||||||
HighlightBuilder.Field teacherHighlight=new HighlightBuilder.Field("teacher");
|
HighlightBuilder.Field teacherHighlight=new HighlightBuilder.Field("teacher");
|
||||||
HighlightBuilder.Field keywordsHighlight=new HighlightBuilder.Field("keywords");
|
// HighlightBuilder.Field keywordsHighlight=new HighlightBuilder.Field("keywords");
|
||||||
highlightBuilder.field(nameHighlight);
|
highlightBuilder.field(nameHighlight);
|
||||||
highlightBuilder.field(teacherHighlight);
|
highlightBuilder.field(teacherHighlight);
|
||||||
highlightBuilder.field(keywordsHighlight);
|
// highlightBuilder.field(keywordsHighlight);
|
||||||
highlightBuilder.field(summaryHighlight);
|
highlightBuilder.field(summaryHighlight);
|
||||||
|
|
||||||
|
|
||||||
@@ -665,7 +663,7 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
|||||||
HighlightField name = highlightFields.get("name");
|
HighlightField name = highlightFields.get("name");
|
||||||
HighlightField summary = highlightFields.get("summary");
|
HighlightField summary = highlightFields.get("summary");
|
||||||
HighlightField teacher = highlightFields.get("teacher");
|
HighlightField teacher = highlightFields.get("teacher");
|
||||||
HighlightField keywords = highlightFields.get("keywords");
|
// HighlightField keywords = highlightFields.get("keywords");
|
||||||
String sourceAsString = hit.getSourceAsString();
|
String sourceAsString = hit.getSourceAsString();
|
||||||
try {
|
try {
|
||||||
CourseFullText cft =mapper.readValue(sourceAsString, CourseFullText.class);
|
CourseFullText cft =mapper.readValue(sourceAsString, CourseFullText.class);
|
||||||
@@ -697,15 +695,15 @@ public class CourseElasticsearchImpl implements ICourseFullTextSearch{
|
|||||||
}
|
}
|
||||||
cft.setTeacher(fmtStr.toString());
|
cft.setTeacher(fmtStr.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(keywords!= null){
|
/*if(keywords!= null){
|
||||||
Text[] fragments = keywords.fragments();
|
Text[] fragments = keywords.fragments();
|
||||||
StringBuffer fmtStr = new StringBuffer("");
|
StringBuffer fmtStr = new StringBuffer("");
|
||||||
for (Text fragment : fragments) {
|
for (Text fragment : fragments) {
|
||||||
fmtStr.append(fragment);
|
fmtStr.append(fragment);
|
||||||
}
|
}
|
||||||
cft.setKeywords(fmtStr.toString());
|
cft.setKeywords(fmtStr.toString());
|
||||||
}
|
}*/
|
||||||
list.add(cft);
|
list.add(cft);
|
||||||
}catch(Exception ee) {
|
}catch(Exception ee) {
|
||||||
log.error("转化json到对应失败");
|
log.error("转化json到对应失败");
|
||||||
|
|||||||
@@ -72,10 +72,11 @@ public class CasesRecommendApi extends ApiBaseController {
|
|||||||
PageList<CasesRecommend> page = iCasesRecommendService.page(casesRecommendVo.getPageIndex(), casesRecommendVo.getPageSize(), casesRecommendVo);
|
PageList<CasesRecommend> page = iCasesRecommendService.page(casesRecommendVo.getPageIndex(), casesRecommendVo.getPageSize(), casesRecommendVo);
|
||||||
// 组装查看率
|
// 组装查看率
|
||||||
page.getList().forEach(it -> {
|
page.getList().forEach(it -> {
|
||||||
List<CasesRecommendPushRecord> recordList = iCasesRecommendPushRecordService.findReadByRecommendId(it.getId());
|
List<CasesRecommendPushRecord> recordList = iCasesRecommendPushRecordService.findAllByRecommendId(it.getId());
|
||||||
if (CollectionUtil.isNotEmpty(recordList)) {
|
if (CollectionUtil.isNotEmpty(recordList)) {
|
||||||
|
List<CasesRecommendPushRecord> collect = recordList.stream().filter(casesRecommendPushRecord -> casesRecommendPushRecord.getReadFlag().equals(1)).collect(Collectors.toList());
|
||||||
// 查看率:查看率=案例查看人数(各案例查看人数之合)/(当条推荐记录包含的案例 × 用户数)
|
// 查看率:查看率=案例查看人数(各案例查看人数之合)/(当条推荐记录包含的案例 × 用户数)
|
||||||
it.setViewRate(String.valueOf(recordList.size() * 100 / recordList.size()).concat("%"));
|
it.setViewRate(String.valueOf(collect.size() * 100 / recordList.size()).concat("%"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class AsyncSendCasesRecommendService {
|
|||||||
}
|
}
|
||||||
//修改为推送中
|
//修改为推送中
|
||||||
updateProcessStatus(casesRecommend.getId(), CasesPushStatusEnum.PUSH_ING.getStatus());
|
updateProcessStatus(casesRecommend.getId(), CasesPushStatusEnum.PUSH_ING.getStatus());
|
||||||
List<String> caseIds = casesRecommendPushRecords.stream().map(CasesRecommendPushRecord::getCaseId).collect(Collectors.toList());
|
List<String> caseIds = casesRecommendPushRecords.stream().map(CasesRecommendPushRecord::getCaseId).distinct().collect(Collectors.toList());
|
||||||
if (caseIds.size() > 1) {
|
if (caseIds.size() > 1) {
|
||||||
sendMixCaseRecommend(casesRecommendPushRecords);
|
sendMixCaseRecommend(casesRecommendPushRecords);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ public class CasesRecommendLaunchImportServiceImpl implements ICasesRecommendLau
|
|||||||
if (CollectionUtil.isEmpty(dataList) || dataList.size() < 1) {
|
if (CollectionUtil.isEmpty(dataList) || dataList.size() < 1) {
|
||||||
throw new RuntimeException("导入数据为空");
|
throw new RuntimeException("导入数据为空");
|
||||||
}
|
}
|
||||||
|
String title = dataList.get(0).get(0).toString();
|
||||||
|
if (!"标题".equals(title.trim())) {
|
||||||
|
throw new RuntimeException("导入模版错误");
|
||||||
|
}
|
||||||
int totalNum = dataList.size() - 1;
|
int totalNum = dataList.size() - 1;
|
||||||
int successNum = 0;
|
int successNum = 0;
|
||||||
int failNum = 0;
|
int failNum = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user