|
@@ -3,11 +3,14 @@ package cn.cslg.pas.service.business.es;
|
|
|
import cn.cslg.pas.common.core.base.IfConstant;
|
|
|
import cn.cslg.pas.common.dto.*;
|
|
|
import cn.cslg.pas.common.dto.business.ContentDetailDTO;
|
|
|
+import cn.cslg.pas.common.model.cronModel.Personnel;
|
|
|
+import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
import cn.cslg.pas.common.model.cronModel.Records;
|
|
|
import cn.cslg.pas.common.model.request.MapRequest;
|
|
|
import cn.cslg.pas.common.model.request.OrderDTO;
|
|
|
import cn.cslg.pas.common.model.request.QueryRequest;
|
|
|
import cn.cslg.pas.common.model.request.StringRequest;
|
|
|
+import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
import cn.cslg.pas.common.utils.FormatUtil;
|
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.expressManager;
|
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.operateNode;
|
|
@@ -19,9 +22,15 @@ import cn.cslg.pas.common.vo.PatentWithIdVO;
|
|
|
import cn.cslg.pas.common.vo.business.PatentKinDetailVO;
|
|
|
import cn.cslg.pas.common.vo.business.PatentKinVO;
|
|
|
import cn.cslg.pas.common.vo.business.PatentNoVO;
|
|
|
+import cn.cslg.pas.common.vo.business.SelectProductVO;
|
|
|
+import cn.cslg.pas.domain.business.Product;
|
|
|
+import cn.cslg.pas.domain.business.ProductCategory;
|
|
|
import cn.cslg.pas.domain.es.*;
|
|
|
+import cn.cslg.pas.mapper.ProductCategoryMapper;
|
|
|
+import cn.cslg.pas.mapper.ProductMapper;
|
|
|
import cn.cslg.pas.service.business.CommonService;
|
|
|
import cn.cslg.pas.service.common.FileManagerService;
|
|
|
+import cn.cslg.pas.service.permissions.PermissionService;
|
|
|
import cn.cslg.pas.service.query.FormatQueryService;
|
|
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
|
|
import co.elastic.clients.elasticsearch._types.SortOrder;
|
|
@@ -39,6 +48,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -47,10 +57,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -61,8 +68,17 @@ public class EsPatentService {
|
|
|
private final FormatQueryService formatQueryService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private PermissionService permissionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private FileManagerService fileManagerService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProductMapper productMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProductCategoryMapper productCategoryMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 根据专利号查询专利详情
|
|
|
*
|
|
@@ -299,6 +315,97 @@ public class EsPatentService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 根据专利号查询出商品化专利
|
|
|
+ *
|
|
|
+ * @param vo
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ public SelectProductMapDTO selectProductByPatentNo(SelectProductVO vo) throws IOException {
|
|
|
+ String patentNo = vo.getPatentNo();
|
|
|
+ Long pageNum = vo.getPageNum();
|
|
|
+ Long pageSize = vo.getPageSize();
|
|
|
+ Integer type = vo.getType();
|
|
|
+ List<SelectProductDTO> list = new ArrayList<>();
|
|
|
+ List<Integer> productIds = new ArrayList<>();
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
+ //设置查询索引
|
|
|
+ builder.index("patent");
|
|
|
+ //申请号
|
|
|
+ Query q1 = QueryBuilders.term(t -> t.field("app_no.keyword").value(patentNo));
|
|
|
+ //公开号
|
|
|
+ Query q2 = QueryBuilders.term(t -> t.field("public_no.keyword").value(patentNo));
|
|
|
+ //授权号
|
|
|
+ Query q3 = QueryBuilders.term(t -> t.field("grant_no.keyword").value(patentNo));
|
|
|
+ Query bool = QueryBuilders.bool(i -> i.should(q1, q2, q3));
|
|
|
+ builder.query(bool);
|
|
|
+
|
|
|
+ SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ List<Hit<Patent>> hits = response.hits().hits();
|
|
|
+ for (Hit<Patent> hit : hits) {
|
|
|
+ Patent patent = hit.source();
|
|
|
+ if (patent.getProductId() != null) {
|
|
|
+ productIds.add(patent.getProductId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Product> products = productMapper.selectBatchIds(productIds);
|
|
|
+ if (!CollectionUtils.isEmpty(products)) {
|
|
|
+ for (Product product : products) {
|
|
|
+ ProductCategory category = new ProductCategory();
|
|
|
+ if (product.getCategoryId() != null) {
|
|
|
+ category = productCategoryMapper.selectById(product.getCategoryId());
|
|
|
+ }
|
|
|
+ SelectProductDTO dto = new SelectProductDTO();
|
|
|
+ BeanUtils.copyProperties(product, dto);
|
|
|
+ //获取产品类别名称
|
|
|
+ dto.setCategoryName(category.getName());
|
|
|
+ list.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Personnel> personnels = new ArrayList<>();
|
|
|
+ List<String> createIds = list.stream().map(SelectProductDTO::getCreateId).collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(createIds)) {
|
|
|
+ String res = permissionService.getPersonnelByIdsFromPCS(createIds);
|
|
|
+ com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(res);
|
|
|
+ personnels = com.alibaba.fastjson.JSONObject.parseArray(jsonObject.getString("data"), Personnel.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (SelectProductDTO dto : list) {
|
|
|
+ //装载创建人人员信息
|
|
|
+ Personnel personnel = personnels.stream().filter(item -> item.getId().equals(dto.getCreateId())).findFirst().orElse(null);
|
|
|
+ if (personnel != null) {
|
|
|
+ dto.setCreateName(personnel.getPersonnelName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SelectProductDTO> sortList = list.stream().sorted(Comparator.comparing(SelectProductDTO::getMarketTime).reversed()).collect(Collectors.toList());
|
|
|
+ List<SelectProductDTO> filterList = sortList.stream().filter(i -> StringUtils.isNotEmpty(vo.getName()) && i.getName().equals(vo.getName()))
|
|
|
+ .filter(i -> StringUtils.isNotEmpty(vo.getCategoryName()) && i.getCategoryName().equals(vo.getCategoryName()))
|
|
|
+ .filter(i -> StringUtils.isNotEmpty(vo.getCompanyName()) && i.getCompanyName().equals(vo.getCompanyName()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ SelectProductMapDTO mapDTO = new SelectProductMapDTO();
|
|
|
+ if (type == 0) {
|
|
|
+ Map<String, List<SelectProductDTO>> map = new HashMap<>();
|
|
|
+ List<SelectProductDTO> returnData = filterList.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
|
|
|
+ map.put("无分组", returnData);
|
|
|
+ mapDTO.setProductMap(map);
|
|
|
+ mapDTO.setTotal(Long.valueOf(String.valueOf(filterList.size())));
|
|
|
+ } else if (type == 1) {
|
|
|
+ Map<String, List<SelectProductDTO>> collect = filterList.stream().collect(Collectors.groupingBy(SelectProductDTO::getCategoryName));
|
|
|
+ mapDTO.setProductMap(collect);
|
|
|
+ mapDTO.setTotal(Long.valueOf(String.valueOf(collect.keySet().size())));
|
|
|
+ } else if (type == 2) {
|
|
|
+ Map<String, List<SelectProductDTO>> collect = filterList.stream().collect(Collectors.groupingBy(SelectProductDTO::getCompanyName));
|
|
|
+ mapDTO.setProductMap(collect);
|
|
|
+ mapDTO.setTotal(Long.valueOf(String.valueOf(collect.keySet().size())));
|
|
|
+ }
|
|
|
+
|
|
|
+ return mapDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 根据专利号批量查询专利
|
|
|
*
|
|
|
* @param patentNos
|