Browse Source

7/8 韶音修改

lwhhszx 1 year ago
parent
commit
650e33dc3b

+ 1 - 1
src/main/java/cn/cslg/pas/common/config/ElasticSearchClientConfig.java

@@ -56,7 +56,7 @@ public class  ElasticSearchClientConfig {
         public ElasticsearchClient elasticsearchClient() throws Exception {
             RestClientBuilder builder = RestClient.builder(new HttpHost(config, 9200, "http"));
             CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
-            credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "xiaoshi221101"));
+            credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "Xiaoshi221101"));
             SSLContext sslContext = SSLContextBuilder.create()
                     .loadTrustMaterial(new TrustSelfSignedStrategy())
                     .build();

+ 2 - 1
src/main/java/cn/cslg/pas/common/utils/DateUtils.java

@@ -173,8 +173,9 @@ public class DateUtils {
 
             return sf1.parse(dateString);
         } catch (Exception e) {
+            System.out.println ("时间转化格式错误" + "[dateString=" + dateString + "]" + "[FORMAT_STRING=" + FORMAT_STRING + "]");
 
-            throw new RuntimeException("时间转化格式错误" + "[dateString=" + dateString + "]" + "[FORMAT_STRING=" + FORMAT_STRING + "]");
+            return null;
         }
     }
 

+ 4 - 3
src/main/java/cn/cslg/pas/controller/ExportProjectController.java

@@ -7,6 +7,7 @@ import cn.cslg.pas.service.exportProject.ImportProjectService;
 import io.swagger.v3.oas.annotations.Operation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -32,9 +33,9 @@ public class ExportProjectController {
     }
 
     @Operation(summary = "查询无效理由")
-    @PostMapping("/readProjectFromFile")
-    public Response readProjectFromFile() {
-        importProjectService.getFileFromZip();
+    @GetMapping("/export")
+    public Response readProjectFromFile(String path) {
+        importProjectService.getFileFromZip (path);
         return Response.success("");
     }
 }

+ 1 - 1
src/main/java/cn/cslg/pas/service/common/FileManagerService.java

@@ -166,7 +166,7 @@ public class FileManagerService {
         Response response = null;
         response = okHttpClient.newCall(request).execute();
         // 最后记得删除临时文件
-        FileUtils.deleteQuietly(file);
+//        FileUtils.deleteQuietly(file);
 
         return Objects.requireNonNull(response.body()).string();
     }

+ 1 - 0
src/main/java/cn/cslg/pas/service/exportProject/Constants.java

@@ -14,4 +14,5 @@ public class Constants {
     public static final String PATENT_JSON ="patent.json";
     public static final String LABELS_JSON="labels.json";
     public static final String PATENT_IMAGE="image";
+    public static final String PATENT_PDF="pdf";
 }

+ 90 - 27
src/main/java/cn/cslg/pas/service/exportProject/ImportFromFileToEsService.java

@@ -6,6 +6,7 @@ import cn.cslg.pas.common.dto.business.CustomOptionDTO;
 import cn.cslg.pas.common.dto.business.EsPatentFamilyDTO;
 import cn.cslg.pas.common.dto.business.TreeNodeDTO;
 import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
+import cn.cslg.pas.common.model.importTaskModel.PatentInventor;
 import cn.cslg.pas.common.utils.DateUtils;
 import cn.cslg.pas.common.utils.FileUtils;
 import cn.cslg.pas.common.utils.FormatUtil;
@@ -187,6 +188,7 @@ public class ImportFromFileToEsService {
         } else if (grantNo != null) {
             usedNo = grantNo;
         }
