Procházet zdrojové kódy

add:商品化专利数量

zero před 1 rokem
rodič
revize
da9cf22220

+ 0 - 5
src/main/java/cn/cslg/pas/common/dto/PatentDTO.java

@@ -14,10 +14,5 @@ public class PatentDTO {
 
     private Long pageSize;
 
-    //商品化专利数量
-    private Long productNum;
-    //商品化专利相关数量
-    private Long relevantProductNum;
-
     private List<PatentColumnDTO> patents;
 }

+ 2 - 0
src/main/java/cn/cslg/pas/common/vo/ReTreeNodeVO.java

@@ -46,4 +46,6 @@ public class ReTreeNodeVO {
     private String description;
     @Schema(description = "文件信息")
     private List<SystemFile> systemFileList;
+    @Schema(description = "专利相关数量")
+    private Long relevantProductNum;
 }

+ 4 - 0
src/main/java/cn/cslg/pas/common/vo/business/ProductVO.java

@@ -56,4 +56,8 @@ public class ProductVO {
     private String companyName;
     @Schema(description = "文件信息")
     private List<SystemFile> systemFileList;
+    @Schema(description = "商品化专利数量")
+    private Long productNum;
+    @Schema(description = "商品化专利相关数量")
+    private Long relevantProductNum;
 }

+ 3 - 0
src/main/java/cn/cslg/pas/common/vo/business/TreeNodeVO.java

@@ -57,4 +57,7 @@ public class TreeNodeVO {
 
     @Schema(description = "文件信息")
     private List<SystemFile> systemFileList;
+
+    @Schema(description = "商品化专利相关数量")
+    private Long relevantProductNum;
 }

+ 15 - 0
src/main/java/cn/cslg/pas/service/business/ProductService.java

@@ -15,6 +15,7 @@ import cn.cslg.pas.exception.UnLoginException;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.businessFactory.Business;
 import cn.cslg.pas.mapper.ProductMapper;
+import cn.cslg.pas.service.business.es.EsProductPatentService;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.permissions.PermissionService;
 import cn.cslg.pas.service.query.FormatQueryService;
@@ -26,6 +27,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -70,6 +72,10 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
     @Autowired
     private AssoProductPersonService assoProductPersonService;
 
+    @Autowired
+    @Lazy
+    private EsProductPatentService esProductPatentService;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Object queryMessage(QueryRequest queryRequest) throws Exception {
@@ -77,6 +83,15 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
         sqls = this.loadSearchSql(sqls);
         //根据sql查询产品信息
         List<ProductVO> productVOS = productMapper.getProduct(sqls.get(0), sqls.get(1), sqls.get(2));
+        if (!CollectionUtils.isEmpty(productVOS)) {
+            for (ProductVO productVO : productVOS) {
+                Integer productId = productVO.getId();
+                Long productNum = esProductPatentService.selectProductNum(productId);
+                productVO.setProductNum(productNum);
+                Long relevantProductNum = esProductPatentService.selectRelevantProductNum(productId);
+                productVO.setRelevantProductNum(relevantProductNum);
+            }
+        }
         //查询总数
         Long total = productMapper.getProductCount(sqls.get(0));
         //装载产品信息

+ 20 - 2
src/main/java/cn/cslg/pas/service/business/TreeNodeService.java

@@ -21,6 +21,7 @@ import cn.cslg.pas.exception.UnLoginException;
 import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.businessFactory.Business;
 import cn.cslg.pas.mapper.TreeNodeMapper;
+import cn.cslg.pas.service.business.es.EsProductPatentService;
 import cn.cslg.pas.service.common.FileManagerService;
 import cn.cslg.pas.service.permissions.PermissionService;
 import cn.cslg.pas.service.query.FormatQueryService;
@@ -33,6 +34,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
@@ -75,6 +77,9 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
     @Autowired
     private AssoProjectTreeNodeService assoProjectTreeNodeService;
 
+    @Autowired
+    private EsProductPatentService esProductPatentService;
+
     @Override
     public Object queryMessage(QueryRequest queryRequest) throws Exception {
         List<String> sqls = formatQueryService.reSqls(queryRequest, "treeNode");
@@ -157,7 +162,6 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
                 return records;
             }
         }
-
         //返回树
         this.loadTreeNode(treeNodes);
         reTreeNodeVOS = this.reTrees(treeNodes);
@@ -453,7 +457,7 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
     }
 
 
