zero 9 місяців тому
батько
коміт
83638b210a

+ 50 - 18
src/main/java/cn/cslg/pas/service/business/es/EsExportService.java

@@ -584,7 +584,7 @@ public class EsExportService {
 
     public void loadExport(List<String> list) throws Exception {
         try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
-            List<String> headers = Arrays.asList("专利号");
+            List<String> headers = Arrays.asList("专利号","位数");
             HSSFWorkbook hssfWorkbook = new HSSFWorkbook();//新建工作簿
             HSSFSheet sheet = hssfWorkbook.createSheet();//新建sheet页
             sheet.setDefaultColumnWidth(30);
@@ -613,6 +613,12 @@ public class EsExportService {
                 commonCellStyle.setWrapText(true);
                 cell.setCellStyle(commonCellStyle);
                 cell.setCellValue(no);
+                HSSFCell cell1 = row.createCell(1);
+                ExcelUtils.setExcelCellStyle(commonCellStyle);
+                commonCellStyle.setVerticalAlignment(VerticalAlignment.TOP);
+                commonCellStyle.setWrapText(true);
+                cell1.setCellStyle(commonCellStyle);
+                cell1.setCellValue(no.length());
             }
             hssfWorkbook.write(out);
             byte[] bytes = out.toByteArray();
@@ -900,8 +906,10 @@ public class EsExportService {
                 .readTimeout(60, TimeUnit.SECONDS)
                 .build();
         Request request = new Request.Builder()
-                .url("http://192.168.2.107:8087/api/xiaoshi/importTask/addImportTask")
-                .addHeader("Cookie", "token=5T_nvys1wCh4QKm4t_XYSxxNz0Me6O4PrV__")
+                .url("https://xsip.cn/api/xiaoshi/importTask/addImportTask")
+//                .url("http://192.168.2.107:8087/api/xiaoshi/importTask/addImportTask")
+                .addHeader("Cookie", "_ga=GA1.1.1311128280.1715044933; _ga_73YJPXJTLX=GS1.1.1732081012.6.0.1732081012.0.0.0; token=DS_hs9LNS6qwwZsd8_wnRUpFiOw3oZjMwN__")
+//                .addHeader("Cookie", "token=5T_nvys1wCh4QKm4t_XYSxxNz0Me6O4PrV__")
                 .post(requestBody)
                 .build();
         return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
@@ -1096,13 +1104,22 @@ public class EsExportService {
                 }
                 String newPatentId = "";
                 if (patentNo.startsWith("CN")) {
+                    if (patentNo.length() == 13 && patentNo.contains("W")) {
+                        continue;
+                    }
                     //中国专利
                     if (patentNo.length() == 12 && patentNo.contains(".")) {
                         String newPatentNo = this.formatCnNumber(patentNo);
                         newPatentId = this.queryNewByPatentNo(newPatentNo, oldPatentId);
-                    } else if (patentNo.length() == 15){
+                    } else if (patentNo.length() == 15 && !patentNo.contains(".")){
                         String newPatentNo = this.formatNumber(patentNo);
                         newPatentId = this.queryNewByPatentNo(newPatentNo, oldPatentId);
+                    } else if (patentNo.length() == 15 && patentNo.contains(".")) {
+                        String newPatentNo = this.formatNumber1(patentNo);
+                        newPatentId = this.queryNewByPatentNo(newPatentNo, oldPatentId);
+                    } else if (patentNo.length() == 14) {
+                        String newPatentNo = this.formatNumber2(patentNo);
+                        newPatentId = this.queryNewByPatentNo(newPatentNo, oldPatentId);
                     } else {
                         newPatentId = this.queryNewByPatentNo(patentNo, oldPatentId);
                     }
@@ -1129,6 +1146,19 @@ public class EsExportService {
                 str.substring(14, 15);
     }
 
+    public String formatNumber1(String str) {
+        String s1 = str.substring(0, 7) + "0" + str.substring(7, str.indexOf("."));
+        String s2 = s1.substring(2);
+        char c = calculateChecksum(s2);
+        return s1 + "." + c;
+//        String s = str.substring(str.indexOf(".") + 1);
+//        return str.substring(0, 13) + s + ".0";
+    }
+
+    public String formatNumber2(String str) {
+        return str + ".0";
+    }
+
     public String formatCnNumber(String str) {
         StringBuilder builder = new StringBuilder();
         builder.append(str, 0, 2);
@@ -1203,18 +1233,18 @@ public class EsExportService {
         List<String> list = new ArrayList<>();
         String newPatentId = "";
         if (!CollectionUtils.isEmpty(hits)) {
-            for (Hit<Patent> hit : hits) {
-                String patentId = hit.id();
-                if (!patentId.equals(oldPatentId)) {
-                    Patent patent = hit.source();
-                    if (!CollectionUtils.isEmpty(patent.getApplicant()) &&
-                            !CollectionUtils.isEmpty(patent.getRightHolder()) &&
-                            !CollectionUtils.isEmpty(patent.getInventor())) {
-                        newPatentId = patentId;
-                        break;
-                    }
-                }
-            }
+//            for (Hit<Patent> hit : hits) {
+//                String patentId = hit.id();
+//                if (!patentId.equals(oldPatentId)) {
+//                    Patent patent = hit.source();
+//                    if (!CollectionUtils.isEmpty(patent.getApplicant()) &&
+//                            !CollectionUtils.isEmpty(patent.getRightHolder()) &&
+//                            !CollectionUtils.isEmpty(patent.getInventor())) {
+//                        newPatentId = patentId;
+//                        break;
+//                    }
+//                }
+//            }
             if (StringUtils.isEmpty(newPatentId)) {
                 Hit<Patent> hit = hits.stream().filter(i -> !i.id().equals(oldPatentId)).findFirst().orElse(null);
                 if (ObjectUtils.isNotEmpty(hit) && hit != null) {
@@ -1223,7 +1253,7 @@ public class EsExportService {
                     newPatentId = this.queryWDExtra(newPatentNo);
 //                    Boolean flag = this.queryExtra(newPatentNo);
 //                    if (Boolean.TRUE.equals(flag)) {
-//                        this.importPatent(Collections.singletonList(newPatentNo), 614);
+//                        this.importPatent(Collections.singletonList(newPatentNo), 5473);
 //                        Thread.sleep(3000);
 //                        newPatentId = this.queryOldByPatentNo(newPatentNo);
 //                    }
@@ -1239,7 +1269,7 @@ public class EsExportService {
             newPatentId = this.queryWDExtra(newPatentNo);
 //            Boolean flag = this.queryExtra(newPatentNo);
 //            if (Boolean.TRUE.equals(flag)) {
-//                this.importPatent(Collections.singletonList(newPatentNo), 614);
+//                this.importPatent(Collections.singletonList(newPatentNo), 5473);
 //                Thread.sleep(3000);
 //                newPatentId = this.queryOldByPatentNo(newPatentNo);
 //            }
@@ -1275,6 +1305,8 @@ public class EsExportService {
         String patentId = "";
         PatentStarListDTO vo = new PatentStarListDTO();
         vo.setCurrentQuery("F XX (" + patentNo + "/PN-CN/GJ)");
+//        vo.setCurrentQuery("F XX (" + patentNo + "/AN)");
+//        vo.setDBType("CN");
         vo.setDBType("WD");
         vo.setPageNum(1);
         vo.setRowCount(10);

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

@@ -813,10 +813,28 @@ public class EventServiceTests {
 
     @Test
     public void test118() throws Exception {
-        esExportService.getCNPatentNO();
-        System.out.println("--------------------finished-------------------");
+//        esExportService.getCNPatentNO();
+//        System.out.println("--------------------finished-------------------");
+//        String s = "CN00109126.3";
+//        System.out.println(s.length());
+//        final String s1 = esExportService.formatCnNumber(s);
+//        System.out.println(s1);
+
+        List<String> list = new ArrayList<>();
+        list.add("US62543082P0");
+//        list.add("CN201980102379.8");
+//        list.add("CN20121040471.2");
+        esExportService.formatPatentNO(list);
+//        String s = "CN20121014770.8";
+//        String s1 = s.substring(0, 7) + "0" + s.substring(7, s.indexOf("."));
+//        String s2 = s1.substring(2);
+//        char c = calculateChecksum(s2);
+//        String s3 = s1 + "." + c;
+//        System.out.println(s3);
+
     }
 
+
     @Test
     public void test119() throws Exception {
 //        esExportService.timingImportPatent();
@@ -833,7 +851,8 @@ public class EventServiceTests {
 //        final String s = esExportService.get("CN104276485A1");
 //        System.out.println(s);
 //        final String deficency = esExportService.getCNDeficency("CN202420077302.8");
-//        esExportService.getCNNum();
+//        final Long cnNumber = esExportService.getCNNumber();
+//        System.out.println(cnNumber);
 //        final Long worldNumber = esExportService.getWorldNumber();
 //        System.out.println("--------------------finished-------------------");
         // CN 19 998 00 15538.2     CN199910027176.0
@@ -862,8 +881,9 @@ public class EventServiceTests {
 //
 //        }
 //        System.out.println("AAA:" + builder);
-//        esExportService.cnPatent();
-        esExportService.worldPatent();
+        esExportService.cnPatent();
+//        esExportService.worldPatent();
+//        esExportService.getWOErrorPatent();
 
 //        PatentStarListDTO vo = new PatentStarListDTO();
 //        vo.setCurrentQuery("F XX (WO2023051704A1/PN-CN/GJ)");
@@ -885,29 +905,9 @@ public class EventServiceTests {
 //        esExportService.formatPatentNO(list);
     }
 
+    @Test
+    public void test120() throws Exception {
 
-    public char calculateChecksum(String input) {
-        int sum = 0;
-        int[] weights = {2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5};
-
-        // 遍历字符串中的每个字符,并计算乘积之和
-        for (int i = 0; i < input.length(); i++) {
-            char digit = input.charAt(i);
-            int num = Character.getNumericValue(digit);
-            sum += num * weights[i];
-        }
-
-        // 计算总和除以11的余数
-        int remainder = sum % 11;
-
-        // 根据余数确定校验位
-        char checksum;
-        if (remainder < 10) {
-            checksum = (char) ('0' + remainder);
-        } else {
-            checksum = 'X';
-        }
-
-        return checksum;
     }
+
 }