Browse Source

add 商品化专利

zero 1 năm trước cách đây
mục cha
commit
e3c960d67b

+ 2 - 0
src/main/java/cn/cslg/pas/common/dto/QueryFieldsDTO.java

@@ -15,4 +15,6 @@ import java.util.List;
 public class QueryFieldsDTO {
 public class QueryFieldsDTO {
  private String tableName;
  private String tableName;
  private Integer projectId;
  private Integer projectId;
+ //商品化专利
+ private Integer productId;
 }
 }

+ 2 - 0
src/main/java/cn/cslg/pas/common/dto/patentCount/GetTabelColumDTO.java

@@ -12,4 +12,6 @@ public class GetTabelColumDTO {
     //任务id
     //任务id
     private Integer taskId;
     private Integer taskId;
     private String tableName;
     private String tableName;
+    //商品化专利
+    private Integer productId;
 }
 }

+ 2 - 1
src/main/java/cn/cslg/pas/common/vo/PatentWithIdVO.java

@@ -14,7 +14,8 @@ import java.util.Map;
 @Accessors(chain = true)
 @Accessors(chain = true)
 @Data
 @Data
 public class PatentWithIdVO {
 public class PatentWithIdVO {
-private String id;
+
+    private String id;
     /**
     /**
      * 专利摘要附图
      * 专利摘要附图
      */
      */

+ 0 - 9
src/main/java/cn/cslg/pas/common/vo/es/EsPatentFieldVO.java

@@ -1,9 +0,0 @@
-package cn.cslg.pas.common.vo.es;
-
-import lombok.Data;
-
-@Data
-public class EsPatentFieldVO {
-    String patentNo;
-
-}

+ 14 - 0
src/main/java/cn/cslg/pas/common/vo/es/EsProductPatentVO.java

@@ -0,0 +1,14 @@
+package cn.cslg.pas.common.vo.es;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class EsProductPatentVO {
+
+    private List<Integer> productIds;
+
+    private List<String> patentNos;
+
+}

+ 20 - 0
src/main/java/cn/cslg/pas/controller/PatentController.java

@@ -20,6 +20,7 @@ import cn.cslg.pas.common.vo.business.PatentKinVO;
 import cn.cslg.pas.common.vo.business.PatentNoVO;
 import cn.cslg.pas.common.vo.business.PatentNoVO;
 import cn.cslg.pas.common.vo.es.EsCustomFieldBatchVO;
 import cn.cslg.pas.common.vo.es.EsCustomFieldBatchVO;
 import cn.cslg.pas.common.vo.es.EsDateRangeVO;
 import cn.cslg.pas.common.vo.es.EsDateRangeVO;
+import cn.cslg.pas.common.vo.es.EsProductPatentVO;
 import cn.cslg.pas.domain.business.ImportTask;
 import cn.cslg.pas.domain.business.ImportTask;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.businessFactory.Business;
 import cn.cslg.pas.factorys.businessFactory.Business;
@@ -31,6 +32,7 @@ import cn.cslg.pas.service.business.PatentExportService;
 import cn.cslg.pas.service.business.MergePersonService;
 import cn.cslg.pas.service.business.MergePersonService;
 import cn.cslg.pas.service.business.es.EsCountService;
 import cn.cslg.pas.service.business.es.EsCountService;
 import cn.cslg.pas.service.business.es.EsPatentService;
 import cn.cslg.pas.service.business.es.EsPatentService;
+import cn.cslg.pas.service.business.es.EsProductPatentService;
 import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.business.es.EsService;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.common.PatentStarApiService;
 import cn.cslg.pas.service.common.PatentStarApiService;
@@ -71,6 +73,9 @@ public class PatentController {
     private EsService esService;
     private EsService esService;
 
 
     @Autowired
     @Autowired
+    private EsProductPatentService esProductPatentService;
+
+    @Autowired
     private PatentStarApiService patentStarApiService;
     private PatentStarApiService patentStarApiService;
 
 
     @Autowired
     @Autowired
@@ -294,4 +299,19 @@ public class PatentController {
         records.setData("导出专利");
         records.setData("导出专利");
         return Response.success(records);
         return Response.success(records);
     }
     }
+
+    //---------------------------------商品化专利----------------
+    @Operation(summary = "添加商品化专利")
+    @PostMapping("/addProductPatent")
+    public Response addProductPatent(EsProductPatentVO vo) throws Exception {
+        List<Integer> ids = esProductPatentService.addProductPatent(vo);
+        return Response.success(ids);
+    }
+
+    @Operation(summary = "删除商品化专利")
+    @PostMapping("/delProductPatent")
+    public Response delProductPatent(EsProductPatentVO vo) throws Exception {
+        List<Integer> ids = esProductPatentService.delProductPatent(vo);
+        return Response.success(ids);
+    }
 }
 }

