|
@@ -1,24 +1,30 @@
|
|
|
package cn.cslg.pas.service.outApi;
|
|
|
|
|
|
+import cn.cslg.pas.common.config.XDns;
|
|
|
import cn.cslg.pas.common.model.PersonnelVO;
|
|
|
import cn.cslg.pas.common.model.outApi.PatentStarDto;
|
|
|
import cn.cslg.pas.common.model.outApi.PatentStarListDto;
|
|
|
import cn.cslg.pas.common.model.vo.outApi.StarPatentVO;
|
|
|
import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
+import cn.cslg.pas.common.utils.DateUtils2;
|
|
|
import cn.cslg.pas.common.utils.FormatUtil;
|
|
|
import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
|
|
|
import cn.cslg.pas.common.utils.ThrowException;
|
|
|
import cn.cslg.pas.domain.*;
|
|
|
+import cn.cslg.pas.service.WebLoginConfigService;
|
|
|
import cn.cslg.pas.service.upLoadPatent.RetrieveRecordService;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import io.swagger.v3.oas.models.security.SecurityScheme;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import okhttp3.FormBody;
|
|
|
import okhttp3.OkHttpClient;
|
|
|
import okhttp3.Request;
|
|
|
import okhttp3.Response;
|
|
|
+import org.joda.time.DateTime;
|
|
|
+import org.joda.time.format.DateTimeFormat;
|
|
|
+import org.joda.time.format.DateTimeFormatter;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -42,12 +48,26 @@ public class PatentStarApiService {
|
|
|
private final RetrieveRecordService retrieveRecordService;
|
|
|
private final CacheUtils cacheUtils;
|
|
|
private final LoginUtils loginUtils;
|
|
|
+ private final WebLoginConfigService webLoginConfigService;
|
|
|
|
|
|
public static String formatValue(String value) {
|
|
|
return value.replace("~", ">");
|
|
|
}
|
|
|
|
|
|
public static String formQuery(String query) {
|
|
|
+ String regexSim = "\\'.*?\\'";
|
|
|
+ Pattern patternSim = Pattern.compile(regexSim);
|
|
|
+ Matcher matcherSim = patternSim.matcher(query);
|
|
|
+ Map<String, String> map = new LinkedHashMap<>();
|
|
|
+ Integer i = 1;
|
|
|
+ while (matcherSim.find()) {
|
|
|
+ String aa = matcherSim.group();
|
|
|
+ map.put("$" + i, matcherSim.group());
|
|
|
+ query = query.replaceFirst(matcherSim.group(), "\\$" + i);
|
|
|
+ i++;
|
|
|
+ System.out.println(query);
|
|
|
+ }
|
|
|
+ // 统一改成大写
|
|
|
query = query.toUpperCase();
|
|
|
query = "(" + query + ")";
|
|
|
query = query
|
|
@@ -55,11 +75,15 @@ public class PatentStarApiService {
|
|
|
.replace(" OR ", "+")
|
|
|
.replace(" NOT ", "-");
|
|
|
|
|
|
+ for (String key : map.keySet()) {
|
|
|
+ query = query.replace(key, map.get(key));
|
|
|
+
|
|
|
+ }
|
|
|
//记录偏移量
|
|
|
int t = 0;
|
|
|
StringBuilder query2 = new StringBuilder(query);
|
|
|
//匹配形如ab=(cd OR ef);
|
|
|
- String regexOrg = "([^=^\\*^\\+^\\(^\\)^\\-]+=\\([^=^\\)]+\\))+?";
|
|
|
+ String regexOrg = "([^=^\\*^\\+^\\(^\\)^\\-]+=[\\s]*\\([^=^\\)]+\\))+?";
|
|
|
Pattern patternOrg = Pattern.compile(regexOrg);
|
|
|
Matcher matcherOrg = patternOrg.matcher(query);
|
|
|
while (matcherOrg.find()) {
|
|
@@ -70,7 +94,7 @@ public class PatentStarApiService {
|
|
|
query2.delete(matcherOrg.start() + t, matcherOrg.start() + b.length() + 1 + t);
|
|
|
t = t - b.length() - 1;
|
|
|
String c = bc[1];
|
|
|
- String regexOrg1 = "([^\\+^\\*^\\-^\\(^\\)])+";
|
|
|
+ String regexOrg1 = "(?<=[\\(\\)\\+\\-=\\*])[^\\+^\\*^\\-^\\(^\\)]+?(?=[\\(\\+\\-=\\)\\*])";
|
|
|
Pattern patternOrg1 = Pattern.compile(regexOrg1);
|
|
|
Matcher matcherOrg1 = patternOrg1.matcher(c);
|
|
|
while (matcherOrg1.find()) {
|
|
@@ -93,14 +117,17 @@ public class PatentStarApiService {
|
|
|
Map<Integer, Integer> map = new LinkedHashMap<>();
|
|
|
while (matcher.find()) {
|
|
|
String a = matcher.group();
|
|
|
- String regex2 = "[^\\(^\\)^\\+^-^=^*]";
|
|
|
- Pattern pattern2 = Pattern.compile(regex2);
|
|
|
- Matcher matcher2 = pattern2.matcher(a);
|
|
|
- Integer start = matcher.start();
|
|
|
- if (matcher2.find()) {
|
|
|
- start += matcher2.start();
|
|
|
+ String tme = a.replace(" ", "");
|
|
|
+ if (!tme.equals("")) {
|
|
|
+ String regex2 = "[^\\(^\\)^\\+^-^=^*]";
|
|
|
+ Pattern pattern2 = Pattern.compile(regex2);
|
|
|
+ Matcher matcher2 = pattern2.matcher(a);
|
|
|
+ Integer start = matcher.start();
|
|
|
+ if (matcher2.find()) {
|
|
|
+ start += matcher2.start();
|
|
|
+ }
|
|
|
+ map.put(start, matcher.end());
|
|
|
}
|
|
|
- map.put(start, matcher.end());
|
|
|
}
|
|
|
if (map.size() == 0) {
|
|
|
return "";
|
|
@@ -131,35 +158,63 @@ public class PatentStarApiService {
|
|
|
public void loadStarPatentVOS(List<StarPatentVO> starPatentVOS, JSONObject Data) {
|
|
|
String aa = Data.toString();
|
|
|
starPatentVOS.forEach(item -> {
|
|
|
+ //专利类型
|
|
|
+ Integer patentType = item.getPatentType();
|
|
|
+ if (patentType != null) {
|
|
|
+ if (patentType.equals(2) || patentType.equals(9)) {
|
|
|
+ item.setType("实用新型");
|
|
|
+ } else if (patentType.equals(1) || patentType.equals(8)) {
|
|
|
+ item.setType("发明");
|
|
|
+ } else if (patentType.equals(3)) {
|
|
|
+ item.setType("外观设计");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//如果有公开号,则将公开号作为专利号
|
|
|
- if (item.getPublicNo() != null && !item.getPublicNo().equals("")) {
|
|
|
+ if (item.getApplicationNo() != null && !item.getApplicationNo().equals("") && item.getApplicationNo().contains("CN")) {
|
|
|
+ item.setPatentNo(item.getApplicationNo());
|
|
|
+ } else if (item.getPublicNo() != null && !item.getPublicNo().equals("")) {
|
|
|
item.setPatentNo(item.getPublicNo());
|
|
|
//如果没有公开号,但是有公告号,则将公告号作为公开号和专利号
|
|
|
- } else if (item.getAnnounceNo() != null && !item.getAnnounceNo().equals("")) {
|
|
|
- item.setPublicNo(item.getAnnounceNo());
|
|
|
- item.setPatentNo(item.getAnnounceNo());
|
|
|
+ }
|
|
|
+ if (item.getPublicAccreditNo() != null && !item.getPublicAccreditNo().equals("")) {
|
|
|
+ if (item.getPublicNo() == null || item.getPublicNo().equals("")) {
|
|
|
+ item.setPublicNo(item.getPublicAccreditNo());
|
|
|
+ }
|
|
|
+ if (item.getPatentNo() == null) {
|
|
|
+ item.setPatentNo(item.getPublicAccreditNo());
|
|
|
+ }
|
|
|
} else {
|
|
|
System.out.println("");
|
|
|
|
|
|
}
|
|
|
- //陈宇 ↓ 如果没有公开日就将公告日作为公开日
|
|
|
+
|
|
|
+ //如果没有公开日就将公告日作为公开日
|
|
|
if (item.getPublicDate() == null || item.getPublicDate().equals("")) {
|
|
|
item.setPublicDate(item.getPublicAccreditDate());
|
|
|
}
|
|
|
item.setApplicant(new ArrayList<>());
|
|
|
item.setAgent(new ArrayList<>());
|
|
|
item.setIpcList(Arrays.asList(item.getIpcListStr().split(";")));
|
|
|
+ if (item.getApplicationAddress() == null) {
|
|
|
+ item.setApplicationAddress("");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> applicationAddress = Arrays.asList(item.getApplicationAddress().split(";"));
|
|
|
List<String> applicants = Arrays.asList(item.getApplicantStr().split(";"));
|
|
|
//装载申请人
|
|
|
- applicants.forEach(
|
|
|
- tem -> {
|
|
|
- PatentApplicant patentApplicant = new PatentApplicant();
|
|
|
- patentApplicant.setType(2);
|
|
|
- patentApplicant.setDataType(2);
|
|
|
- patentApplicant.setName(tem);
|
|
|
- item.getApplicant().add(patentApplicant);
|
|
|
- }
|
|
|
- );
|
|
|
+ for (int i = 0; i < applicants.size(); i++) {
|
|
|
+ PatentApplicant patentApplicant = new PatentApplicant();
|
|
|
+ patentApplicant.setType(2);
|
|
|
+ patentApplicant.setDataType(2);
|
|
|
+ patentApplicant.setName(applicants.get(i));
|
|
|
+ if (applicationAddress.size() > i) {
|
|
|
+ patentApplicant.setAddressStr(applicationAddress.get(i));
|
|
|
+ }
|
|
|
+ item.getApplicant().add(patentApplicant);
|
|
|
+ }
|
|
|
+
|
|
|
+ //装载权利人
|
|
|
if (item.getCurrentApplicantStr() != null && !item.getCurrentApplicantStr().equals("")) {
|
|
|
List<String> cApplicants = Arrays.asList(item.getCurrentApplicantStr().split(";"));
|
|
|
cApplicants.forEach(
|
|
@@ -172,12 +227,19 @@ public class PatentStarApiService {
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ //优先权
|
|
|
+ if (item.getPriorityNo() != null && !item.getPriorityNo().equals("")) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//代理机构
|
|
|
if (item.getAgencyStr() != null && !item.getAgencyStr().equals("")) {
|
|
|
PatentAgency patentAgency = new PatentAgency();
|
|
|
patentAgency.setName(item.getAgencyStr().split(" ")[0]);
|
|
|
item.setAgency(patentAgency);
|
|
|
}
|
|
|
+
|
|
|
//发明人
|
|
|
if (item.getInventorStr() != null && !item.getInventorStr().equals("")) {
|
|
|
item.setInventor(new ArrayList<>());
|
|
@@ -191,6 +253,7 @@ public class PatentStarApiService {
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
//代理人
|
|
|
if (item.getAgentStr() != null && !item.getAgentStr().equals("")) {
|
|
|
List<String> agent = Arrays.asList(item.getAgentStr().split(";"));
|
|
@@ -202,9 +265,14 @@ public class PatentStarApiService {
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
+ //TODO 此处不调用取附图接口,(遍历调接口效率太低) 提出者:罗总
|
|
|
//附图
|
|
|
- String apN = item.getApplicationNo().replace(".", "");
|
|
|
- item.setAbstractPath(this.getPictureApi(apN.substring(2)));
|
|
|
+// if (item.getApplicationNo() != null && item.getApplicationNo() != "") {
|
|
|
+// String apN = item.getApplicationNo().replace(".", "");
|
|
|
+//
|
|
|
+// //String path = this.getPictureApi(apN.substring(2));
|
|
|
+// //item.setAbstractPath(path);
|
|
|
+// }
|
|
|
if (item.getLG() != null) {
|
|
|
switch (item.getLG()) {
|
|
|
case 1:
|
|
@@ -223,7 +291,6 @@ public class PatentStarApiService {
|
|
|
}
|
|
|
|
|
|
public Map<String, Object> patentStarSearchLocal(PatentStarListDto patentStarListDto) throws IOException {
|
|
|
-
|
|
|
RetrieveRecord retrieveRecord = new RetrieveRecord();
|
|
|
retrieveRecord.setConditions(patentStarListDto.getCurrentQuery());
|
|
|
if (patentStarListDto.getRetrieveRecordId() != null) {
|
|
@@ -257,28 +324,39 @@ public class PatentStarApiService {
|
|
|
|
|
|
public Map<String, Object> patentStarSearchApi(PatentStarListDto patentStarListDto) throws IOException {
|
|
|
try {
|
|
|
- String formQuery = patentStarListDto.getCurrentQuery();
|
|
|
- patentStarListDto.setCurrentQuery(PatentStarApiService.formatQuery(formQuery));
|
|
|
+ if (patentStarListDto.getFormed() == null || patentStarListDto.getFormed() == false) {
|
|
|
+ String formQuery = patentStarListDto.getCurrentQuery();
|
|
|
+ patentStarListDto.setCurrentQuery(PatentStarApiService.formatQuery(formQuery));
|
|
|
+ if (patentStarListDto.getDBType().equals("WD")) {
|
|
|
+ StringBuilder stringBuilder = new StringBuilder(patentStarListDto.getCurrentQuery());
|
|
|
+ stringBuilder.insert(patentStarListDto.getCurrentQuery().length() - 1, "-CN/GJ");
|
|
|
+ patentStarListDto.setCurrentQuery(stringBuilder.toString());
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
return null;
|
|
|
}
|
|
|
+ JSONObject configObject = this.getConfigObject(4, 1);
|
|
|
+ String appId = configObject.getString("appId");
|
|
|
+ String appKey = configObject.getString("appKey");
|
|
|
PatentStarDto patentStarDto = new PatentStarDto();
|
|
|
BeanUtils.copyProperties(patentStarListDto, patentStarDto);
|
|
|
String json = JSONObject.toJSONString(patentStarDto);
|
|
|
String url = "http://s.patentstar.com.cn/SearchAPI/PatentSearch/ResultGet";
|
|
|
Long currentTimeMillis = System.currentTimeMillis() / 1000;
|
|
|
- String Sign = "FNYJD7902206FFB741E163BE6536C3689D55" + currentTimeMillis.toString();
|
|
|
+ String Sign = appKey + currentTimeMillis.toString();
|
|
|
String signMd5 = FormatUtil.MD5(Sign);
|
|
|
// 创建一个OkHttpClient对象
|
|
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
.connectTimeout(60, TimeUnit.SECONDS)
|
|
|
.writeTimeout(60, TimeUnit.SECONDS)
|
|
|
.readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .dns(new XDns(100000))
|
|
|
.build();
|
|
|
// 创建一个RequestBody(参数1:数据类型 参数2传递的json串)
|
|
|
FormBody.Builder builder = new FormBody.Builder();
|
|
|
- builder.add("AppID", "K8FFB741E163BE6536");
|
|
|
+ builder.add("AppID", appId);
|
|
|
builder.add("Stamp", currentTimeMillis.toString());
|
|
|
builder.add("Sign", signMd5);
|
|
|
builder.add("QueryJson", json);
|
|
@@ -313,6 +391,61 @@ public class PatentStarApiService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ public List<PatentStarListDto> getSplitedConditions(PatentStarListDto patentStarListDto, int patentNum) throws IOException {
|
|
|
+ DateTime nowDate = new DateTime();
|
|
|
+ DateTime date = DateUtils2.formStrToDateTime("1900-01-01");
|
|
|
+ //超过1万的列表
|
|
|
+ List<PatentStarListDto> patentStarListDtos = new ArrayList<>();
|
|
|
+ //返回的列表
|
|
|
+ List<PatentStarListDto> reDtos = new ArrayList<>();
|
|
|
+ patentStarListDto.setStartTime(date);
|
|
|
+ patentStarListDto.setEndTime(nowDate);
|
|
|
+ String formQuery = patentStarListDto.getCurrentQuery();
|
|
|
+ patentStarListDto.setOrginCondition(PatentStarApiService.formatQuery(formQuery));
|
|
|
+ patentStarListDtos.add(patentStarListDto);
|
|
|
+ while (patentStarListDtos.size() > 0) {
|
|
|
+ PatentStarListDto dto = patentStarListDtos.get(0);
|
|
|
+ patentStarListDtos.remove(dto);
|
|
|
+ Map<String, Object> map1 = this.patentStarSearchApi(dto);
|
|
|
+ Integer total1 = Integer.parseInt(map1.get("total").toString());
|
|
|
+ dto.setTotal(total1);
|
|
|
+ patentStarListDto.setFormed(true);
|
|
|
+ if (total1 > patentNum) {
|
|
|
+ DateTime startTime1 = dto.getStartTime();
|
|
|
+ DateTime endTime1 = dto.getEndTime();
|
|
|
+ List<DateTime> dateTimes = DateUtils2.formStrToDateTime(startTime1, endTime1);
|
|
|
+ PatentStarListDto dto1 = new PatentStarListDto();
|
|
|
+ BeanUtils.copyProperties(dto, dto1);
|
|
|
+ dto1.setStartTime(dateTimes.get(0));
|
|
|
+ dto1.setEndTime(dateTimes.get(1));
|
|
|
+ this.setConditions(dto1);
|
|
|
+ PatentStarListDto dto2 = new PatentStarListDto();
|
|
|
+ BeanUtils.copyProperties(dto, dto2);
|
|
|
+ dto2.setStartTime(dateTimes.get(2));
|
|
|
+ dto2.setEndTime(dateTimes.get(3));
|
|
|
+ this.setConditions(dto2);
|
|
|
+ patentStarListDtos.add(dto1);
|
|
|
+ patentStarListDtos.add(dto2);
|
|
|
+ } else if (total1 != 0) {
|
|
|
+ reDtos.add(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return reDtos;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setConditions(PatentStarListDto patentStarListDto) {
|
|
|
+ DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMMdd");
|
|
|
+ String startStr = formatter.print(patentStarListDto.getStartTime());
|
|
|
+ String endStr = formatter.print(patentStarListDto.getEndTime());
|
|
|
+ String cond = "*(" + startStr + ">" + endStr + "/" + "AD)";
|
|
|
+ Integer len = patentStarListDto.getOrginCondition().length();
|
|
|
+ StringBuilder stringBuilder = new StringBuilder(patentStarListDto.getOrginCondition());
|
|
|
+ stringBuilder.insert(len - 1, cond);
|
|
|
+ patentStarListDto.setCurrentQuery(stringBuilder.toString());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param appNo
|
|
|
* @return
|
|
@@ -322,16 +455,18 @@ public class PatentStarApiService {
|
|
|
*/
|
|
|
public String getCnBibApi(String appNo) {
|
|
|
String url = "https://api.patentstar.com.cn/api/Patent/CnBibo/" + appNo;
|
|
|
- String appId = "2000041";
|
|
|
- String appkey = "F0E183D5F02C48E391F5FADF1B646F54";
|
|
|
+ JSONObject configObject = this.getConfigObject(4, 2);
|
|
|
+ String appId = configObject.getString("appId");
|
|
|
+ String appKey = configObject.getString("appKey");
|
|
|
Long currentTimeMillis = System.currentTimeMillis() / 1000;
|
|
|
- String Sign = appId + appkey + currentTimeMillis.toString();
|
|
|
+ String Sign = appId + appKey + currentTimeMillis.toString();
|
|
|
String signMd5 = FormatUtil.MD5(Sign);
|
|
|
// 创建一个OkHttpClient对象
|
|
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
.connectTimeout(60, TimeUnit.SECONDS)
|
|
|
.writeTimeout(60, TimeUnit.SECONDS)
|
|
|
.readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .dns(new XDns(100000))
|
|
|
.build();
|
|
|
// 创建一个请求对象
|
|
|
Request request = new Request.Builder().url(url)
|
|
@@ -344,7 +479,6 @@ public class PatentStarApiService {
|
|
|
Response response = okHttpClient.newCall(request).execute();
|
|
|
// 判断请求是否成功
|
|
|
if (response.isSuccessful()) {
|
|
|
- response.body().toString();
|
|
|
// 打印服务端返回结果
|
|
|
return Objects.requireNonNull(response.body()).string();
|
|
|
}
|
|
@@ -364,20 +498,22 @@ public class PatentStarApiService {
|
|
|
*/
|
|
|
public String getPictureApi(String appNo) {
|
|
|
String url = "https://api.patentstar.com.cn/api/Patent/CnMainImage/" + appNo;
|
|
|
- String appId = "2000041";
|
|
|
- String appkey = "F0E183D5F02C48E391F5FADF1B646F54";
|
|
|
+ JSONObject configObject = this.getConfigObject(4, 2);
|
|
|
+ String appId = configObject.getString("appId");
|
|
|
+ String appKey = configObject.getString("appKey");
|
|
|
Long currentTimeMillis = System.currentTimeMillis() / 1000;
|
|
|
- String Sign = appId + appkey + currentTimeMillis.toString();
|
|
|
+ String Sign = appId + appKey + currentTimeMillis.toString();
|
|
|
String signMd5 = FormatUtil.MD5(Sign);
|
|
|
// 创建一个OkHttpClient对象
|
|
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
.connectTimeout(60, TimeUnit.SECONDS)
|
|
|
.writeTimeout(60, TimeUnit.SECONDS)
|
|
|
.readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .dns(new XDns(100000))
|
|
|
.build();
|
|
|
// 创建一个请求对象
|
|
|
Request request = new Request.Builder().url(url)
|
|
|
- .addHeader("_appid", "2000041")
|
|
|
+ .addHeader("_appid", appId)
|
|
|
.addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
.addHeader("_sign", signMd5)
|
|
|
.get().build();
|
|
@@ -386,12 +522,12 @@ public class PatentStarApiService {
|
|
|
Response response = okHttpClient.newCall(request).execute();
|
|
|
// 判断请求是否成功
|
|
|
if (response.isSuccessful()) {
|
|
|
- response.body().toString();
|
|
|
// 打印服务端返回结果
|
|
|
return Objects.requireNonNull(response.body()).string();
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
+ return null;
|
|
|
}
|
|
|
return "{}";
|
|
|
}
|
|
@@ -406,20 +542,22 @@ public class PatentStarApiService {
|
|
|
public String getWGPictureApi(String appNo) throws IOException {
|
|
|
|
|
|
String url = "https://api.patentstar.com.cn/api/Patent/CnWGImage/" + appNo;
|
|
|
- String appId = "2000041";
|
|
|
- String appkey = "F0E183D5F02C48E391F5FADF1B646F54";
|
|
|
+ JSONObject configObject = this.getConfigObject(4, 2);
|
|
|
+ String appId = configObject.getString("appId");
|
|
|
+ String appKey = configObject.getString("appKey");
|
|
|
Long currentTimeMillis = System.currentTimeMillis() / 1000;
|
|
|
- String Sign = appId + appkey + currentTimeMillis.toString();
|
|
|
+ String Sign = appId + appKey + currentTimeMillis.toString();
|
|
|
String signMd5 = FormatUtil.MD5(Sign);
|
|
|
// 创建一个OkHttpClient对象
|
|
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
.connectTimeout(60, TimeUnit.SECONDS)
|
|
|
.writeTimeout(60, TimeUnit.SECONDS)
|
|
|
.readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .dns(new XDns(100000))
|
|
|
.build();
|
|
|
// 创建一个请求对象
|
|
|
Request request = new Request.Builder().url(url)
|
|
|
- .addHeader("_appid", "2000041")
|
|
|
+ .addHeader("_appid", appId)
|
|
|
.addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
.addHeader("_sign", signMd5)
|
|
|
.get().build();
|
|
@@ -428,7 +566,6 @@ public class PatentStarApiService {
|
|
|
Response response = okHttpClient.newCall(request).execute();
|
|
|
// 判断请求是否成功
|
|
|
if (response.isSuccessful()) {
|
|
|
- response.body().toString();
|
|
|
// 打印服务端返回结果
|
|
|
return Objects.requireNonNull(response.body()).string();
|
|
|
}
|
|
@@ -447,20 +584,22 @@ public class PatentStarApiService {
|
|
|
*/
|
|
|
public String getCnLegalApi(String appNo) {
|
|
|
String url = "https://api.patentstar.com.cn/api/Patent/CnLegal/" + appNo;
|
|
|
- String appId = "2000041";
|
|
|
- String appkey = "F0E183D5F02C48E391F5FADF1B646F54";
|
|
|
+ JSONObject configObject = this.getConfigObject(4, 2);
|
|
|
+ String appId = configObject.getString("appId");
|
|
|
+ String appKey = configObject.getString("appKey");
|
|
|
Long currentTimeMillis = System.currentTimeMillis() / 1000;
|
|
|
- String Sign = appId + appkey + currentTimeMillis.toString();
|
|
|
+ String Sign = appId + appKey + currentTimeMillis.toString();
|
|
|
String signMd5 = FormatUtil.MD5(Sign);
|
|
|
// 创建一个OkHttpClient对象
|
|
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
.connectTimeout(60, TimeUnit.SECONDS)
|
|
|
.writeTimeout(60, TimeUnit.SECONDS)
|
|
|
.readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .dns(new XDns(100000))
|
|
|
.build();
|
|
|
// 创建一个请求对象
|
|
|
Request request = new Request.Builder().url(url)
|
|
|
- .addHeader("_appid", "2000041")
|
|
|
+ .addHeader("_appid", appId)
|
|
|
.addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
.addHeader("_sign", signMd5)
|
|
|
.get().build();
|
|
@@ -469,7 +608,6 @@ public class PatentStarApiService {
|
|
|
Response response = okHttpClient.newCall(request).execute();
|
|
|
// 判断请求是否成功
|
|
|
if (response.isSuccessful()) {
|
|
|
- response.body().toString();
|
|
|
// 打印服务端返回结果
|
|
|
return Objects.requireNonNull(response.body()).string();
|
|
|
}
|
|
@@ -488,20 +626,22 @@ public class PatentStarApiService {
|
|
|
*/
|
|
|
public String getCnPdfApi(String appNo) throws IOException {
|
|
|
String url = "https://api.patentstar.com.cn/api/Patent/CnPdf/" + appNo;
|
|
|
- String appId = "2000041";
|
|
|
- String appkey = "F0E183D5F02C48E391F5FADF1B646F54";
|
|
|
+ JSONObject configObject = this.getConfigObject(4, 2);
|
|
|
+ String appId = configObject.getString("appId");
|
|
|
+ String appKey = configObject.getString("appKey");
|
|
|
Long currentTimeMillis = System.currentTimeMillis() / 1000;
|
|
|
- String Sign = appId + appkey + currentTimeMillis.toString();
|
|
|
+ String Sign = appId + appKey + currentTimeMillis.toString();
|
|
|
String signMd5 = FormatUtil.MD5(Sign);
|
|
|
// 创建一个OkHttpClient对象
|
|
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
.connectTimeout(60, TimeUnit.SECONDS)
|
|
|
.writeTimeout(60, TimeUnit.SECONDS)
|
|
|
.readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .dns(new XDns(100000))
|
|
|
.build();
|
|
|
// 创建一个请求对象
|
|
|
Request request = new Request.Builder().url(url)
|
|
|
- .addHeader("_appid", "2000041")
|
|
|
+ .addHeader("_appid", appId)
|
|
|
.addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
.addHeader("_sign", signMd5)
|
|
|
.get().build();
|
|
@@ -510,7 +650,6 @@ public class PatentStarApiService {
|
|
|
Response response = okHttpClient.newCall(request).execute();
|
|
|
// 判断请求是否成功
|
|
|
if (response.isSuccessful()) {
|
|
|
- response.body().toString();
|
|
|
// 打印服务端返回结果
|
|
|
return Objects.requireNonNull(response.body()).string();
|
|
|
}
|
|
@@ -530,20 +669,22 @@ public class PatentStarApiService {
|
|
|
|
|
|
public String getCnFullXmlApi(String appNo) throws IOException {
|
|
|
String url = "https://api.patentstar.com.cn/api/Patent/CnFullXml/" + appNo;
|
|
|
- String appId = "2000041";
|
|
|
- String appkey = "F0E183D5F02C48E391F5FADF1B646F54";
|
|
|
+ JSONObject configObject = this.getConfigObject(4, 2);
|
|
|
+ String appId = configObject.getString("appId");
|
|
|
+ String appKey = configObject.getString("appKey");
|
|
|
Long currentTimeMillis = System.currentTimeMillis() / 1000;
|
|
|
- String Sign = appId + appkey + currentTimeMillis.toString();
|
|
|
+ String Sign = appId + appKey + currentTimeMillis.toString();
|
|
|
String signMd5 = FormatUtil.MD5(Sign);
|
|
|
// 创建一个OkHttpClient对象
|
|
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
.connectTimeout(60, TimeUnit.SECONDS)
|
|
|
.writeTimeout(60, TimeUnit.SECONDS)
|
|
|
.readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .dns(new XDns(100000))
|
|
|
.build();
|
|
|
// 创建一个请求对象
|
|
|
Request request = new Request.Builder().url(url)
|
|
|
- .addHeader("_appid", "2000041")
|
|
|
+ .addHeader("_appid", appId)
|
|
|
.addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
.addHeader("_sign", signMd5)
|
|
|
.get().build();
|
|
@@ -552,7 +693,6 @@ public class PatentStarApiService {
|
|
|
Response response = okHttpClient.newCall(request).execute();
|
|
|
// 判断请求是否成功
|
|
|
if (response.isSuccessful()) {
|
|
|
- response.body().toString();
|
|
|
// 打印服务端返回结果
|
|
|
return Objects.requireNonNull(response.body()).string();
|
|
|
}
|
|
@@ -571,20 +711,24 @@ public class PatentStarApiService {
|
|
|
*/
|
|
|
public String getEnPdfApi(String patentNo) {
|
|
|
String url = " https://api.patentstar.com.cn/api/Patent/EnPdf/" + patentNo;
|
|
|
- String appId = "2000041";
|
|
|
- String appkey = "F0E183D5F02C48E391F5FADF1B646F54";
|
|
|
+ JSONObject configObject = this.getConfigObject(4, 2);
|
|
|
+ String appId = configObject.getString("appId");
|
|
|
+ String appKey = configObject.getString("appKey");
|
|
|
+// String appId = "1000046";
|
|
|
+// String appkey = "6AE6D4DC6AF94F26862501EDEE9E27A2";
|
|
|
Long currentTimeMillis = System.currentTimeMillis() / 1000;
|
|
|
- String Sign = appId + appkey + currentTimeMillis.toString();
|
|
|
+ String Sign = appId + appKey + currentTimeMillis.toString();
|
|
|
String signMd5 = FormatUtil.MD5(Sign);
|
|
|
// 创建一个OkHttpClient对象
|
|
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
.connectTimeout(60, TimeUnit.SECONDS)
|
|
|
.writeTimeout(60, TimeUnit.SECONDS)
|
|
|
.readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .dns(new XDns(100000))
|
|
|
.build();
|
|
|
// 创建一个请求对象
|
|
|
Request request = new Request.Builder().url(url)
|
|
|
- .addHeader("_appid", "2000041")
|
|
|
+ .addHeader("_appid", appId)
|
|
|
.addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
.addHeader("_sign", signMd5)
|
|
|
.get().build();
|
|
@@ -593,7 +737,6 @@ public class PatentStarApiService {
|
|
|
Response response = okHttpClient.newCall(request).execute();
|
|
|
// 判断请求是否成功
|
|
|
if (response.isSuccessful()) {
|
|
|
- response.body().toString();
|
|
|
// 打印服务端返回结果
|
|
|
return Objects.requireNonNull(response.body()).string();
|
|
|
}
|
|
@@ -611,21 +754,23 @@ public class PatentStarApiService {
|
|
|
* 从专利之星获取世界专利著录信息
|
|
|
*/
|
|
|
public String getENBibApi(String patentNo) {
|
|
|
- String url = "https://api.patentstar.com.cn/api/Patent/ENBib/" + patentNo;
|
|
|
- String appId = "2000041";
|
|
|
- String appkey = "F0E183D5F02C48E391F5FADF1B646F54";
|
|
|
+ String url = "https://api.patentstar.com.cn/api/Patent/EnBib/" + patentNo;
|
|
|
+ JSONObject configObject = this.getConfigObject(4, 2);
|
|
|
+ String appId = configObject.getString("appId");
|
|
|
+ String appKey = configObject.getString("appKey");
|
|
|
Long currentTimeMillis = System.currentTimeMillis() / 1000;
|
|
|
- String Sign = appId + appkey + currentTimeMillis.toString();
|
|
|
+ String Sign = appId + appKey + currentTimeMillis.toString();
|
|
|
String signMd5 = FormatUtil.MD5(Sign);
|
|
|
// 创建一个OkHttpClient对象
|
|
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
.connectTimeout(60, TimeUnit.SECONDS)
|
|
|
.writeTimeout(60, TimeUnit.SECONDS)
|
|
|
.readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .dns(new XDns(100000))
|
|
|
.build();
|
|
|
// 创建一个请求对象
|
|
|
Request request = new Request.Builder().url(url)
|
|
|
- .addHeader("_appid", "2000041")
|
|
|
+ .addHeader("_appid", appId)
|
|
|
.addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
.addHeader("_sign", signMd5)
|
|
|
.get().build();
|
|
@@ -634,7 +779,6 @@ public class PatentStarApiService {
|
|
|
Response response = okHttpClient.newCall(request).execute();
|
|
|
// 判断请求是否成功
|
|
|
if (response.isSuccessful()) {
|
|
|
- response.body().toString();
|
|
|
// 打印服务端返回结果
|
|
|
return Objects.requireNonNull(response.body()).string();
|
|
|
}
|
|
@@ -653,20 +797,22 @@ public class PatentStarApiService {
|
|
|
*/
|
|
|
public String getFamilyByPubNoApi(String patentNo) {
|
|
|
String url = "https://api.patentstar.com.cn/api/Patent/FamilyByPubNo/" + patentNo;
|
|
|
- String appId = "2000041";
|
|
|
- String appkey = "F0E183D5F02C48E391F5FADF1B646F54";
|
|
|
+ JSONObject configObject = this.getConfigObject(4, 2);
|
|
|
+ String appId = configObject.getString("appId");
|
|
|
+ String appKey = configObject.getString("appKey");
|
|
|
Long currentTimeMillis = System.currentTimeMillis() / 1000;
|
|
|
- String Sign = appId + appkey + currentTimeMillis.toString();
|
|
|
+ String Sign = appId + appKey + currentTimeMillis.toString();
|
|
|
String signMd5 = FormatUtil.MD5(Sign);
|
|
|
// 创建一个OkHttpClient对象
|
|
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
.connectTimeout(60, TimeUnit.SECONDS)
|
|
|
.writeTimeout(60, TimeUnit.SECONDS)
|
|
|
.readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .dns(new XDns(100000))
|
|
|
.build();
|
|
|
// 创建一个请求对象
|
|
|
Request request = new Request.Builder().url(url)
|
|
|
- .addHeader("_appid", "2000041")
|
|
|
+ .addHeader("_appid", appId)
|
|
|
.addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
.addHeader("_sign", signMd5)
|
|
|
.get().build();
|
|
@@ -675,7 +821,6 @@ public class PatentStarApiService {
|
|
|
Response response = okHttpClient.newCall(request).execute();
|
|
|
// 判断请求是否成功
|
|
|
if (response.isSuccessful()) {
|
|
|
- response.body().toString();
|
|
|
// 打印服务端返回结果
|
|
|
return Objects.requireNonNull(response.body()).string();
|
|
|
}
|
|
@@ -694,20 +839,22 @@ public class PatentStarApiService {
|
|
|
*/
|
|
|
public String getCitedNumByPubNoApi(String patentNo) throws IOException {
|
|
|
String url = "https://api.patentstar.com.cn/api/Patent/CitedNumByPubNo/" + patentNo;
|
|
|
- String appId = "2000041";
|
|
|
- String appkey = "F0E183D5F02C48E391F5FADF1B646F54";
|
|
|
+ JSONObject configObject = this.getConfigObject(4, 2);
|
|
|
+ String appId = configObject.getString("appId");
|
|
|
+ String appKey = configObject.getString("appKey");
|
|
|
Long currentTimeMillis = System.currentTimeMillis() / 1000;
|
|
|
- String Sign = appId + appkey + currentTimeMillis.toString();
|
|
|
+ String Sign = appId + appKey + currentTimeMillis.toString();
|
|
|
String signMd5 = FormatUtil.MD5(Sign);
|
|
|
// 创建一个OkHttpClient对象
|
|
|
OkHttpClient okHttpClient = new OkHttpClient.Builder()
|
|
|
.connectTimeout(60, TimeUnit.SECONDS)
|
|
|
.writeTimeout(60, TimeUnit.SECONDS)
|
|
|
.readTimeout(60, TimeUnit.SECONDS)
|
|
|
+ .dns(new XDns(100000))
|
|
|
.build();
|
|
|
// 创建一个请求对象
|
|
|
Request request = new Request.Builder().url(url)
|
|
|
- .addHeader("_appid", "2000041")
|
|
|
+ .addHeader("_appid", appId)
|
|
|
.addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
.addHeader("_sign", signMd5)
|
|
|
.get().build();
|
|
@@ -716,7 +863,6 @@ public class PatentStarApiService {
|
|
|
Response response = okHttpClient.newCall(request).execute();
|
|
|
// 判断请求是否成功
|
|
|
if (response.isSuccessful()) {
|
|
|
- response.body().toString();
|
|
|
// 打印服务端返回结果
|
|
|
return Objects.requireNonNull(response.body()).string();
|
|
|
}
|
|
@@ -726,4 +872,16 @@ public class PatentStarApiService {
|
|
|
return "{}";
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public JSONObject getConfigObject(Integer webId, Integer webGroup) {
|
|
|
+
|
|
|
+ WebLoginConfig webLoginConfig = webLoginConfigService.getConfig(webId, webGroup);
|
|
|
+ if (webLoginConfig == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String config = webLoginConfig.getWebConfig();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(config);
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+
|
|
|
}
|