|
@@ -927,4 +927,74 @@ public class EsCustomFieldService {
|
|
|
|
|
|
return patentWithIdVOS;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //查询自定义字段
|
|
|
+ public PatentWithIdVO getEsCustomFieldNow(EsCustomFieldDTO esCustomFieldDTO) throws Exception {
|
|
|
+ PatentWithIdVO patentWithIdVO = new PatentWithIdVO();
|
|
|
+ Integer projectId = esCustomFieldDTO.getProjectId();
|
|
|
+ Integer taskId = esCustomFieldDTO.getTaskId();
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
+ String patentNo = esCustomFieldDTO.getPatentNo();
|
|
|
+ //设置查询索引
|
|
|
+ builder.index("patent");
|
|
|
+
|
|
|
+ //栏位
|
|
|
+ Query q1 = QueryBuilders.term(t -> t.field("custom_field.project_id").value(projectId));
|
|
|
+
|
|
|
+ Query q2 = QueryBuilders.term((t -> t.field("custom_field.field").value(esCustomFieldDTO.getFieldId())));
|
|
|
+
|
|
|
+ Query q4 = QueryBuilders.term(t -> t.field("custom_field.field_type").value(esCustomFieldDTO.getFieldType()));
|
|
|
+
|
|
|
+ Query parentQ1 = QueryBuilders.term(t -> t.field("app_no.keyword").value(patentNo));
|
|
|
+ //公开号
|
|
|
+ Query parentQ2 = QueryBuilders.term(t -> t.field("public_no.keyword").value(patentNo));
|
|
|
+
|
|
|
+ //授权号
|
|
|
+ Query parentQ3 = QueryBuilders.term(t -> t.field("grant_no.keyword").value(patentNo));
|
|
|
+
|
|
|
+ Query parentQ = QueryBuilders.bool(i -> i.should(parentQ1, parentQ2, parentQ3));
|
|
|
+
|
|
|
+ Query q3 = QueryBuilders.hasParent(t -> t.parentType("patent").query(parentQ));
|
|
|
+
|
|
|
+ Query bool = null;
|
|
|
+
|
|
|
+ if (taskId == null) {
|
|
|
+
|
|
|
+ bool = QueryBuilders.bool(i -> i.must(q1, q2, q3, q4));
|
|
|
+ } else {
|
|
|
+ Query q5 = QueryBuilders.term((t -> t.field("custom_field.task_id").value(taskId)));
|
|
|
+ bool = QueryBuilders.bool(i -> i.must(q1, q2, q3, q4, q5));
|
|
|
+ }
|
|
|
+
|
|
|
+ builder.query(bool);
|
|
|
+ builder.sort(sortOptionsBuilder -> sortOptionsBuilder
|
|
|
+ .field(fieldSortBuilder -> fieldSortBuilder
|
|
|
+ .field("custom_field.create_time").order(SortOrder.Desc)));
|
|
|
+ SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ long total = response.hits().total().value();
|
|
|
+ if (total > 0) {
|
|
|
+ List<Hit<Patent>> hits = response.hits().hits();
|
|
|
+ Hit<Patent> hit = hits.get(0);
|
|
|
+ Patent patent = hit.source();
|
|
|
+ patentWithIdVO.setPatent(patent);
|
|
|
+ patentWithIdVO.setId(hit.id());
|
|
|
+ } else {
|
|
|
+ patentWithIdVO = null;
|
|
|
+ }
|
|
|
+ return patentWithIdVO;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //查询自定义字段
|
|
|
+ public PatentWithIdVO updateEsCustomFieldState(EsCustomFieldDTO esCustomFieldDTO) throws Exception {
|
|
|
+ PatentWithIdVO patentWithIdVO = new PatentWithIdVO();
|
|
|
+ PatentWithIdVO patent = this.getEsCustomField(esCustomFieldDTO);
|
|
|
+ return patentWithIdVO;
|
|
|
+ }
|
|
|
}
|