|
@@ -1,11 +1,13 @@
|
|
|
package cn.cslg.pas.service.business.es;
|
|
|
|
|
|
+import cn.cslg.pas.common.dto.PatentColumnDTO;
|
|
|
import cn.cslg.pas.common.dto.PatentDTO;
|
|
|
import cn.cslg.pas.common.dto.business.EsCountDTO;
|
|
|
import cn.cslg.pas.common.dto.business.EsCountDetailDTO;
|
|
|
import cn.cslg.pas.common.model.request.QueryRequest;
|
|
|
import cn.cslg.pas.common.vo.EsConfigVO;
|
|
|
import cn.cslg.pas.common.vo.business.EsCountVO;
|
|
|
+import cn.cslg.pas.common.vo.business.PatentNoVO;
|
|
|
import cn.cslg.pas.domain.es.Patent;
|
|
|
import cn.cslg.pas.factorys.EsBuilderFactory.IQueryBuilder;
|
|
|
import cn.cslg.pas.factorys.EsCountBuilderFactory.EsCountBuilderFactory;
|
|
@@ -13,18 +15,23 @@ import cn.cslg.pas.factorys.EsCountBuilderFactory.IEsCountBuilder;
|
|
|
import cn.cslg.pas.service.business.CommonService;
|
|
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
|
|
import co.elastic.clients.elasticsearch._types.aggregations.*;
|
|
|
+import co.elastic.clients.elasticsearch._types.query_dsl.HasChildQuery;
|
|
|
+import co.elastic.clients.elasticsearch._types.query_dsl.Query;
|
|
|
import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
|
|
|
import co.elastic.clients.elasticsearch.core.SearchRequest;
|
|
|
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
|
|
+import co.elastic.clients.elasticsearch.core.search.Hit;
|
|
|
import co.elastic.clients.json.JsonData;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.data.elasticsearch.client.elc.ElasticsearchAggregations;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Comparator;
|
|
@@ -61,7 +68,7 @@ public class EsCountService {
|
|
|
Integer topN = vo.getTopN();
|
|
|
|
|
|
SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
- builder.index("patent_v1");
|
|
|
+ builder.index("patent");
|
|
|
IEsCountBuilder iEsCountBuilder = null;
|
|
|
String json = CommonService.readJsonFile("esCount.json");
|
|
|
List<EsConfigVO> esConfigVOS = JSON.parseArray(json, EsConfigVO.class);
|
|
@@ -140,4 +147,28 @@ public class EsCountService {
|
|
|
esCountDTO.setDetailDTOS(detailDTOS);
|
|
|
return esCountDTO;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据专利号查询专利详情
|
|
|
+ * @param vo
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public PatentColumnDTO selectPatentDetail(PatentNoVO vo) throws IOException {
|
|
|
+ PatentColumnDTO dto = new PatentColumnDTO();
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
+ //设置查询索引
|
|
|
+ builder.index("patent");
|
|
|
+ Query q = QueryBuilders.term(i -> i.field("patent_no.keyword").value(vo.getPatentNo()));
|
|
|
+ Query query = QueryBuilders.bool(i -> i.must(q));
|
|
|
+ builder.query(query);
|
|
|
+ SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ List<PatentColumnDTO> list = new ArrayList<>();
|
|
|
+ List<Hit<Patent>> hits = response.hits().hits();
|
|
|
+ for (Hit<Patent> hit : hits) {
|
|
|
+ Patent esMess = hit.source();
|
|
|
+ BeanUtils.copyProperties(esMess, dto);
|
|
|
+ }
|
|
|
+ return dto;
|
|
|
+ }
|
|
|
}
|