|
@@ -37,6 +37,7 @@ import cn.cslg.pas.service.common.FileManagerService;
|
|
|
import cn.cslg.pas.service.permissions.PermissionService;
|
|
|
import cn.cslg.pas.service.query.FormatQueryService;
|
|
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
|
|
+import co.elastic.clients.elasticsearch._types.ElasticsearchException;
|
|
|
import co.elastic.clients.elasticsearch._types.SortOptions;
|
|
|
import co.elastic.clients.elasticsearch._types.SortOrder;
|
|
|
import co.elastic.clients.elasticsearch._types.aggregations.Aggregate;
|
|
@@ -108,7 +109,12 @@ public class EsPatentService {
|
|
|
Query q3 = QueryBuilders.term(t -> t.field("grant_no.keyword").value(vo.getPatentNo()));
|
|
|
Query query = QueryBuilders.bool(i -> i.should(q1, q2, q3));
|
|
|
builder.query(query);
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ SearchResponse<Patent> response = null;
|
|
|
+ try {
|
|
|
+ response = client.search(builder.build(), Patent.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
|
|
|
+ }
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
for (Hit<Patent> hit : hits) {
|
|
|
Patent esMess = hit.source();
|
|
@@ -199,7 +205,12 @@ public class EsPatentService {
|
|
|
Query query = QueryBuilders.hasParent(i -> i.parentType("patent").query(ids));
|
|
|
Query q = QueryBuilders.bool(i -> i.must(nested, query));
|
|
|
builder.query(q);
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ SearchResponse<Patent> response = null;
|
|
|
+ try {
|
|
|
+ response = client.search(builder.build(), Patent.class);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
|
|
|
+ }
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
List<PatentMergePerson> list = new ArrayList<>();
|
|
|
for (Hit<Patent> hit : hits) {
|
|
@@ -228,7 +239,12 @@ public class EsPatentService {
|
|
|
Query query = QueryBuilders.hasParent(i -> i.parentType("patent").query(ids));
|
|
|
Query q = QueryBuilders.bool(i -> i.must(nested, query));
|
|
|
builder.query(q);
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ SearchResponse<Patent> response = null;
|
|
|
+ try {
|
|
|
+ response = client.search(builder.build(), Patent.class);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
|
|
|
+ }
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
List<PatentMergePerson> list = new ArrayList<>();
|
|
|
for (Hit<Patent> hit : hits) {
|
|
@@ -257,7 +273,12 @@ public class EsPatentService {
|
|
|
Query query = QueryBuilders.hasParent(i -> i.parentType("patent").query(ids));
|
|
|
Query q = QueryBuilders.bool(i -> i.must(nested, query));
|
|
|
builder.query(q);
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ SearchResponse<Patent> response = null;
|
|
|
+ try {
|
|
|
+ response = client.search(builder.build(), Patent.class);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
|
|
|
+ }
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
List<PatentMergePerson> list = new ArrayList<>();
|
|
|
for (Hit<Patent> hit : hits) {
|
|
@@ -453,7 +474,12 @@ public class EsPatentService {
|
|
|
// if (pageNum > 0 && pageSize > 0) {
|
|
|
// builder.from((pageNum - 1) * pageSize).size(pageSize);
|
|
|
// }
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ SearchResponse<Patent> response = null;
|
|
|
+ try {
|
|
|
+ response = client.search(builder.build(), Patent.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
|
|
|
+ }
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
for (Hit<Patent> hit : hits) {
|
|
|
PatentKinDTO kinDTO = new PatentKinDTO();
|
|
@@ -503,7 +529,12 @@ public class EsPatentService {
|
|
|
Query bool1 = QueryBuilders.bool(i -> i.must(q, query));
|
|
|
builder.query(bool1);
|
|
|
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ SearchResponse<Patent> response = null;
|
|
|
+ try {
|
|
|
+ response = client.search(builder.build(), Patent.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
|
|
|
+ }
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
for (Hit<Patent> hit : hits) {
|
|
|
Patent patent = hit.source();
|
|
@@ -554,7 +585,12 @@ public class EsPatentService {
|
|
|
} else {
|
|
|
builder.from(0).size(10000);
|
|
|
}
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ SearchResponse<Patent> response = null;
|
|
|
+ try {
|
|
|
+ response = client.search(builder.build(), Patent.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
|
|
|
+ }
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
if (hits != null && hits.size() > 0) {
|
|
|
hits.forEach(item -> {
|
|
@@ -601,7 +637,12 @@ public class EsPatentService {
|
|
|
esPatentCommonVO.setSize(null);
|
|
|
SearchRequest.Builder builder = esService.getCommonPatent(esPatentCommonVO);
|
|
|
Records records = new Records();
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ SearchResponse<Patent> response = null;
|
|
|
+ try {
|
|
|
+ response = client.search(builder.build(), Patent.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
|
|
|
+ }
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
for (Hit<Patent> hit : hits) {
|
|
|
PatentPageMessageVO patentPageMessageVO = new PatentPageMessageVO();
|
|
@@ -655,7 +696,12 @@ public class EsPatentService {
|
|
|
.filter(fieldSourceBuilder -> fieldSourceBuilder
|
|
|
.includes(reSources)));
|
|
|
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ SearchResponse<Patent> response = null;
|
|
|
+ try {
|
|
|
+ response = client.search(builder.build(), Patent.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
|
|
|
+ }
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
for (Hit<Patent> hit : hits) {
|
|
|
if (hits != null && hits.size() > 0) {
|
|
@@ -679,7 +725,12 @@ public class EsPatentService {
|
|
|
builder.source(sourceOptionsBuilder -> sourceOptionsBuilder
|
|
|
.filter(fieldSourceBuilder -> fieldSourceBuilder
|
|
|
.includes(reSources)));
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ SearchResponse<Patent> response = null;
|
|
|
+ try {
|
|
|
+ response = client.search(builder.build(), Patent.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
|
|
|
+ }
|
|
|
return response.hits().total().value();
|
|
|
}
|
|
|
|
|
@@ -797,7 +848,12 @@ public class EsPatentService {
|
|
|
builder.index("patent");
|
|
|
Query q = QueryBuilders.ids(i -> i.values(ids));
|
|
|
builder.query(q);
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ SearchResponse<Patent> response = null;
|
|
|
+ try {
|
|
|
+ response = client.search(builder.build(), Patent.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
|
|
|
+ }
|
|
|
long total = response.hits().total().value();
|
|
|
if (total > 0) {
|
|
|
patents = response.hits().hits();
|
|
@@ -820,7 +876,12 @@ public class EsPatentService {
|
|
|
esPatentCommonVO.setStartNum(startNum);
|
|
|
esPatentCommonVO.setEndNum(endNum);
|
|
|
SearchRequest.Builder builder = esService.getCommonPatent(esPatentCommonVO);
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ SearchResponse<Patent> response = null;
|
|
|
+ try {
|
|
|
+ response = client.search(builder.build(), Patent.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
|
|
|
+ }
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
for (Hit<Patent> hit : hits) {
|
|
|
if ((patentNos == null || patentNos.size() == 0) || (!patentNos.contains(hit.source().getPatentNo()))) {
|
|
@@ -865,7 +926,12 @@ public class EsPatentService {
|
|
|
FieldCollapse collapse = FieldCollapse.of(i -> i.field("project_id"));
|
|
|
builder.collapse(collapse);
|
|
|
builder.trackTotalHits(i -> i.enabled(true));
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ SearchResponse<Patent> response = null;
|
|
|
+ try {
|
|
|
+ response = client.search(builder.build(), Patent.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
|
|
|
+ }
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
if (hits != null && hits.size() > 0) {
|
|
|
hits.forEach(item -> {
|