|
@@ -19,10 +19,12 @@ import cn.cslg.pas.domain.BaseEntity;
|
|
import cn.cslg.pas.domain.business.FollowUp;
|
|
import cn.cslg.pas.domain.business.FollowUp;
|
|
import cn.cslg.pas.domain.business.MergePerson;
|
|
import cn.cslg.pas.domain.business.MergePerson;
|
|
import cn.cslg.pas.domain.es.Patent;
|
|
import cn.cslg.pas.domain.es.Patent;
|
|
|
|
+import cn.cslg.pas.domain.es.PatentMergePerson;
|
|
import cn.cslg.pas.domain.es.PersonAddress;
|
|
import cn.cslg.pas.domain.es.PersonAddress;
|
|
import cn.cslg.pas.exception.UnLoginException;
|
|
import cn.cslg.pas.exception.UnLoginException;
|
|
import cn.cslg.pas.mapper.MergePersonMapper;
|
|
import cn.cslg.pas.mapper.MergePersonMapper;
|
|
import cn.cslg.pas.service.business.es.EsPatentService;
|
|
import cn.cslg.pas.service.business.es.EsPatentService;
|
|
|
|
+import cn.cslg.pas.service.business.es.EsService;
|
|
import cn.cslg.pas.service.query.FormatQueryService;
|
|
import cn.cslg.pas.service.query.FormatQueryService;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.PageUtil;
|
|
import cn.hutool.core.util.PageUtil;
|
|
@@ -36,11 +38,13 @@ import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
|
|
import co.elastic.clients.elasticsearch.core.SearchRequest;
|
|
import co.elastic.clients.elasticsearch.core.SearchRequest;
|
|
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
|
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
|
import co.elastic.clients.elasticsearch.core.search.Hit;
|
|
import co.elastic.clients.elasticsearch.core.search.Hit;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
+import com.google.gson.JsonArray;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -50,10 +54,8 @@ import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -75,9 +77,13 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
private FormatQueryService formatQueryService;
|
|
private FormatQueryService formatQueryService;
|
|
@Autowired
|
|
@Autowired
|
|
private EsPatentService esPatentService;
|
|
private EsPatentService esPatentService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private EsService esService;
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
|
- public Integer mergePerson(MergePersonVO vo) {
|
|
|
|
|
|
+ public Integer mergePerson(MergePersonVO vo) throws IOException {
|
|
|
|
+ Integer type = vo.getType();
|
|
|
|
+ List<String> mergedNames = vo.getMergedName();
|
|
//获取登陆人信息 用于设置创建人
|
|
//获取登陆人信息 用于设置创建人
|
|
PersonnelVO personnelVO = new PersonnelVO();
|
|
PersonnelVO personnelVO = new PersonnelVO();
|
|
try {
|
|
try {
|
|
@@ -91,7 +97,53 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
person.setCreateTime(new Date());
|
|
person.setCreateTime(new Date());
|
|
person.insert();
|
|
person.insert();
|
|
//todo 关联相关专利
|
|
//todo 关联相关专利
|
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
|
+ //设置查询索引
|
|
|
|
+ builder.index("patent");
|
|
|
|
+
|
|
|
|
+ List<Query> queries = new ArrayList<>();
|
|
|
|
+ if (type == 0) {
|
|
|
|
+ for (String mergedName : mergedNames) {
|
|
|
|
+ Query q = QueryBuilders.term(i -> i.field("applicant.name").value(mergedName));
|
|
|
|
+ Query query = QueryBuilders.nested(i -> i.path("applicant").query(q));
|
|
|
|
+ queries.add(query);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ for (String mergedName : mergedNames) {
|
|
|
|
+ Query q = QueryBuilders.term(i -> i.field("inventor.name").value(mergedName));
|
|
|
|
+ Query query = QueryBuilders.nested(i -> i.path("inventor").query(q));
|
|
|
|
+ queries.add(query);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Query query = QueryBuilders.bool(i -> i.should(queries));
|
|
|
|
+ builder.query(query);
|
|
|
|
+ SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
|
+ List<Hit<Patent>> hits = response.hits().hits();
|
|
|
|
+ List<String> ids = new ArrayList<>();
|
|
|
|
+ Map<String, Patent> map = new HashMap<>();
|
|
|
|
+ for (Hit<Patent> hit : hits) {
|
|
|
|
+ String id = hit.id();
|
|
|
|
+ map.put(id, hit.source());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!CollectionUtils.isEmpty(ids)) {
|
|
|
|
+ List<PatentMergePerson> mergePersonList = new ArrayList<>();
|
|
|
|
+ PatentMergePerson mergePerson = new PatentMergePerson();
|
|
|
|
+ mergePerson.setName(vo.getName());
|
|
|
|
+ mergePerson.setProjectId(vo.getProjectId().toString());
|
|
|
|
+ mergePerson.setType("1");
|
|
|
|
+ mergePerson.setOrder(1);
|
|
|
|
+ mergePersonList.add(mergePerson);
|
|
|
|
+
|
|
|
|
+ for (String id : map.keySet()) {
|
|
|
|
+ Patent patent = map.get(id);
|
|
|
|
+ List<PatentMergePerson> mergeApplicant = patent.getMergeApplicant();
|
|
|
|
|
|
|
|
+ patent.setMergeApplicant(mergePersonList);
|
|
|
|
+ patent.setMergeRightHolder(mergePersonList);
|
|
|
|
+ esService.updateMergePerson(patent, id);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return person.getId();
|
|
return person.getId();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -146,8 +198,6 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
String searchCondition = "";
|
|
String searchCondition = "";
|
|
Integer projectId = vo.getProjectId();
|
|
Integer projectId = vo.getProjectId();
|
|
Integer taskId = vo.getTaskId();
|
|
Integer taskId = vo.getTaskId();
|
|
- String name = vo.getName();
|
|
|
|
- String field = vo.getField();
|
|
|
|
Integer pageNum = vo.getPageNum();
|
|
Integer pageNum = vo.getPageNum();
|
|
Integer pageSize = vo.getPageSize();
|
|
Integer pageSize = vo.getPageSize();
|
|
if (taskId != null) {
|
|
if (taskId != null) {
|
|
@@ -172,19 +222,22 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
builder.query(q);
|
|
builder.query(q);
|
|
SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
List<Hit<Patent>> hits = response.hits().hits();
|
|
|
|
+ long total = response.hits().total().value();
|
|
List<GetEsAllPersonDTO> personDTOS = new ArrayList<>();
|
|
List<GetEsAllPersonDTO> personDTOS = new ArrayList<>();
|
|
for (Hit<Patent> hit : hits) {
|
|
for (Hit<Patent> hit : hits) {
|
|
Patent esMess = hit.source();
|
|
Patent esMess = hit.source();
|
|
- PersonAddress applicantAddr = esMess.getApplicantAddr();
|
|
|
|
|
|
+ PersonAddress applicantAddr = null;
|
|
GetEsAllPersonDTO personDTO = new GetEsAllPersonDTO();
|
|
GetEsAllPersonDTO personDTO = new GetEsAllPersonDTO();
|
|
- personDTO.setAddress(applicantAddr.getAddress());
|
|
|
|
- personDTO.setCountry(applicantAddr.getCountry());
|
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(esMess.getApplicantAddr())) {
|
|
|
|
+ applicantAddr = esMess.getApplicantAddr();
|
|
|
|
+ personDTO.setAddress(applicantAddr.getAddress());
|
|
|
|
+ personDTO.setCountry(applicantAddr.getCountry());
|
|
|
|
+ }
|
|
personDTO.setApplicant(esPatentService.loadName(esMess.getApplicant()));
|
|
personDTO.setApplicant(esPatentService.loadName(esMess.getApplicant()));
|
|
personDTO.setRightHolder(esPatentService.loadName(esMess.getRightHolder()));
|
|
personDTO.setRightHolder(esPatentService.loadName(esMess.getRightHolder()));
|
|
personDTO.setInventor(esPatentService.loadName(esMess.getInventor()));
|
|
personDTO.setInventor(esPatentService.loadName(esMess.getInventor()));
|
|
personDTOS.add(personDTO);
|
|
personDTOS.add(personDTO);
|
|
}
|
|
}
|
|
- List<GetAllPersonDTO> allPersonDTOS = new ArrayList<>();
|
|
|
|
List<String> applicants = new ArrayList<>();
|
|
List<String> applicants = new ArrayList<>();
|
|
List<String> inventors = new ArrayList<>();
|
|
List<String> inventors = new ArrayList<>();
|
|
for (GetEsAllPersonDTO personDTO : personDTOS) {
|
|
for (GetEsAllPersonDTO personDTO : personDTOS) {
|
|
@@ -193,24 +246,57 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
}
|
|
}
|
|
List<String> applicantList = applicants.stream().distinct().collect(Collectors.toList());
|
|
List<String> applicantList = applicants.stream().distinct().collect(Collectors.toList());
|
|
List<String> inventorList = inventors.stream().distinct().collect(Collectors.toList());
|
|
List<String> inventorList = inventors.stream().distinct().collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ IPage<MergePerson> page = new Page<>(vo.getPageNum(), vo.getPageSize());
|
|
|
|
+ LambdaQueryWrapper<MergePerson> wrapper = new LambdaQueryWrapper<MergePerson>()
|
|
|
|
+ .eq(StringUtils.isNotEmpty(vo.getProjectId().toString()), MergePerson::getProjectId, vo.getProjectId());
|
|
|
|
+ IPage<MergePerson> record = mergePersonMapper.selectPage(page, wrapper);
|
|
|
|
+ List<String> applicantMergeList = new ArrayList<>();
|
|
|
|
+ List<String> inventorMergeList = new ArrayList<>();
|
|
|
|
+ for (MergePerson person : record.getRecords()) {
|
|
|
|
+ if (person.getType() == 0) {
|
|
|
|
+ applicantMergeList = JSONArray.parseArray(person.getMergedName(), String.class);
|
|
|
|
+ } else if (person.getType() == 2) {
|
|
|
|
+ inventorMergeList = JSONArray.parseArray(person.getMergedName(), String.class);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ applicantList.removeAll(applicantMergeList);
|
|
|
|
+ inventorList.removeAll(inventorMergeList);
|
|
|
|
+ List<GetAllPersonDTO> applicantDTOS = new ArrayList<>();
|
|
|
|
+ List<GetAllPersonDTO> inventorDTOS = new ArrayList<>();
|
|
for (String applicant : applicantList) {
|
|
for (String applicant : applicantList) {
|
|
GetAllPersonDTO dto = new GetAllPersonDTO();
|
|
GetAllPersonDTO dto = new GetAllPersonDTO();
|
|
dto.setName(applicant);
|
|
dto.setName(applicant);
|
|
dto.setType(0);
|
|
dto.setType(0);
|
|
- allPersonDTOS.add(dto);
|
|
|
|
|
|
+ applicantDTOS.add(dto);
|
|
}
|
|
}
|
|
for (String inventor : inventorList) {
|
|
for (String inventor : inventorList) {
|
|
GetAllPersonDTO dto = new GetAllPersonDTO();
|
|
GetAllPersonDTO dto = new GetAllPersonDTO();
|
|
dto.setName(inventor);
|
|
dto.setName(inventor);
|
|
dto.setType(2);
|
|
dto.setType(2);
|
|
- allPersonDTOS.add(dto);
|
|
|
|
|
|
+ inventorDTOS.add(dto);
|
|
}
|
|
}
|
|
-// List<GetAllPersonDTO> list = allPersonDTOS.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
|
+
|
|
Records records = new Records();
|
|
Records records = new Records();
|
|
-// records.setCurrent(queryRequest.getCurrent());
|
|
|
|
-// records.setSize(queryRequest.getSize());
|
|
|
|
-// records.setData(patentDTO.getPatents());
|
|
|
|
-// records.setTotal(patentDTO.getTotal());
|
|
|
|
|
|
+ records.setCurrent(vo.getPageNum().longValue());
|
|
|
|
+ records.setSize(vo.getPageSize().longValue());
|
|
|
|
+ if (vo.getType() == 0) {
|
|
|
|
+ int size = applicantDTOS.size();
|
|
|
|
+ records.setData(applicantDTOS.stream().limit(vo.getPageSize()).collect(Collectors.toList()));
|
|
|
|
+ if (total >= size) {
|
|
|
|
+ records.setTotal((long)size);
|
|
|
|
+ } else {
|
|
|
|
+ records.setTotal(total);
|
|
|
|
+ }
|
|
|
|
+ } else if (vo.getType() == 2) {
|
|
|
|
+ int size = inventorDTOS.size();
|
|
|
|
+ records.setData(inventorDTOS.stream().limit(vo.getPageSize()).collect(Collectors.toList()));
|
|
|
|
+ if (total >= size) {
|
|
|
|
+ records.setTotal((long)size);
|
|
|
|
+ } else {
|
|
|
|
+ records.setTotal(total);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return records;
|
|
return records;
|
|
}
|
|
}
|
|
|
|
|