|
@@ -164,38 +164,13 @@ public class EsService {
|
|
if (!CollectionUtils.isEmpty(customFields)) {
|
|
if (!CollectionUtils.isEmpty(customFields)) {
|
|
searchCondition = this.parseCustomField(customFields,projectId,taskId);
|
|
searchCondition = this.parseCustomField(customFields,projectId,taskId);
|
|
}
|
|
}
|
|
- if (taskId != null) {
|
|
|
|
- if (searchCondition != null && !"".equals(searchCondition.trim())) {
|
|
|
|
- searchCondition = "taskId = " + taskId + " AND " + searchCondition;
|
|
|
|
- } else {
|
|
|
|
- searchCondition = "taskId = " + taskId;
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if (StringUtils.isNotEmpty(productFrom)) {
|
|
|
|
- if (productId != null) {
|
|
|
|
- if (searchCondition != null && !"".equals(searchCondition.trim())) {
|
|
|
|
- searchCondition = "productId = " + productId + " AND " + searchCondition;
|
|
|
|
- } else {
|
|
|
|
- searchCondition = "productId = " + productId;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if (projectId != null) {
|
|
|
|
- if (searchCondition != null && !"".equals(searchCondition.trim())) {
|
|
|
|
- searchCondition = "projectId = " + projectId + " AND " + searchCondition;
|
|
|
|
- } else {
|
|
|
|
- searchCondition = "projectId = " + projectId;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ String condition = this.appendIdsCondition(searchCondition, taskId, productFrom, projectId, productId);
|
|
|
|
|
|
SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
//设置查询索引
|
|
//设置查询索引
|
|
builder.index("patent");
|
|
builder.index("patent");
|
|
//1. 解析检索条件
|
|
//1. 解析检索条件
|
|
- treeNode tree = expressManager.getInstance().Parse(searchCondition, false);
|
|
|
|
|
|
+ treeNode tree = expressManager.getInstance().Parse(condition, false);
|
|
//3. 从es中检索数据
|
|
//3. 从es中检索数据
|
|
Query q = formatQueryService.EsQueryToQuery((operateNode) tree, "patent",projectId);
|
|
Query q = formatQueryService.EsQueryToQuery((operateNode) tree, "patent",projectId);
|
|
//判断同族分组
|
|
//判断同族分组
|
|
@@ -263,7 +238,6 @@ public class EsService {
|
|
builder.from((current.intValue() - 1) * size.intValue()).size(size.intValue());
|
|
builder.from((current.intValue() - 1) * size.intValue()).size(size.intValue());
|
|
} else {
|
|
} else {
|
|
builder.from(0).size(99999);
|
|
builder.from(0).size(99999);
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//解除最大条数限制
|
|
//解除最大条数限制
|
|
@@ -283,44 +257,7 @@ public class EsService {
|
|
String id = hit.id();
|
|
String id = hit.id();
|
|
JsonData data = hit.source();
|
|
JsonData data = hit.source();
|
|
Patent patent1 = JSONObject.parseObject(String.valueOf(data), Patent.class);
|
|
Patent patent1 = JSONObject.parseObject(String.valueOf(data), Patent.class);
|
|
- PatentColumnDTO columnDTO = new PatentColumnDTO();
|
|
|
|
- BeanUtils.copyProperties(patent1, columnDTO);
|
|
|
|
- if (projectId != null) {
|
|
|
|
- try {
|
|
|
|
- columnDTO.setMergeApplicant(esPatentService.getMergeApp(projectId, id));
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- columnDTO.setMergeApplicant(new ArrayList<>());
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
- columnDTO.setMergeRightHolder(esPatentService.getMergeRight(projectId, id));
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- columnDTO.setMergeRightHolder(new ArrayList<>());
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
- columnDTO.setMergeInventor(esPatentService.getMergeInventor(projectId, id));
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- columnDTO.setMergeInventor(new ArrayList<>());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (ObjectUtils.isNotEmpty(patent1.getApplicantAddr())) {
|
|
|
|
- PersonAddress applicantAddr = patent1.getApplicantAddr();
|
|
|
|
- columnDTO.setAppAddress(applicantAddr.getAddress());
|
|
|
|
- columnDTO.setApplicantCountry(applicantAddr.getCountry());
|
|
|
|
- columnDTO.setAppProvince(applicantAddr.getProvince());
|
|
|
|
- columnDTO.setAppCity(applicantAddr.getCity());
|
|
|
|
- columnDTO.setAppDistrict(applicantAddr.getDistrict());
|
|
|
|
- }
|
|
|
|
- if (ObjectUtils.isNotEmpty(patent1.getRightHolderAddr())) {
|
|
|
|
- PersonAddress rightAddr = patent1.getRightHolderAddr();
|
|
|
|
- columnDTO.setRightAddress(rightAddr.getAddress());
|
|
|
|
- columnDTO.setRightCountry(rightAddr.getCountry());
|
|
|
|
- columnDTO.setRightProvince(rightAddr.getProvince());
|
|
|
|
- columnDTO.setRightCity(rightAddr.getCity());
|
|
|
|
- columnDTO.setRightDistrict(rightAddr.getDistrict());
|
|
|
|
- }
|
|
|
|
- columnDTO.setApplicant(esPatentService.loadName(patent1.getApplicant()));
|
|
|
|
- columnDTO.setRightHolder(esPatentService.loadName(patent1.getRightHolder()));
|
|
|
|
- columnDTO.setInventor(esPatentService.loadName(patent1.getInventor()));
|
|
|
|
|
|
+ PatentColumnDTO columnDTO = this.getPatentColumnDTO(patent1, projectId, id);
|
|
list.add(columnDTO);
|
|
list.add(columnDTO);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -330,47 +267,8 @@ public class EsService {
|
|
for (Hit<Patent> hit : hits) {
|
|
for (Hit<Patent> hit : hits) {
|
|
String id = hit.id();
|
|
String id = hit.id();
|
|
Patent esMess = hit.source();
|
|
Patent esMess = hit.source();
|
|
- PatentColumnDTO columnDTO = new PatentColumnDTO();
|
|
|
|
-// columnDTO.setPatentNo(esMess.getPatentNo());
|
|
|
|
- BeanUtils.copyProperties(esMess, columnDTO);
|
|
|
|
- if (projectId != null) {
|
|
|
|
- try {
|
|
|
|
- columnDTO.setMergeApplicant(esPatentService.getMergeApp(projectId, id));
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- columnDTO.setMergeApplicant(new ArrayList<>());
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
- columnDTO.setMergeRightHolder(esPatentService.getMergeRight(projectId, id));
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- columnDTO.setMergeRightHolder(new ArrayList<>());
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
- columnDTO.setMergeInventor(esPatentService.getMergeInventor(projectId, id));
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- columnDTO.setMergeInventor(new ArrayList<>());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (ObjectUtils.isNotEmpty(esMess.getApplicantAddr())) {
|
|
|
|
- PersonAddress applicantAddr = esMess.getApplicantAddr();
|
|
|
|
- columnDTO.setAppAddress(applicantAddr.getAddress());
|
|
|
|
- columnDTO.setApplicantCountry(applicantAddr.getCountry());
|
|
|
|
- columnDTO.setAppProvince(applicantAddr.getProvince());
|
|
|
|
- columnDTO.setAppCity(applicantAddr.getCity());
|
|
|
|
- columnDTO.setAppDistrict(applicantAddr.getDistrict());
|
|
|
|
- }
|
|
|
|
- if (ObjectUtils.isNotEmpty(esMess.getRightHolderAddr())) {
|
|
|
|
- PersonAddress rightAddr = esMess.getRightHolderAddr();
|
|
|
|
- columnDTO.setRightAddress(rightAddr.getAddress());
|
|
|
|
- columnDTO.setRightCountry(rightAddr.getCountry());
|
|
|
|
- columnDTO.setRightProvince(rightAddr.getProvince());
|
|
|
|
- columnDTO.setRightCity(rightAddr.getCity());
|
|
|
|
- columnDTO.setRightDistrict(rightAddr.getDistrict());
|
|
|
|
- }
|
|
|
|
- columnDTO.setApplicant(esPatentService.loadName(esMess.getApplicant()));
|
|
|
|
- columnDTO.setRightHolder(esPatentService.loadName(esMess.getRightHolder()));
|
|
|
|
- columnDTO.setInventor(esPatentService.loadName(esMess.getInventor()));
|
|
|
|
|
|
+ PatentColumnDTO columnDTO = this.getPatentColumnDTO(esMess, projectId, id);
|
|
list.add(columnDTO);
|
|
list.add(columnDTO);
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.loadCoulumnDTO(list);
|
|
this.loadCoulumnDTO(list);
|
|
@@ -381,6 +279,81 @@ public class EsService {
|
|
return dto;
|
|
return dto;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //装载专利清单列表的数据
|
|
|
|
+ public PatentColumnDTO getPatentColumnDTO(Patent patent, Integer projectId, String id) {
|
|
|
|
+ PatentColumnDTO columnDTO = new PatentColumnDTO();
|
|
|
|
+ BeanUtils.copyProperties(patent, columnDTO);
|
|
|
|
+ if (projectId != null) {
|
|
|
|
+ try {
|
|
|
|
+ columnDTO.setMergeApplicant(esPatentService.getMergeApp(projectId, id));
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ columnDTO.setMergeApplicant(new ArrayList<>());
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ columnDTO.setMergeRightHolder(esPatentService.getMergeRight(projectId, id));
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ columnDTO.setMergeRightHolder(new ArrayList<>());
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ columnDTO.setMergeInventor(esPatentService.getMergeInventor(projectId, id));
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ columnDTO.setMergeInventor(new ArrayList<>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (ObjectUtils.isNotEmpty(patent.getApplicantAddr())) {
|
|
|
|
+ PersonAddress applicantAddr = patent.getApplicantAddr();
|
|
|
|
+ columnDTO.setAppAddress(applicantAddr.getAddress());
|
|
|
|
+ columnDTO.setApplicantCountry(applicantAddr.getCountry());
|
|
|
|
+ columnDTO.setAppProvince(applicantAddr.getProvince());
|
|
|
|
+ columnDTO.setAppCity(applicantAddr.getCity());
|
|
|
|
+ columnDTO.setAppDistrict(applicantAddr.getDistrict());
|
|
|
|
+ }
|
|
|
|
+ if (ObjectUtils.isNotEmpty(patent.getRightHolderAddr())) {
|
|
|
|
+ PersonAddress rightAddr = patent.getRightHolderAddr();
|
|
|
|
+ columnDTO.setRightAddress(rightAddr.getAddress());
|
|
|
|
+ columnDTO.setRightCountry(rightAddr.getCountry());
|
|
|
|
+ columnDTO.setRightProvince(rightAddr.getProvince());
|
|
|
|
+ columnDTO.setRightCity(rightAddr.getCity());
|
|
|
|
+ columnDTO.setRightDistrict(rightAddr.getDistrict());
|
|
|
|
+ }
|
|
|
|
+ columnDTO.setApplicant(esPatentService.loadName(patent.getApplicant()));
|
|
|
|
+ columnDTO.setRightHolder(esPatentService.loadName(patent.getRightHolder()));
|
|
|
|
+ columnDTO.setInventor(esPatentService.loadName(patent.getInventor()));
|
|
|
|
+ return columnDTO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //拼接专题库id或其他id条件
|
|
|
|
+ public String appendIdsCondition(String searchCondition,Integer taskId,String productFrom,Integer projectId,Integer productId) {
|
|
|
|
+ String condition = "";
|
|
|
|
+ if (taskId != null) {
|
|
|
|
+ if (searchCondition != null && !"".equals(searchCondition.trim())) {
|
|
|
|
+ searchCondition = "taskId = " + taskId + " AND " + searchCondition;
|
|
|
|
+ } else {
|
|
|
|
+ searchCondition = "taskId = " + taskId;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (StringUtils.isNotEmpty(productFrom)) {
|
|
|
|
+ if (productId != null) {
|
|
|
|
+ if (searchCondition != null && !"".equals(searchCondition.trim())) {
|
|
|
|
+ searchCondition = "productId = " + productId + " AND " + searchCondition;
|
|
|
|
+ } else {
|
|
|
|
+ searchCondition = "productId = " + productId;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (projectId != null) {
|
|
|
|
+ if (searchCondition != null && !"".equals(searchCondition.trim())) {
|
|
|
|
+ searchCondition = "projectId = " + projectId + " AND " + searchCondition;
|
|
|
|
+ } else {
|
|
|
|
+ searchCondition = "projectId = " + projectId;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ condition = searchCondition;
|
|
|
|
+ return condition;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 解析自定义栏位和值
|
|
* 解析自定义栏位和值
|
|
*
|
|
*
|
|
@@ -474,46 +447,25 @@ public class EsService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * @param key
|
|
|
|
- * @param page
|
|
|
|
- * @param limit
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public List<Patent> search(String key, Integer page, Integer limit) throws IOException {
|
|
|
|
- SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
|
- //设置查询索引
|
|
|
|
- builder.index("patent");
|
|
|
|
- //组装查询条件
|
|
|
|
- BoolQuery.Builder boolQuery = new BoolQuery.Builder();
|
|
|
|
- boolQuery.should(q -> q.match(v -> v
|
|
|
|
- .query(key)
|
|
|
|
- //字段名
|
|
|
|
- .field("patent_no")
|
|
|
|
- ));
|
|
|
|
-
|
|
|
|
- //多字段匹配
|
|
|
|
-// boolQuery.should(q -> q.matchPhrasePrefix(m -> m.query(key).field("content")));
|
|
|
|
-
|
|
|
|
- builder.query(q -> q.bool(boolQuery.build()));
|
|
|
|
- //分页
|
|
|
|
- if (page != null && limit != null) {
|
|
|
|
- builder.from(page).size(limit);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //排序
|
|
|
|
-// builder.sort(sortOptionsBuilder -> sortOptionsBuilder
|
|
|
|
-// .field(fieldSortBuilder -> fieldSortBuilder
|
|
|
|
-// .field("createTime").order(SortOrder.Desc)));
|
|
|
|
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
|
- List<Patent> list = new ArrayList<>();
|
|
|
|
- List<Hit<Patent>> hits = response.hits().hits();
|
|
|
|
- for (Hit<Patent> hit : hits) {
|
|
|
|
- Patent esMess = hit.source();
|
|
|
|
- list.add(esMess);
|
|
|
|
|
|
+ //拼接专利号
|
|
|
|
+ public String appendPatentNo(List<String> nos) {
|
|
|
|
+ String str = "NO = ";
|
|
|
|
+ if (nos.size() > 1) {
|
|
|
|
+ str = str + "(";
|
|
|
|
+ for (int i = 0; i < nos.size(); i++) {
|
|
|
|
+ String s = nos.get(i);
|
|
|
|
+ if (i != nos.size() - 1) {
|
|
|
|
+ str = str + s + " " + "OR" + " ";
|
|
|
|
+ } else {
|
|
|
|
+ str = str + s + ")";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ for (String no : nos) {
|
|
|
|
+ str = str + no;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
- return list;
|
|
|
|
|
|
+ return str;
|
|
}
|
|
}
|
|
|
|
|
|
//更新patent
|
|
//更新patent
|
|
@@ -1377,25 +1329,6 @@ public class EsService {
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|
|
- public String appendPatentNo(List<String> nos) {
|
|
|
|
- String str = "NO = ";
|
|
|
|
- if (nos.size() > 1) {
|
|
|
|
- str = str + "(";
|
|
|
|
- for (int i = 0; i < nos.size(); i++) {
|
|
|
|
- String s = nos.get(i);
|
|
|
|
- if (i != nos.size() - 1) {
|
|
|
|
- str = str + s + " " + "OR" + " ";
|
|
|
|
- } else {
|
|
|
|
- str = str + s + ")";
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- for (String no : nos) {
|
|
|
|
- str = str + no;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return str;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|