|
@@ -18,6 +18,7 @@ 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.*;
|
|
|
+import cn.cslg.pas.common.vo.es.PatentFamilyMessageWithId;
|
|
|
import cn.cslg.pas.domain.es.*;
|
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
|
import cn.cslg.pas.service.business.CommonService;
|
|
@@ -73,7 +74,6 @@ public class EsService {
|
|
|
.document(patent)
|
|
|
);
|
|
|
return indexResponse.id();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -261,6 +261,8 @@ public class EsService {
|
|
|
builder.from((current.intValue() - 1) * size.intValue()).size(size.intValue());
|
|
|
}
|
|
|
|
|
|
+ //解除最大条数限制
|
|
|
+ builder.trackTotalHits(i -> i.enabled(true));
|
|
|
SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
List<PatentColumnDTO> list = new ArrayList<>();
|
|
|
long total = 0L;
|
|
@@ -699,7 +701,7 @@ public class EsService {
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- public EsPatentFamilyDTO addEsPatentFamily(List<String> nos, String type) throws IOException {
|
|
|
+ public EsPatentFamilyDTO addEsPatentFamily(Patent patent, List<String> nos, String type) throws Exception {
|
|
|
EsPatentFamilyDTO esDTO = new EsPatentFamilyDTO();
|
|
|
|
|
|
List<String> absentList = new ArrayList<>();
|
|
@@ -707,31 +709,37 @@ public class EsService {
|
|
|
PatentFamilyMessage patentFamilyMessage = null;
|
|
|
String id = "";
|
|
|
|
|
|
- //遍历,根据专利号查询同族
|
|
|
- for (String no : nos) {
|
|
|
- SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
- //设置查询索引
|
|
|
- builder.index("patent_family");
|
|
|
- //申请号
|
|
|
- Query q1 = QueryBuilders.term(t -> t.field("patent.app_no").value(no));
|
|
|
- //公开号
|
|
|
- Query q2 = QueryBuilders.term(t -> t.field("patent.public_no").value(no));
|
|
|
- //授权号
|
|
|
- Query q3 = QueryBuilders.term(t -> t.field("patent.grant_no").value(no));
|
|
|
- //类型
|
|
|
- Query q4 = QueryBuilders.term(t -> t.field("family_type").value(type));
|
|
|
- Query p =QueryBuilders.bool(i -> i.should(q1, q2, q3));
|
|
|
- Query bool = QueryBuilders.bool(i -> i.must(q4,p));
|
|
|
- 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();
|
|
|
- Hit<PatentFamilyMessage> hit = hits.get(0);
|
|
|
- id = hit.id();
|
|
|
- patentFamilyMessage = hit.source();
|
|
|
- break;
|
|
|
+ PatentFamilyMessageWithId patentFamilyMessageWithId = queryPatentFamily(patent, type);
|
|
|
+ if (patentFamilyMessageWithId != null) {
|
|
|
+ patentFamilyMessage = patentFamilyMessageWithId.getPatentFamilyMessage();
|
|
|
+ id = patentFamilyMessageWithId.getId();
|
|
|
+ } else {
|
|
|
+ //遍历,根据专利号查询同族
|
|
|
+ for (String no : nos) {
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
+ //设置查询索引
|
|
|
+ builder.index("patent_family");
|
|
|
+ //申请号
|
|
|
+ Query q1 = QueryBuilders.term(t -> t.field("patent.app_no").value(no));
|
|
|
+ //公开号
|
|
|
+ Query q2 = QueryBuilders.term(t -> t.field("patent.public_no").value(no));
|
|
|
+ //授权号
|
|
|
+ Query q3 = QueryBuilders.term(t -> t.field("patent.grant_no").value(no));
|
|
|
+ //类型
|
|
|
+ Query q4 = QueryBuilders.term(t -> t.field("family_type").value(type));
|
|
|
+ Query p = QueryBuilders.bool(i -> i.should(q1, q2, q3));
|
|
|
+ Query bool = QueryBuilders.bool(i -> i.must(q4, p));
|
|
|
+ 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();
|
|
|
+ Hit<PatentFamilyMessage> hit = hits.get(0);
|
|
|
+ id = hit.id();
|
|
|
+ patentFamilyMessage = hit.source();
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -760,49 +768,64 @@ public class EsService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if (notInNos.size() > 0) {
|
|
|
- //所有专利号的专利详情
|
|
|
- List<StarPatentVO> starPatents = new ArrayList<>();
|
|
|
-
|
|
|
- PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
|
|
|
- List<PatentStarListDTO> patentStarListDtos = patentStarApiService.splitPatentNoByType(notInNos, patentStarListDTO);
|
|
|
- while (patentStarListDtos.size() > 0) {
|
|
|
- PatentStarListDTO patentStarListDTO1 = patentStarListDtos.remove(0);
|
|
|
- patentStarListDTO1.setPageNum(1);
|
|
|
- patentStarListDTO1.setRowCount(50);
|
|
|
- Map<String, Object> resultMap = patentStarApiService.patentStarSearchApi(patentStarListDTO1);
|
|
|
- if (resultMap == null || (Integer) resultMap.get("total") == 0) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- starPatents.addAll((List<StarPatentVO>) resultMap.get("records"));
|
|
|
+ List<FamilyPatent> familyPatents = patentFamilyMessage.getPatent();
|
|
|
+ String appNo = "";
|
|
|
+ String publicNo = "";
|
|
|
+ String grantNo = "";
|
|
|
+ if (patent.getAppNo() != null) {
|
|
|
+ appNo = patent.getAppNo();
|
|
|
+ }
|
|
|
+ if (patent.getPublicNo() != null) {
|
|
|
+ publicNo = patent.getPublicNo();
|
|
|
+ }
|
|
|
+ if (patent.getGrantNo() != null) {
|
|
|
+ grantNo = patent.getGrantNo();
|
|
|
+ }
|
|
|
+ String appNo1 = appNo;
|
|
|
+ String publicNo1 = publicNo;
|
|
|
+ String grantNo1 = grantNo;
|
|
|
+ FamilyPatent patent1 = familyPatents.stream().filter(item ->
|
|
|
+ publicNo1.equals(item.getPublicNo())
|
|
|
+ || publicNo1.equals(item.getGrantNo())
|
|
|
+ || grantNo1.equals(item.getPublicNo())
|
|
|
+ || grantNo1.equals(item.getGrantNo())
|
|
|
+ ).findFirst().orElse(null);
|
|
|
+ if (patent1 == null) {
|
|
|
+ patent1 = new FamilyPatent();
|
|
|
+ patent1.setGrantNo(patent.getGrantNo());
|
|
|
+ patent1.setAppNo(patent.getAppNo());
|
|
|
+ patent1.setPublicNo(patent.getPublicNo());
|
|
|
+ familyPatents.add(patent1);
|
|
|
+ } else {
|
|
|
+ patent1.setGrantNo(patent.getGrantNo());
|
|
|
+ patent1.setAppNo(patent.getAppNo());
|
|
|
+ patent1.setPublicNo(patent.getPublicNo());
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ if (notInNos.size() > 0) {
|
|
|
+ //所有专利号的专利详情
|
|
|
List<FamilyPatent> patents = new ArrayList<>();
|
|
|
- starPatents.forEach(item -> {
|
|
|
+ notInNos.forEach(item -> {
|
|
|
FamilyPatent familyPatent = new FamilyPatent();
|
|
|
- familyPatent.setAppNo(item.getApplicationNo());
|
|
|
- familyPatent.setPublicNo(item.getPublicNo());
|
|
|
- familyPatent.setGrantNo(item.getPublicAccreditNo());
|
|
|
+ familyPatent.setPublicNo(item);
|
|
|
patents.add(familyPatent);
|
|
|
});
|
|
|
-
|
|
|
patentFamilyMessage.getPatent().addAll(patents);
|
|
|
|
|
|
+ }
|
|
|
+ //当id不为null时
|
|
|
+ if (!id.equals("")) {
|
|
|
|
|
|
- //当id不为null时
|
|
|
- if (!id.equals("")) {
|
|
|
-
|
|
|
- this.updatePatentFamily(patentFamilyMessage, id);
|
|
|
+ this.updatePatentFamily(patentFamilyMessage, id);
|
|
|
|
|
|
- } else {
|
|
|
- try {
|
|
|
- id = this.addPatentFamily(patentFamilyMessage);
|
|
|
- } catch (Exception e) {
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ id = this.addPatentFamily(patentFamilyMessage);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- }
|
|
|
}
|
|
|
esDTO.setPatentFamilyId(id);
|
|
|
esDTO.setFamilyNum(patentFamilyMessage.getPatent().size());
|
|
@@ -924,8 +947,7 @@ public class EsService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public String addEsQuotePatent(String no, List<String> nos) throws Exception {
|
|
|
- StarPatentVO starPatentVO = patentStarApiService.getPatentByNo(no);
|
|
|
+ public String addEsQuotePatent(StarPatentVO starPatentVO, List<String> nos) throws Exception {
|
|
|
if (starPatentVO == null) {
|
|
|
return null;
|
|
|
}
|
|
@@ -954,20 +976,27 @@ public class EsService {
|
|
|
quotePatents = patentQuoteMessage.getQuotedPatents();
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- for (String patentNo : nos) {
|
|
|
- StarPatentVO starPatentVO1 = patentStarApiService.getPatentByNo(patentNo);
|
|
|
- QuotePatent quotePatent1 = null;
|
|
|
- if (quotePatents.size() > 0) {
|
|
|
- quotePatent1 = quotePatents.stream()
|
|
|
- .filter(item -> item.getAppNo().equals(starPatentVO1.getApplicationNo())).findFirst().orElse(null);
|
|
|
- }
|
|
|
- if (quotePatent1 == null) {
|
|
|
- quotePatent1 = this.reQuotePatent(starPatentVO1);
|
|
|
- quotePatents.add(quotePatent1);
|
|
|
+ if (nos != null && nos.size() > 0) {
|
|
|
+ List<Patent> patents = esPatentService.getPatentsByNo(nos, true, null, null);
|
|
|
+ for (String patentNo : nos) {
|
|
|
+ QuotePatent quotePatent1 = null;
|
|
|
+ if (quotePatents.size() > 0) {
|
|
|
+ quotePatent1 = quotePatents.stream()
|
|
|
+ .filter(item -> patentNo.equals(item.getAppNo()) || patentNo.equals(item.getPublicNo()) || patentNo.equals(item.getGrantNo())).findFirst().orElse(null);
|
|
|
+ }
|
|
|
+ Patent patent= patents.stream().filter(item -> patentNo.equals(item.getAppNo())).findFirst().orElse(null);
|
|
|
+ if (quotePatent1 == null) {
|
|
|
+ quotePatent1 = this.reQuotePatent(patent,patentNo);
|
|
|
+ quotePatents.add(quotePatent1);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ quotePatent1 = this.reQuotePatent(patent,patentNo);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
if (patentQuoteMessage == null) {
|
|
|
if (quotePatents.size() != 0) {
|
|
|
patentQuoteMessage = new PatentQuoteMessage();
|
|
@@ -1022,12 +1051,30 @@ public class EsService {
|
|
|
return quotePatent;
|
|
|
}
|
|
|
|
|
|
- public String addEsLegalEvent(String patentNo) {
|
|
|
+
|
|
|
+ private QuotePatent reQuotePatent(Patent patent, String no) {
|
|
|
+ QuotePatent quotePatent = new QuotePatent();
|
|
|
+ if (patent == null) {
|
|
|
+ quotePatent.setPublicNo(no);
|
|
|
+ return quotePatent;
|
|
|
+ }
|
|
|
+ //装载申请人
|
|
|
+
|
|
|
+ quotePatent.setApplicant(patent.getApplicant());
|
|
|
+
|
|
|
+ quotePatent.setRightHolder(patent.getRightHolder());
|
|
|
+
|
|
|
+ quotePatent.setAppNo(patent.getAppNo());
|
|
|
+ quotePatent.setGrantNo(patent.getGrantNo());
|
|
|
+ quotePatent.setPublicNo(patent.getPublicNo());
|
|
|
+ return quotePatent;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String addEsLegalEvent(StarPatentVO starPatentVO) {
|
|
|
LegalEvent legalEvent = null;
|
|
|
String id = "";
|
|
|
|
|
|
//根据专利号查询
|
|
|
- StarPatentVO starPatentVO = patentStarApiService.getPatentByNo(patentNo);
|
|
|
if (starPatentVO == null) {
|
|
|
return null;
|
|
|
}
|
|
@@ -1216,6 +1263,67 @@ public class EsService {
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public PatentFamilyMessageWithId queryPatentFamily(Patent patent, String type) throws Exception {
|
|
|
+ //查询该专利是否已有同族
|
|
|
+ SearchRequest.Builder builderPatent = new SearchRequest.Builder();
|
|
|
+ //设置查询索引
|
|
|
+ builderPatent.index("patent_family");
|
|
|
+ //申请号
|
|
|
+ List<Query> queries = new ArrayList<>();
|
|
|
+ if (patent.getAppNo() != null) {
|
|
|
+ Query q1 = QueryBuilders.term(t -> t.field("patent.app_no").value(patent.getAppNo()));
|
|
|
+ //公开号
|
|
|
+ Query q2 = QueryBuilders.term(t -> t.field("patent.public_no").value(patent.getAppNo()));
|
|
|
+ //授权号
|
|
|
+ Query q3 = QueryBuilders.term(t -> t.field("patent.grant_no").value(patent.getAppNo()));
|
|
|
+ //类型
|
|
|
+ queries.add(q1);
|
|
|
+ queries.add(q2);
|
|
|
+ queries.add(q3);
|
|
|
+ }
|
|
|
+ if (patent.getPublicNo() != null) {
|
|
|
+ Query q1 = QueryBuilders.term(t -> t.field("patent.app_no").value(patent.getPublicNo()));
|
|
|
+ //公开号
|
|
|
+ Query q2 = QueryBuilders.term(t -> t.field("patent.public_no").value(patent.getPublicNo()));
|
|
|
+ //授权号
|
|
|
+ Query q3 = QueryBuilders.term(t -> t.field("patent.grant_no").value(patent.getPublicNo()));
|
|
|
+ queries.add(q1);
|
|
|
+ queries.add(q2);
|
|
|
+ queries.add(q3);
|
|
|
+ }
|
|
|
+ if (patent.getGrantNo() != null) {
|
|
|
+ Query q1 = QueryBuilders.term(t -> t.field("patent.app_no").value(patent.getGrantNo()));
|
|
|
+ //公开号
|
|
|
+ Query q2 = QueryBuilders.term(t -> t.field("patent.public_no").value(patent.getGrantNo()));
|
|
|
+ //授权号
|
|
|
+ Query q3 = QueryBuilders.term(t -> t.field("patent.grant_no").value(patent.getGrantNo()));
|
|
|
+ queries.add(q1);
|
|
|
+ queries.add(q2);
|
|
|
+ queries.add(q3);
|
|
|
+ }
|
|
|
+
|
|
|
+ Query q4 = QueryBuilders.term(t -> t.field("family_type").value(type));
|
|
|
+ Query p = QueryBuilders.bool(i -> i.should(queries));
|
|
|
+ Query bool = QueryBuilders.bool(i -> i.must(q4, p));
|
|
|
+ builderPatent.query(bool);
|
|
|
+ SearchResponse<PatentFamilyMessage> response = client.search(builderPatent.build(), PatentFamilyMessage.class);
|
|
|
+ long total = response.hits().total().value();
|
|
|
+ if (total > 0) {
|
|
|
+ List<FamilyPatent> list = new ArrayList<>();
|
|
|
+ List<Hit<PatentFamilyMessage>> hits = response.hits().hits();
|
|
|
+ Hit<PatentFamilyMessage> hit = hits.get(0);
|
|
|
+ String id = hit.id();
|
|
|
+ PatentFamilyMessageWithId patentFamilyMessageWithId = new PatentFamilyMessageWithId();
|
|
|
+ patentFamilyMessageWithId.setId(id);
|
|
|
+ patentFamilyMessageWithId.setPatentFamilyMessage(hit.source());
|
|
|
+
|
|
|
+ return patentFamilyMessageWithId;
|
|
|
+
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|