|
@@ -171,15 +171,27 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
|
Map<String, List<PatentMergePerson>> appMap = this.getChildMergePerson(id, projectId, "merge_applicant");
|
|
|
if (!CollectionUtils.isEmpty(appMap)) {
|
|
|
for (String appId : appMap.keySet()) {
|
|
|
+ List<PatentMergePerson> appMergeList = new ArrayList<>(mergePersonList);
|
|
|
List<PatentMergePerson> appList = appMap.get(appId);
|
|
|
List<String> collect = appList.stream().map(PatentMergePerson::getName).collect(Collectors.toList());
|
|
|
if (!collect.contains(vo.getName())) {
|
|
|
for (String mergedName : mergedNames) {
|
|
|
- this.delSingleMerge(appId, type, mergedName);
|
|
|
+ appList.removeIf(i -> i.getName().equals(mergedName));
|
|
|
}
|
|
|
- Integer num = this.add(appId, type, mergePersonList);
|
|
|
- if (num < 0) {
|
|
|
+ appMergeList.addAll(appList);
|
|
|
+ //添加子文档
|
|
|
+ Patent newPatent = new Patent();
|
|
|
+ PatentJoin patentJoin = new PatentJoin();
|
|
|
+ patentJoin.setParent(id);
|
|
|
+ patentJoin.setName("merge_applicant");
|
|
|
+ newPatent.setPatentJoin(patentJoin);
|
|
|
+ newPatent.setMergeApplicant(appMergeList);
|
|
|
+ String child = this.addChild(newPatent, id);
|
|
|
+ if (StringUtils.isEmpty(child)) {
|
|
|
throw new XiaoShiException("合并失败");
|
|
|
+ } else {
|
|
|
+ //删除原子文档
|
|
|
+ this.delete(Arrays.asList(appId));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -188,16 +200,36 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
|
Map<String, List<PatentMergePerson>> rightMap = this.getChildMergePerson(id, projectId, "merge_right_holder");
|
|
|
if (!CollectionUtils.isEmpty(rightMap)) {
|
|
|
for (String rightId : rightMap.keySet()) {
|
|
|
+ List<PatentMergePerson> rightMergeList = new ArrayList<>(mergePersonList);
|
|
|
List<PatentMergePerson> rightList = rightMap.get(rightId);
|
|
|
List<String> collect = rightList.stream().map(PatentMergePerson::getName).collect(Collectors.toList());
|
|
|
if (!collect.contains(vo.getName())) {
|
|
|
for (String mergedName : mergedNames) {
|
|
|
- this.delSingleMerge(rightId, type, mergedName);
|
|
|
+ rightList.removeIf(i -> i.getName().equals(mergedName));
|
|
|
}
|
|
|
- Integer num = this.add(rightId, type, mergePersonList);
|
|
|
- if (num < 0) {
|
|
|
+ rightMergeList.addAll(rightList);
|
|
|
+ //添加子文档
|
|
|
+ Patent newPatent = new Patent();
|
|
|
+ PatentJoin patentJoin = new PatentJoin();
|
|
|
+ patentJoin.setParent(id);
|
|
|
+ patentJoin.setName("merge_right_holder");
|
|
|
+ newPatent.setPatentJoin(patentJoin);
|
|
|
+ newPatent.setMergeInventor(rightMergeList);
|
|
|
+ String child = this.addChild(newPatent, id);
|
|
|
+ if (StringUtils.isEmpty(child)) {
|
|
|
throw new XiaoShiException("合并失败");
|
|
|
+ } else {
|
|
|
+ //删除原子文档
|
|
|
+ this.delete(Arrays.asList(rightId));
|
|
|
}
|
|
|
+
|
|
|
+// for (String mergedName : mergedNames) {
|
|
|
+// this.delSingleMerge(rightId, type, mergedName);
|
|
|
+// }
|
|
|
+// Integer num = this.add(rightId, type, mergePersonList);
|
|
|
+// if (num < 0) {
|
|
|
+// throw new XiaoShiException("合并失败");
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -205,15 +237,27 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
|
Map<String, List<PatentMergePerson>> inventorMap = this.getChildMergePerson(id, projectId, "merge_inventor");
|
|
|
if (!CollectionUtils.isEmpty(inventorMap)) {
|
|
|
for (String inventorId : inventorMap.keySet()) {
|
|
|
+ List<PatentMergePerson> inventorMergeList = new ArrayList<>(mergePersonList);
|
|
|
List<PatentMergePerson> inventorList = inventorMap.get(inventorId);
|
|
|
List<String> collect = inventorList.stream().map(PatentMergePerson::getName).collect(Collectors.toList());
|
|
|
if (!collect.contains(vo.getName())) {
|
|
|
for (String mergedName : mergedNames) {
|
|
|
- this.delSingleMerge(inventorId, type, mergedName);
|
|
|
+ inventorList.removeIf(i -> i.getName().equals(mergedName));
|
|
|
}
|
|
|
- Integer add = this.add(inventorId, type, mergePersonList);
|
|
|
- if (add < 0) {
|
|
|
+ inventorMergeList.addAll(inventorList);
|
|
|
+ //添加子文档
|
|
|
+ Patent newPatent = new Patent();
|
|
|
+ PatentJoin patentJoin = new PatentJoin();
|
|
|
+ patentJoin.setParent(id);
|
|
|
+ patentJoin.setName("merge_inventor");
|
|
|
+ newPatent.setPatentJoin(patentJoin);
|
|
|
+ newPatent.setMergeInventor(inventorMergeList);
|
|
|
+ String child = this.addChild(newPatent, id);
|
|
|
+ if (StringUtils.isEmpty(child)) {
|
|
|
throw new XiaoShiException("合并失败");
|
|
|
+ } else {
|
|
|
+ //删除原子文档
|
|
|
+ this.delete(Arrays.asList(inventorId));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -454,15 +498,15 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
|
Long pageSize = vo.getPageSize();
|
|
|
Integer type = vo.getType();
|
|
|
String condition = vo.getSearchQuery();
|
|
|
- String name = vo.getName();
|
|
|
|
|
|
List<String> conditionList = new ArrayList<>();
|
|
|
if (StringUtils.isNotEmpty(condition)) {
|
|
|
- if (condition.contains("or")) {
|
|
|
- String[] split = condition.split("or");
|
|
|
+ String s = condition.substring(condition.indexOf("=") + 1);
|
|
|
+ if (s.contains("or")) {
|
|
|
+ String[] split = s.split("or");
|
|
|
conditionList.addAll(Arrays.asList(split));
|
|
|
} else {
|
|
|
- conditionList.add(condition);
|
|
|
+ conditionList.add(s);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -471,41 +515,30 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
|
//设置查询索引
|
|
|
builder.index("patent");
|
|
|
if (!CollectionUtils.isEmpty(conditionList)) {
|
|
|
- for (String s : conditionList) {
|
|
|
+ for (String name : conditionList) {
|
|
|
List<Query> queries = new ArrayList<>();
|
|
|
if (type == 0) {
|
|
|
- Query q1 = QueryBuilders.term(i -> i.field("merge_applicant.project_id").value(projectId));
|
|
|
- Query query1 = QueryBuilders.nested(i -> i.path("merge_applicant").query(q1));
|
|
|
- if (StringUtils.isNotEmpty(name)) {
|
|
|
- Query q3 = QueryBuilders.match(i -> i.field("merge_applicant.name").query(s));
|
|
|
- Query query3 = QueryBuilders.nested(i -> i.path("merge_applicant").query(q3));
|
|
|
- Query bool = QueryBuilders.bool(i -> i.must(query1).should(query3));
|
|
|
- queries.add(bool);
|
|
|
- } else {
|
|
|
- queries.add(query1);
|
|
|
- }
|
|
|
-
|
|
|
- Query q2 = QueryBuilders.term(i -> i.field("merge_right_holder.project_id").value(projectId));
|
|
|
- Query query2 = QueryBuilders.nested(i -> i.path("merge_right_holder").query(q2));
|
|
|
- if (StringUtils.isNotEmpty(name)) {
|
|
|
- Query q4 = QueryBuilders.match(i -> i.field("merge_right_holder.name").query(s));
|
|
|
- Query query4 = QueryBuilders.nested(i -> i.path("merge_applicant").query(q4));
|
|
|
- Query bool1 = QueryBuilders.bool(i -> i.must(query2).should(query4));
|
|
|
- queries.add(bool1);
|
|
|
- } else {
|
|
|
- queries.add(query2);
|
|
|
- }
|
|
|
+ //合并申请人
|
|
|
+ Query idQ1 = QueryBuilders.term(i -> i.field("merge_applicant.project_id").value(projectId));
|
|
|
+ Query q1 = QueryBuilders.term(i -> i.field("merge_applicant.name.raw").value(name));
|
|
|
+ Query bool = QueryBuilders.bool(i -> i.must(idQ1, q1));
|
|
|
+ Query query1 = QueryBuilders.nested(i -> i.path("merge_applicant").query(bool));
|
|
|
+ Query childQ1 = QueryBuilders.hasChild(i -> i.type("merge_applicat").query(query1));
|
|
|
+ //合并权利人
|
|
|
+ Query idQ2 = QueryBuilders.term(i -> i.field("merge_right_holder.project_id").value(projectId));
|
|
|
+ Query q2 = QueryBuilders.term(i -> i.field("merge_right_holder.name.raw").value(name));
|
|
|
+ Query bool1 = QueryBuilders.bool(i -> i.must(idQ2, q2));
|
|
|
+ Query query2 = QueryBuilders.nested(i -> i.path("merge_right_holder").query(bool1));
|
|
|
+ Query childQ2 = QueryBuilders.hasChild(i -> i.type("merge_right_holder").query(query2));
|
|
|
+ queries.add(childQ1);
|
|
|
+ queries.add(childQ2);
|
|
|
} else {
|
|
|
- Query q = QueryBuilders.term(i -> i.field("merge_inventor.project_id").value(projectId));
|
|
|
- Query query = QueryBuilders.nested(i -> i.path("merge_inventor").query(q));
|
|
|
- if (StringUtils.isNotEmpty(name)) {
|
|
|
- Query q5 = QueryBuilders.match(i -> i.field("merge_inventor.name").query(s));
|
|
|
- Query query5 = QueryBuilders.nested(i -> i.path("merge_inventor").query(q5));
|
|
|
- Query bool1 = QueryBuilders.bool(i -> i.must(query).should(query5));
|
|
|
- queries.add(bool1);
|
|
|
- } else {
|
|
|
- queries.add(query);
|
|
|
- }
|
|
|
+ Query idQ = QueryBuilders.term(i -> i.field("merge_inventor.project_id").value(projectId));
|
|
|
+ Query q = QueryBuilders.term(i -> i.field("merge_inventor.name.raw").value(name));
|
|
|
+ Query bool = QueryBuilders.bool(i -> i.must(idQ, q));
|
|
|
+ Query query = QueryBuilders.nested(i -> i.path("merge_inventor").query(bool));
|
|
|
+ Query childQ = QueryBuilders.hasChild(i -> i.type("merge_inventor").query(query));
|
|
|
+ queries.add(childQ);
|
|
|
}
|
|
|
Query bool = QueryBuilders.bool(i -> i.should(queries));
|
|
|
builder.query(bool);
|
|
@@ -513,23 +546,49 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
|
// if (pageNum > 0 && pageSize > 0) {
|
|
|
// builder.from((pageNum.intValue() - 1) * pageSize.intValue()).size(pageSize.intValue());
|
|
|
// }
|
|
|
-
|
|
|
SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
-
|
|
|
+ Map<String, Patent> map = new HashMap<>();
|
|
|
for (Hit<Patent> hit : hits) {
|
|
|
- Patent esMess = hit.source();
|
|
|
- GetEsAllPersonDTO personDTO = new GetEsAllPersonDTO();
|
|
|
- if (!CollectionUtils.isEmpty(esMess.getMergeInventor())) {
|
|
|
- personDTO.setMergeApplicant(esPatentService.loadMergeName(esMess.getMergeApplicant()));
|
|
|
- }
|
|
|
- if (!CollectionUtils.isEmpty(esMess.getMergeRightHolder())) {
|
|
|
- personDTO.setMergeRightHolder(esPatentService.loadMergeName(esMess.getMergeRightHolder()));
|
|
|
- }
|
|
|
- if (!CollectionUtils.isEmpty(esMess.getMergeInventor())) {
|
|
|
- personDTO.setMergeInventor(esPatentService.loadMergeName(esMess.getMergeInventor()));
|
|
|
+ String id = hit.id();
|
|
|
+ map.put(id, hit.source());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(map)) {
|
|
|
+ for (String id : map.keySet()) {
|
|
|
+ GetEsAllPersonDTO personDTO = new GetEsAllPersonDTO();
|
|
|
+ if (type == 0) {
|
|
|
+ //申请人
|
|
|
+ Map<String, List<PatentMergePerson>> appMap = this.getChildMergePerson(id, projectId, "merge_applicant");
|
|
|
+ if (!CollectionUtils.isEmpty(appMap)) {
|
|
|
+ for (String appId : appMap.keySet()) {
|
|
|
+ List<PatentMergePerson> appList = appMap.get(appId);
|
|
|
+ List<String> collect = appList.stream().map(PatentMergePerson::getName).collect(Collectors.toList());
|
|
|
+ personDTO.setMergeApplicant(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //权利人
|
|
|
+ Map<String, List<PatentMergePerson>> rightMap = this.getChildMergePerson(id, projectId, "merge_right_holder");
|
|
|
+ if (!CollectionUtils.isEmpty(rightMap)) {
|
|
|
+ for (String rightId : rightMap.keySet()) {
|
|
|
+ List<PatentMergePerson> rightList = rightMap.get(rightId);
|
|
|
+ List<String> collect = rightList.stream().map(PatentMergePerson::getName).collect(Collectors.toList());
|
|
|
+ personDTO.setMergeRightHolder(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //发明人
|
|
|
+ Map<String, List<PatentMergePerson>> inventorMap = this.getChildMergePerson(id, projectId, "merge_inventor");
|
|
|
+ if (!CollectionUtils.isEmpty(inventorMap)) {
|
|
|
+ for (String inventorId : inventorMap.keySet()) {
|
|
|
+ List<PatentMergePerson> inventorList = inventorMap.get(inventorId);
|
|
|
+ List<String> collect = inventorList.stream().map(PatentMergePerson::getName).collect(Collectors.toList());
|
|
|
+ personDTO.setMergeInventor(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ personDTOS.add(personDTO);
|
|
|
}
|
|
|
- personDTOS.add(personDTO);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -559,7 +618,6 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
|
|
|
|
SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
-
|
|
|
Map<String, Patent> map = new HashMap<>();
|
|
|
for (Hit<Patent> hit : hits) {
|
|
|
String id = hit.id();
|
|
@@ -994,53 +1052,32 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- public Integer delete(List<String> ids) {
|
|
|
- Query query = QueryBuilders.ids(n -> n.values(ids));
|
|
|
- DeleteByQueryRequest request = DeleteByQueryRequest.of(i -> i.index("patent").query(query));
|
|
|
- try {
|
|
|
- client.deleteByQuery(request);
|
|
|
- return 1;
|
|
|
- } catch (IOException e) {
|
|
|
- throw new XiaoShiException("删除失败");
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
- * 更新合并申请人/权利人/发明人
|
|
|
* @param patent
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
- public Integer editMergePerson(Patent patent, String id) {
|
|
|
- List<PatentMergePerson> mergeApplicant = patent.getMergeApplicant();
|
|
|
- String source = "";
|
|
|
- InlineScript inlineScript = InlineScript.of(i -> i.lang("painless").source(source));
|
|
|
- Script script = Script.of(i -> i.inline(inlineScript));
|
|
|
- Query query = QueryBuilders.term(i -> i.field("_id").value(id));
|
|
|
- UpdateByQueryRequest request = UpdateByQueryRequest.of(i -> i.index("patent").query(query));
|
|
|
- try {
|
|
|
- client.updateByQuery(request);
|
|
|
- return 1;
|
|
|
- } catch (IOException e) {
|
|
|
- return -1;
|
|
|
- }
|
|
|
+ public String addChild(Patent patent, String id) throws Exception {
|
|
|
+ IndexResponse indexResponse = client.index(i -> i
|
|
|
+ .index("patent")
|
|
|
+ .routing(id)
|
|
|
+ //传入user对象
|
|
|
+ .document(patent)
|
|
|
+ );
|
|
|
+ return indexResponse.id();
|
|
|
}
|
|
|
|
|
|
- public Integer edit(Patent patent, String id,String routing) {
|
|
|
- UpdateRequest<Patent, Patent> request = UpdateRequest.of(
|
|
|
- i -> i.index("patent")
|
|
|
- .id(id)
|
|
|
- .routing(routing)
|
|
|
- .doc(patent));
|
|
|
+ public Integer delete(List<String> ids) {
|
|
|
+ Query query = QueryBuilders.ids(n -> n.values(ids));
|
|
|
+ DeleteByQueryRequest request = DeleteByQueryRequest.of(i -> i.index("patent").query(query));
|
|
|
try {
|
|
|
- client.update(request,Patent.class);
|
|
|
+ client.deleteByQuery(request);
|
|
|
return 1;
|
|
|
} catch (IOException e) {
|
|
|
- return -1;
|
|
|
+ throw new XiaoShiException("删除失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 删除申请人/权利人/发明人合并名称
|
|
|
*
|