|
@@ -7,8 +7,10 @@ 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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.example.xiaoshiweixinback.business.common.base.Records;
|
|
import com.example.xiaoshiweixinback.business.exception.BusinessException;
|
|
import com.example.xiaoshiweixinback.business.exception.BusinessException;
|
|
import com.example.xiaoshiweixinback.business.exception.ExceptionEnum;
|
|
import com.example.xiaoshiweixinback.business.exception.ExceptionEnum;
|
|
|
|
+import com.example.xiaoshiweixinback.business.utils.BeanUtil;
|
|
import com.example.xiaoshiweixinback.business.utils.CacheUtil;
|
|
import com.example.xiaoshiweixinback.business.utils.CacheUtil;
|
|
import com.example.xiaoshiweixinback.business.utils.LoginUtils;
|
|
import com.example.xiaoshiweixinback.business.utils.LoginUtils;
|
|
import com.example.xiaoshiweixinback.business.utils.ToolUtil;
|
|
import com.example.xiaoshiweixinback.business.utils.ToolUtil;
|
|
@@ -17,6 +19,8 @@ import com.example.xiaoshiweixinback.domain.es.Patent;
|
|
import com.example.xiaoshiweixinback.domain.es.PatentJoin;
|
|
import com.example.xiaoshiweixinback.domain.es.PatentJoin;
|
|
import com.example.xiaoshiweixinback.domain.es.PatentVector;
|
|
import com.example.xiaoshiweixinback.domain.es.PatentVector;
|
|
import com.example.xiaoshiweixinback.entity.dto.patent.CollectPatentDTO;
|
|
import com.example.xiaoshiweixinback.entity.dto.patent.CollectPatentDTO;
|
|
|
|
+import com.example.xiaoshiweixinback.entity.dto.patent.PatentColumnDTO;
|
|
|
|
+import com.example.xiaoshiweixinback.entity.dto.patent.SelectCollectPatentDTO;
|
|
import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
|
|
import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
|
|
import com.example.xiaoshiweixinback.entity.vo.esPicture.EsPictureNoVo;
|
|
import com.example.xiaoshiweixinback.entity.vo.esPicture.EsPictureNoVo;
|
|
import com.example.xiaoshiweixinback.mapper.AssoPersonProductMapper;
|
|
import com.example.xiaoshiweixinback.mapper.AssoPersonProductMapper;
|
|
@@ -46,7 +50,7 @@ public class EsPatentService {
|
|
private AssoPersonProductMapper assoPersonProductMapper;
|
|
private AssoPersonProductMapper assoPersonProductMapper;
|
|
|
|
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
|
|
+ * 收藏专利
|
|
* @param patentDTO
|
|
* @param patentDTO
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -64,9 +68,9 @@ public class EsPatentService {
|
|
AssoPersonProduct assoPersonProduct = assoPersonProductMapper.selectOne(new LambdaQueryWrapper<AssoPersonProduct>()
|
|
AssoPersonProduct assoPersonProduct = assoPersonProductMapper.selectOne(new LambdaQueryWrapper<AssoPersonProduct>()
|
|
.eq(AssoPersonProduct::getProductId, productId)
|
|
.eq(AssoPersonProduct::getProductId, productId)
|
|
.eq(AssoPersonProduct::getPersonUuid, uuid));
|
|
.eq(AssoPersonProduct::getPersonUuid, uuid));
|
|
- Integer personProductId = assoPersonProduct.getId();
|
|
|
|
|
|
+ Integer assoPersonProductId = assoPersonProduct.getId();
|
|
//判断该专利是否已经被收藏
|
|
//判断该专利是否已经被收藏
|
|
- List<String> patentNoList = this.selectPatentByProductId(personProductId);
|
|
|
|
|
|
+ List<String> patentNoList = this.selectPatentByProductId(assoPersonProductId);
|
|
patentNos.removeAll(patentNoList);
|
|
patentNos.removeAll(patentNoList);
|
|
//根据专利号获取专利id
|
|
//根据专利号获取专利id
|
|
List<String> list = new ArrayList<>();
|
|
List<String> list = new ArrayList<>();
|
|
@@ -74,7 +78,7 @@ public class EsPatentService {
|
|
for (String patentNo : patentNos) {
|
|
for (String patentNo : patentNos) {
|
|
String patentId = this.selectPatentByPatentNo(patentNo);
|
|
String patentId = this.selectPatentByPatentNo(patentNo);
|
|
Patent patent = new Patent();
|
|
Patent patent = new Patent();
|
|
- patent.setProductId(personProductId);
|
|
|
|
|
|
+ patent.setProductId(assoPersonProductId);
|
|
PatentJoin patentJoin = new PatentJoin();
|
|
PatentJoin patentJoin = new PatentJoin();
|
|
patentJoin.setParent(patentId);
|
|
patentJoin.setParent(patentId);
|
|
patentJoin.setName("product");
|
|
patentJoin.setName("product");
|
|
@@ -93,6 +97,49 @@ public class EsPatentService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 查询收藏专利
|
|
|
|
+ * @param dto
|
|
|
|
+ * @return
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ public Records selectCollectPatent(SelectCollectPatentDTO dto) throws IOException {
|
|
|
|
+ Integer assoPersonProductId = dto.getAssoPersonProductId();
|
|
|
|
+ Long pageNum = dto.getCurrent();
|
|
|
|
+ Long pageSize = dto.getSize();
|
|
|
|
+
|
|
|
|
+ List<PatentColumnDTO> list = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
|
+ //设置查询索引
|
|
|
|
+ builder.index("wxpatent");
|
|
|
|
+ Query q = QueryBuilders.term(i -> i.field("product_id").value(assoPersonProductId));
|
|
|
|
+ Query query = QueryBuilders.hasChild(i -> i.type("product").query(q));
|
|
|
|
+ builder.query(query);
|
|
|
|
+ //分页
|
|
|
|
+ if (pageNum != null && pageSize != null && pageNum > 0 && pageSize > 0) {
|
|
|
|
+ builder.from((pageNum.intValue() - 1) * pageSize.intValue()).size(pageSize.intValue());
|
|
|
|
+ }
|
|
|
|
+ //解除最大条数限制
|
|
|
|
+ builder.trackTotalHits(i -> i.enabled(true));
|
|
|
|
+ SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
|
+ List<Hit<Patent>> hits = response.hits().hits();
|
|
|
|
+ long total = response.hits().total().value();
|
|
|
|
+ for (Hit<Patent> hit : hits) {
|
|
|
|
+ Patent patent = hit.source();
|
|
|
|
+ PatentColumnDTO columnDTO = new PatentColumnDTO();
|
|
|
|
+ BeanUtil.copy(patent, columnDTO);
|
|
|
|
+ list.add(columnDTO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Records records = new Records();
|
|
|
|
+ records.setCurrent(pageNum);
|
|
|
|
+ records.setSize(pageSize);
|
|
|
|
+ records.setData(list);
|
|
|
|
+ records.setTotal(total);
|
|
|
|
+ return records;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 根据专利号获取专利id
|
|
* 根据专利号获取专利id
|
|
* @param patentNo
|
|
* @param patentNo
|
|
* @return
|
|
* @return
|