标题检索变更
This commit is contained in:
+1
-1
@@ -64,5 +64,5 @@ public class LawsHomeNormalSearchHistory implements Serializable {
|
||||
/**删除状态(0-正常,1-删除)*/
|
||||
@ApiModelProperty(value = "删除状态(0-正常,1-删除)")
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
private Integer delFlag;
|
||||
}
|
||||
|
||||
+33
-10
@@ -4,22 +4,45 @@
|
||||
|
||||
<select id="getPage" resultType="com.jero.modules.laws.home.vo.LawsHomeNormalSearchVO">
|
||||
select * from (
|
||||
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
|
||||
select id,'1' as resource_type,CONCAT_WS(' ',standard_number,standard_name) AS standard_name,create_time,
|
||||
case when standard_class = 'GB' then 1
|
||||
when standard_class = 'GB/T' then 2
|
||||
when standard_class = 'JT' then 3
|
||||
when standard_class = 'QC/T' then 4
|
||||
when standard_class = 'HJ' then 5
|
||||
else 8
|
||||
end as standard_type_order,
|
||||
case when standard_state = 5 then 2
|
||||
when standard_state = 6 then 1
|
||||
when standard_state = 7 then 3
|
||||
else ''
|
||||
end as standard_state_order,
|
||||
standard_state
|
||||
standard_class,dynamic_type,applicable_vehicle,standard_property,standard_state,'' as standard_code,'' as grade_classification,
|
||||
implementation_date
|
||||
from laws_domestic_standard where del_flag = 0
|
||||
union all
|
||||
select id,'2' as resource_type,standard_number,standard_name,create_time,0 as standard_type,
|
||||
standard_class,'',applicable_vehicle,'',standard_state,'',''
|
||||
select id,'2' as resource_type,CONCAT_WS(' ',standard_number,standard_name) AS standard_name,create_time,7 as standard_type_order,
|
||||
case when standard_state = 5 then 2
|
||||
when standard_state = 6 then 1
|
||||
when standard_state = 7 then 3
|
||||
else ''
|
||||
end as standard_state_order,
|
||||
standard_class,'',applicable_vehicle,'',standard_state,'','',implementation_date
|
||||
from laws_overseas_standard where del_flag = 0
|
||||
union all
|
||||
select id,'3' as resource_type,standard_number,standard_name,create_time,0 as standard_type,
|
||||
'','','','',standard_state,standard_code,grade_classification
|
||||
select id,'3' as resource_type,CONCAT_WS(' ',standard_number,standard_name) AS standard_name,create_time,6 as standard_type_order,
|
||||
case when standard_state = 5 then 2
|
||||
when standard_state = 6 then 1
|
||||
when standard_state = 7 then 3
|
||||
else ''
|
||||
end as standard_state_order,
|
||||
'','','','',standard_state,standard_code,grade_classification,implementation_date
|
||||
from laws_enterprise_standard where del_flag = 0
|
||||
union all
|
||||
select id,'4' as resource_type,'' as standard_number,dynamic_heading as standard_name,create_time,0 as standard_type,
|
||||
'','','','','','',''
|
||||
select id,'4' as resource_type,dynamic_heading as standard_name,create_time,9 as standard_type_order,
|
||||
'' AS standard_state_order,
|
||||
'','','','','','','',''
|
||||
from laws_news_feed where del_flag = 0
|
||||
) as all_data
|
||||
<where>
|
||||
|
||||
+49
-21
@@ -53,8 +53,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Field;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
@@ -135,8 +138,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
@NotNull
|
||||
private QueryWrapper<LawsHomeNormalSearchDTO> getQueryWrapperNormal(LawsHomeNormalSearchDTO 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.gt("instr(standard_name,'" + lawsHomeNormalSearchDTO.getSearchContent() + "')", 0);
|
||||
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);
|
||||
@@ -146,11 +148,11 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
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.orderByAsc("length(REPLACE(standard_name,'" + lawsHomeNormalSearchDTO.getSearchContent() + "',''))/length(standard_name)");
|
||||
queryWrapper.orderByAsc("standard_type_order");
|
||||
queryWrapper.orderByAsc("standard_state_order");
|
||||
queryWrapper.orderByDesc("implementation_date");
|
||||
queryWrapper.orderByDesc(CREATE_TIME);
|
||||
queryWrapper.orderByAsc("CHAR_LENGTH(standard_number)");
|
||||
queryWrapper.orderByAsc("CHAR_LENGTH(standard_name)");
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
@@ -242,11 +244,11 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
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.setTitle((obj.getStandardNumber() + " " + 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);
|
||||
addContent(listSysDict,p,json, obj, LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD_TABLE_NAME,listLawsTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,11 +258,11 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
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.setTitle((obj.getStandardNumber() + " " + 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);
|
||||
addContent(listSysDict,p, json,obj, LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD_TABLE_NAME,listLawsTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,11 +272,11 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
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.setTitle((obj.getStandardNumber() + " " + 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);
|
||||
addContent(listSysDict,p, json,obj, LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD_TABLE_NAME,listLawsTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -311,7 +313,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
return listLawsDomesticStandard;
|
||||
}
|
||||
|
||||
private void addContent(List<SysDictItemCore> listSysDict,LawsHomeNormalSearchVO p, JSONObject json,String tableName, List<LawsTag> listLawsTagAll) {
|
||||
private void addContent(List<SysDictItemCore> listSysDict,LawsHomeNormalSearchVO p, JSONObject json,Object object,String tableName, List<LawsTag> listLawsTagAll) {
|
||||
if (CollectionUtils.isEmpty(listLawsTagAll)) {
|
||||
return;
|
||||
}
|
||||
@@ -325,26 +327,53 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
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)) {
|
||||
String type = lawsTag.getDbType();
|
||||
String fieldName = lawsTag.getDbFieldName();
|
||||
String fieldTxt = lawsTag.getDbFieldTxt();
|
||||
if (StringUtils.isBlank(fieldName) || StringUtils.isBlank(fieldTxt)) {
|
||||
continue;
|
||||
}
|
||||
fileName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, fileName);
|
||||
String key = Objects.isNull(json.get(fileName)) ? "" : String.valueOf(json.get(fileName));
|
||||
fieldName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, fieldName);
|
||||
String key = Objects.isNull(json.get(fieldName)) ? "" : String.valueOf(json.get(fieldName));
|
||||
String textValue = "";
|
||||
// 需要翻译
|
||||
if (!StringUtils.isBlank(code) && !StringUtils.isBlank(key)) {
|
||||
textValue = translateDictValue(listSysDict,code, text, table, key);
|
||||
}else{
|
||||
// 不需要翻译,直接取值
|
||||
textValue = getString(object, type, fieldName, textValue);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(textValue)) {
|
||||
textValue = "--";
|
||||
}
|
||||
str.append(fileTxt).append(":").append(textValue).append(" ");
|
||||
str.append(fieldTxt).append(":").append(textValue).append(" ");
|
||||
}
|
||||
p.setContent(str.toString());
|
||||
}
|
||||
|
||||
private String getString(Object object, String type, String fieldName, String textValue) {
|
||||
for (Field field : oConvertUtils.getAllFields(object)) {
|
||||
if(Objects.equals(field.getName(),fieldName)){
|
||||
try {
|
||||
ReflectionUtils.makeAccessible(field);
|
||||
Object obj = ReflectionUtils.getField(field,object);
|
||||
if(Objects.isNull(obj)){
|
||||
continue;
|
||||
}
|
||||
if(Objects.equals(type,"Date")){
|
||||
textValue = LocalDate.parse(String.valueOf(obj)).toString();
|
||||
}else{
|
||||
textValue = String.valueOf(obj);
|
||||
}
|
||||
} catch (Exception e){
|
||||
log.error("异常", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return textValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译字典文本
|
||||
* @param code 编码
|
||||
@@ -394,8 +423,7 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
||||
public LawsHomeNormalSearchStatisticsVO getNormalSearchTitleCount(LawsHomeNormalSearchDTO lawsHomeNormalSearchDTO) {
|
||||
String searchContent = checkSearchContent(lawsHomeNormalSearchDTO);
|
||||
QueryWrapper<LawsHomeNormalSearchDTO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.and(p -> p.gt("instr(standard_number,'" + searchContent + "')", 0).or()
|
||||
.gt("instr(standard_name,'" + searchContent + "')", 0));
|
||||
queryWrapper.gt("instr(concat_ws(' ',standard_number,standard_name),'" + searchContent + "')", 0);
|
||||
queryWrapper.eq("del_flag",0);
|
||||
String str = "',','))";
|
||||
queryWrapper.gt(!StringUtils.isEmpty(lawsHomeNormalSearchDTO.getStandardClass()),"instr(concat(',',standard_class,','),concat(',','" + lawsHomeNormalSearchDTO.getStandardClass() + str,0);
|
||||
|
||||
Reference in New Issue
Block a user