-    private void loadTreeNode(List<TreeNodeVO> treeNodeVOS) throws IOException {
+    private void loadTreeNode(List<TreeNodeVO> treeNodeVOS) throws Exception {
         List<String> createIds = new ArrayList<>();
         List<Integer> ids = new ArrayList<>();
         treeNodeVOS.forEach(
@@ -467,6 +471,20 @@ public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> imple
                 }
         );
 
+        if (!CollectionUtils.isEmpty(treeNodeVOS)) {
+            for (TreeNodeVO nodeVO : treeNodeVOS) {
+                Integer type = nodeVO.getType();
+                if (type != null) {
+                    if (type == 1 || type == 2) {
+                        Long relevantProductNum = esProductPatentService.selectRelevantProductNum(nodeVO.getId());
+                        nodeVO.setRelevantProductNum(relevantProductNum);
+                    }
+                }
+            }
+        }
+
+
+
         List<Personnel> personnels = new ArrayList<>();
         List<String> guids = new ArrayList<>();
         List<SystemFile> systemFiles = new ArrayList<>();

+ 7 - 5
src/main/java/cn/cslg/pas/service/business/es/EsProductPatentService.java

@@ -129,25 +129,27 @@ public class EsProductPatentService {
         //设置查询索引
         builder.index("patent");
         Query q1 = QueryBuilders.term(t -> t.field("product_id").value(productId));
-        builder.query(q1);
+        Query query = QueryBuilders.hasChild(n -> n.type("product").query(q1));
+        builder.query(query);
         SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
         return response.hits().total().value();
     }
 
     /**
      * 查询商品化专利架构相关数量
-     * @param productId
+     * @param id
      * @return
      * @throws Exception
      */
-    public Long selectRelevantProductNum(Integer productId) throws Exception {
+    public Long selectRelevantProductNum(Integer id) throws Exception {
         SearchRequest.Builder builder = new SearchRequest.Builder();
         //设置查询索引
         builder.index("patent");
-        Query q1 = QueryBuilders.term(t -> t.field("custom_field.field").value(productId));
+        Query q1 = QueryBuilders.term(t -> t.field("custom_field.field").value(id));
         Query q2 = QueryBuilders.term(t -> t.field("custom_field.field_type").value("9"));
         Query bool = QueryBuilders.bool(i -> i.must(q1,q2));
-        builder.query(bool);
+        Query query = QueryBuilders.hasChild(n -> n.type("product").query(bool));
+        builder.query(query);
         SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
         return response.hits().total().value();
     }

+ 0 - 6
src/main/java/cn/cslg/pas/service/business/es/EsService.java

@@ -61,8 +61,6 @@ public class EsService {
     private PatentStarApiService patentStarApiService;
     @Autowired
     private EsPatentService esPatentService;
-    @Autowired
-    private EsProductPatentService esProductPatentService;
 
 
     /**
@@ -180,10 +178,6 @@ public class EsService {
                     } else {
                         searchCondition = "productId = " + productId;
                     }
-                    Long productNum = esProductPatentService.selectProductNum(productId);
-                    dto.setProductNum(productNum);
-                    Long relevantProductNum = esProductPatentService.selectRelevantProductNum(productId);
-                    dto.setRelevantProductNum(relevantProductNum);
                 }
             } else {
                 if (projectId != null) {

+ 17 - 10
src/test/java/cn/cslg/pas/service/EventServiceTests.java

@@ -465,16 +465,23 @@ public class EventServiceTests {
 
     @Test
     public void test101() {
-        Date date = new Date();
-        Calendar calendar = Calendar.getInstance();
-        calendar.setTime(date);
-        calendar.add(Calendar.DAY_OF_MONTH, 1);
-        Date date1 = calendar.getTime();
-        System.out.println(date1);
-
-        List<Integer> list = Arrays.asList(1, 2, 3);
-        String result = String.join(",", String.join(",", list.stream().map(Object::toString).collect(Collectors.toList())));
-        System.out.println(result); // 输出: 1,2,3
+//        Date date = new Date();
+//        Calendar calendar = Calendar.getInstance();
+//        calendar.setTime(date);
+//        calendar.add(Calendar.DAY_OF_MONTH, 1);
+//        Date date1 = calendar.getTime();
+//        System.out.println(date1);
+//
+//        List<Integer> list = Arrays.asList(1, 2, 3);
+//        String result = String.join(",", String.join(",", list.stream().map(Object::toString).collect(Collectors.toList())));
+//        System.out.println(result); // 输出: 1,2,3
+
+        String s = "((type='1') AND  (type_id='7') ) AND  (parent_id='0') ";
+        if (s.contains("type='1") || s.contains("type='2'")) {
+            System.out.println("Sdggdsgred");
+        } else {
+            System.out.println("end");
+        }
     }
 
 }