|
@@ -1,40 +1,21 @@
|
|
package cn.cslg.pas.service.business.es;
|
|
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.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.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.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.EsCountBuilderFactory.EsCountBuilderFactory;
|
|
import cn.cslg.pas.factorys.EsCountBuilderFactory.EsCountBuilderFactory;
|
|
import cn.cslg.pas.factorys.EsCountBuilderFactory.IEsCountBuilder;
|
|
import cn.cslg.pas.factorys.EsCountBuilderFactory.IEsCountBuilder;
|
|
import cn.cslg.pas.service.business.CommonService;
|
|
import cn.cslg.pas.service.business.CommonService;
|
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
|
import co.elastic.clients.elasticsearch._types.aggregations.*;
|
|
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.SearchRequest;
|
|
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
|
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 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.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
-import org.springframework.data.elasticsearch.client.elc.ElasticsearchAggregations;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
@@ -44,7 +25,6 @@ import java.util.Arrays;
|
|
import java.util.Comparator;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
@@ -149,122 +129,8 @@ public class EsCountService {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
-// detailDTOS.addAll(countDetailDTOS);
|
|
|
|
}
|
|
}
|
|
esCountDTO.setDetailDTOS(detailDTOS);
|
|
esCountDTO.setDetailDTOS(detailDTOS);
|
|
return esCountDTO;
|
|
return esCountDTO;
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 根据专利号查询专利详情
|
|
|
|
- * @param vo
|
|
|
|
- * @return
|
|
|
|
- * @throws IOException
|
|
|
|
- */
|
|
|
|
- public PatentDetailDTO selectPatentDetail(PatentNoVO vo) throws IOException {
|
|
|
|
- PatentDetailDTO dto = new PatentDetailDTO();
|
|
|
|
- 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<Hit<Patent>> hits = response.hits().hits();
|
|
|
|
- for (Hit<Patent> hit : hits) {
|
|
|
|
- Patent esMess = hit.source();
|
|
|
|
- BeanUtils.copyProperties(esMess, 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;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|