一般检索(全文)添加

This commit is contained in:
梁琦涛
2023-11-20 19:05:51 +08:00
parent 6436a790e5
commit 728d056076
3 changed files with 60 additions and 43 deletions
@@ -39,5 +39,18 @@ public class LawsHomeSearchCommon {
*/
public static final String LAWS_ES_DELETE = "3";
/**
* 国内标准 表名
*/
public static final String LAWS_DOMESTIC_STANDARD_TABLE_NAME = "laws_domestic_standard";
/**
* 海外标准 表名
*/
public static final String LAWS_OVERSEAS_STANDARD_TABLE_NAME = "laws_overseas_standard";
/**
* 企业标准 表名
*/
public static final String LAWS_ENTERPRISE_STANDARD_TABLE_NAME = "laws_enterprise_standard";
}
@@ -86,10 +86,6 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
@Resource
private ISysBaseAPI sysBaseAPI;
@Resource
private ISysUserService sysUserService;
@Resource
private ISysDepartService sysDepartService;
@Resource
private IOSSFileService oSSFileService;
@Resource
private JeroElasticsearchTemplate jeroElasticsearchTemplate;
@@ -186,6 +182,13 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
List<LawsEnterpriseStandard> finalListLawsEnterpriseStandard = listLawsEnterpriseStandard;
List<LawsNewsFeed> finalListLawsNewsFeed = listLawsNewsFeed;
LambdaQueryWrapper<LawsTag> query = new LambdaQueryWrapper<>();
query.select(LawsTag::getTableName,LawsTag::getDbFieldName,LawsTag::getDbFieldTxt,LawsTag::getDictField,LawsTag::getDictTable,LawsTag::getDictText,LawsTag::getHomeSearchContextOrder);
query.in(LawsTag::getTableName, Arrays.asList(LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD_TABLE_NAME,
LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD_TABLE_NAME,LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD_TABLE_NAME));
query.isNotNull(LawsTag::getHomeSearchContextOrder);
query.orderByAsc(LawsTag::getHomeSearchContextOrder);
List<LawsTag> listLawsTag = lawsTagService.list(query);
List<SysDictItemCore> listDict = commonAPI.getDictItemAll();
String yyyyMMdd = "yyyy-MM-dd";
list.parallelStream().forEach(p->{
@@ -199,7 +202,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
p.setReleaseDate(obj.getReleaseDate());
// 生成正文
JSONObject json = JSON.parseObject(JSON.toJSONStringWithDateFormat(obj,yyyyMMdd));
addContent(listDict, p, json, "laws_domestic_standard");
addContent(listDict, p, json, LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD_TABLE_NAME,listLawsTag);
}
}
break;
@@ -212,7 +215,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
p.setReleaseDate(obj.getReleaseDate());
// 生成正文
JSONObject json = JSON.parseObject(JSON.toJSONStringWithDateFormat(obj,yyyyMMdd));
addContent(listDict, p, json, "laws_overseas_standard");
addContent(listDict, p, json, LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD_TABLE_NAME,listLawsTag);
}
}
break;
@@ -225,7 +228,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
p.setReleaseDate(obj.getReleaseDate());
// 生成正文
JSONObject json = JSON.parseObject(JSON.toJSONStringWithDateFormat(obj,yyyyMMdd));
addContent(listDict, p, json, "laws_enterprise_standard");
addContent(listDict, p, json, LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD_TABLE_NAME,listLawsTag);
}
}
break;
@@ -246,37 +249,38 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
pageList.setRecords(list);
}
private void addContent(List<SysDictItemCore> listDict, LawsHomeNormalSearchVO p, JSONObject json, String lawsDomesticStandard) {
LambdaQueryWrapper<LawsTag> query = new LambdaQueryWrapper<>();
query.eq(LawsTag::getTableName, lawsDomesticStandard);
query.isNotNull(LawsTag::getHomeSearchContextOrder);
query.orderByAsc(LawsTag::getHomeSearchContextOrder);
List<LawsTag> listLawsTag = lawsTagService.list(query);
if (!CollectionUtils.isEmpty(listLawsTag)) {
StringBuilder str = new StringBuilder();
for (LawsTag lawsTag : listLawsTag) {
String code = lawsTag.getDictField();
String text = lawsTag.getDictText();
String table = lawsTag.getDictTable();
String fileName = lawsTag.getDbFieldName();
String fileTxt = lawsTag.getDbFieldTxt();
if (StringUtils.isBlank(fileName) || StringUtils.isBlank(fileTxt)) {
continue;
}
fileName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, fileName);
String key = Objects.isNull(json.get(fileName)) ? "" : String.valueOf(json.get(fileName));
String textValue = "";
if (!StringUtils.isBlank(code) && !StringUtils.isBlank(key)) {
textValue = translateDictValue(code, text, table, key, listDict);
}
if (StringUtils.isBlank(textValue)) {
textValue = "--";
}
str.append(fileTxt).append(":").append(textValue).append(" ");
}
p.setContent(str.toString());
private void addContent(List<SysDictItemCore> listDict, LawsHomeNormalSearchVO p, JSONObject json,String tableName, List<LawsTag> listLawsTagAll) {
if (CollectionUtils.isEmpty(listLawsTagAll)) {
return;
}
List<LawsTag> listLawsTag = listLawsTagAll.stream().filter(o->Objects.equals(o.getTableName(),tableName)).collect(Collectors.toList());
if(CollectionUtils.isEmpty(listLawsTag)){
return;
}
listLawsTag = listLawsTag.stream().sorted(Comparator.comparing(LawsTag::getHomeSearchContextOrder)).collect(Collectors.toList());
StringBuilder str = new StringBuilder();
for (LawsTag lawsTag : listLawsTag) {
String code = lawsTag.getDictField();
String text = lawsTag.getDictText();
String table = lawsTag.getDictTable();
String fileName = lawsTag.getDbFieldName();
String fileTxt = lawsTag.getDbFieldTxt();
if (StringUtils.isBlank(fileName) || StringUtils.isBlank(fileTxt)) {
continue;
}
fileName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, fileName);
String key = Objects.isNull(json.get(fileName)) ? "" : String.valueOf(json.get(fileName));
String textValue = "";
if (!StringUtils.isBlank(code) && !StringUtils.isBlank(key)) {
textValue = translateDictValue(code, text, table, key, listDict);
}
if (StringUtils.isBlank(textValue)) {
textValue = "--";
}
str.append(fileTxt).append(":").append(textValue).append(" ");
}
p.setContent(str.toString());
}
/**
@@ -745,7 +749,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
List<OSSFile> listFile = new ArrayList<>();
if(!CollectionUtils.isEmpty(list)){
LambdaQueryWrapper<LawsTag> query = new LambdaQueryWrapper<>();
query.eq(LawsTag::getTableName,"laws_domestic_standard");
query.eq(LawsTag::getTableName,LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD_TABLE_NAME);
query.isNotNull(LawsTag::getHomeSearchFileOrder);
query.orderByAsc(LawsTag::getHomeSearchFileOrder);
List<LawsTag> listLawsTag = lawsTagService.list(query);
@@ -827,7 +831,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
List<OSSFile> listFile = new ArrayList<>();
if(!CollectionUtils.isEmpty(list)){
LambdaQueryWrapper<LawsTag> query = new LambdaQueryWrapper<>();
query.eq(LawsTag::getTableName,"laws_overseas_standard");
query.eq(LawsTag::getTableName,LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD_TABLE_NAME);
query.isNotNull(LawsTag::getHomeSearchFileOrder);
query.orderByAsc(LawsTag::getHomeSearchFileOrder);
List<LawsTag> listLawsTag = lawsTagService.list(query);
@@ -904,7 +908,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
List<OSSFile> listFile = new ArrayList<>();
if(!CollectionUtils.isEmpty(list)){
LambdaQueryWrapper<LawsTag> query = new LambdaQueryWrapper<>();
query.eq(LawsTag::getTableName,"laws_enterprise_standard");
query.eq(LawsTag::getTableName,LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD_TABLE_NAME);
query.isNotNull(LawsTag::getHomeSearchFileOrder);
query.orderByAsc(LawsTag::getHomeSearchFileOrder);
List<LawsTag> listLawsTag = lawsTagService.list(query);
@@ -417,11 +417,11 @@ public class LawsTag implements Serializable {
* 展示区域-英文名称
*/
/**首页检索正文拼接排序*/
private String homeSearchContextOrder;
private Integer homeSearchContextOrder;
/**首页检索中心上传附件顺序*/
private String homeSearchFileOrder;
private Integer homeSearchFileOrder;
@TableField(exist = false)
private String showAreaEnName;
}
}