|
|
@@ -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;
|
|
|
}
|