|
@@ -2,13 +2,19 @@ package cn.cslg.pas.service.business.es;
|
|
|
|
|
|
import cn.cslg.pas.common.dto.PatentColumnDTO;
|
|
import cn.cslg.pas.common.dto.PatentColumnDTO;
|
|
import cn.cslg.pas.common.dto.PatentDTO;
|
|
import cn.cslg.pas.common.dto.PatentDTO;
|
|
|
|
+import cn.cslg.pas.common.dto.PatentDetailDTO;
|
|
|
|
+import cn.cslg.pas.common.dto.PatentKinDTO;
|
|
import cn.cslg.pas.common.dto.business.EsCountDTO;
|
|
import cn.cslg.pas.common.dto.business.EsCountDTO;
|
|
import cn.cslg.pas.common.dto.business.EsCountDetailDTO;
|
|
import cn.cslg.pas.common.dto.business.EsCountDetailDTO;
|
|
import cn.cslg.pas.common.model.request.QueryRequest;
|
|
import cn.cslg.pas.common.model.request.QueryRequest;
|
|
import cn.cslg.pas.common.vo.EsConfigVO;
|
|
import cn.cslg.pas.common.vo.EsConfigVO;
|
|
import cn.cslg.pas.common.vo.business.EsCountVO;
|
|
import cn.cslg.pas.common.vo.business.EsCountVO;
|
|
|
|
+import cn.cslg.pas.common.vo.business.PatentKinDetailVO;
|
|
|
|
+import cn.cslg.pas.common.vo.business.PatentKinVO;
|
|
import cn.cslg.pas.common.vo.business.PatentNoVO;
|
|
import cn.cslg.pas.common.vo.business.PatentNoVO;
|
|
|
|
+import cn.cslg.pas.domain.es.FamilyPatent;
|
|
import cn.cslg.pas.domain.es.Patent;
|
|
import cn.cslg.pas.domain.es.Patent;
|
|
|
|
+import cn.cslg.pas.domain.es.PatentFamilyMessage;
|
|
import cn.cslg.pas.factorys.EsBuilderFactory.IQueryBuilder;
|
|
import cn.cslg.pas.factorys.EsBuilderFactory.IQueryBuilder;
|
|
import cn.cslg.pas.factorys.EsCountBuilderFactory.EsCountBuilderFactory;
|
|
import cn.cslg.pas.factorys.EsCountBuilderFactory.EsCountBuilderFactory;
|
|
import cn.cslg.pas.factorys.EsCountBuilderFactory.IEsCountBuilder;
|
|
import cn.cslg.pas.factorys.EsCountBuilderFactory.IEsCountBuilder;
|
|
@@ -24,6 +30,7 @@ import co.elastic.clients.elasticsearch.core.search.Hit;
|
|
import co.elastic.clients.json.JsonData;
|
|
import co.elastic.clients.json.JsonData;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
@@ -43,8 +50,8 @@ import java.util.stream.Stream;
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
public class EsCountService {
|
|
public class EsCountService {
|
|
private final List<String> termList = Arrays.asList();
|
|
private final List<String> termList = Arrays.asList();
|
|
- private final List<String> nestedList = Arrays.asList("PA","IN","PE");
|
|
|
|
- private final List<String> dateList = Arrays.asList("PD","AD");
|
|
|
|
|
|
+ private final List<String> nestedList = Arrays.asList("PA", "IN", "PE");
|
|
|
|
+ private final List<String> dateList = Arrays.asList("PD", "AD");
|
|
|
|
|
|
private final ElasticsearchClient client;
|
|
private final ElasticsearchClient client;
|
|
|
|
|
|
@@ -154,8 +161,9 @@ public class EsCountService {
|
|
* @return
|
|
* @return
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
- public PatentColumnDTO selectPatentDetail(PatentNoVO vo) throws IOException {
|
|
|
|
- PatentColumnDTO dto = new PatentColumnDTO();
|
|
|
|
|
|
+ public PatentDetailDTO selectPatentDetail(PatentNoVO vo) throws IOException {
|
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
|
+ PatentDetailDTO dto = new PatentDetailDTO();
|
|
SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
//设置查询索引
|
|
//设置查询索引
|
|
builder.index("patent");
|
|
builder.index("patent");
|
|
@@ -163,12 +171,111 @@ public class EsCountService {
|
|
Query query = QueryBuilders.bool(i -> i.must(q));
|
|
Query query = QueryBuilders.bool(i -> i.must(q));
|
|
builder.query(query);
|
|
builder.query(query);
|
|
SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
- List<PatentColumnDTO> list = new ArrayList<>();
|
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
for (Hit<Patent> hit : hits) {
|
|
for (Hit<Patent> hit : hits) {
|
|
Patent esMess = hit.source();
|
|
Patent esMess = hit.source();
|
|
BeanUtils.copyProperties(esMess, dto);
|
|
BeanUtils.copyProperties(esMess, dto);
|
|
}
|
|
}
|
|
|
|
+ PatentKinVO kinVO = new PatentKinVO();
|
|
|
|
+ kinVO.setPatentNo(vo.getPatentNo());
|
|
|
|
+ kinVO.setPageNum(1);
|
|
|
|
+ kinVO.setPageSize(10);
|
|
|
|
+ kinVO.setType("inpadoc");
|
|
|
|
+ List<PatentKinDTO> kinDTOS = this.selectKinByPatentNo(kinVO);
|
|
|
|
+ dto.setKinDTOS(kinDTOS);
|
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
|
+ long l = endTime - startTime;
|
|
|
|
+ System.out.println("方法执行了共" + l + "毫秒");
|
|
return dto;
|
|
return dto;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据专利号查询出同族专利列表
|
|
|
|
+ * @param vo
|
|
|
|
+ * @return
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ public List<PatentKinDTO> selectKinByPatentNo(PatentKinVO vo) throws IOException {
|
|
|
|
+ //1.根据专利号查询出同族
|
|
|
|
+ String no = vo.getPatentNo();
|
|
|
|
+ Integer pageNum = vo.getPageNum();
|
|
|
|
+ Integer pageSize = vo.getPageSize();
|
|
|
|
+ String type = vo.getType();
|
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
|
+ //设置查询索引
|
|
|
|
+ builder.index("patent_family");
|
|
|
|
+ //申请号
|
|
|
|
+ Query q1 = QueryBuilders.term(t -> t.field("app_no.keyword").value(no));
|
|
|
|
+ //公开号
|
|
|
|
+ Query q2 = QueryBuilders.term(t -> t.field("public_no.keyword").value(no));
|
|
|
|
+ //授权号
|
|
|
|
+ Query q3 = QueryBuilders.term(t -> t.field("grant_no.keyword").value(no));
|
|
|
|
+ //同族类型
|
|
|
|
+ Query q4 = QueryBuilders.term(t -> t.field("family_type").value(type));
|
|
|
|
+ Query bool = QueryBuilders.bool(i -> i.must(q4).should(q1, q2, q3));
|
|
|
|
+ builder.query(bool);
|
|
|
|
+ //分页
|
|
|
|
+ if (pageNum > 0 && pageSize > 0) {
|
|
|
|
+ builder.from((pageNum - 1) * pageSize).size(pageSize);
|
|
|
|
+ }
|
|
|
|
+ SearchResponse<PatentFamilyMessage> response = client.search(builder.build(), PatentFamilyMessage.class);
|
|
|
|
+ List<Hit<PatentFamilyMessage>> hits = response.hits().hits();
|
|
|
|
+ List<PatentKinDTO> kinDTOS = new ArrayList<>();
|
|
|
|
+ for (Hit<PatentFamilyMessage> hit : hits) {
|
|
|
|
+ PatentFamilyMessage familyMessage = hit.source();
|
|
|
|
+ List<FamilyPatent> patentList = familyMessage.getPatent();
|
|
|
|
+ if (!CollectionUtils.isEmpty(patentList)) {
|
|
|
|
+ for (FamilyPatent familyPatent : patentList) {
|
|
|
|
+ PatentKinDetailVO kinDetailVO = new PatentKinDetailVO();
|
|
|
|
+ kinDetailVO.setAppNo(familyPatent.getAppNo());
|
|
|
|
+ kinDetailVO.setPublicNo(familyPatent.getPublicNo());
|
|
|
|
+ kinDetailVO.setGrantNo(familyPatent.getGrantNo());
|
|
|
|
+ PatentKinDTO kinDTO = this.selectPatentKindDetail(kinDetailVO)
|
|
|
|
+ .stream().findFirst().orElse(null);
|
|
|
|
+ if (kinDTO != null) {
|
|
|
|
+ kinDTOS.add(kinDTO);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
|
+ return kinDTOS;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<PatentKinDTO> selectPatentKindDetail(PatentKinDetailVO vo) throws IOException {
|
|
|
|
+ List<PatentKinDTO> list = new ArrayList<>();
|
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
|
+ //设置查询索引
|
|
|
|
+ builder.index("patent");
|
|
|
|
+ //申请号
|
|
|
|
+ if (StringUtils.isNotEmpty(vo.getAppNo())) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ Query q1 = QueryBuilders.term(t -> t.field("patent_no.keyword").value(vo.getAppNo()));
|
|
|
|
+ //公开号
|
|
|
|
+ Query q2 = QueryBuilders.term(t -> t.field("patent_no.keyword").value(vo.getPublicNo()));
|
|
|
|
+ //授权号
|
|
|
|
+// Query q3 = QueryBuilders.term(t -> t.field("patent_no.keyword").value(vo.getGrantNo()));
|
|
|
|
+ Query bool = QueryBuilders.bool(i -> i.should(q1, q2));
|
|
|
|
+ builder.query(bool);
|
|
|
|
+ SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
|
+ List<Hit<Patent>> hits = response.hits().hits();
|
|
|
|
+ for (Hit<Patent> hit : hits) {
|
|
|
|
+ PatentKinDTO kinDTO = new PatentKinDTO();
|
|
|
|
+ Patent patent = hit.source();
|
|
|
|
+ if (patent != null) {
|
|
|
|
+ kinDTO.setPatentNo(patent.getPatentNo());
|
|
|
|
+ kinDTO.setAppNo(patent.getAppNo());
|
|
|
|
+ kinDTO.setPublicNo(patent.getPublicNo());
|
|
|
|
+ kinDTO.setGrantNo(patent.getGrantNo());
|
|
|
|
+ kinDTO.setTitle(patent.getTitle());
|
|
|
|
+ kinDTO.setAbstractStr(patent.getAbstractStr());
|
|
|
|
+ kinDTO.setApplicant(patent.getApplicant());
|
|
|
|
+ kinDTO.setRightHolder(patent.getRightHolder());
|
|
|
|
+ list.add(kinDTO);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
}
|
|
}
|