+ 1 - 1
src/main/java/cn/cslg/pas/domain/es/Patent.java

@@ -394,7 +394,7 @@ public class Patent {
      * 专题库或报告id
      * 专题库或报告id
      */
      */
     @JsonProperty("product_id")
     @JsonProperty("product_id")
-    private String productId;
+    private Integer productId;
 
 
     /**
     /**
      * 专题库或报告的任务
      * 专题库或报告的任务

+ 60 - 0
src/main/java/cn/cslg/pas/factorys/EsBuilderFactory/ProductQueryBuilder.java

@@ -0,0 +1,60 @@
+package cn.cslg.pas.factorys.EsBuilderFactory;
+
+import co.elastic.clients.elasticsearch._types.query_dsl.Query;
+import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
+import org.springframework.stereotype.Component;
+
+import java.text.ParseException;
+
+@Component
+public class ProductQueryBuilder implements IQueryBuilder {
+    private String field = "";
+    private String value = "";
+    private String operator = "";
+    public String path = "";
+
+    @Override
+    public Query creteQuery() throws ParseException {
+        return QueryBuilders.hasChild(child -> child.type("product").query(i -> i.match(j -> j.field(field).query(value))));
+    }
+
+    @Override
+    public String getField() {
+        return field;
+    }
+
+    @Override
+    public void setField(String field) {
+        this.field = field;
+    }
+
+    @Override
+    public String getValue() {
+        return value;
+    }
+
+    @Override
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    @Override
+    public String getOperator() {
+        return operator;
+    }
+
+    @Override
+    public void setOperator(String operator) {
+        this.operator = operator;
+    }
+
+    @Override
+    public String getPath() {
+        return path;
+    }
+
+    @Override
+    public void setPath(String path) {
+        this.path = path;
+    }
+}

+ 78 - 0
src/main/java/cn/cslg/pas/service/business/es/EsProductPatentService.java

@@ -0,0 +1,78 @@
+package cn.cslg.pas.service.business.es;
+
+
+import cn.cslg.pas.common.dto.business.SelectClaimDTO;
+import cn.cslg.pas.common.vo.PatentWithIdVO;
+import cn.cslg.pas.common.vo.es.EsProductPatentVO;
+import cn.cslg.pas.domain.es.Patent;
+import cn.cslg.pas.domain.es.PatentJoin;
+import cn.cslg.pas.service.query.FormatQueryService;
+import co.elastic.clients.elasticsearch.ElasticsearchClient;
+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 lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
+public class EsProductPatentService {
+    private final ElasticsearchClient client;
+    private final FormatQueryService formatQueryService;
+
+    @Autowired
+    private EsService esService;
+
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
+    public List<Integer> addProductPatent(EsProductPatentVO vo) throws Exception {
+        List<Integer> ids = new ArrayList<>();
+        List<String> patentNos = vo.getPatentNos();
+        for (String patentNo : patentNos) {
+            PatentWithIdVO patentWithIdVO = esService.getIdByPatentNo(patentNo);
+            String id = patentWithIdVO.getId();
+            Patent patent = new Patent();
+            PatentJoin patentJoin = new PatentJoin();
+            patentJoin.setParent(id);
+            patentJoin.setName("product");
+            patent.setPatentJoin(patentJoin);
+            List<Integer> productIds = vo.getProductIds();
+            for (Integer productId : productIds) {
+                patent.setProductId(productId);
+                esService.addChildPatent(patent, id);
+                ids.add(productId);
+            }
+        }
+        return ids;
+    }
+
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
+    public List<Integer> delProductPatent(EsProductPatentVO vo) throws Exception {
+        List<Integer> ids = new ArrayList<>();
+        List<Integer> productIds = vo.getProductIds();
+        for (Integer productId : productIds) {
+            SearchRequest.Builder builder = new SearchRequest.Builder();
+            //设置查询索引
+            builder.index("patent");
+            Query q = QueryBuilders.term(n -> n.field("product_id").value(productId));
+            Query query = QueryBuilders.hasChild(i -> i.type("product").query(q));
+            builder.query(query);
+            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();
+
+            }
+        }
+
+        return ids;
+    }
+}

+ 13 - 0
src/main/resources/jsons/patent.json

@@ -118,6 +118,19 @@
     "ifStats": "false"
     "ifStats": "false"
   },
   },
   {
   {
+    "name": "商品化专利id",
+    "type": "String",
+    "value": "productId",
+    "field": "productId",
+    "esField": "product_id",
+    "esClass": "productQueryBuilder",
+    "ifSearch": "false",
+    "ifGroup": "false",
+    "ifShow": "false",
+    "ifAsCondition": "true",
+    "ifStats": "false"
+  },
+  {
     "name": "摘要",
     "name": "摘要",
     "type": "Object",
     "type": "Object",
     "value": "abstractStr",
     "value": "abstractStr",