lrj 4 месяцев назад
Родитель
Сommit
f25ae42b00

+ 19 - 7
src/main/java/cn/cslg/pas/common/utils/ReadExcelUtils.java

@@ -238,14 +238,16 @@ public class ReadExcelUtils {
      * @return
      * @throws IOException
      */
-    public static Map<String,List<String>>  getPatentNoFromExcel(Sheet sheet) throws IOException {
-        Map<String,List<String>> map =new HashMap<>();
+    public static Map<String, List<String>> getPatentNoFromExcel(Sheet sheet) throws IOException {
+        Map<String, List<String>> map = new HashMap<>();
 
         int rows = sheet.getPhysicalNumberOfRows();
         Integer PNOCellId = null;
         Integer ANOCellId = null;
+        Integer PANOCellId = null;
         List<String> publicNos = new ArrayList<>();
         List<String> appNos = new ArrayList<>();
+        List<String> patentNos = new ArrayList<>();
         //开始装载专利数据
         Row firstRow = sheet.getRow(0);
 
@@ -259,25 +261,35 @@ public class ReadExcelUtils {
             if (firstRow.getCell(t).toString().trim().equals("公开(公告)号")) {
                 PNOCellId = t;
             }
+            if (firstRow.getCell(t).toString().trim().equals("专利号")) {
+                PANOCellId = t;
+            }
         }
         for (int i = 1; i < rows; i++) {
             Row row = sheet.getRow(i);
             if (ANOCellId != null) {
-                if(row.getCell(ANOCellId)!=null) {
+                if (row.getCell(ANOCellId) != null) {
                     String appNo = row.getCell(ANOCellId).toString();
                     appNos.add(appNo);
                 }
             }
-            if(PNOCellId!=null){
-                if(row.getCell(PNOCellId)!=null) {
+            if (PNOCellId != null) {
+                if (row.getCell(PNOCellId) != null) {
                     String publicNo = row.getCell(PNOCellId).toString();
                     publicNos.add(publicNo);
                 }
             }
+            if (PANOCellId != null) {
+                if (row.getCell(PANOCellId) != null) {
+                    String patentNo = row.getCell(PANOCellId).toString();
+                    patentNos.add(patentNo);
+                }
+            }
 
         }
-        map.put(BusinessUtil.APP_NO,appNos);
-        map.put(BusinessUtil.PUBLIC_NO,publicNos);
+        map.put(BusinessUtil.APP_NO, appNos);
+        map.put(BusinessUtil.PUBLIC_NO, publicNos);
+        map.put(BusinessUtil.PATENT_NO, patentNos);
         return map;
     }
 

+ 17 - 2
src/main/java/cn/cslg/pas/common/utils/commonUtils/BusinessUtil.java

@@ -7,27 +7,42 @@ import java.util.*;
 public class BusinessUtil {
     public static String PUBLIC_NO="publicNo";
     public static String APP_NO="appNo";
+    public static String PATENT_NO="patentNo";
+    public static String SPLIT_REFIX="[,|,|;|;|\\n|\\s+]";
     public static Map<String, List<String>> getPatentNosMap(String conditions) {
         Map<String, List<String>> map = new HashMap<>();
         JSONObject jsonObject = JSONObject.parseObject(conditions);
         String publicNoStr = null;
         String appNoStr =null;
+        String patentNoStr=null;
         if(jsonObject.get(PUBLIC_NO)!=null) {
             publicNoStr= jsonObject.get(PUBLIC_NO).toString();
         }
         if(jsonObject.get(APP_NO)!=null) {
             appNoStr=jsonObject.get(APP_NO).toString();
         }
+        if(jsonObject.get(PATENT_NO)!=null){
+            patentNoStr=jsonObject.get(PATENT_NO).toString();
+        }
+
         List<String> publicNos = new ArrayList<>();
         List<String> appNos = new ArrayList<>();
+        List<String> patentNos =new ArrayList<>();
         if (publicNoStr != null&&!publicNoStr.trim().equals("")) {
-            publicNos = Arrays.asList(publicNoStr.split("[,|,]"));  //生成专利号集合
+            publicNos =new ArrayList<>(Arrays.asList(publicNoStr.split(SPLIT_REFIX)));
+            publicNos.removeIf(i->i.trim().equals(""));//生成专利号集合
         }
         if (appNoStr != null&&!appNoStr.trim().equals("")) {
-            appNos = Arrays.asList(appNoStr.split("[,|,]"));
+            appNos =new ArrayList<>(Arrays.asList(appNoStr.split(SPLIT_REFIX)));
+            appNos.removeIf(i->i.trim().equals(""));
+        }
+        if(patentNoStr!=null&&!patentNoStr.trim().equals("")){
+            patentNos=new ArrayList<>(Arrays.asList(patentNoStr.split(SPLIT_REFIX)));
+            patentNos.removeIf(i->i.trim().equals(""));
         }
         map.put(PUBLIC_NO, publicNos);
         map.put(APP_NO, appNos);
+        map.put(PATENT_NO, patentNos);
         return map;
     }
 }

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

@@ -227,7 +227,7 @@ public class ImportTaskService extends ServiceImpl<ImportTaskMapper, ImportTask>
                 Map<String, List<String>> map = BusinessUtil.getPatentNosMap(importTaskCondition.getSearchCondition());
                 totalNum += map.get(BusinessUtil.PUBLIC_NO).size();
                 totalNum += map.get(BusinessUtil.APP_NO).size();
-
+                totalNum += map.get(BusinessUtil.PATENT_NO).size();
             } else if (importTaskCondition.getType().equals(3)) {
                 try {
                     String res = fileManagerService.getSystemFileFromFMS(Arrays.asList(importTaskCondition.getFileGuid()));

+ 8 - 0
src/main/java/cn/cslg/pas/service/dify/DifyTempleExportService.java

@@ -0,0 +1,8 @@
+package cn.cslg.pas.service.dify;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class DifyTempleExportService {
+
+}

+ 44 - 0
src/main/java/cn/cslg/pas/service/dify/GenerateInstructionService.java

@@ -0,0 +1,44 @@
+package cn.cslg.pas.service.dify;
+
+import cn.cslg.pas.common.utils.ClaimUtils.ClaimSplitUtils;
+import cn.cslg.pas.common.vo.PatentRightParams;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+@Service
+public class GenerateInstructionService {
+    public void generateContent(String claim){
+        PatentRightParams params =new PatentRightParams();
+        params.setCountry("CN");
+        params.setContent(claim);
+        params.setPatentNo("CN");
+      ClaimSplitUtils.formatPatentRight(params);
+
+    }
+
+    public String getClaimContent(String claim){
+        // 正则表达式模式(注意 Java 中需要双反斜杠转义)
+        String regex = "其特征在于[,。;!?、]+(.+)";
+        Pattern pattern = Pattern.compile(regex);
+        Matcher matcher = pattern.matcher(claim);
+        if (matcher.find()) {
+            // 提取第一个捕获组的内容(即括号内的部分)
+            return matcher.group(1).trim();
+        }
+        return "其中,"+claim; // 未找到匹配时返回空字符串
+
+    }
+    public String getMainClaimContent(String claim){
+        // 正则表达式模式(注意 Java 中需要双反斜杠转义)
+        String regex1 = "^[0-9]+\\.[^0-9]+?";
+        String regex2="^\\[[0-9]+]";
+        String outPut1=claim.replaceAll(regex1,"");
+        String outPut2=outPut1.replaceAll(regex2,"");
+        return "为解决上述问题,本申请提出"+outPut2; // 未找到匹配时返回空字符串
+
+    }
+
+}

+ 43 - 39
src/main/java/cn/cslg/pas/service/importPatent/ImportFromWebToEsService.java

@@ -31,10 +31,7 @@ import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 
@@ -149,50 +146,57 @@ public class ImportFromWebToEsService implements PatentImportImp {
             }
 
             //当专利为专利号导入时
-            else if (importTaskAMVO.getType().equals(2)) {
+            if (importTaskAMVO.getType().equals(2) || importTaskAMVO.getType().equals(3)) {
+
+                Map<String, List<String>> map=new HashMap<>();
                 PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
                 patentStarListDTO.setCurrentQuery(conditions)
                         .setOrderBy(orderBy)
                         .setOrderByType(orderByType)
                         .setDBType(dbType);
-                Map<String, List<String>> map = BusinessUtil.getPatentNosMap(conditions);
-                List<PatentStarListDTO> patentStarListDtos1 = patentStarApiService.splitPatentNoByType(map.get(BusinessUtil.PUBLIC_NO), patentStarListDTO, 1);
-                List<PatentStarListDTO> patentStarListDtos2 = patentStarApiService.splitPatentNoByType(map.get(BusinessUtil.APP_NO), patentStarListDTO, 0);
-                patentStarListDtos.addAll(patentStarListDtos1);
-                patentStarListDtos.addAll(patentStarListDtos2);
-            }
+                if (importTaskAMVO.getType().equals(2)) {
+                    map = BusinessUtil.getPatentNosMap(conditions);
+
+                }
+
+                //当专利为专利号文件导入时
+                else if (importTaskAMVO.getType().equals(3)) {
+                    FileManagerService fileManagerService = applicationContext.getBean(FileManagerService.class);
+
+                    String res = fileManagerService.getSystemFileFromFMS(Arrays.asList(importTaskAMVO.getFileGuid()));
+                    List<SystemFile> systemFiles = JSONArray.parseArray(res, SystemFile.class);
+                    SystemFile systemFile = systemFiles.get(0);
+                    String suffix = systemFile.getFileName().substring(systemFile.getFileName().lastIndexOf("."));
+                    //调用文件系统取出文件接口,获得文件流
+                    byte[] bytes = fileManagerService.downloadSystemFileFromFMS(importTaskAMVO.getFileGuid());
+                    //创建临时文件tempFile,并将文件读取到tempFile
+                    File tempFile = File.createTempFile(systemFile.getFileName() + "temp", suffix);
+                    try (
+                            InputStream inputStream = new ByteArrayInputStream(bytes);
+                            FileOutputStream outputStream = new FileOutputStream(tempFile)
+                    ) {
+                        IOUtils.copy(inputStream, outputStream); // 将输入流复制到临时文件
+                    }
+                    Sheet sheet = ReadExcelUtils.readExcel(tempFile);
+                    map = ReadExcelUtils.getPatentNoFromExcel(sheet);
 
-            //当专利为专利号文件导入时
-            else if (importTaskAMVO.getType().equals(3)) {
-                FileManagerService fileManagerService = applicationContext.getBean(FileManagerService.class);
-
-                String res = fileManagerService.getSystemFileFromFMS(Arrays.asList(importTaskAMVO.getFileGuid()));
-                List<SystemFile> systemFiles = JSONArray.parseArray(res, SystemFile.class);
-                SystemFile systemFile = systemFiles.get(0);
-                String suffix = systemFile.getFileName().substring(systemFile.getFileName().lastIndexOf("."));
-                //调用文件系统取出文件接口,获得文件流
-                byte[] bytes = fileManagerService.downloadSystemFileFromFMS(importTaskAMVO.getFileGuid());
-                //创建临时文件tempFile,并将文件读取到tempFile
-                File tempFile = File.createTempFile(systemFile.getFileName() + "temp", suffix);
-                try (
-                        InputStream inputStream = new ByteArrayInputStream(bytes);
-                        FileOutputStream outputStream = new FileOutputStream(tempFile)
-                ) {
-                    IOUtils.copy(inputStream, outputStream); // 将输入流复制到临时文件
                 }
-                Sheet sheet = ReadExcelUtils.readExcel(tempFile);
-                Map<String, List<String>> map = ReadExcelUtils.getPatentNoFromExcel(sheet);
                 List<String> appNos = map.get(BusinessUtil.APP_NO);
                 List<String> publicNos = map.get(BusinessUtil.PUBLIC_NO);
-                PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
-                patentStarListDTO.setCurrentQuery(conditions)
-                        .setOrderBy(orderBy)
-                        .setOrderByType(orderByType)
-                        .setDBType(dbType);
-                List<PatentStarListDTO> patentStarListDtos1 = patentStarApiService.splitPatentNoByType(appNos, patentStarListDTO, 0);
-                List<PatentStarListDTO> patentStarListDtos2 = patentStarApiService.splitPatentNoByType(publicNos, patentStarListDTO, 1);
-                patentStarListDtos.addAll(patentStarListDtos1);
-                patentStarListDtos.addAll(patentStarListDtos2);
+                List<String> patentNos =map.get(BusinessUtil.PATENT_NO);
+                if(appNos!=null&&appNos.size()>0){
+                    List<PatentStarListDTO> patentStarListDtos1 = patentStarApiService.splitPatentNoByType(appNos, patentStarListDTO, 0);
+                    patentStarListDtos.addAll(patentStarListDtos1);
+                }
+                if(publicNos!=null&&publicNos.size()>0){
+                    List<PatentStarListDTO> patentStarListDtos2 = patentStarApiService.splitPatentNoByType(publicNos, patentStarListDTO, 1);
+                    patentStarListDtos.addAll(patentStarListDtos2);
+                }
+                if(patentNos!=null&&patentNos.size()>0){
+                    List<PatentStarListDTO> patentStarListDtos3 = patentStarApiService.splitPatentNoByType(map.get(BusinessUtil.PATENT_NO), patentStarListDTO, 3);
+                    patentStarListDtos.addAll(patentStarListDtos3);
+                }
+
             }
 
             char ifCataloguing = importTaskAMVO.getIfAddCatalogue();

+ 1 - 0
src/main/resources/application-dev.yml

@@ -89,4 +89,5 @@ DIFY:
   apiKey: app-DDGJt4QUmzlc2aFQ5voOAXIj
   cliamKey: app-fxpiWOYqtJM1BOaJnG54NlCZ
   OAApiKey: app-mmfvVywt7wdS8HofrYpFy4RL
+  checkApiKey: aa
   url: http://192.168.2.24/v1/

+ 10 - 0
src/test/java/cn/cslg/pas/DifyTest.java

@@ -1,6 +1,7 @@
 package cn.cslg.pas;
 
 import cn.cslg.pas.common.utils.FileUtils;
+import cn.cslg.pas.common.utils.commonUtils.BusinessUtil;
 import cn.cslg.pas.service.common.POIService;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
 import org.junit.jupiter.api.Test;
@@ -9,6 +10,9 @@ import org.springframework.boot.test.context.SpringBootTest;
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.util.List;
+import java.util.Map;
+
 @SpringBootTest
 public class DifyTest {
 @Autowired
@@ -25,4 +29,10 @@ private POIService poiService;
 //        out.close();
 //        doc.close();
     }
+
+    @Test
+    public void checkFile1() throws Exception {
+        Map<String, List<String>> map=   BusinessUtil.getPatentNosMap("{\"publicNo\":\"CN202021689802.5;  , CN202021689802.5;CN202021689802.5\"}");
+           System.out.println(map);
+    }
 }

+ 37 - 0
src/test/java/cn/cslg/pas/service/dify/GenerateInstructionServiceTests.java

@@ -0,0 +1,37 @@
+package cn.cslg.pas.service.dify;
+
+import cn.cslg.pas.common.dto.DomainFieldDTO;
+import cn.cslg.pas.common.utils.GenerateObjectUtil;
+import cn.cslg.pas.domain.business.FollowUp;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Author xiexiang
+ * @Date 2023/12/5
+ */
+@SpringBootTest
+public class GenerateInstructionServiceTests {
+@Autowired
+private GenerateInstructionService generateInstructionService;
+
+
+    @Test
+    public void getClaimContent() throws Exception {
+       String re= generateInstructionService.getClaimContent("2. 根据权利要求1所述的电磁弹簧,其特征在于,所述弹簧丝在所述电磁件所在区域开设有若干安装槽,所述电磁件嵌设于对应的所述安装槽内。");
+    System.out.println(re);
+    }
+    @Test
+    public void getMainClaimContent() throws Exception {
+        String re= generateInstructionService.getMainClaimContent("1. 一种电磁弹簧,其特征在于,包括:\n" +
+                "螺旋弹性体,由弹簧丝绕一轴线螺旋环绕形成,所述螺旋弹性体至少包括两匝;\n" +
+                "所述螺旋弹性体的至少一组相邻设置的两个匝圈上均设有一电磁件,且所述两个匝圈上的所述电磁件沿所述轴线的正投影至少部分重叠;\n" +
+                "若干线束,沿所述轴线延伸设置于所述螺旋弹性体,所述电磁件连接于至少一所述线束,所述线束用于调节所述电磁件的磁力。");
+        System.out.println(re);
+    }
+
+}