|
@@ -1,20 +1,41 @@
|
|
|
package cn.cslg.pas.service.business;
|
|
|
|
|
|
+import cn.cslg.pas.common.dto.GetAllPersonDTO;
|
|
|
import cn.cslg.pas.common.dto.MergePersonQueryDTO;
|
|
|
+import cn.cslg.pas.common.dto.PatentColumnDTO;
|
|
|
+import cn.cslg.pas.common.dto.patentCount.GetEsAllPersonDTO;
|
|
|
import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
import cn.cslg.pas.common.model.cronModel.Records;
|
|
|
import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
import cn.cslg.pas.common.utils.LoginUtils;
|
|
|
+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.business.GetAllPersonVO;
|
|
|
import cn.cslg.pas.common.vo.business.MergePersonIdVO;
|
|
|
import cn.cslg.pas.common.vo.business.MergePersonQueryVO;
|
|
|
import cn.cslg.pas.common.vo.business.MergePersonVO;
|
|
|
import cn.cslg.pas.domain.BaseEntity;
|
|
|
import cn.cslg.pas.domain.business.FollowUp;
|
|
|
import cn.cslg.pas.domain.business.MergePerson;
|
|
|
+import cn.cslg.pas.domain.es.Patent;
|
|
|
+import cn.cslg.pas.domain.es.PersonAddress;
|
|
|
import cn.cslg.pas.exception.UnLoginException;
|
|
|
import cn.cslg.pas.mapper.MergePersonMapper;
|
|
|
+import cn.cslg.pas.service.business.es.EsPatentService;
|
|
|
+import cn.cslg.pas.service.query.FormatQueryService;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.PageUtil;
|
|
|
+import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
|
|
+import co.elastic.clients.elasticsearch._types.aggregations.Aggregation;
|
|
|
+import co.elastic.clients.elasticsearch._types.aggregations.AggregationBuilders;
|
|
|
+import co.elastic.clients.elasticsearch._types.aggregations.NestedAggregation;
|
|
|
+import co.elastic.clients.elasticsearch._types.aggregations.TermsAggregation;
|
|
|
+import co.elastic.clients.elasticsearch._types.query_dsl.Query;
|
|
|
+import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
|
|
|
+import co.elastic.clients.elasticsearch.core.SearchRequest;
|
|
|
+import co.elastic.clients.elasticsearch.core.SearchResponse;
|
|
|
+import co.elastic.clients.elasticsearch.core.search.Hit;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -27,10 +48,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Author xiexiang
|
|
@@ -40,11 +64,17 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePerson> {
|
|
|
@Autowired
|
|
|
+ private ElasticsearchClient client;
|
|
|
+ @Autowired
|
|
|
private CacheUtils cacheUtils;
|
|
|
@Autowired
|
|
|
private LoginUtils loginUtils;
|
|
|
@Autowired
|
|
|
private MergePersonMapper mergePersonMapper;
|
|
|
+ @Autowired
|
|
|
+ private FormatQueryService formatQueryService;
|
|
|
+ @Autowired
|
|
|
+ private EsPatentService esPatentService;
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
|
|
|
public Integer mergePerson(MergePersonVO vo) {
|
|
@@ -112,10 +142,84 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
|
return records;
|
|
|
}
|
|
|
|
|
|
+ public Records getMergePerson(GetAllPersonVO vo) throws Exception {
|
|
|
+ String searchCondition = "";
|
|
|
+ Integer projectId = vo.getProjectId();
|
|
|
+ Integer taskId = vo.getTaskId();
|
|
|
+ String name = vo.getName();
|
|
|
+ String field = vo.getField();
|
|
|
+ Integer pageNum = vo.getPageNum();
|
|
|
+ Integer pageSize = vo.getPageSize();
|
|
|
+ if (taskId != null) {
|
|
|
+ searchCondition = "taskId = " + taskId;
|
|
|
+ } else {
|
|
|
+ if (projectId != null) {
|
|
|
+ searchCondition = "projectId = " + projectId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
+ //设置查询索引
|
|
|
+ builder.index("patent");
|
|
|
+ //1. 解析检索条件
|
|
|
+ treeNode tree = expressManager.getInstance().Parse(searchCondition, false);
|
|
|
+ //格式化检索式
|
|
|
+ //3. 从es中检索数据
|
|
|
+ Query q = formatQueryService.EsQueryToQuery((operateNode) tree, "patent");
|
|
|
+ //分页
|
|
|
+ if (pageNum > 0 && pageSize > 0) {
|
|
|
+ builder.from((pageNum - 1) * pageSize).size(pageSize);
|
|
|
+ }
|
|
|
+ builder.query(q);
|
|
|
+ SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ List<Hit<Patent>> hits = response.hits().hits();
|
|
|
+ List<GetEsAllPersonDTO> personDTOS = new ArrayList<>();
|
|
|
+ for (Hit<Patent> hit : hits) {
|
|
|
+ Patent esMess = hit.source();
|
|
|
+ PersonAddress applicantAddr = esMess.getApplicantAddr();
|
|
|
+ GetEsAllPersonDTO personDTO = new GetEsAllPersonDTO();
|
|
|
+ personDTO.setAddress(applicantAddr.getAddress());
|
|
|
+ personDTO.setCountry(applicantAddr.getCountry());
|
|
|
+ personDTO.setApplicant(esPatentService.loadName(esMess.getApplicant()));
|
|
|
+ personDTO.setRightHolder(esPatentService.loadName(esMess.getRightHolder()));
|
|
|
+ personDTO.setInventor(esPatentService.loadName(esMess.getInventor()));
|
|
|
+ personDTOS.add(personDTO);
|
|
|
+ }
|
|
|
+ List<GetAllPersonDTO> allPersonDTOS = new ArrayList<>();
|
|
|
+ List<String> applicants = new ArrayList<>();
|
|
|
+ List<String> inventors = new ArrayList<>();
|
|
|
+ for (GetEsAllPersonDTO personDTO : personDTOS) {
|
|
|
+ applicants.addAll(personDTO.getApplicant());
|
|
|
+ inventors.addAll(personDTO.getInventor());
|
|
|
+ }
|
|
|
+ List<String> applicantList = applicants.stream().distinct().collect(Collectors.toList());
|
|
|
+ List<String> inventorList = inventors.stream().distinct().collect(Collectors.toList());
|
|
|
+ for (String applicant : applicantList) {
|
|
|
+ GetAllPersonDTO dto = new GetAllPersonDTO();
|
|
|
+ dto.setName(applicant);
|
|
|
+ dto.setType(0);
|
|
|
+ allPersonDTOS.add(dto);
|
|
|
+ }
|
|
|
+ for (String inventor : inventorList) {
|
|
|
+ GetAllPersonDTO dto = new GetAllPersonDTO();
|
|
|
+ dto.setName(inventor);
|
|
|
+ dto.setType(2);
|
|
|
+ allPersonDTOS.add(dto);
|
|
|
+ }
|
|
|
+// List<GetAllPersonDTO> list = allPersonDTOS.stream().distinct().collect(Collectors.toList());
|
|
|
+ Records records = new Records();
|
|
|
+// records.setCurrent(queryRequest.getCurrent());
|
|
|
+// records.setSize(queryRequest.getSize());
|
|
|
+// records.setData(patentDTO.getPatents());
|
|
|
+// records.setTotal(patentDTO.getTotal());
|
|
|
+ return records;
|
|
|
+ }
|
|
|
+
|
|
|
public Integer delMergePerson(MergePersonIdVO vo) {
|
|
|
LambdaQueryWrapper<MergePerson> wrapper = new LambdaQueryWrapper<MergePerson>()
|
|
|
.eq(BaseEntity::getId, vo.getId());
|
|
|
this.remove(wrapper);
|
|
|
+
|
|
|
+ //todo 删掉相关合并的名称
|
|
|
return vo.getId();
|
|
|
}
|
|
|
}
|