|
@@ -587,37 +587,28 @@ public class EsPatentService {
|
|
|
Long current = queryRequest.getCurrent();
|
|
|
Long size = queryRequest.getSize();
|
|
|
EsPatentCommonVO esPatentCommonVO = esService.tranPatentRequestToComVO(queryRequest);
|
|
|
- esPatentCommonVO.setStartNum(current);
|
|
|
- esPatentCommonVO.setEndNum(current+size);
|
|
|
- esPatentCommonVO.setCurrent(null);
|
|
|
- esPatentCommonVO.setSize(null);
|
|
|
+ esPatentCommonVO.setStartNum(current);
|
|
|
+ esPatentCommonVO.setEndNum(current + size);
|
|
|
+ esPatentCommonVO.setCurrent(null);
|
|
|
+ esPatentCommonVO.setSize(null);
|
|
|
SearchRequest.Builder builder = esService.getCommonPatent(esPatentCommonVO);
|
|
|
Records records = new Records();
|
|
|
- if (esPatentCommonVO.getEsField() == null || esPatentCommonVO.getEsField().equals("")) {
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
- List<Hit<Patent>> hits = response.hits().hits();
|
|
|
- for (Hit<Patent> hit : hits) {
|
|
|
- PatentPageMessageVO patentPageMessageVO = new PatentPageMessageVO();
|
|
|
- patentPageMessageVO.setPatentNo(hit.source().getPatentNo());
|
|
|
- patentPageMessageVOS.add(patentPageMessageVO);
|
|
|
- }
|
|
|
- records.setTotal(response.hits().total().value());
|
|
|
+ SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ List<Hit<Patent>> hits = response.hits().hits();
|
|
|
+ for (Hit<Patent> hit : hits) {
|
|
|
+ PatentPageMessageVO patentPageMessageVO = new PatentPageMessageVO();
|
|
|
+ patentPageMessageVO.setPatentNo(hit.source().getPatentNo());
|
|
|
+ patentPageMessageVOS.add(patentPageMessageVO);
|
|
|
+ }
|
|
|
+ long total = 0L;
|
|
|
+ if (StringUtils.isNotEmpty(esPatentCommonVO.getEsField())) {
|
|
|
+ Aggregate aggregate = response.aggregations().get("count");
|
|
|
+ total = aggregate.cardinality().value();
|
|
|
} else {
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
- Aggregate statsAgg = response.aggregations().get("statsBucket");
|
|
|
- Long total = statsAgg.statsBucket().count();
|
|
|
- records.setTotal(total);
|
|
|
- Aggregate agg = response.aggregations().get("Agg");
|
|
|
- List<StringTermsBucket> termsBuckets = agg.sterms().buckets().array();
|
|
|
-
|
|
|
- for (StringTermsBucket termsBucket : termsBuckets) {
|
|
|
- PatentPageMessageVO patentPageMessageVO = new PatentPageMessageVO();
|
|
|
- String key = termsBucket.key().stringValue();
|
|
|
- PatentWithIdVO patentWithIdVO = esService.getPatentColumnDTOByGroup2(key, esPatentCommonVO.getProjectId(), esPatentCommonVO.getEsField());
|
|
|
- patentPageMessageVO.setPatentNo(patentWithIdVO.getPatent().getPatentNo());
|
|
|
- patentPageMessageVOS.add(patentPageMessageVO);
|
|
|
- }
|
|
|
+ total = response.hits().total().value();
|
|
|
}
|
|
|
+ records.setTotal(total);
|
|
|
+
|
|
|
records.setSize(size);
|
|
|
records.setCurrent(current);
|
|
|
records.setData(patentPageMessageVOS);
|
|
@@ -804,8 +795,6 @@ public class EsPatentService {
|
|
|
esPatentCommonVO.setStartNum(startNum);
|
|
|
esPatentCommonVO.setEndNum(endNum);
|
|
|
SearchRequest.Builder builder = esService.getCommonPatent(esPatentCommonVO);
|
|
|
- if (esPatentCommonVO.getEsField() == null || esPatentCommonVO.getEsField().equals("")) {
|
|
|
-
|
|
|
SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
for (Hit<Patent> hit : hits) {
|
|
@@ -817,22 +806,6 @@ public class EsPatentService {
|
|
|
patentWithIdVOS.add(patentWithIdVO);
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
- Aggregate agg = response.aggregations().get("Agg");
|
|
|
- List<StringTermsBucket> termsBuckets = agg.sterms().buckets().array();
|
|
|
-
|
|
|
- for (StringTermsBucket termsBucket : termsBuckets) {
|
|
|
- String key = termsBucket.key().stringValue();
|
|
|
- PatentWithIdVO patentWithIdVO = esService.getPatentColumnDTOByGroup2(key, esPatentCommonVO.getProjectId(), esPatentCommonVO.getEsField());
|
|
|
- if ((patentNos == null || patentNos.size() == 0) || (!patentNos.contains(patentWithIdVO.getPatent().getPatentNo()))) {
|
|
|
- PatentNoWithIdVO patentNoWithIdVO = new PatentNoWithIdVO();
|
|
|
- patentNoWithIdVO.setId(patentWithIdVO.getId());
|
|
|
- patentNoWithIdVO.setPatentNo(patentWithIdVO.getPatent().getPatentNo());
|
|
|
- patentWithIdVOS.add(patentNoWithIdVO);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
return patentWithIdVOS;
|
|
|
}
|
|
|
}
|