|
@@ -12,7 +12,9 @@ import cn.cslg.pas.common.utils.parseQueryToTree.expressManager;
|
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.operateNode;
|
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.treeNode;
|
|
|
import cn.cslg.pas.common.vo.PatentWithIdVO;
|
|
|
+import cn.cslg.pas.domain.es.FamilyPatent;
|
|
|
import cn.cslg.pas.domain.es.Patent;
|
|
|
+import cn.cslg.pas.domain.es.PatentFamilyMessage;
|
|
|
import cn.cslg.pas.service.query.FormatQueryService;
|
|
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
|
|
import co.elastic.clients.elasticsearch._types.SortOrder;
|
|
@@ -290,7 +292,7 @@ public class EsService {
|
|
|
* @param projectId
|
|
|
* @return
|
|
|
*/
|
|
|
- public Boolean search(String parentId, Integer projectId) throws IOException {
|
|
|
+ public Boolean searchPatent(String parentId, Integer projectId) throws IOException {
|
|
|
boolean flag = false;
|
|
|
SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
//设置查询索引
|
|
@@ -307,6 +309,96 @@ public class EsService {
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询同族
|
|
|
+ * @param nos
|
|
|
+ * @param type
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public EsPatentFamilyDTO selectEsPatentFamily(List<String> nos, String type) throws IOException {
|
|
|
+ EsPatentFamilyDTO esDTO = new EsPatentFamilyDTO();
|
|
|
+
|
|
|
+ List<String> absentList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (String no : nos) {
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
+ //设置查询索引
|
|
|
+ builder.index("patent_family");
|
|
|
+ //申请号
|
|
|
+ Query q1 = QueryBuilders.term(t -> t.field("app_no").value(no));
|
|
|
+ //公开号
|
|
|
+ Query q2 = QueryBuilders.term(t -> t.field("public_no").value(no));
|
|
|
+ //授权号
|
|
|
+ Query q3 = QueryBuilders.term(t -> t.field("grant_no").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);
|
|
|
+ SearchResponse<PatentFamilyMessage> response = client.search(builder.build(), PatentFamilyMessage.class);
|
|
|
+ long total = response.hits().total().value();
|
|
|
+ if (total > 0) {
|
|
|
+ List<FamilyPatent> list = new ArrayList<>();
|
|
|
+ List<Hit<PatentFamilyMessage>> hits = response.hits().hits();
|
|
|
+ for (Hit<PatentFamilyMessage> hit : hits) {
|
|
|
+ String id = hit.id();
|
|
|
+ PatentFamilyMessage esMess = hit.source();
|
|
|
+ list.addAll(esMess.getPatent());
|
|
|
+ esDTO.setPatentFamilyId(id);
|
|
|
+ }
|
|
|
+ esDTO.setFamilyNum(list.size());
|
|
|
+ } else {
|
|
|
+ //获取不存在的号码
|
|
|
+ absentList.add(no);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //todo 判断是否全新/部分
|
|
|
+ if (absentList.size() == nos.size()) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return esDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加同族
|
|
|
+ * @param message
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public String addPatentFamily(PatentFamilyMessage message) throws Exception {
|
|
|
+ IndexResponse indexResponse = client.index(i -> i
|
|
|
+ .index("patent_family")
|
|
|
+ .document(message)
|
|
|
+ );
|
|
|
+ return indexResponse.id();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新同族
|
|
|
+ * @param familyPatent
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Integer updateatentFamily(FamilyPatent familyPatent, String id) {
|
|
|
+ UpdateRequest<FamilyPatent, FamilyPatent> req;
|
|
|
+ req = UpdateRequest.of(
|
|
|
+ b -> b.index("patent_family")
|
|
|
+ .id(id)
|
|
|
+ .doc(familyPatent)
|
|
|
+ );
|
|
|
+ try {
|
|
|
+ client.update(req, FamilyPatent.class);
|
|
|
+ return 1;
|
|
|
+ } catch (IOException e) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|