一般检索(全文)添加
This commit is contained in:
-1
@@ -60,7 +60,6 @@ public class LawsHomeSearchController {
|
||||
@ApiOperation(value="首页-一般检索(全文)(数据统计)", notes="首页-一般检索(全文)(数据统计)")
|
||||
@GetMapping(value = "/getNormalSearchAllCount")
|
||||
public Result<LawsHomeNormalSearchStatisticsVO> getNormalSearchAllCount(LawsHomeNormalSearchDTO homeNormalSearchDTO) {
|
||||
// todo 待开发
|
||||
return Result.OK(lawsHomeSearchService.getNormalSearchAllCount(homeNormalSearchDTO));
|
||||
}
|
||||
|
||||
|
||||
+11
@@ -5,10 +5,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.common.system.vo.SysDictItemCore;
|
||||
import com.jero.modules.laws.home.dto.LawsHomeNormalSearchDTO;
|
||||
import com.jero.modules.laws.home.entity.LawsHomeNormalSearchHistory;
|
||||
import com.jero.modules.laws.home.vo.LawsHomeNormalSearchCountVO;
|
||||
import com.jero.modules.laws.home.vo.LawsHomeNormalSearchVO;
|
||||
import com.jero.modules.system.entity.SysDict;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -57,5 +59,14 @@ public interface LawsHomeSearchMapper extends BaseMapper<LawsHomeNormalSearchHis
|
||||
*/
|
||||
List<LawsHomeNormalSearchCountVO> getCount3(@Param(Constants.WRAPPER) QueryWrapper<LawsHomeNormalSearchDTO> queryWrapper);
|
||||
|
||||
/**
|
||||
* 获取数据所需要的字典
|
||||
* @author LQT
|
||||
* @date 2023/11/22 15:52
|
||||
* @param queryWrapper
|
||||
* @return java.util.List<com.jero.common.system.vo.SysDictItemCore>
|
||||
*/
|
||||
List<SysDictItemCore> translateManyDict(@Param(Constants.WRAPPER) QueryWrapper<SysDict> queryWrapper);
|
||||
|
||||
|
||||
}
|
||||
|
||||
+17
-4
@@ -4,21 +4,21 @@
|
||||
|
||||
<select id="getPage" resultType="com.jero.modules.laws.home.vo.LawsHomeNormalSearchVO">
|
||||
select * from (
|
||||
select id,'1' as resource_type,standard_number,standard_name,
|
||||
select id,'1' as resource_type,standard_number,standard_name,create_time,
|
||||
case when standard_class = 'GB' then 2
|
||||
when standard_class = 'GB/T' then 1 end as standard_type,
|
||||
standard_class,dynamic_type,applicable_vehicle,standard_property,standard_state,'' as standard_code,'' as grade_classification
|
||||
from laws_domestic_standard where del_flag = 0
|
||||
union all
|
||||
select id,'2' as resource_type,standard_number,standard_name,0 as standard_type,
|
||||
select id,'2' as resource_type,standard_number,standard_name,create_time,0 as standard_type,
|
||||
standard_class,'',applicable_vehicle,'',standard_state,'',''
|
||||
from laws_overseas_standard where del_flag = 0
|
||||
union all
|
||||
select id,'3' as resource_type,standard_number,standard_name,0 as standard_type,
|
||||
select id,'3' as resource_type,standard_number,standard_name,create_time,0 as standard_type,
|
||||
'','','','',standard_state,standard_code,grade_classification
|
||||
from laws_enterprise_standard where del_flag = 0
|
||||
union all
|
||||
select id,'4' as resource_type,'' as standard_number,dynamic_heading as standard_name,0 as standard_type,
|
||||
select id,'4' as resource_type,'' as standard_number,dynamic_heading as standard_name,create_time,0 as standard_type,
|
||||
'','','','','','',''
|
||||
from laws_news_feed where del_flag = 0
|
||||
) as all_data
|
||||
@@ -62,6 +62,19 @@
|
||||
select 'standard_state' as field_name,standard_state,count(*) from laws_enterprise_standard
|
||||
<where>${ew.sqlSegment}</where> group by standard_state
|
||||
</select>
|
||||
<select id="translateManyDict" resultType="com.jero.common.system.vo.SysDictItemCore">
|
||||
SELECT
|
||||
sys_dict.dict_code,
|
||||
sys_dict_item.item_text,
|
||||
sys_dict_item.item_value
|
||||
FROM
|
||||
sys_dict_item
|
||||
LEFT JOIN sys_dict ON sys_dict_item.dict_id = sys_dict.id
|
||||
WHERE
|
||||
STATUS = 1
|
||||
AND sys_dict_item.del_flag = 0
|
||||
AND ${ew.sqlSegment}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
+315
-272
@@ -22,7 +22,6 @@ import com.jero.modules.document.utils.ReadPdfUtil;
|
||||
import com.jero.modules.document.utils.ReadWordUtil;
|
||||
import com.jero.modules.laws.home.common.LawsHomeSearchCommon;
|
||||
import com.jero.modules.laws.home.dto.LawsHomeNormalSearchDTO;
|
||||
import com.jero.modules.laws.home.dto.SearchVO;
|
||||
import com.jero.modules.laws.home.entity.LawsHomeNormalSearchHistory;
|
||||
import com.jero.modules.laws.home.enums.HomeSearchEnum;
|
||||
import com.jero.modules.laws.home.mapper.LawsHomeSearchMapper;
|
||||
@@ -42,6 +41,7 @@ import com.jero.modules.laws.standard.service.ILawsNewsFeedService;
|
||||
import com.jero.modules.laws.standard.service.ILawsOverseasStandardService;
|
||||
import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
import com.jero.modules.system.entity.SysDict;
|
||||
import com.jero.modules.tag.entity.LawsTag;
|
||||
import com.jero.modules.tag.service.ILawsTagService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -97,14 +97,27 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
// 标识(es数据带此标识的代表全文和段落的数据,不带此标识的代表列表数据)
|
||||
public static final String SEARCH_FLAG = "魑";
|
||||
|
||||
public static final String RESOURCE_TYPE = "resource_type";
|
||||
public static final String STANDARD_TYPE = "standard_type";
|
||||
public static final String CREATE_TIME = "create_time";
|
||||
public static final String STANDARD_CODE = "standard_code";
|
||||
public static final String ENTERPRISE_STANDARD_STATE = "enterprise_standard_state";
|
||||
public static final String STANDARD_STATE = "standard_state";
|
||||
public static final String GRADE_CLASSIFICATION = "grade_classification";
|
||||
public static final String STANDARD_CLASS = "standard_class";
|
||||
public static final String APPLICABLE_VEHICLE = "applicable_vehicle";
|
||||
public static final String DYNAMIC_TYPE = "dynamic_type";
|
||||
public static final String STANDARD_PROPERTY = "standard_property";
|
||||
public static final String CONTENT = "content";
|
||||
public static final String SYNC_ES_ERR = "同步ES数据异常:";
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = JeroBootException.class)
|
||||
public IPage<LawsHomeNormalSearchVO> getNormalSearchTitlePage(LawsHomeNormalSearchDTO lawsHomeNormalSearchDTO,
|
||||
Integer pageNo,Integer pageSize) {
|
||||
String searchContent = lawsHomeNormalSearchDTO.getSearchContent();
|
||||
if(StringUtils.isBlank(searchContent)){
|
||||
throw new JeroBootException(ResultCommon.PLEASE_SEARCH_TO_IMPORT);
|
||||
}
|
||||
String searchContent = checkSearchContent(lawsHomeNormalSearchDTO);
|
||||
// 添加检索历史
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
LawsHomeNormalSearchHistory lawsHomeNormalSearchHistory = new LawsHomeNormalSearchHistory();
|
||||
@@ -124,18 +137,18 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
QueryWrapper<LawsHomeNormalSearchDTO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.and(p -> p.gt("instr(standard_number,'" + lawsHomeNormalSearchDTO.getSearchContent() + "')", 0).or()
|
||||
.gt("instr(standard_name,'" + lawsHomeNormalSearchDTO.getSearchContent() + "')", 0));
|
||||
queryWrapper.eq(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getResourceType()),"resource_type",lawsHomeNormalSearchDTO.getResourceType());
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardClass()),"instr(concat(',',standard_class,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardClass() + "',','))",0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getDynamicType()),"instr(concat(',',dynamic_type,','),concat(',','" + lawsHomeNormalSearchDTO.getDynamicType() + "',','))",0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getApplicableVehicle()),"instr(concat(',',applicable_vehicle,','),concat(',','" + lawsHomeNormalSearchDTO.getApplicableVehicle() + "',','))",0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardProperty()),"instr(concat(',',standard_property,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardProperty() + "',','))",0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardState()),"instr(concat(',',standard_state,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardState() + "',','))",0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardCode()),"instr(concat(',',standard_code,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardCode() + "',','))",0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getGradeClassification()),"instr(concat(',',grade_classification,','),concat(',','" + lawsHomeNormalSearchDTO.getGradeClassification() + "',','))",0);
|
||||
queryWrapper.orderByAsc("resource_type");
|
||||
queryWrapper.orderByDesc("standard_type");
|
||||
// todo 排序号
|
||||
// queryWrapper.orderByDesc("standard_type");
|
||||
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);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getDynamicType()),"instr(concat(',',dynamic_type,','),concat(',','" + lawsHomeNormalSearchDTO.getDynamicType() + str,0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getApplicableVehicle()),"instr(concat(',',applicable_vehicle,','),concat(',','" + lawsHomeNormalSearchDTO.getApplicableVehicle() + str,0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardProperty()),"instr(concat(',',standard_property,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardProperty() + str,0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardState()),"instr(concat(',',standard_state,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardState() + str,0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardCode()),"instr(concat(',',standard_code,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardCode() + str,0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getGradeClassification()),"instr(concat(',',grade_classification,','),concat(',','" + lawsHomeNormalSearchDTO.getGradeClassification() + str,0);
|
||||
queryWrapper.orderByAsc(RESOURCE_TYPE);
|
||||
queryWrapper.orderByDesc(STANDARD_TYPE);
|
||||
queryWrapper.orderByDesc(CREATE_TIME);
|
||||
queryWrapper.orderByAsc("CHAR_LENGTH(standard_number)");
|
||||
queryWrapper.orderByAsc("CHAR_LENGTH(standard_name)");
|
||||
return queryWrapper;
|
||||
@@ -145,6 +158,7 @@ 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<>();
|
||||
@@ -159,26 +173,10 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
default:lawsNewsFeedIds.add(obj.getId());break;
|
||||
}
|
||||
}
|
||||
List<LawsDomesticStandard> listLawsDomesticStandard = new ArrayList<>();
|
||||
if(!CollectionUtils.isEmpty(lawsDomesticStandardIds)){
|
||||
listLawsDomesticStandard = lawsDomesticStandardService.listByIds(lawsDomesticStandardIds);
|
||||
}
|
||||
List<LawsOverseasStandard> listLawsOverseasStandard = new ArrayList<>();
|
||||
if(!CollectionUtils.isEmpty(lawsOverseasStandardIds)){
|
||||
listLawsOverseasStandard = lawsOverseasStandardService.listByIds(lawsOverseasStandardIds);
|
||||
}
|
||||
List<LawsEnterpriseStandard> listLawsEnterpriseStandard = new ArrayList<>();
|
||||
if(!CollectionUtils.isEmpty(lawsEnterpriseStandardIds)){
|
||||
listLawsEnterpriseStandard = lawsEnterpriseStandardService.listByIds(lawsEnterpriseStandardIds);
|
||||
}
|
||||
List<LawsNewsFeed> listLawsNewsFeed = new ArrayList<>();
|
||||
if(!CollectionUtils.isEmpty(lawsNewsFeedIds)){
|
||||
listLawsNewsFeed = lawsNewsFeedService.listByIds(lawsNewsFeedIds);
|
||||
}
|
||||
List<LawsDomesticStandard> finalListLawsDomesticStandard = listLawsDomesticStandard;
|
||||
List<LawsOverseasStandard> finalListLawsOverseasStandard = listLawsOverseasStandard;
|
||||
List<LawsEnterpriseStandard> finalListLawsEnterpriseStandard = listLawsEnterpriseStandard;
|
||||
List<LawsNewsFeed> finalListLawsNewsFeed = listLawsNewsFeed;
|
||||
List<LawsDomesticStandard> listLawsDomesticStandard = listLawsDomesticStandard(lawsDomesticStandardIds);
|
||||
List<LawsOverseasStandard> listLawsOverseasStandard = listLawsOverseasStandard(lawsOverseasStandardIds);
|
||||
List<LawsEnterpriseStandard> listLawsEnterpriseStandard = listLawsEnterpriseStandard(lawsEnterpriseStandardIds);
|
||||
List<LawsNewsFeed> listLawsNewsFeed = listLawsNewsFeed(lawsNewsFeedIds);
|
||||
|
||||
LambdaQueryWrapper<LawsTag> query = new LambdaQueryWrapper<>();
|
||||
query.select(LawsTag::getTableName,LawsTag::getDbFieldName,LawsTag::getDbFieldTxt,LawsTag::getDictField,LawsTag::getDictTable,LawsTag::getDictText,LawsTag::getHomeSearchContextOrder);
|
||||
@@ -187,67 +185,133 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
query.isNotNull(LawsTag::getHomeSearchContextOrder);
|
||||
query.orderByAsc(LawsTag::getHomeSearchContextOrder);
|
||||
List<LawsTag> listLawsTag = lawsTagService.list(query);
|
||||
List<SysDictItemCore> listDict = commonAPI.getDictItemAll();
|
||||
List<SysDictItemCore> listSysDict = getSysDictItemCores(listLawsTag);
|
||||
|
||||
long l = System.currentTimeMillis();
|
||||
String yyyyMMdd = "yyyy-MM-dd";
|
||||
list.parallelStream().forEach(p->{
|
||||
switch (p.getResourceType()){
|
||||
case LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD:
|
||||
if(!CollectionUtils.isEmpty(finalListLawsDomesticStandard)){
|
||||
Optional<LawsDomesticStandard> op = finalListLawsDomesticStandard.stream().filter(o-> Objects.equals(o.getId(),p.getId())).findFirst();
|
||||
if(op.isPresent()){
|
||||
LawsDomesticStandard obj = op.get();
|
||||
p.setTitle(obj.getStandardNumber().replace(searchContent,searchContentSpan) + " " + obj.getStandardName().replace(searchContent,searchContentSpan));
|
||||
p.setReleaseDate(obj.getReleaseDate());
|
||||
// 生成正文
|
||||
JSONObject json = JSON.parseObject(JSON.toJSONStringWithDateFormat(obj,yyyyMMdd));
|
||||
addContent(listDict, p, json, LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD_TABLE_NAME,listLawsTag);
|
||||
}
|
||||
}
|
||||
break;
|
||||
addLawsDomesticStandard(listSysDict,searchContent, searchContentSpan, listLawsDomesticStandard, listLawsTag, yyyyMMdd, p);
|
||||
break;
|
||||
case LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD:
|
||||
if(!CollectionUtils.isEmpty(finalListLawsOverseasStandard)){
|
||||
Optional<LawsOverseasStandard> op = finalListLawsOverseasStandard.stream().filter(o->Objects.equals(o.getId(),p.getId())).findFirst();
|
||||
if(op.isPresent()){
|
||||
LawsOverseasStandard obj = op.get();
|
||||
p.setTitle(obj.getStandardNumber().replace(searchContent,searchContentSpan) + " " + obj.getStandardName().replace(searchContent,searchContentSpan));
|
||||
p.setReleaseDate(obj.getReleaseDate());
|
||||
// 生成正文
|
||||
JSONObject json = JSON.parseObject(JSON.toJSONStringWithDateFormat(obj,yyyyMMdd));
|
||||
addContent(listDict, p, json, LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD_TABLE_NAME,listLawsTag);
|
||||
}
|
||||
}
|
||||
addLawsOverseasStandard(listSysDict,searchContent, searchContentSpan, listLawsOverseasStandard, listLawsTag, yyyyMMdd, p);
|
||||
break;
|
||||
case LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD:
|
||||
if(!CollectionUtils.isEmpty(finalListLawsEnterpriseStandard)){
|
||||
Optional<LawsEnterpriseStandard> op = finalListLawsEnterpriseStandard.stream().filter(o->Objects.equals(o.getId(),p.getId())).findFirst();
|
||||
if(op.isPresent()){
|
||||
LawsEnterpriseStandard obj = op.get();
|
||||
p.setTitle(obj.getStandardNumber().replace(searchContent,searchContentSpan) + " " + obj.getStandardName().replace(searchContent,searchContentSpan));
|
||||
p.setReleaseDate(obj.getReleaseDate());
|
||||
// 生成正文
|
||||
JSONObject json = JSON.parseObject(JSON.toJSONStringWithDateFormat(obj,yyyyMMdd));
|
||||
addContent(listDict, p, json, LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD_TABLE_NAME,listLawsTag);
|
||||
}
|
||||
}
|
||||
addLawsEnterpriseStandard(listSysDict,searchContent, searchContentSpan, listLawsEnterpriseStandard, listLawsTag, yyyyMMdd, p);
|
||||
break;
|
||||
default:
|
||||
if(!CollectionUtils.isEmpty(finalListLawsNewsFeed)){
|
||||
Optional<LawsNewsFeed> op = finalListLawsNewsFeed.stream().filter(o->Objects.equals(o.getId(),p.getId())).findFirst();
|
||||
if(op.isPresent()){
|
||||
LawsNewsFeed obj = op.get();
|
||||
p.setTitle(obj.getDynamicHeading().replace(searchContent,searchContentSpan));
|
||||
p.setReleaseDate(obj.getReleaseTime());
|
||||
// 生成正文
|
||||
p.setContent(obj.getDynamicDetails());
|
||||
}
|
||||
}
|
||||
addLawsNewsFeed(searchContent, searchContentSpan, listLawsNewsFeed, p);
|
||||
break;
|
||||
}
|
||||
});
|
||||
long l1 = System.currentTimeMillis();
|
||||
log.info((l1 - l) + "================");
|
||||
pageList.setRecords(list);
|
||||
}
|
||||
|
||||
private void addContent(List<SysDictItemCore> listDict, LawsHomeNormalSearchVO p, JSONObject json,String tableName, List<LawsTag> listLawsTagAll) {
|
||||
private List<SysDictItemCore> getSysDictItemCores(List<LawsTag> listLawsTag) {
|
||||
List<SysDictItemCore> listSysDict = new ArrayList<>();
|
||||
if(!CollectionUtils.isEmpty(listLawsTag)){
|
||||
List<LawsTag> listLawsTagDict = listLawsTag.stream().filter(o->!StringUtils.isBlank(o.getDictField()) && StringUtils.isBlank(o.getDictTable())).collect(Collectors.toList());
|
||||
if(!CollectionUtils.isEmpty(listLawsTagDict)){
|
||||
List<String> listDict = listLawsTagDict.stream().map(LawsTag::getDictField).collect(Collectors.toList());
|
||||
QueryWrapper<SysDict> querySysDict = new QueryWrapper<>();
|
||||
querySysDict.in("sys_dict.dict_code",listDict);
|
||||
listSysDict = lawsHomeSearchMapper.translateManyDict(querySysDict);
|
||||
}
|
||||
}
|
||||
return listSysDict;
|
||||
}
|
||||
|
||||
private void addLawsNewsFeed(String searchContent, String searchContentSpan, 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));
|
||||
p.setReleaseDate(obj.getReleaseTime());
|
||||
// 生成正文
|
||||
p.setContent(obj.getDynamicDetails());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addLawsEnterpriseStandard(List<SysDictItemCore> listSysDict,String searchContent, String searchContentSpan, List<LawsEnterpriseStandard> listLawsEnterpriseStandard, List<LawsTag> listLawsTag, String yyyyMMdd, 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().replace(searchContent,searchContentSpan) + " " + obj.getStandardName().replace(searchContent,searchContentSpan));
|
||||
p.setReleaseDate(obj.getReleaseDate());
|
||||
// 生成正文
|
||||
JSONObject json = JSON.parseObject(JSON.toJSONStringWithDateFormat(obj,yyyyMMdd));
|
||||
addContent(listSysDict,p, json, LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD_TABLE_NAME,listLawsTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addLawsOverseasStandard(List<SysDictItemCore> listSysDict,String searchContent, String searchContentSpan, List<LawsOverseasStandard> listLawsOverseasStandard, List<LawsTag> listLawsTag, String yyyyMMdd, 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().replace(searchContent,searchContentSpan) + " " + obj.getStandardName().replace(searchContent,searchContentSpan));
|
||||
p.setReleaseDate(obj.getReleaseDate());
|
||||
// 生成正文
|
||||
JSONObject json = JSON.parseObject(JSON.toJSONStringWithDateFormat(obj,yyyyMMdd));
|
||||
addContent(listSysDict,p, json, LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD_TABLE_NAME,listLawsTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addLawsDomesticStandard(List<SysDictItemCore> listSysDict,String searchContent, String searchContentSpan, List<LawsDomesticStandard> listLawsDomesticStandard, List<LawsTag> listLawsTag,String yyyyMMdd, 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().replace(searchContent,searchContentSpan) + " " + obj.getStandardName().replace(searchContent,searchContentSpan));
|
||||
p.setReleaseDate(obj.getReleaseDate());
|
||||
// 生成正文
|
||||
JSONObject json = JSON.parseObject(JSON.toJSONStringWithDateFormat(obj,yyyyMMdd));
|
||||
addContent(listSysDict,p, json, LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD_TABLE_NAME,listLawsTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<LawsNewsFeed> listLawsNewsFeed(List<String> lawsNewsFeedIds) {
|
||||
List<LawsNewsFeed> listLawsNewsFeed = new ArrayList<>();
|
||||
if(!CollectionUtils.isEmpty(lawsNewsFeedIds)){
|
||||
listLawsNewsFeed = lawsNewsFeedService.listByIds(lawsNewsFeedIds);
|
||||
}
|
||||
return listLawsNewsFeed;
|
||||
}
|
||||
|
||||
private List<LawsEnterpriseStandard> listLawsEnterpriseStandard(List<String> lawsEnterpriseStandardIds) {
|
||||
List<LawsEnterpriseStandard> listLawsEnterpriseStandard = new ArrayList<>();
|
||||
if(!CollectionUtils.isEmpty(lawsEnterpriseStandardIds)){
|
||||
listLawsEnterpriseStandard = lawsEnterpriseStandardService.listByIds(lawsEnterpriseStandardIds);
|
||||
}
|
||||
return listLawsEnterpriseStandard;
|
||||
}
|
||||
|
||||
private List<LawsOverseasStandard> listLawsOverseasStandard(List<String> lawsOverseasStandardIds) {
|
||||
List<LawsOverseasStandard> listLawsOverseasStandard = new ArrayList<>();
|
||||
if(!CollectionUtils.isEmpty(lawsOverseasStandardIds)){
|
||||
listLawsOverseasStandard = lawsOverseasStandardService.listByIds(lawsOverseasStandardIds);
|
||||
}
|
||||
return listLawsOverseasStandard;
|
||||
}
|
||||
|
||||
private List<LawsDomesticStandard> listLawsDomesticStandard(List<String> lawsDomesticStandardIds) {
|
||||
List<LawsDomesticStandard> listLawsDomesticStandard = new ArrayList<>();
|
||||
if(!CollectionUtils.isEmpty(lawsDomesticStandardIds)){
|
||||
listLawsDomesticStandard = lawsDomesticStandardService.listByIds(lawsDomesticStandardIds);
|
||||
}
|
||||
return listLawsDomesticStandard;
|
||||
}
|
||||
|
||||
private void addContent(List<SysDictItemCore> listSysDict,LawsHomeNormalSearchVO p, JSONObject json,String tableName, List<LawsTag> listLawsTagAll) {
|
||||
if (CollectionUtils.isEmpty(listLawsTagAll)) {
|
||||
return;
|
||||
}
|
||||
@@ -270,7 +334,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
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);
|
||||
textValue = translateDictValue(listSysDict,code, text, table, key);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(textValue)) {
|
||||
@@ -287,9 +351,9 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
* @param text 值
|
||||
* @param table 表名
|
||||
* @param key 键
|
||||
* @param listDict 字典集合
|
||||
* @param listSysDict 字典集合
|
||||
*/
|
||||
private String translateDictValue(String code, String text, String table, String key, List<SysDictItemCore> listDict) {
|
||||
private String translateDictValue(List<SysDictItemCore> listSysDict,String code, String text, String table, String key) {
|
||||
if(oConvertUtils.isEmpty(key)) {
|
||||
return null;
|
||||
}
|
||||
@@ -300,15 +364,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
if (k.trim().length() == 0) {
|
||||
continue; //跳过循环
|
||||
}
|
||||
if (!org.springframework.util.StringUtils.isEmpty(table)){
|
||||
tmpValue = commonAPI.queryTableDictTextByKey(table,text,code,k.trim());
|
||||
}else {
|
||||
List<SysDictItemCore> listNew = listDict.stream().filter(o-> Objects.equals(o.getDictCode(),code) && Objects.equals(o.getItemValue(),k.trim())).collect(Collectors.toList());
|
||||
if(!org.springframework.util.CollectionUtils.isEmpty(listNew)){
|
||||
tmpValue = listNew.get(0).getItemText();
|
||||
}
|
||||
}
|
||||
|
||||
tmpValue = getTmpValue(listSysDict,code, text, table, k, tmpValue);
|
||||
if (tmpValue != null) {
|
||||
if (!"".equals(textValue.toString())) {
|
||||
textValue.append(",");
|
||||
@@ -322,30 +378,33 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
return textValue.toString();
|
||||
}
|
||||
|
||||
private String getDict(String str,String code){
|
||||
if(StringUtils.isBlank(str)){
|
||||
str = "--";
|
||||
private String getTmpValue(List<SysDictItemCore> listSysDict,String code, String text, String table, String k, String tmpValue) {
|
||||
if (!StringUtils.isEmpty(table)){
|
||||
tmpValue = commonAPI.queryTableDictTextByKey(table,text,code,k.trim());
|
||||
}else {
|
||||
List<SysDictItemCore> listNew = listSysDict.stream().filter(o-> Objects.equals(o.getDictCode(),code) && Objects.equals(o.getItemValue(),k.trim())).collect(Collectors.toList());
|
||||
if(!CollectionUtils.isEmpty(listNew)){
|
||||
tmpValue = listNew.get(0).getItemText();
|
||||
}
|
||||
}
|
||||
return str;
|
||||
return tmpValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LawsHomeNormalSearchStatisticsVO getNormalSearchTitleCount(LawsHomeNormalSearchDTO lawsHomeNormalSearchDTO) {
|
||||
String searchContent = lawsHomeNormalSearchDTO.getSearchContent();
|
||||
if(StringUtils.isBlank(searchContent)){
|
||||
throw new JeroBootException(ResultCommon.PLEASE_SEARCH_TO_IMPORT);
|
||||
}
|
||||
String searchContent = checkSearchContent(lawsHomeNormalSearchDTO);
|
||||
QueryWrapper<LawsHomeNormalSearchDTO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.and(p -> p.gt("instr(standard_number,'" + lawsHomeNormalSearchDTO.getSearchContent() + "')", 0).or()
|
||||
.gt("instr(standard_name,'" + lawsHomeNormalSearchDTO.getSearchContent() + "')", 0));
|
||||
queryWrapper.and(p -> p.gt("instr(standard_number,'" + searchContent + "')", 0).or()
|
||||
.gt("instr(standard_name,'" + searchContent + "')", 0));
|
||||
queryWrapper.eq("del_flag",0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardClass()),"instr(concat(',',standard_class,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardClass() + "',','))",0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getDynamicType()),"instr(concat(',',dynamic_type,','),concat(',','" + lawsHomeNormalSearchDTO.getDynamicType() + "',','))",0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getApplicableVehicle()),"instr(concat(',',applicable_vehicle,','),concat(',','" + lawsHomeNormalSearchDTO.getApplicableVehicle() + "',','))",0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardProperty()),"instr(concat(',',standard_property,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardProperty() + "',','))",0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardState()),"instr(concat(',',standard_state,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardState() + "',','))",0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardCode()),"instr(concat(',',standard_code,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardCode() + "',','))",0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getGradeClassification()),"instr(concat(',',grade_classification,','),concat(',','" + lawsHomeNormalSearchDTO.getGradeClassification() + "',','))",0);
|
||||
String str = "',','))";
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardClass()),"instr(concat(',',standard_class,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardClass() + str,0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getDynamicType()),"instr(concat(',',dynamic_type,','),concat(',','" + lawsHomeNormalSearchDTO.getDynamicType() + str,0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getApplicableVehicle()),"instr(concat(',',applicable_vehicle,','),concat(',','" + lawsHomeNormalSearchDTO.getApplicableVehicle() + str,0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardProperty()),"instr(concat(',',standard_property,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardProperty() + str,0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardState()),"instr(concat(',',standard_state,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardState() + str,0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardCode()),"instr(concat(',',standard_code,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardCode() + str,0);
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getGradeClassification()),"instr(concat(',',grade_classification,','),concat(',','" + lawsHomeNormalSearchDTO.getGradeClassification() + str,0);
|
||||
LawsHomeNormalSearchStatisticsVO obj = new LawsHomeNormalSearchStatisticsVO();
|
||||
switch (lawsHomeNormalSearchDTO.getResourceType()){
|
||||
case LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD:
|
||||
@@ -367,17 +426,17 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
|
||||
private void count3(List<LawsHomeNormalSearchCountVO> list,LawsHomeNormalSearchStatisticsVO obj) {
|
||||
// 企业标准代号
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list1 = addLawsHomeNormalSearchStatistics(list, "enterprise_standard_code", "standard_code");
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list1 = addLawsHomeNormalSearchStatistics(list, "enterprise_standard_code", STANDARD_CODE);
|
||||
if(!CollectionUtils.isEmpty(list1)){
|
||||
obj.setStandardCode(list1);
|
||||
}
|
||||
// 标准状态
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list2 = addLawsHomeNormalSearchStatistics(list, "enterprise_standard_state", "standard_state");
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list2 = addLawsHomeNormalSearchStatistics(list, ENTERPRISE_STANDARD_STATE, STANDARD_STATE);
|
||||
if(!CollectionUtils.isEmpty(list2)){
|
||||
obj.setEnterpriseStandardState(list2);
|
||||
}
|
||||
// 标准等级分类
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list3 = addLawsHomeNormalSearchStatistics(list,"standard_grade_classify", "grade_classification");
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list3 = addLawsHomeNormalSearchStatistics(list,"standard_grade_classify", GRADE_CLASSIFICATION);
|
||||
if(!CollectionUtils.isEmpty(list3)){
|
||||
obj.setGradeClassification(list3);
|
||||
}
|
||||
@@ -385,17 +444,17 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
|
||||
private void count2(List<LawsHomeNormalSearchCountVO> list,LawsHomeNormalSearchStatisticsVO obj) {
|
||||
// 标准类别
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list1 = addLawsHomeNormalSearchStatistics(list, "standard_type_overseas", "standard_class");
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list1 = addLawsHomeNormalSearchStatistics(list, "standard_type_overseas", STANDARD_CLASS);
|
||||
if(!CollectionUtils.isEmpty(list1)){
|
||||
obj.setStandardClass(list1);
|
||||
}
|
||||
// 适用车辆类型
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list2 = addLawsHomeNormalSearchStatistics(list, "APPLICATIONS_OVERSEAS", "applicable_vehicle");
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list2 = addLawsHomeNormalSearchStatistics(list, "APPLICATIONS_OVERSEAS", APPLICABLE_VEHICLE);
|
||||
if(!CollectionUtils.isEmpty(list2)){
|
||||
obj.setApplicableVehicle(list2);
|
||||
}
|
||||
// 状态
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list3 = addLawsHomeNormalSearchStatistics(list, "standard_state", "standard_state");
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list3 = addLawsHomeNormalSearchStatistics(list, STANDARD_STATE, STANDARD_STATE);
|
||||
if(!CollectionUtils.isEmpty(list3)){
|
||||
obj.setStandardState(list3);
|
||||
}
|
||||
@@ -403,27 +462,27 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
|
||||
private void count1(List<LawsHomeNormalSearchCountVO> list, LawsHomeNormalSearchStatisticsVO obj) {
|
||||
// 标准类别
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list1 = addLawsHomeNormalSearchStatistics(list,"standard_type", "standard_class");
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list1 = addLawsHomeNormalSearchStatistics(list,STANDARD_TYPE, STANDARD_CLASS);
|
||||
if(!CollectionUtils.isEmpty(list1)){
|
||||
obj.setStandardClass(list1);
|
||||
}
|
||||
// 动力类型
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list2 = addLawsHomeNormalSearchStatistics(list, "POWER_TYPE_DOMESTIC", "dynamic_type");
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list2 = addLawsHomeNormalSearchStatistics(list, "POWER_TYPE_DOMESTIC", DYNAMIC_TYPE);
|
||||
if(!CollectionUtils.isEmpty(list2)){
|
||||
obj.setDynamicType(list2);
|
||||
}
|
||||
// 适用车辆类型
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list3 = addLawsHomeNormalSearchStatistics(list,"APPLICATIONS_DOMESTIC", "applicable_vehicle");
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list3 = addLawsHomeNormalSearchStatistics(list,"APPLICATIONS_DOMESTIC", APPLICABLE_VEHICLE);
|
||||
if(!CollectionUtils.isEmpty(list3)){
|
||||
obj.setApplicableVehicle(list3);
|
||||
}
|
||||
// 标准类型
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list4 = addLawsHomeNormalSearchStatistics(list, "standard_property", "standard_property");
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list4 = addLawsHomeNormalSearchStatistics(list, STANDARD_PROPERTY, STANDARD_PROPERTY);
|
||||
if(!CollectionUtils.isEmpty(list4)){
|
||||
obj.setStandardProperty(list4);
|
||||
}
|
||||
// 状态
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list5 = addLawsHomeNormalSearchStatistics(list,"standard_state", "standard_state");
|
||||
List<LawsHomeNormalSearchStatisticsObjVO> list5 = addLawsHomeNormalSearchStatistics(list,STANDARD_STATE, STANDARD_STATE);
|
||||
if(!CollectionUtils.isEmpty(list5)){
|
||||
obj.setStandardState(list5);
|
||||
}
|
||||
@@ -453,10 +512,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
|
||||
@Override
|
||||
public IPage<LawsHomeNormalSearchVO> getNormalSearchAllPage(LawsHomeNormalSearchDTO homeNormalSearchDTO,Integer pageNo,Integer pageSize) {
|
||||
String searchContent = homeNormalSearchDTO.getSearchContent();
|
||||
if(StringUtils.isBlank(searchContent)){
|
||||
throw new JeroBootException(ResultCommon.PLEASE_SEARCH_TO_IMPORT);
|
||||
}
|
||||
String searchContent = checkSearchContent(homeNormalSearchDTO);
|
||||
// 添加检索历史
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
LawsHomeNormalSearchHistory lawsHomeNormalSearchHistory = new LawsHomeNormalSearchHistory();
|
||||
@@ -464,54 +520,44 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
lawsHomeNormalSearchHistory.setSearchContent(searchContent);
|
||||
lawsHomeNormalSearchHistoryService.save(lawsHomeNormalSearchHistory);
|
||||
|
||||
SearchVO searchVO = new SearchVO();
|
||||
searchVO.setSelectValue(homeNormalSearchDTO.getSearchContent());
|
||||
searchVO.setPageNo(pageNo);
|
||||
searchVO.setPageSize(pageSize);
|
||||
JSONArray queryJsonMustNot = new JSONArray();
|
||||
if(StringUtils.isBlank(searchVO.getSelectValue())){
|
||||
searchVO.setSelectValue(SEARCH_FLAG);
|
||||
if(StringUtils.isBlank(searchContent)){
|
||||
searchContent = SEARCH_FLAG;
|
||||
}
|
||||
|
||||
//判断索引是否存在
|
||||
boolean flagTemp;
|
||||
flagTemp = jeroElasticsearchTemplate.indexExists(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue());
|
||||
if (!flagTemp) {
|
||||
return new Page(searchVO.getPageNo(), searchVO.getPageSize());
|
||||
return new Page<>(pageNo, pageSize);
|
||||
}
|
||||
|
||||
String selectValue = searchVO.getSelectValue();
|
||||
|
||||
//1. 需要查询的字段
|
||||
// List<String> fieldList = new ArrayList<>();
|
||||
// fieldList.add("content");//权重1
|
||||
Map<String,String> mapDict = new HashMap<>();
|
||||
if(!StringUtils.isBlank(homeNormalSearchDTO.getResourceType())){
|
||||
mapDict.put("resource_type",homeNormalSearchDTO.getResourceType());
|
||||
mapDict.put(RESOURCE_TYPE,homeNormalSearchDTO.getResourceType());
|
||||
}
|
||||
if(!StringUtils.isBlank(homeNormalSearchDTO.getStandardClass())){
|
||||
mapDict.put("standard_class",homeNormalSearchDTO.getStandardClass());
|
||||
mapDict.put(STANDARD_CLASS,homeNormalSearchDTO.getStandardClass());
|
||||
}
|
||||
if(!StringUtils.isBlank(homeNormalSearchDTO.getDynamicType())){
|
||||
mapDict.put("dynamic_type",homeNormalSearchDTO.getDynamicType());
|
||||
mapDict.put(DYNAMIC_TYPE,homeNormalSearchDTO.getDynamicType());
|
||||
}
|
||||
if(!StringUtils.isBlank(homeNormalSearchDTO.getApplicableVehicle())){
|
||||
mapDict.put("applicable_vehicle",homeNormalSearchDTO.getApplicableVehicle());
|
||||
mapDict.put(APPLICABLE_VEHICLE,homeNormalSearchDTO.getApplicableVehicle());
|
||||
}
|
||||
if(!StringUtils.isBlank(homeNormalSearchDTO.getStandardProperty())){
|
||||
mapDict.put("standard_property",homeNormalSearchDTO.getStandardProperty());
|
||||
mapDict.put(STANDARD_PROPERTY,homeNormalSearchDTO.getStandardProperty());
|
||||
}
|
||||
if(!StringUtils.isBlank(homeNormalSearchDTO.getStandardState())){
|
||||
mapDict.put("standard_state",homeNormalSearchDTO.getStandardState());
|
||||
mapDict.put(STANDARD_STATE,homeNormalSearchDTO.getStandardState());
|
||||
}
|
||||
if(!StringUtils.isBlank(homeNormalSearchDTO.getStandardCode())){
|
||||
mapDict.put("standard_code",homeNormalSearchDTO.getStandardCode());
|
||||
mapDict.put(STANDARD_CODE,homeNormalSearchDTO.getStandardCode());
|
||||
}
|
||||
if(!StringUtils.isBlank(homeNormalSearchDTO.getEnterpriseStandardState())){
|
||||
mapDict.put("enterprise_standard_state",homeNormalSearchDTO.getEnterpriseStandardState());
|
||||
mapDict.put(ENTERPRISE_STANDARD_STATE,homeNormalSearchDTO.getEnterpriseStandardState());
|
||||
}
|
||||
if(!StringUtils.isBlank(homeNormalSearchDTO.getGradeClassification())){
|
||||
mapDict.put("grade_classification",homeNormalSearchDTO.getGradeClassification());
|
||||
mapDict.put(GRADE_CLASSIFICATION,homeNormalSearchDTO.getGradeClassification());
|
||||
}
|
||||
JSONObject jsonAll = new JSONObject();
|
||||
JSONArray queryMapJsonAll = new JSONArray();
|
||||
@@ -528,11 +574,11 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
Map<String,Object> mapHighlight = new HashMap<>();
|
||||
Map<String,Object> mapHighlight1 = new HashMap<>();
|
||||
// 封装首次的条件
|
||||
if (StringUtils.isNotBlank(selectValue)) {
|
||||
selectValue = selectValue.toLowerCase();
|
||||
getQueryMapJson(queryMapJson, selectValue, "content");
|
||||
if (StringUtils.isNotBlank(searchContent)) {
|
||||
searchContent = searchContent.toLowerCase();
|
||||
getQueryMapJson(queryMapJson, searchContent, CONTENT);
|
||||
//高亮
|
||||
highlight(mapHighlight, "content");
|
||||
highlight(mapHighlight, CONTENT);
|
||||
mapHighlight1.put("fields",mapHighlight);
|
||||
}
|
||||
if(CollectionUtils.isNotEmpty(queryMapJson)){
|
||||
@@ -553,12 +599,12 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
Map<String,Object> issueTime = new HashMap<>();
|
||||
issueTimeDesc.put("order","desc");
|
||||
issueTimeAsc.put("order","asc");
|
||||
issueTime.put("resource_type",issueTimeAsc);
|
||||
issueTime.put("standard_type",issueTimeDesc);
|
||||
issueTime.put("create_time",issueTimeDesc);
|
||||
issueTime.put(RESOURCE_TYPE,issueTimeAsc);
|
||||
issueTime.put(STANDARD_TYPE,issueTimeDesc);
|
||||
issueTime.put(CREATE_TIME,issueTimeDesc);
|
||||
sort.putAll(issueTime);
|
||||
IPage page = getIPage(selectValue, queryMapJsonAll, mapHighlight1,
|
||||
pageNo, pageSize, sort,queryJsonMustNot);
|
||||
IPage page = getIPage(searchContent, queryMapJsonAll, mapHighlight1,
|
||||
pageNo, pageSize, sort);
|
||||
if(!CollectionUtils.isEmpty(page.getRecords())){
|
||||
// 下划线转驼峰
|
||||
List<Map<String, Object>> listNew = new ArrayList<>();
|
||||
@@ -576,13 +622,22 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
return page;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String checkSearchContent(LawsHomeNormalSearchDTO homeNormalSearchDTO) {
|
||||
String searchContent = homeNormalSearchDTO.getSearchContent();
|
||||
if (StringUtils.isBlank(searchContent)) {
|
||||
throw new JeroBootException(ResultCommon.PLEASE_SEARCH_TO_IMPORT);
|
||||
}
|
||||
return searchContent;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
private IPage getIPage(String selectValue,JSONArray queryMapJson,Map<String,Object> highlightMap, Integer pageNo, Integer pageSize,
|
||||
JSONObject querySort,JSONArray queryMustNot) {
|
||||
JSONObject querySort) {
|
||||
JSONObject jsonObject;
|
||||
//基础添加封装
|
||||
jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJson, queryMustNot, null);
|
||||
jsonObject = jeroElasticsearchTemplate.buildBoolQuery(queryMapJson, null, null);
|
||||
JSONArray jsonArraySort = new JSONArray();
|
||||
if (SEARCH_FLAG.equals(selectValue)) {
|
||||
jsonArraySort.add(querySort);
|
||||
@@ -609,10 +664,10 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
}
|
||||
}
|
||||
String createTime = "";
|
||||
if(ObjectUtils.isNotEmpty(mapSource.get("create_time"))){
|
||||
createTime = DateUtils.formatTime((Long) mapSource.get("create_time"));
|
||||
if(ObjectUtils.isNotEmpty(mapSource.get(CREATE_TIME))){
|
||||
createTime = DateUtils.formatTime((Long) mapSource.get(CREATE_TIME));
|
||||
}
|
||||
mapSource.put("create_time",createTime);
|
||||
mapSource.put(CREATE_TIME,createTime);
|
||||
mapList.add(mapSource);
|
||||
}
|
||||
//处理分页
|
||||
@@ -643,11 +698,13 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
private void getQueryMapJson(JSONArray queryMapJson, String selectValue, String field) {
|
||||
// 前缀匹配 缺点是前缀一定不能断开
|
||||
//情况举例:用户只记得前面那段字
|
||||
String boost = "boost";
|
||||
String query = "query";
|
||||
Map<String, Object> map21 = new HashMap<>();
|
||||
Map<String, Object> map31 = new HashMap<>();
|
||||
Map<String, Object> map41 = new HashMap<>();
|
||||
if("content".equals(field)){
|
||||
map31.put("boost",0.01);
|
||||
if(CONTENT.equals(field)){
|
||||
map31.put(boost,0.01);
|
||||
}
|
||||
map31.put("value", selectValue);
|
||||
map21.put(field + ".keyword", map31);
|
||||
@@ -658,10 +715,10 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
Map<String, Object> map22 = new HashMap<>();
|
||||
Map<String, Object> map32 = new HashMap<>();
|
||||
Map<String, Object> map42 = new HashMap<>();
|
||||
if("content".equals(field)){
|
||||
map32.put("boost",0.01);
|
||||
if(CONTENT.equals(field)){
|
||||
map32.put(boost,0.01);
|
||||
}
|
||||
map32.put("query", selectValue);
|
||||
map32.put(query, selectValue);
|
||||
map22.put(field, map32);
|
||||
map42.put("match_phrase_prefix", map22);
|
||||
queryMapJson.add(map42);
|
||||
@@ -671,10 +728,10 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
Map<String, Object> map23 = new HashMap<>();
|
||||
Map<String, Object> map33 = new HashMap<>();
|
||||
Map<String, Object> map43 = new HashMap<>();
|
||||
if("content".equals(field)){
|
||||
map33.put("boost",0.01);
|
||||
if(CONTENT.equals(field)){
|
||||
map33.put(boost,0.01);
|
||||
}
|
||||
map33.put("query", selectValue);
|
||||
map33.put(query, selectValue);
|
||||
map23.put(field, map33);
|
||||
map43.put("match", map23);
|
||||
queryMapJson.add(map43);
|
||||
@@ -691,10 +748,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
@Override
|
||||
public LawsHomeNormalSearchStatisticsVO getNormalSearchAllCount(LawsHomeNormalSearchDTO homeNormalSearchDTO) {
|
||||
LawsHomeNormalSearchStatisticsVO obj = new LawsHomeNormalSearchStatisticsVO();
|
||||
String searchContent = homeNormalSearchDTO.getSearchContent();
|
||||
if(StringUtils.isBlank(searchContent)){
|
||||
throw new JeroBootException(ResultCommon.PLEASE_SEARCH_TO_IMPORT);
|
||||
}
|
||||
String searchContent = checkSearchContent(homeNormalSearchDTO);
|
||||
|
||||
//判断索引是否存在
|
||||
boolean flagTemp;
|
||||
@@ -703,23 +757,18 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
return obj;
|
||||
}
|
||||
|
||||
SearchVO searchVO = new SearchVO();
|
||||
searchVO.setSelectValue(homeNormalSearchDTO.getSearchContent());
|
||||
if(StringUtils.isBlank(searchVO.getSelectValue())){
|
||||
searchVO.setSelectValue(SEARCH_FLAG);
|
||||
}
|
||||
String selectValue = searchVO.getSelectValue().toLowerCase();
|
||||
searchContent = searchContent.toLowerCase();
|
||||
|
||||
List<String> listField = new ArrayList<>();
|
||||
listField.add("resource_type");
|
||||
listField.add("standard_class");
|
||||
listField.add("dynamic_type");
|
||||
listField.add("applicable_vehicle");
|
||||
listField.add("standard_property");
|
||||
listField.add("standard_state");
|
||||
listField.add("standard_code");
|
||||
listField.add("enterprise_standard_state");
|
||||
listField.add("grade_classification");
|
||||
listField.add(RESOURCE_TYPE);
|
||||
listField.add(STANDARD_CLASS);
|
||||
listField.add(DYNAMIC_TYPE);
|
||||
listField.add(APPLICABLE_VEHICLE);
|
||||
listField.add(STANDARD_PROPERTY);
|
||||
listField.add(STANDARD_STATE);
|
||||
listField.add(STANDARD_CODE);
|
||||
listField.add(ENTERPRISE_STANDARD_STATE);
|
||||
listField.add(GRADE_CLASSIFICATION);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
for (String s : listField) {
|
||||
@@ -732,43 +781,42 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
jsonObject.put("aggs",map);
|
||||
jsonObject.put("size",0);
|
||||
|
||||
// JSONArray queryMapJson = new JSONArray();
|
||||
// // 封装首次的条件
|
||||
// if (StringUtils.isNotBlank(selectValue)) {
|
||||
// getQueryMapJson(queryMapJson, selectValue, "content");
|
||||
// }
|
||||
// if(CollectionUtils.isNotEmpty(queryMapJson)){
|
||||
// JSONObject object = new JSONObject();
|
||||
// object.put("should",queryMapJson);
|
||||
// jsonObject.put("query",object);
|
||||
// }
|
||||
|
||||
JSONArray queryMapJson = new JSONArray();
|
||||
// 封装首次的条件
|
||||
if (StringUtils.isNotBlank(searchContent)) {
|
||||
getQueryMapJson(queryMapJson, searchContent, CONTENT);
|
||||
}
|
||||
if(CollectionUtils.isNotEmpty(queryMapJson)){
|
||||
JSONObject object = jeroElasticsearchTemplate.buildBoolQuery(null,null,queryMapJson);
|
||||
jsonObject.put("query",object);
|
||||
}
|
||||
|
||||
//2. 数据查询
|
||||
JSONObject search = jeroElasticsearchTemplate.search(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue(), HomeSearchEnum.TYPE_NAME_DOCUMENT_ZQ.getValue(), jsonObject);
|
||||
LawsHomeNormalSearchStatisticsVO objVo = new LawsHomeNormalSearchStatisticsVO();
|
||||
String standardStateAggs = "standard_state_aggs";
|
||||
switch (homeNormalSearchDTO.getResourceType()){
|
||||
case LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD:
|
||||
List<LawsHomeNormalSearchCountVO> list1 = new ArrayList<>();
|
||||
addVo(search, list1, "standard_class_aggs", "standard_class");
|
||||
addVo(search, list1, "dynamic_type_aggs", "dynamic_type");
|
||||
addVo(search, list1, "applicable_vehicle_aggs", "applicable_vehicle");
|
||||
addVo(search, list1, "standard_property_aggs", "standard_property");
|
||||
addVo(search, list1, "standard_state_aggs", "standard_state");
|
||||
addVo(search, list1, "standard_class_aggs", STANDARD_CLASS);
|
||||
addVo(search, list1, "dynamic_type_aggs", DYNAMIC_TYPE);
|
||||
addVo(search, list1, "applicable_vehicle_aggs", APPLICABLE_VEHICLE);
|
||||
addVo(search, list1, "standard_property_aggs", STANDARD_PROPERTY);
|
||||
addVo(search, list1, standardStateAggs, STANDARD_STATE);
|
||||
count1(list1,objVo);
|
||||
break;
|
||||
case LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD:
|
||||
List<LawsHomeNormalSearchCountVO> list2 = new ArrayList<>();
|
||||
addVo(search, list2, "standard_class_aggs", "standard_class");
|
||||
addVo(search, list2, "applicable_vehicle_aggs", "applicable_vehicle");
|
||||
addVo(search, list2, "standard_state_aggs", "standard_state");
|
||||
addVo(search, list2, "standard_class_aggs", STANDARD_CLASS);
|
||||
addVo(search, list2, "applicable_vehicle_aggs", APPLICABLE_VEHICLE);
|
||||
addVo(search, list2, standardStateAggs, STANDARD_STATE);
|
||||
count2(list2,objVo);
|
||||
break;
|
||||
case LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD:
|
||||
List<LawsHomeNormalSearchCountVO> list3 = new ArrayList<>();
|
||||
addVo(search, list3, "standard_code_aggs", "standard_code");
|
||||
addVo(search, list3, "standard_state_aggs", "standard_state");
|
||||
addVo(search, list3, "grade_classification_aggs", "grade_classification");
|
||||
addVo(search, list3, "standard_code_aggs", STANDARD_CODE);
|
||||
addVo(search, list3, standardStateAggs, STANDARD_STATE);
|
||||
addVo(search, list3, "grade_classification_aggs", GRADE_CLASSIFICATION);
|
||||
count3(list3,objVo);
|
||||
break;
|
||||
default:break;
|
||||
@@ -776,15 +824,15 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
return objVo;
|
||||
}
|
||||
|
||||
private void addVo(JSONObject search, List<LawsHomeNormalSearchCountVO> list, String standard_class_aggs, String standard_class) {
|
||||
List<Map<String, Object>> list1 = (List<Map<String, Object>>) ((Map) ((Map) search.get("aggregations")).get(standard_class_aggs)).get("buckets");
|
||||
private void addVo(JSONObject search, List<LawsHomeNormalSearchCountVO> list, String aggs, String fieldName) {
|
||||
List<Map<String, Object>> list1 = (List<Map<String, Object>>) ((Map) ((Map) search.get("aggregations")).get(aggs)).get("buckets");
|
||||
if (!CollectionUtils.isEmpty(list1)) {
|
||||
for (Map<String, Object> stringObjectMap : list1) {
|
||||
LawsHomeNormalSearchCountVO objVo = new LawsHomeNormalSearchCountVO();
|
||||
if (Objects.isNull(stringObjectMap.get("key"))) {
|
||||
continue;
|
||||
}
|
||||
objVo.setFieldName(standard_class);
|
||||
objVo.setFieldName(fieldName);
|
||||
objVo.setDict(stringObjectMap.get("key").toString());
|
||||
objVo.setCount(Objects.isNull(stringObjectMap.get("doc_count")) ? "0" : stringObjectMap.get("doc_count").toString());
|
||||
list.add(objVo);
|
||||
@@ -794,7 +842,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
|
||||
@Override
|
||||
public void updateEsData(String resourceType, String ids, String opType) {
|
||||
if(StringUtils.isBlank(resourceType) || StringUtils.isBlank(resourceType) || StringUtils.isBlank(resourceType)){
|
||||
if(StringUtils.isBlank(resourceType) || StringUtils.isBlank(ids) || StringUtils.isBlank(opType)){
|
||||
throw new JeroBootException(ResultCommon.PARAMETER_NOT_RECOGNIZED);
|
||||
}
|
||||
log.info("================ES更新数据开始=================");
|
||||
@@ -841,9 +889,6 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
int endIndex = getEndIndex(startIndex, batchCount, listIds);
|
||||
List<String> listIdsSub = listIds.subList(startIndex, endIndex);
|
||||
List<LawsDomesticStandard> listLawsDomesticStandard = lawsDomesticStandardService.listByIds(listIdsSub);
|
||||
if(CollectionUtils.isEmpty(listLawsDomesticStandard)){
|
||||
continue;
|
||||
}
|
||||
CompletableFuture.runAsync(()->{
|
||||
for (LawsDomesticStandard lawsDomesticStandard : listLawsDomesticStandard) {
|
||||
try {
|
||||
@@ -865,7 +910,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
List<OSSFile> listFile = getOssFilesLawsDomesticStandard(lawsDomesticStandard);
|
||||
updateES(opType, obj, listFile, lawsDomesticStandard.getId());
|
||||
}catch (Exception e){
|
||||
log.error("同步ES数据异常:",e.getMessage());
|
||||
log.error(SYNC_ES_ERR,e.getMessage());
|
||||
}
|
||||
}
|
||||
},pool);
|
||||
@@ -949,7 +994,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
List<OSSFile> listFile = getOssFilesLawsOverseasStandard(lawsOverseasStandard);
|
||||
updateES(opType, obj, listFile, lawsOverseasStandard.getId());
|
||||
}catch (Exception e){
|
||||
log.error("同步ES数据异常:",e.getMessage());
|
||||
log.error(SYNC_ES_ERR,e.getMessage());
|
||||
}
|
||||
}
|
||||
},pool);
|
||||
@@ -965,27 +1010,28 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
ossFile.orderByAsc(OSSFile::getCreateTime);
|
||||
List<OSSFile> list = oSSFileService.list(ossFile);
|
||||
List<OSSFile> listFile = new ArrayList<>();
|
||||
if(!CollectionUtils.isEmpty(list)){
|
||||
LambdaQueryWrapper<LawsTag> query = new LambdaQueryWrapper<>();
|
||||
query.eq(LawsTag::getTableName,LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD_TABLE_NAME);
|
||||
query.isNotNull(LawsTag::getHomeSearchFileOrder);
|
||||
query.orderByAsc(LawsTag::getHomeSearchFileOrder);
|
||||
List<LawsTag> listLawsTag = lawsTagService.list(query);
|
||||
if(!CollectionUtils.isEmpty(listLawsTag)){
|
||||
List<OSSFile> op = list.stream().filter(o-> Objects.equals(o.getStandardFileType(),listLawsTag.get(0).getDbFieldName())).collect(Collectors.toList());
|
||||
List<OSSFile> opTr = list.stream().filter(o-> Objects.equals(o.getStandardFileType(),listLawsTag.get(1).getDbFieldName())).collect(Collectors.toList());
|
||||
// 有发布稿
|
||||
if(!CollectionUtils.isEmpty(op) || !CollectionUtils.isEmpty(opTr)){
|
||||
if(!CollectionUtils.isEmpty(op)){
|
||||
listFile.addAll(op);
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(opTr)){
|
||||
listFile.addAll(opTr);
|
||||
}
|
||||
}else{
|
||||
for (int i = 2; i < listLawsTag.size(); i++) {
|
||||
getOp(list, listFile, listLawsTag.get(i).getDbFieldName());
|
||||
}
|
||||
if(CollectionUtils.isEmpty(list)){
|
||||
return listFile;
|
||||
}
|
||||
LambdaQueryWrapper<LawsTag> query = new LambdaQueryWrapper<>();
|
||||
query.eq(LawsTag::getTableName,LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD_TABLE_NAME);
|
||||
query.isNotNull(LawsTag::getHomeSearchFileOrder);
|
||||
query.orderByAsc(LawsTag::getHomeSearchFileOrder);
|
||||
List<LawsTag> listLawsTag = lawsTagService.list(query);
|
||||
if(!CollectionUtils.isEmpty(listLawsTag)){
|
||||
List<OSSFile> op = list.stream().filter(o-> Objects.equals(o.getStandardFileType(),listLawsTag.get(0).getDbFieldName())).collect(Collectors.toList());
|
||||
List<OSSFile> opTr = list.stream().filter(o-> Objects.equals(o.getStandardFileType(),listLawsTag.get(1).getDbFieldName())).collect(Collectors.toList());
|
||||
// 有发布稿
|
||||
if(!CollectionUtils.isEmpty(op) || !CollectionUtils.isEmpty(opTr)){
|
||||
if(!CollectionUtils.isEmpty(op)){
|
||||
listFile.addAll(op);
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(opTr)){
|
||||
listFile.addAll(opTr);
|
||||
}
|
||||
}else{
|
||||
for (int i = 2; i < listLawsTag.size(); i++) {
|
||||
getOp(list, listFile, listLawsTag.get(i).getDbFieldName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1026,7 +1072,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
List<OSSFile> listFile = getOssFilesLawsEnterpriseStandard(lawsEnterpriseStandard);
|
||||
updateES(opType, obj, listFile, lawsEnterpriseStandard.getId());
|
||||
}catch (Exception e){
|
||||
log.error("同步ES数据异常:",e.getMessage());
|
||||
log.error(SYNC_ES_ERR,e.getMessage());
|
||||
}
|
||||
}
|
||||
},pool);
|
||||
@@ -1087,7 +1133,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
obj.setResourceType(resourceType);
|
||||
updateESLawsNewsFeed(opType, lawsNewsFeed, obj);
|
||||
}catch (Exception e){
|
||||
log.error("同步ES数据异常:",e.getMessage());
|
||||
log.error(SYNC_ES_ERR,e.getMessage());
|
||||
}
|
||||
}
|
||||
},pool);
|
||||
@@ -1119,23 +1165,9 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
|| ossFile.getFileName().endsWith(".docx")
|
||||
|| ossFile.getFileName().endsWith(".DOC")
|
||||
|| ossFile.getFileName().endsWith(".DOCX")) {
|
||||
try {
|
||||
String wordContent = ReadWordUtil.readWord(ossFile.getUrl(),uploadpath);
|
||||
if (StringUtils.isNotBlank(wordContent)) {
|
||||
fileTextAll.append(wordContent).append(",");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("文档库: 读取word内容失败");
|
||||
}
|
||||
getFileTextAll(fileTextAll, ReadWordUtil.readWord(ossFile.getUrl(), uploadpath), "文档库: 读取word内容失败");
|
||||
} else if (ossFile.getFileName().endsWith(".pdf") || ossFile.getFileName().endsWith(".PDF")) {
|
||||
try {
|
||||
String pdfContent = ReadPdfUtil.readPdf(ossFile.getUrl());
|
||||
if (StringUtils.isNotBlank(pdfContent)) {
|
||||
fileTextAll.append(pdfContent).append(",");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("文档库: 读取PDF文件内容失败");
|
||||
}
|
||||
getFileTextAll(fileTextAll, ReadPdfUtil.readPdf(ossFile.getUrl()), "文档库: 读取PDF文件内容失败");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -1145,22 +1177,33 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
return fileTextAll;
|
||||
}
|
||||
|
||||
private void getFileTextAll(StringBuilder fileTextAll, String s, String s2) {
|
||||
try {
|
||||
String wordContent = s;
|
||||
if (StringUtils.isNotBlank(wordContent)) {
|
||||
fileTextAll.append(wordContent).append(",");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(s2);
|
||||
}
|
||||
}
|
||||
|
||||
private void addES(LawsHomeNormalSearchVO obj, String idTemp, StringBuilder fileTextAll) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", obj.getId());
|
||||
map.put("title", obj.getTitle());
|
||||
map.put("content", fileTextAll);
|
||||
map.put("resource_type", obj.getResourceType());
|
||||
map.put("standard_class", obj.getStandardClass());
|
||||
map.put("dynamic_type", obj.getDynamicType());
|
||||
map.put("applicable_vehicle", obj.getApplicableVehicle());
|
||||
map.put("standard_property", obj.getStandardProperty());
|
||||
map.put("standard_state", obj.getStandardState());
|
||||
map.put("standard_code",obj.getStandardCode());
|
||||
map.put("enterprise_standard_state",obj.getEnterpriseStandardState());
|
||||
map.put("grade_classification",obj.getGradeClassification());
|
||||
map.put("standard_type",obj.getStandardType());
|
||||
map.put("create_time",new Date());
|
||||
map.put(CONTENT, fileTextAll);
|
||||
map.put(RESOURCE_TYPE, obj.getResourceType());
|
||||
map.put(STANDARD_CLASS, obj.getStandardClass());
|
||||
map.put(DYNAMIC_TYPE, obj.getDynamicType());
|
||||
map.put(APPLICABLE_VEHICLE, obj.getApplicableVehicle());
|
||||
map.put(STANDARD_PROPERTY, obj.getStandardProperty());
|
||||
map.put(STANDARD_STATE, obj.getStandardState());
|
||||
map.put(STANDARD_CODE,obj.getStandardCode());
|
||||
map.put(ENTERPRISE_STANDARD_STATE,obj.getEnterpriseStandardState());
|
||||
map.put(GRADE_CLASSIFICATION,obj.getGradeClassification());
|
||||
map.put(STANDARD_TYPE,obj.getStandardType());
|
||||
map.put(CREATE_TIME,new Date());
|
||||
//添加es
|
||||
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(map));
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user