bug:手机端,搜索中心修改
This commit is contained in:
+128
-19
@@ -6,22 +6,20 @@ import com.adc.da.search.util.DateUtil;
|
|||||||
import com.adc.da.search.util.InitStandAttrSearchUtil;
|
import com.adc.da.search.util.InitStandAttrSearchUtil;
|
||||||
import com.adc.da.sys.dao.DicTypeEODao;
|
import com.adc.da.sys.dao.DicTypeEODao;
|
||||||
import com.adc.da.sys.entity.DicTypeEO;
|
import com.adc.da.sys.entity.DicTypeEO;
|
||||||
import com.adc.da.sys.sarMenuStandard.entity.SarMenuStandard;
|
|
||||||
import com.adc.da.sys.sarMenuStandard.service.ISarMenuStandardService;
|
import com.adc.da.sys.sarMenuStandard.service.ISarMenuStandardService;
|
||||||
|
import com.adc.da.sys.sarResource.entity.SysTsResource;
|
||||||
|
import com.adc.da.sys.sarResource.service.ISysTsResourceService;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.beanutils.BeanUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.poi.ss.formula.functions.T;
|
|
||||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
import org.elasticsearch.action.search.SearchType;
|
import org.elasticsearch.action.search.SearchType;
|
||||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||||
import org.elasticsearch.client.transport.TransportClient;
|
import org.elasticsearch.client.transport.TransportClient;
|
||||||
import org.elasticsearch.common.collect.HppcMaps;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.text.Text;
|
import org.elasticsearch.common.text.Text;
|
||||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||||
@@ -45,7 +43,6 @@ import org.springframework.stereotype.Component;
|
|||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -61,6 +58,9 @@ public class SearchCenterServiceImpl implements SearchCenterService {
|
|||||||
@Resource
|
@Resource
|
||||||
private ISarMenuStandardService sarMenuStandardService;
|
private ISarMenuStandardService sarMenuStandardService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ISysTsResourceService tsResourceService;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TransportClient transportClient;
|
private TransportClient transportClient;
|
||||||
@@ -231,6 +231,7 @@ public class SearchCenterServiceImpl implements SearchCenterService {
|
|||||||
String sortField1 = "";
|
String sortField1 = "";
|
||||||
String sortField2 = "";
|
String sortField2 = "";
|
||||||
String sortField3 = "";
|
String sortField3 = "";
|
||||||
|
String sortField4 = "";
|
||||||
if("laws".equals(searchInfoEO.getSelectIndex())){
|
if("laws".equals(searchInfoEO.getSelectIndex())){
|
||||||
sortField1 = "lawsNumber";
|
sortField1 = "lawsNumber";
|
||||||
sortField2 = "lawsYear";
|
sortField2 = "lawsYear";
|
||||||
@@ -240,18 +241,69 @@ public class SearchCenterServiceImpl implements SearchCenterService {
|
|||||||
sortField2 = "standYear";
|
sortField2 = "standYear";
|
||||||
sortField3 = "standSort.keyword";
|
sortField3 = "standSort.keyword";
|
||||||
}
|
}
|
||||||
|
// if("laws".equals(searchInfoEO.getSelectIndex())){
|
||||||
|
// sortField1 = "lawsNumber";
|
||||||
|
// sortField2 = "lawsYear";
|
||||||
|
// sortField3 = "lawsType.keyword";
|
||||||
|
// } else if("bussstand".equals(searchInfoEO.getSelectIndex())) {
|
||||||
|
// sortField1 = "putTime";
|
||||||
|
// sortField2 = "standNumber";
|
||||||
|
// sortField3 = "standYear";
|
||||||
|
// sortField4 = "standSort.keyword";
|
||||||
|
// } else if ("stand".equals(searchInfoEO.getSelectIndex())) {
|
||||||
|
// sortField1 = "SSRQ";
|
||||||
|
// sortField2 = "standNumber";
|
||||||
|
// sortField3 = "standYear";
|
||||||
|
// sortField4 = "standSort.keyword";
|
||||||
|
// } else {
|
||||||
|
// sortField1 = "standNumber";
|
||||||
|
// sortField2 = "standYear";
|
||||||
|
// sortField3 = "standSort.keyword";
|
||||||
|
// }
|
||||||
|
|
||||||
List<String> menuNameList = new ArrayList<>();
|
|
||||||
// 国内海外查询标准体系字段由id变为文字
|
// 国内海外查询标准体系字段由id变为文字
|
||||||
|
// if (StringUtils.isNotBlank(searchInfoEO.getStandSystem())) {
|
||||||
|
// ArrayList<String> menuIdList = new ArrayList<>();
|
||||||
|
// Collections.addAll(menuIdList,searchInfoEO.getStandSystem().split(","));
|
||||||
|
// LambdaQueryWrapper<SarMenuStandard> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
// wrapper.in(SarMenuStandard::getId,menuIdList);
|
||||||
|
// wrapper.select(SarMenuStandard::getMenuName);
|
||||||
|
// List<SarMenuStandard> sarMenuStandardList = sarMenuStandardService.list(wrapper);
|
||||||
|
// menuNameList = sarMenuStandardList.stream().map(SarMenuStandard::getMenuName).collect(Collectors.toList());
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 处理菜单名称
|
||||||
|
List<String> menuNameList = new ArrayList<>();
|
||||||
if (StringUtils.isNotBlank(searchInfoEO.getStandSystem())) {
|
if (StringUtils.isNotBlank(searchInfoEO.getStandSystem())) {
|
||||||
ArrayList<String> menuIdList = new ArrayList<>();
|
ArrayList<String> menuIdList = new ArrayList<>();
|
||||||
Collections.addAll(menuIdList,searchInfoEO.getStandSystem().split(","));
|
Collections.addAll(menuIdList, searchInfoEO.getStandSystem().split(","));
|
||||||
LambdaQueryWrapper<SarMenuStandard> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysTsResource> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.in(SarMenuStandard::getId,menuIdList);
|
wrapper.in(SysTsResource::getId, menuIdList);
|
||||||
wrapper.select(SarMenuStandard::getMenuName);
|
wrapper.select(SysTsResource::getMenuName);
|
||||||
List<SarMenuStandard> sarMenuStandardList = sarMenuStandardService.list(wrapper);
|
List<SysTsResource> tsResourceList = tsResourceService.list(wrapper);
|
||||||
menuNameList = sarMenuStandardList.stream().map(SarMenuStandard::getMenuName).collect(Collectors.toList());
|
List<String> tempList = tsResourceList.stream().map(SysTsResource::getMenuName).collect(Collectors.toList());
|
||||||
|
if ("bussstand".equals(searchInfoEO.getSelectIndex())) {
|
||||||
|
// 和ES中的类别对应
|
||||||
|
for (String menuName : tempList) {
|
||||||
|
menuNameList.add(getReplaceStandSortStr(menuName));
|
||||||
|
}
|
||||||
|
} else if ("stand".equals(searchInfoEO.getSelectIndex())) {
|
||||||
|
if (StringUtils.isNotBlank(searchInfoEO.getStandSystem())) {
|
||||||
|
// 使用正则表达式提取括号内的内容
|
||||||
|
Pattern pattern = Pattern.compile("(([^()]+))");
|
||||||
|
for (String menuName : tempList) {
|
||||||
|
Matcher matcher = pattern.matcher(menuName);
|
||||||
|
if (matcher.find()) {
|
||||||
|
String contentInBrackets = matcher.group(1);
|
||||||
|
menuNameList.add(contentInBrackets);
|
||||||
|
} else {
|
||||||
|
menuNameList.add(menuName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchRequestBuilder = client.prepareSearch(searchInfoEO.getSelectIndex())
|
searchRequestBuilder = client.prepareSearch(searchInfoEO.getSelectIndex())
|
||||||
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
||||||
.addSort(new ScoreSortBuilder().order(SortOrder.DESC))
|
.addSort(new ScoreSortBuilder().order(SortOrder.DESC))
|
||||||
@@ -366,19 +418,34 @@ public class SearchCenterServiceImpl implements SearchCenterService {
|
|||||||
}
|
}
|
||||||
boolQueryBuilder.must(boolQueryShould);
|
boolQueryBuilder.must(boolQueryShould);
|
||||||
}else {
|
}else {
|
||||||
|
// if (!menuNameList.isEmpty()) {
|
||||||
|
// menuNameList.forEach(each -> {
|
||||||
|
// if ("stand".equals(searchInfoEO.getSelectIndex())) {
|
||||||
|
// boolQueryBuilder.must(QueryBuilders.matchQuery("standSystem","*"+each+"*"));
|
||||||
|
// }else if ("bussstand".equals(searchInfoEO.getSelectIndex())) {
|
||||||
|
// boolQueryBuilder.must(QueryBuilders.matchQuery("TXLBBUSS",each));
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
if (!menuNameList.isEmpty()) {
|
if (!menuNameList.isEmpty()) {
|
||||||
menuNameList.forEach(each -> {
|
menuNameList.forEach(each -> boolQueryBuilder.must(QueryBuilders.matchQuery("standSort","*"+each+"*")));
|
||||||
if ("stand".equals(searchInfoEO.getSelectIndex())) {
|
|
||||||
boolQueryBuilder.must(QueryBuilders.matchQuery("standSystem","*"+each+"*"));
|
|
||||||
}else if ("bussstand".equals(searchInfoEO.getSelectIndex())) {
|
|
||||||
boolQueryBuilder.must(QueryBuilders.matchQuery("TXLBBUSS",each));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if ("stand".equals(searchInfoEO.getSelectIndex()) && StringUtils.isNotBlank(searchInfoEO.getStandType())) {
|
if ("stand".equals(searchInfoEO.getSelectIndex()) && StringUtils.isNotBlank(searchInfoEO.getStandType())) {
|
||||||
boolQueryBuilder.must(QueryBuilders.wildcardQuery("standType.keyword", "*"+searchInfoEO.getStandType()+"*"));
|
boolQueryBuilder.must(QueryBuilders.wildcardQuery("standType.keyword", "*"+searchInfoEO.getStandType()+"*"));
|
||||||
}
|
}
|
||||||
boolQueryBuilder.must(boolQueryShould);
|
boolQueryBuilder.must(boolQueryShould);
|
||||||
|
if (StringUtils.isNotBlank(searchInfoEO.getTextStatus())) {
|
||||||
|
if (searchInfoEO.getSelectIndex().equals("bussstand")) {
|
||||||
|
if ("现行有效".equals(searchInfoEO.getTextStatus())) {
|
||||||
|
boolQueryBuilder.must(QueryBuilders.termQuery("textStatusBuss", "9z741h2m3j")).boost(1009f);
|
||||||
|
}
|
||||||
|
} else if (searchInfoEO.getSelectIndex().equals("stand")) {
|
||||||
|
if ("现行有效".equals(searchInfoEO.getTextStatus())) {
|
||||||
|
boolQueryBuilder.must(QueryBuilders.termQuery("textStatus", "vsaga7nwub")).boost(1009f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchRequestBuilder.setQuery(boolQueryBuilder).setTrackTotalHits(true);
|
searchRequestBuilder.setQuery(boolQueryBuilder).setTrackTotalHits(true);
|
||||||
@@ -2207,6 +2274,48 @@ public class SearchCenterServiceImpl implements SearchCenterService {
|
|||||||
log.info(response.getHits().toString());
|
log.info(response.getHits().toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getReplaceStandSortStr(String standSort){
|
||||||
|
switch (standSort){
|
||||||
|
case "A类标准(技术条件)":
|
||||||
|
return "Q/FT A";
|
||||||
|
case "B类标准(技术基础)":
|
||||||
|
return "Q/FT B";
|
||||||
|
case "C类标准(产品标准)":
|
||||||
|
return "Q/FT C";
|
||||||
|
case "E类标准(发动机)":
|
||||||
|
return "Q/FT E";
|
||||||
|
case " F类标准(仿真分析)":
|
||||||
|
return "Q/FT F";
|
||||||
|
case "G类标准":
|
||||||
|
return "Q/FT G";
|
||||||
|
case "M类标准(工程机械)":
|
||||||
|
return "Q/FT M";
|
||||||
|
case "P类标准(工艺工装)":
|
||||||
|
return "Q/FT P";
|
||||||
|
case "Q类标准(质量评审)":
|
||||||
|
return "Q/FT Q";
|
||||||
|
case "T类标准(试验标准)":
|
||||||
|
return "Q/FT T";
|
||||||
|
case "R类标准(设计规范)":
|
||||||
|
return "Q/FT R";
|
||||||
|
case "V类标准(评价标准)":
|
||||||
|
return "Q/FT V";
|
||||||
|
case "X类标准(出口车)":
|
||||||
|
return "Q/FT X";
|
||||||
|
case "Z类标准(指导性技术文件)":
|
||||||
|
return "Q/FT Z";
|
||||||
|
case "S类标准(产品试制标准)":
|
||||||
|
return "Q/FT S";
|
||||||
|
case "Y类标准(标杆研究标准)":
|
||||||
|
return "Q/FT Y";
|
||||||
|
case "参考标准":
|
||||||
|
return "FT";
|
||||||
|
default:
|
||||||
|
return "其他企业标准";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.adc.da.sys.sarResource.dao;
|
||||||
|
|
||||||
|
import com.adc.da.sys.sarResource.entity.SysTsResource;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zyl
|
||||||
|
* @since 2021-06-30
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public interface SysTsResourceDao extends BaseMapper<SysTsResource> {
|
||||||
|
|
||||||
|
List<SysTsResource> queryMenuByDis(SysTsResource sarMenuEO);
|
||||||
|
|
||||||
|
List<SysTsResource> selectMenuByRole(SysTsResource sarMenuEO);
|
||||||
|
|
||||||
|
int insertTsRoleResource(HashMap<String,Object> map);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
package com.adc.da.sys.sarResource.entity;
|
||||||
|
|
||||||
|
import com.adc.da.base.entity.BaseEntity;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zyl
|
||||||
|
* @since 2021-06-30
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value="TsResource对象", description="")
|
||||||
|
@TableName("ts_resource")
|
||||||
|
public class SysTsResource extends BaseEntity {
|
||||||
|
public interface update{
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
@TableId(value = "ID",type = IdType.UUID)
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "标准法规划分")
|
||||||
|
@TableField("SOR_DIVIDE")
|
||||||
|
private String sorDivide;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "目录名称")
|
||||||
|
@TableField("MENU_NAME")
|
||||||
|
private String menuName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "父级ID")
|
||||||
|
@TableField("PARENT_ID")
|
||||||
|
private String parentId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "父级ID")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String middleParentId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "父级ID集合")
|
||||||
|
@TableField("PARENT_IDS")
|
||||||
|
private String parentIds;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "排序序号")
|
||||||
|
@TableField("DISPLAY_SEQ")
|
||||||
|
private Integer displaySeq;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否有效")
|
||||||
|
@TableField("VALID_FLAG")
|
||||||
|
private Integer validFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
@TableField("CREATION_TIME")
|
||||||
|
private Date creationTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "修改时间")
|
||||||
|
@TableField("MODIFY_TIME")
|
||||||
|
private Date modifyTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
@TableField("REMARKS")
|
||||||
|
private String remarks;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "子菜单")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<SysTsResource> children;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "上级菜单名称")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String parentIdsName;
|
||||||
|
|
||||||
|
@TableField(exist=false)
|
||||||
|
private List<String> roleIds;
|
||||||
|
|
||||||
|
@TableField(exist=false)
|
||||||
|
private List<String> childMenuIds;
|
||||||
|
|
||||||
|
@TableField(exist=false)
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String isFlow;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "树结构数据 区分 类型: 标准数据 tsr 技术系列 sarMs")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String treeType;
|
||||||
|
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package com.adc.da.sys.sarResource.service;
|
||||||
|
|
||||||
|
import com.adc.da.sys.sarResource.entity.SysTsResource;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zyl
|
||||||
|
* @since 2021-06-30
|
||||||
|
*/
|
||||||
|
public interface ISysTsResourceService extends IService<SysTsResource> {
|
||||||
|
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package com.adc.da.sys.sarResource.service.impl;
|
||||||
|
|
||||||
|
import com.adc.da.sys.sarResource.dao.SysTsResourceDao;
|
||||||
|
import com.adc.da.sys.sarResource.entity.SysTsResource;
|
||||||
|
import com.adc.da.sys.sarResource.service.ISysTsResourceService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zyl
|
||||||
|
* @since 2021-06-30
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysTsResourceServiceImpl extends ServiceImpl<SysTsResourceDao, SysTsResource> implements ISysTsResourceService {
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user