+
         String contry = usedNo.substring(0, 2);
         if (contry.equals("CN")) {
             patent.setPatentNo(appNo);
@@ -222,22 +224,24 @@ public class ImportFromFileToEsService {
 
         //装载说明书
         List<Text> textInstructions = new ArrayList<>();
-        if (oldPatentDTO.getManual() != null) {
-            Text text = new Text();
-            text.setTextContent(oldPatentDTO.getManual());
-            text.setIfOrigin(true);
-            text.setLanguage(contry);
-            texts.add(text);
-        }
-        if (oldPatentDTO.getManualOut() != null) {
-            Text text = new Text();
-            text.setTextContent(oldPatentDTO.getManualOut());
-            text.setIfOrigin(false);
-            text.setLanguage("CN");
-            texts.add(text);
-        }
-        if (textInstructions.size() != 0) {
-            patent.setPublicFullText(textInstructions);
+        if(oldPatentDTO.getInstruction()!=null) {
+            if (oldPatentDTO.getInstruction().getManual() != null) {
+                Text text = new Text();
+                text.setTextContent(oldPatentDTO.getInstruction().getManual());
+                text.setIfOrigin(true);
+                text.setLanguage(contry);
+                textInstructions.add(text);
+            }
+            if (oldPatentDTO.getInstruction().getManualOut() != null) {
+                Text text = new Text();
+                text.setTextContent(oldPatentDTO.getInstruction().getManualOut());
+                text.setIfOrigin(false);
+                text.setLanguage("CN");
+                textInstructions.add(text);
+            }
+            if (textInstructions.size() != 0) {
+                patent.setPublicFullText(textInstructions);
+            }
         }
 
 
@@ -248,7 +252,8 @@ public class ImportFromFileToEsService {
             text.setTextContent(oldPatentDTO.getAbstractStr());
             text.setIfOrigin(true);
             text.setLanguage(contry);
-            texts.add(text);
+
+            textsAbstractStr.add(text);
         }
         if (oldPatentDTO.getAbstractOut() != null) {
             Text text = new Text();
@@ -256,6 +261,7 @@ public class ImportFromFileToEsService {
             text.setIfOrigin(false);
             text.setLanguage("CN");
             texts.add(text);
+            textsAbstractStr.add(text);
         }
         if (textsAbstractStr.size() != 0) {
             patent.setAbstractStr(textsAbstractStr);
@@ -310,6 +316,19 @@ public class ImportFromFileToEsService {
             }
         }
 
+        //发明人
+        List<OldPatentInventor> patentInventorList = oldPatentDTO.getInventor();
+        if (patentInventorList != null && patentInventorList.size() > 0) {
+            List<PatentPerson> patentPeople = new ArrayList<>();
+            for (int i = 0; i < patentInventorList.size(); i++) {
+                PatentPerson patentPerson = new PatentPerson();
+                patentPerson.setOrder(i + 1);
+                patentPerson.setType("1");
+                patentPerson.setName(patentInventorList.get(i).getName());
+                patentPeople.add(patentPerson);
+            }
+            patent.setInventor(patentPeople);
+        }
         //装载审查员
         patent.setExaminer(oldPatentDTO.getExaminer());
 
@@ -425,10 +444,47 @@ public class ImportFromFileToEsService {
         }
 
         //简单法律状态
-        patent.setSimpleStatus(oldPatentDTO.getSimpleStatus());
-        //专利类型
-        patent.setPatentType(oldPatentDTO.getType());
+        if(oldPatentDTO.getSimpleStatus()!=null) {
+            switch (oldPatentDTO.getSimpleStatus()) {
+                case "有效":
+                    patent.setSimpleStatus("1");
+                    break;
+                case "审中":
+                    patent.setSimpleStatus("3");
+                    break;
+                case "失效":
+                    patent.setSimpleStatus("2");
+                    break;
+                default:
+                    patent.setSimpleStatus("1");
+                    break;
+            }
+        }
+        if(oldPatentDTO.getType()!=null){
+
 
+        }
+        //专利类型
+        String type = oldPatentDTO.getType();
+        if (type != null) {
+            type = type.trim();
+            switch (type) {
+                case "授权发明":
+                case "发明申请":
+                    type = "1";
+                    break;
+                case "实用新型":
+                    type = "2";
+                    break;
+                case "外观设计":
+                    type = "3";
+                    break;
+                default:
+                    type = null;
+                    break;
+            }
+            patent.setPatentType(type);
+        }
         //装载权利要求
         if (oldPatentDTO.getRights() != null && oldPatentDTO.getRights().size() > 0) {
             List<Text> rightTexts = new ArrayList<>();
@@ -575,19 +631,26 @@ public class ImportFromFileToEsService {
 
     public void savePatentPicture(File file, Patent patent) throws Exception {
         File imageDiretory = FileUtils.getFileByName(file, Constants.PATENT_IMAGE);
+       if(imageDiretory==null){
+           return;
+       }
         File[] imageFiles = imageDiretory.listFiles();
-        for (int i = 0; i < imageFiles.length; i++) {
-            File ImageFile =imageFiles[i];
+        if(imageFiles.length>0){
+            File ImageFile =imageFiles[0];
             String guid = FormatUtil.getPictureFormat(patent.getAppNo());
-            String guid1 = guid+i;
-            fileManagerService.uploadFileWithGuid(ImageFile, guid1);
+            fileManagerService.uploadFileWithGuid(ImageFile, guid);
         }
 
 
 }
 
     public void savePatentPDF(File file, Patent patent) throws Exception {
-        File pdfDiretory = FileUtils.getFileByName(file, Constants.PATENT_IMAGE);
+        File pdfDiretory = FileUtils.getFileByName(file, Constants.PATENT_PDF);
+        if(pdfDiretory==null||!pdfDiretory.exists()){
+
+            System.out.println(patent.getPatentNo());
+            return;
+        }
         File[] pdfFiles = pdfDiretory.listFiles();
         for (int i = 0; i < pdfFiles.length; i++) {
             File pdfFile = pdfFiles[i];
@@ -597,8 +660,8 @@ public class ImportFromFileToEsService {
             if (names[1].contains("2")) {
                 type = 1;
             }
-            String guid1 = FormatUtil.getPDFFormat(patent.getAppNo(), type);
-            fileManagerService.uploadFileWithGuid(pdfFile, guid1);
+            String guid1 = FormatUtil.getPDFFormat(patent.getPatentNo(), type);
+            fileManagerService.uploadFileWithGuid(pdfFile,guid1);
         }
     }
 

+ 12 - 4
src/main/java/cn/cslg/pas/service/exportProject/ImportProjectService.java

@@ -51,9 +51,9 @@ public class ImportProjectService {
 
     @Autowired
     private SavePatentToEsService savePatentToEsService;
-    public void getFileFromZip() {
+    public void getFileFromZip(String path) {
         try {
-            File file = new File("D:\\LastPAS\\PAS\\target\\file\\temp\\4d99e86aee2948178b664a97b82ff8d1");
+            File file = new File(path);
            //导入专题库
             Integer projectId = this.ImportProject(file);
             //导入分享信息
@@ -91,9 +91,13 @@ public class ImportProjectService {
             File[] patentFileList = patentFiles.listFiles();
             for (int i = 0; i < patentFileList.length; i++) {
                 File patentFile = patentFileList[i];
+                System.out.println("文件名称"+patentFile.getName());
+                if (patentFile.getName().equals("null")) {
+                    continue;
+                }
                 File patentJsonFile = this.getFileByName(patentFile, Constants.PATENT_JSON);
                 String patentJsons = CommonService.readJsonFile(patentJsonFile);
-                OldPatentDTO oldPatentDTO = JSON.parseObject(patentJsons, OldPatentDTO.class);
+                OldPatentDTO oldPatentDTO = JSON.parseObject(patentJsons,OldPatentDTO.class);
                 Patent patent = importFromFileToEsService.loadPatent(oldPatentDTO);
 
                 File patentFolderLinkFile = this.getFileByName(patentFile, Constants.PATENT_FOLDER_LINK);
@@ -150,7 +154,11 @@ public class ImportProjectService {
         if (file1 != null) {
             File[] files = file1.listFiles();
             if (files != null && files.length > 0) {
-                fileGuids = fileManagerService.uploadFileGetGuid2(Arrays.asList(files));
+                for(int i=0;i<files.length;i++) {
+                    File file2 =files[i];
+                  List<String>  fileGuids2 = fileManagerService.uploadFileGetGuid2(Arrays.asList(file2));
+                  fileGuids.addAll(fileGuids2);
+                }
             }
         }
 

+ 1 - 0
src/main/java/cn/cslg/pas/service/exportProject/oldPasEntity/OldCustomAnalysisItemSchema.java

@@ -1,5 +1,6 @@
 package cn.cslg.pas.service.exportProject.oldPasEntity;
 
+
 import lombok.Data;
 
 @Data

+ 2 - 2
src/main/resources/application-testNetIn.yml

@@ -66,8 +66,8 @@ PCSUrl: http://localhost:8880
 #OPSUrl: http://192.168.1.24:5001
 OPSUrl: http://139.224.24.90:5001
 PASUrl: http://localhost:8880
-FMSUrl: http://localhost:8885
-FileSource: 3
+FMSUrl: http://localhost:8803
+FileSource: 6
 ES:
   patentVector: patent_vector
   patent: wxpatent

+ 2 - 2
src/main/resources/application.yml

@@ -1,7 +1,7 @@
 server:
   servlet:
     context-path: /
-  port: 8879
+  port: 8123
 #  sa-token:
 #  activity-timeout: 18000
 #  token-name: token
@@ -20,7 +20,7 @@ spring:
       max-file-size: 1000MB
       max-request-size: 1000MB
   profiles:
-    active: dev
+    active: testNetIn
   jackson:
     default-property-inclusion: non_null
     serialization:

+ 1 - 1
src/test/java/cn/cslg/pas/service/ExportProjectServiceTests.java

@@ -33,7 +33,7 @@ public class ExportProjectServiceTests {
 
     @Test
     public void testUpdate() {
-        importProjectService.getFileFromZip();
+        importProjectService.getFileFromZip("");
 
     }