Browse Source

20250922-生成专利申请文档

lrj 2 months ago
parent
commit
6c6b5be35b

+ 1 - 1
src/main/java/cn/cslg/pas/common/core/base/Constants.java

@@ -49,7 +49,7 @@ public class Constants {
     public static final Integer PATENT_CLASS_NUMBER_CPC = 2;
     public static final Integer PATENT_CLASS_NUMBER_UPC = 3;
     public static final Integer PATENT_CLASS_NUMBER_LOC = 4;
-    public static final Integer MAX_IMPORT_TASK_COUNT=5;
+    public static final Integer MAX_IMPORT_TASK_COUNT=2;
     public static final  Integer IMPORT_PATENT_TO=1;
     public static final String   IMPORT_TASK_CONFIG="importTaskConfig";
     /**

+ 36 - 19
src/main/java/cn/cslg/pas/service/common/PatentStarApiService.java

@@ -424,7 +424,7 @@ public class PatentStarApiService {
      * 从专利之星获取中国专利摘要附图
      */
     public String getPictureApi(String appNo) {
-
+        Integer tryTime = 0;
         String url = "https://api.patentstar.com.cn/api/Patent/CnMainImage/" + appNo;
         JSONObject configObject = this.getConfigObject(4, 2);
         String appId = configObject.getString("appId");
@@ -445,19 +445,26 @@ public class PatentStarApiService {
                 .addHeader("_timestamp", currentTimeMillis.toString())
                 .addHeader("_sign", signMd5)
                 .get().build();
+        String re="";
         // 发送请求获取响应
-        try {
-            Response response = okHttpClient.newCall(request).execute();
-            // 判断请求是否成功
-            if (response.isSuccessful() && response.code() == 200) {
-                // 打印服务端返回结果
-                return Objects.requireNonNull(response.body()).string();
+        while (tryTime < 3) {
+            try {
+                Response response = okHttpClient.newCall(request).execute();
+                // 判断请求是否成功
+                re = Objects.requireNonNull(response.body()).string();
+                if (response.isSuccessful() && response.code() == 200 && re.contains("https")) {
+                    // 打印服务端返回结果
+                    tryTime = 4;
+                    return re;
+                } else {
+                    tryTime++;
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+                return null;
             }
-        } catch (IOException e) {
-            e.printStackTrace();
-            return null;
         }
-        return null;
+        return re;
     }
 
     /**
@@ -512,6 +519,7 @@ public class PatentStarApiService {
      * 从专利之星获取中国专利法律状态
      */
     public String getCnLegalApi(String appNo) {
+        Integer tryTime=0;
         String url = "https://api.patentstar.com.cn/api/Patent/CnLegal/" + appNo;
         JSONObject configObject = this.getConfigObject(4, 2);
         String appId = configObject.getString("appId");
@@ -532,16 +540,25 @@ public class PatentStarApiService {
                 .addHeader("_timestamp", currentTimeMillis.toString())
                 .addHeader("_sign", signMd5)
                 .get().build();
+        String re="";
         // 发送请求获取响应
-        try {
-            Response response = okHttpClient.newCall(request).execute();
-            // 判断请求是否成功
-            if (response.isSuccessful()) {
-                // 打印服务端返回结果
-                return Objects.requireNonNull(response.body()).string();
+        while (tryTime<3) {
+            try {
+
+                Response response = okHttpClient.newCall(request).execute();
+                // 判断请求是否成功
+                if (response.isSuccessful()) {
+                    // 打印服务端返回结果
+                    re=Objects.requireNonNull(response.body()).string();
+                    if(re.equals("{}")||re.contains("[")){
+                        tryTime=4;
+                        return re;
+                    }
+                }
+                tryTime++;
+            } catch (IOException e) {
+                e.printStackTrace();
             }
-        } catch (IOException e) {
-            e.printStackTrace();
         }
         return null;
     }