标题检索变更
This commit is contained in:
+63
-18
@@ -116,6 +116,9 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
public static final String YYYY_MM_DD = "yyyy-MM-dd";
|
||||
public static final String IMPLEMENTATION_DATE = "implementation_date";
|
||||
|
||||
public static final String SPAN_CLASS = "<span class='highlight-Es-class'>";
|
||||
public static final String SPAN = "</span>";
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@@ -140,7 +143,15 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
@NotNull
|
||||
private QueryWrapper<LawsHomeNormalSearchDTO> getQueryWrapperNormal(LawsHomeNormalSearchDTO lawsHomeNormalSearchDTO) {
|
||||
QueryWrapper<LawsHomeNormalSearchDTO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.gt("instr(standard_name,'" + lawsHomeNormalSearchDTO.getSearchContent() + "')", 0);
|
||||
String[] searchContent = lawsHomeNormalSearchDTO.getSearchContent().split(" ");
|
||||
queryWrapper.and(s->{
|
||||
for (int i = 0; i < searchContent.length; i++) {
|
||||
s.gt("instr(standard_name,'" + searchContent[i] + "')", 0);
|
||||
if(i != searchContent.length - 1){
|
||||
s.or();
|
||||
}
|
||||
}
|
||||
});
|
||||
queryWrapper.eq(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getResourceType()),RESOURCE_TYPE,lawsHomeNormalSearchDTO.getResourceType());
|
||||
String str = "',','))";
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardClass()),"instr(concat(',',standard_class,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardClass() + str,0);
|
||||
@@ -162,8 +173,6 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
if(CollectionUtils.isEmpty(pageList.getRecords())) {
|
||||
return;
|
||||
}
|
||||
|
||||
String searchContentSpan = "<span class='highlight-Es-class'>" + searchContent + "</span>";
|
||||
List<LawsHomeNormalSearchVO> list = pageList.getRecords();
|
||||
List<String> lawsDomesticStandardIds = new ArrayList<>();
|
||||
List<String> lawsOverseasStandardIds = new ArrayList<>();
|
||||
@@ -194,16 +203,16 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
list.parallelStream().forEach(p->{
|
||||
switch (p.getResourceType()){
|
||||
case LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD:
|
||||
addLawsDomesticStandard(searchContent, searchContentSpan, listLawsDomesticStandard, listLawsTag, p);
|
||||
addLawsDomesticStandard(searchContent, listLawsDomesticStandard, listLawsTag, p);
|
||||
break;
|
||||
case LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD:
|
||||
addLawsOverseasStandard(searchContent, searchContentSpan, listLawsOverseasStandard, listLawsTag, p);
|
||||
addLawsOverseasStandard(searchContent, listLawsOverseasStandard, listLawsTag, p);
|
||||
break;
|
||||
case LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD:
|
||||
addLawsEnterpriseStandard(searchContent, searchContentSpan, listLawsEnterpriseStandard, listLawsTag, p);
|
||||
addLawsEnterpriseStandard(searchContent, listLawsEnterpriseStandard, listLawsTag, p);
|
||||
break;
|
||||
default:
|
||||
addLawsNewsFeed(searchContent, searchContentSpan, listLawsNewsFeed, p);
|
||||
addLawsNewsFeed(searchContent, listLawsNewsFeed, p);
|
||||
break;
|
||||
}
|
||||
});
|
||||
@@ -226,12 +235,19 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
return listSysDict;
|
||||
}
|
||||
|
||||
private void addLawsNewsFeed(String searchContent, String searchContentSpan, List<LawsNewsFeed> listLawsNewsFeed, LawsHomeNormalSearchVO p) {
|
||||
private void addLawsNewsFeed(String searchContent, List<LawsNewsFeed> listLawsNewsFeed, LawsHomeNormalSearchVO p) {
|
||||
if(!CollectionUtils.isEmpty(listLawsNewsFeed)){
|
||||
Optional<LawsNewsFeed> op = listLawsNewsFeed.stream().filter(o-> Objects.equals(o.getId(),p.getId())).findFirst();
|
||||
if(op.isPresent()){
|
||||
LawsNewsFeed obj = op.get();
|
||||
p.setTitle(obj.getDynamicHeading().replace(searchContent,searchContentSpan));
|
||||
String[] text = searchContent.split(" ");
|
||||
String content = obj.getDynamicHeading();
|
||||
for (int i = 0; i < text.length; i++) {
|
||||
String searchContentSpan = SPAN_CLASS + text[i] + SPAN;
|
||||
content = content.replace(text[i],searchContentSpan);
|
||||
|
||||
}
|
||||
p.setTitle(content);
|
||||
p.setReleaseDate(obj.getReleaseTime());
|
||||
// 生成正文
|
||||
p.setContent(obj.getDynamicDetails());
|
||||
@@ -239,12 +255,19 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
}
|
||||
}
|
||||
|
||||
private void addLawsEnterpriseStandard(String searchContent, String searchContentSpan, List<LawsEnterpriseStandard> listLawsEnterpriseStandard, List<LawsTag> listLawsTag, LawsHomeNormalSearchVO p) {
|
||||
private void addLawsEnterpriseStandard(String searchContent, List<LawsEnterpriseStandard> listLawsEnterpriseStandard, List<LawsTag> listLawsTag, LawsHomeNormalSearchVO p) {
|
||||
if(!CollectionUtils.isEmpty(listLawsEnterpriseStandard)){
|
||||
Optional<LawsEnterpriseStandard> op = listLawsEnterpriseStandard.stream().filter(o-> Objects.equals(o.getId(),p.getId())).findFirst();
|
||||
if(op.isPresent()){
|
||||
LawsEnterpriseStandard obj = op.get();
|
||||
p.setTitle((obj.getStandardNumber() + " " + obj.getStandardName()).replace(searchContent,searchContentSpan));
|
||||
String[] text = searchContent.split(" ");
|
||||
String content = obj.getStandardNumber() + " " + obj.getStandardName();
|
||||
for (int i = 0; i < text.length; i++) {
|
||||
String searchContentSpan = SPAN_CLASS + text[i] + SPAN;
|
||||
content = content.replace(text[i],searchContentSpan);
|
||||
|
||||
}
|
||||
p.setTitle(content);
|
||||
p.setReleaseDate(obj.getReleaseDate());
|
||||
// 生成正文
|
||||
JSONObject json = JSON.parseObject(JSON.toJSONStringWithDateFormat(obj,YYYY_MM_DD));
|
||||
@@ -253,12 +276,19 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
}
|
||||
}
|
||||
|
||||
private void addLawsOverseasStandard(String searchContent, String searchContentSpan, List<LawsOverseasStandard> listLawsOverseasStandard, List<LawsTag> listLawsTag, LawsHomeNormalSearchVO p) {
|
||||
private void addLawsOverseasStandard(String searchContent, List<LawsOverseasStandard> listLawsOverseasStandard, List<LawsTag> listLawsTag, LawsHomeNormalSearchVO p) {
|
||||
if(!CollectionUtils.isEmpty(listLawsOverseasStandard)){
|
||||
Optional<LawsOverseasStandard> op = listLawsOverseasStandard.stream().filter(o-> Objects.equals(o.getId(),p.getId())).findFirst();
|
||||
if(op.isPresent()){
|
||||
LawsOverseasStandard obj = op.get();
|
||||
p.setTitle((obj.getStandardNumber() + " " + obj.getStandardName()).replace(searchContent,searchContentSpan));
|
||||
String[] text = searchContent.split(" ");
|
||||
String content = obj.getStandardNumber() + " " + obj.getStandardName();
|
||||
for (int i = 0; i < text.length; i++) {
|
||||
String searchContentSpan = SPAN_CLASS + text[i] + SPAN;
|
||||
content = content.replace(text[i],searchContentSpan);
|
||||
|
||||
}
|
||||
p.setTitle(content);
|
||||
p.setReleaseDate(obj.getReleaseDate());
|
||||
// 生成正文
|
||||
JSONObject json = JSON.parseObject(JSON.toJSONStringWithDateFormat(obj,YYYY_MM_DD));
|
||||
@@ -267,12 +297,19 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
}
|
||||
}
|
||||
|
||||
private void addLawsDomesticStandard(String searchContent, String searchContentSpan, List<LawsDomesticStandard> listLawsDomesticStandard, List<LawsTag> listLawsTag, LawsHomeNormalSearchVO p) {
|
||||
private void addLawsDomesticStandard(String searchContent, List<LawsDomesticStandard> listLawsDomesticStandard, List<LawsTag> listLawsTag, LawsHomeNormalSearchVO p) {
|
||||
if(!CollectionUtils.isEmpty(listLawsDomesticStandard)){
|
||||
Optional<LawsDomesticStandard> op = listLawsDomesticStandard.stream().filter(o-> Objects.equals(o.getId(),p.getId())).findFirst();
|
||||
if(op.isPresent()){
|
||||
LawsDomesticStandard obj = op.get();
|
||||
p.setTitle((obj.getStandardNumber() + " " + obj.getStandardName()).replace(searchContent,searchContentSpan));
|
||||
String[] text = searchContent.split(" ");
|
||||
String content = obj.getStandardNumber() + " " + obj.getStandardName();
|
||||
for (int i = 0; i < text.length; i++) {
|
||||
String searchContentSpan = SPAN_CLASS + text[i] + SPAN;
|
||||
content = content.replace(text[i],searchContentSpan);
|
||||
|
||||
}
|
||||
p.setTitle(content);
|
||||
p.setReleaseDate(obj.getReleaseDate());
|
||||
// 生成正文
|
||||
JSONObject json = JSON.parseObject(JSON.toJSONStringWithDateFormat(obj,YYYY_MM_DD));
|
||||
@@ -420,7 +457,15 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
public LawsHomeNormalSearchStatisticsVO getNormalSearchTitleCount(LawsHomeNormalSearchDTO lawsHomeNormalSearchDTO) {
|
||||
String searchContent = checkSearchContent(lawsHomeNormalSearchDTO);
|
||||
QueryWrapper<LawsHomeNormalSearchDTO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.gt("instr(concat_ws(' ',standard_number,standard_name),'" + searchContent + "')", 0);
|
||||
String[] text = searchContent.split(" ");
|
||||
queryWrapper.and(s->{
|
||||
for (int i = 0; i < text.length; i++) {
|
||||
s.gt("instr(concat_ws(' ',standard_number,standard_name),'" + text[i] + "')", 0);
|
||||
if(i != text.length - 1){
|
||||
s.or();
|
||||
}
|
||||
}
|
||||
});
|
||||
queryWrapper.eq("del_flag",0);
|
||||
String str = "',','))";
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardClass()),"instr(concat(',',standard_class,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardClass() + str,0);
|
||||
@@ -741,9 +786,9 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
private void highlight(Map<String, Object> mapHighlight, String key) {
|
||||
Map<String, Object> mapTemp = new HashMap<>();
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("<span class='highlight-Es-class'>");
|
||||
list.add(SPAN_CLASS);
|
||||
List<String> list1 = new ArrayList<>();
|
||||
list1.add("</span>");
|
||||
list1.add(SPAN);
|
||||
mapTemp.put("pre_tags", list);
|
||||
mapTemp.put("post_tags", list1);
|
||||
//高亮字段内容长度,去除html样式标签,统计字数,设置为200
|
||||
|
||||
Reference in New Issue
Block a user