Bläddra i källkod

Merge remote-tracking branch 'origin/export_project'

lwhhszx 1 år sedan
förälder
incheckning
c714fbb31f

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

@@ -35,6 +35,7 @@ import co.elastic.clients.elasticsearch.core.*;
 import co.elastic.clients.elasticsearch.core.search.Hit;
 import co.elastic.clients.json.JsonData;
 import com.alibaba.fastjson.JSON;
+import com.rabbitmq.client.impl.nio.WriteRequest;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -524,7 +525,6 @@ public class EsService {
                 b -> b.index("patent").id(id)
                         .doc(patent).refresh(Refresh.True)
         );
-
         try {
             client.update(req, Patent.class);
             return 1;

+ 33 - 6
src/main/java/cn/cslg/pas/service/exportProject/ExportProjectService.java

@@ -3,6 +3,7 @@ package cn.cslg.pas.service.exportProject;
 
 import cn.cslg.pas.common.dto.PatentColumnDTO;
 import cn.cslg.pas.common.dto.PatentDTO;
+import cn.cslg.pas.common.dto.business.PatentProjectDTO;
 import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.common.utils.FileUtils;
 import cn.cslg.pas.common.utils.JsonUtils;
@@ -60,14 +61,15 @@ public class ExportProjectService {
     private TreeNodeService treeNodeService;
     @Autowired
     private EsCustomFieldService esCustomFieldService;
-     @Autowired
-     private PatentProjectService patentProjectService;
+    @Autowired
+    private PatentProjectService patentProjectService;
+
     public void exportProject(Integer projectId) {
         String directoryName = IdUtil.simpleUUID();
         String url = FileUtils.getStaticPath(directoryName);
 
         this.writeProjectToFile(projectId, url);
-        this.getPatentsFromEs(projectId,url);
+        this.getPatentsFromEs(projectId, url);
         List<CustomField> customFields = this.getCustomFiled(projectId, url);
         this.getCustomFiledLabel(customFields, url);
         String outUrl = FileUtils.getStaticPath("");
@@ -80,7 +82,7 @@ public class ExportProjectService {
     public void writeProjectToFile(Integer projectId, String url) {
         //根据projectId查询对象
         try {
-            PatentProjectVO patentProjectVO=patentProjectService.getPatentProjectVOById(projectId);
+            PatentProjectVO patentProjectVO = patentProjectService.getPatentProjectVOById(projectId);
             String projectUrl = url + "\\project.json";
             ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(projectUrl));
             oos.writeObject(patentProjectVO);
@@ -112,7 +114,7 @@ public class ExportProjectService {
     /**
      * 获取专利对象
      */
-    private void getPatentsFromEs(Integer projectId,String url) {
+    private void getPatentsFromEs(Integer projectId, String url) {
         QueryRequest queryRequest = new QueryRequest();
         queryRequest.setProjectId(projectId);
         queryRequest.setCurrent(1L);
@@ -127,7 +129,7 @@ public class ExportProjectService {
                 Long total = patentDTO.getTotal();
                 Long size = patentDTO.getPageSize();
                 Long current = patentDTO.getPageNum();
-                List<PatentColumnDTO> patents =patentDTO.getPatents();
+                List<PatentColumnDTO> patents = patentDTO.getPatents();
                 if (size * current < total) {
                     QueryRequest queryRequest1 = new QueryRequest();
                     queryRequest1.setCurrent(current + 1);
@@ -266,4 +268,29 @@ public class ExportProjectService {
         }
 
     }
+
+
+    //将项目对象写进文件
+    public void writeObjectToFile(Object object, String url) {
+        //根据projectId查询对象
+        try {
+            String projectUrl = url;
+            ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(projectUrl));
+            oos.writeObject(object);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    //装载专利数据库DTO
+    private PatentProjectDTO getProjectDTO(Integer projectId) {
+        PatentProjectDTO patentProjectDTO =new PatentProjectDTO();
+        PatentProjectVO patentProjectVO=  patentProjectService.getPatentProjectVOById(projectId);
+         BeanUtils.copyProperties(patentProjectVO,patentProjectDTO);
+        return patentProjectDTO;
+    }
+
+
 }