|
@@ -0,0 +1,783 @@
|
|
|
+package cn.cslg.pas.service.common;
|
|
|
+
|
|
|
+import cn.cslg.pas.common.config.XDns;
|
|
|
+
|
|
|
+import cn.cslg.pas.common.dto.PatentStarDTO;
|
|
|
+import cn.cslg.pas.common.dto.PatentStarListDTO;
|
|
|
+import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
+import cn.cslg.pas.common.model.importTaskModel.PatentApplicant;
|
|
|
+import cn.cslg.pas.common.utils.*;
|
|
|
+import cn.cslg.pas.common.vo.StarPatentVO;
|
|
|
+import cn.cslg.pas.domain.WebLoginConfig;
|
|
|
+import cn.cslg.pas.domain.business.RetrieveRecord;
|
|
|
+import cn.cslg.pas.service.WebLoginConfigService;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+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;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 调用外部接口的Service类 PCS:权限系统
|
|
|
+ *
|
|
|
+ * @Author chenyu
|
|
|
+ * @Date 2023/4/25
|
|
|
+ */
|
|
|
+@RequiredArgsConstructor
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+
|
|
|
+public class PatentStarApiService {
|
|
|
+ private final RetrieveRecordService retrieveRecordService;
|
|
|
+ private final CacheUtils cacheUtils;
|
|
|
+ private final LoginUtils loginUtils;
|
|
|
+ private final WebLoginConfigService webLoginConfigService;
|
|
|
+//
|
|
|
+// //装载专利信息
|
|
|
+// 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.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());
|
|
|
+// //如果没有公开号,但是有公告号,则将公告号作为公开号和专利号
|
|
|
+// }
|
|
|
+// 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(";"));
|
|
|
+// //装载申请人
|
|
|
+// 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(
|
|
|
+// tem -> {
|
|
|
+// PatentApplicant patentApplicant = new PatentApplicant();
|
|
|
+// patentApplicant.setType(2);
|
|
|
+// patentApplicant.setDataType(1);
|
|
|
+// patentApplicant.setName(tem);
|
|
|
+// item.getApplicant().add(patentApplicant);
|
|
|
+// }
|
|
|
+// );
|
|
|
+// }
|
|
|
+//
|
|
|
+// //优先权
|
|
|
+// 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<>());
|
|
|
+// List<String> inventors = Arrays.asList(item.getInventorStr().split(";"));
|
|
|
+// inventors.forEach(
|
|
|
+// tem -> {
|
|
|
+// PatentInventor patentInventor = new PatentInventor();
|
|
|
+// patentInventor.setName(tem);
|
|
|
+// item.getInventor().add(patentInventor);
|
|
|
+// ;
|
|
|
+// }
|
|
|
+// );
|
|
|
+// }
|
|
|
+//
|
|
|
+// //代理人
|
|
|
+// if (item.getAgentStr() != null && !item.getAgentStr().equals("")) {
|
|
|
+// List<String> agent = Arrays.asList(item.getAgentStr().split(";"));
|
|
|
+// agent.forEach(
|
|
|
+// tem -> {
|
|
|
+// PatentAgent patentAgent = new PatentAgent();
|
|
|
+// patentAgent.setName(tem);
|
|
|
+// item.getAgent().add(patentAgent);
|
|
|
+// }
|
|
|
+// );
|
|
|
+// }
|
|
|
+// //TODO 此处不调用取附图接口,(遍历调接口效率太低) 提出者:罗总
|
|
|
+// //附图
|
|
|
+//// 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:
|
|
|
+// item.setSimpleStatus("有效");
|
|
|
+// break;
|
|
|
+// case 2:
|
|
|
+// item.setSimpleStatus("失效");
|
|
|
+// break;
|
|
|
+// case 3:
|
|
|
+// item.setSimpleStatus("审中");
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //法律状态
|
|
|
+// });
|
|
|
+// }
|
|
|
+
|
|
|
+ public Map<String, Object> patentStarSearchLocal(PatentStarListDTO PatentStarListDTO) throws IOException {
|
|
|
+ RetrieveRecord retrieveRecord = new RetrieveRecord();
|
|
|
+ retrieveRecord.setConditions(PatentStarListDTO.getCurrentQuery());
|
|
|
+ if (PatentStarListDTO.getRetrieveRecordId() != null) {
|
|
|
+ //retrieveRecord = retrieveRecordService.getById(PatentStarListDTO.getRetrieveRecordId());
|
|
|
+ //PatentStarListDTO.setCurrentQuery(retrieveRecord.getConditions());
|
|
|
+ //PatentStarListDTO.setDBType(retrieveRecord.getDbType());
|
|
|
+ }
|
|
|
+ Map<String, Object> map = this.patentStarSearchApi(PatentStarListDTO);
|
|
|
+ if (map == null) {
|
|
|
+ ThrowException.throwXiaoShiException("检索失败,请检查检索式");
|
|
|
+ }
|
|
|
+ //记录检索历史
|
|
|
+ retrieveRecord.setRetrieveTime(new Date());
|
|
|
+ retrieveRecord.setTotalNum(Integer.parseInt(map.get("total").toString()));
|
|
|
+ retrieveRecord.setDbType(PatentStarListDTO.getDBType());
|
|
|
+ if (PatentStarListDTO.getRetrieveRecordId() == null) {
|
|
|
+ //获取创建人信息
|
|
|
+ PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ retrieveRecord.setCreateTime(new Date());
|
|
|
+ retrieveRecord.setCreateId(personnelVO.getId());
|
|
|
+ retrieveRecord.setTenantId(personnelVO.getTenantId());
|
|
|
+ retrieveRecord.insert();
|
|
|
+ }
|
|
|
+// else {
|
|
|
+// retrieveRecord.updateById();
|
|
|
+// }
|
|
|
+ map.put("retrieveRecordId", retrieveRecord.getId());
|
|
|
+ return map;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public Map<String, Object> patentStarSearchApi(PatentStarListDTO PatentStarListDTO) throws IOException {
|
|
|
+ try {
|
|
|
+ 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 = 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", appId);
|
|
|
+ builder.add("Stamp", currentTimeMillis.toString());
|
|
|
+ builder.add("Sign", signMd5);
|
|
|
+ builder.add("QueryJson", json);
|
|
|
+ FormBody requestBody = builder.build();
|
|
|
+ // 创建一个请求对象
|
|
|
+ Request request = new Request.Builder().url(url).post(requestBody).build();
|
|
|
+ // 发送请求获取响应
|
|
|
+ try {
|
|
|
+ Response response = okHttpClient.newCall(request).execute();
|
|
|
+ // 判断请求是否成功
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(Objects.requireNonNull(response.body()).string());
|
|
|
+ if (jsonObject.get("Ret").equals(500) || jsonObject.get("Data") == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ JSONObject Data = (JSONObject) jsonObject.get("Data");
|
|
|
+ List<StarPatentVO> starPatentVOS = JSONArray.parseArray(Data.get("List").toString(), StarPatentVO.class);
|
|
|
+// this.loadStarPatentVOS(starPatentVOS, Data);
|
|
|
+ // 打印服务端返回结果
|
|
|
+ // return Objects.requireNonNull(response.body()).string();
|
|
|
+ Map<String, Object> reMap = new HashMap<>();
|
|
|
+ reMap.put("size", PatentStarListDTO.getRowCount());
|
|
|
+ reMap.put("current", PatentStarListDTO.getPageNum());
|
|
|
+ reMap.put("records", starPatentVOS);
|
|
|
+ reMap.put("total", Data.get("HitCount"));
|
|
|
+ return reMap;
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ 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
|
|
|
+ * @throws IOException
|
|
|
+ * @author 李仁杰
|
|
|
+ * 从专利之星获取中国专利著录
|
|
|
+ */
|
|
|
+ public String getCnBibApi(String appNo) {
|
|
|
+ String url = "https://api.patentstar.com.cn/api/Patent/CnBibo/" + appNo;
|
|
|
+ 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 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", appId)
|
|
|
+ .addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
+ .addHeader("_sign", signMd5)
|
|
|
+ .get().build();
|
|
|
+ // 发送请求获取响应
|
|
|
+ try {
|
|
|
+ Response response = okHttpClient.newCall(request).execute();
|
|
|
+ // 判断请求是否成功
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ // 打印服务端返回结果
|
|
|
+ return Objects.requireNonNull(response.body()).string();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return "{}";
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ * @author 李仁杰
|
|
|
+ * 从专利之星获取中国专利摘要附图
|
|
|
+ */
|
|
|
+ public String getPictureApi(String appNo) {
|
|
|
+ String url = "https://api.patentstar.com.cn/api/Patent/CnMainImage/" + appNo;
|
|
|
+ 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 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", appId)
|
|
|
+ .addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
+ .addHeader("_sign", signMd5)
|
|
|
+ .get().build();
|
|
|
+ // 发送请求获取响应
|
|
|
+ try {
|
|
|
+ Response response = okHttpClient.newCall(request).execute();
|
|
|
+ // 判断请求是否成功
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ // 打印服务端返回结果
|
|
|
+ return Objects.requireNonNull(response.body()).string();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return "{}";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param appNo
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ * @author 李仁杰
|
|
|
+ * 从专利之星获取中国专利外观图
|
|
|
+ */
|
|
|
+ public String getWGPictureApi(String appNo) throws IOException {
|
|
|
+
|
|
|
+ String url = "https://api.patentstar.com.cn/api/Patent/CnWGImage/" + appNo;
|
|
|
+ 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 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", appId)
|
|
|
+ .addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
+ .addHeader("_sign", signMd5)
|
|
|
+ .get().build();
|
|
|
+ // 发送请求获取响应
|
|
|
+ try {
|
|
|
+ Response response = okHttpClient.newCall(request).execute();
|
|
|
+ // 判断请求是否成功
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ // 打印服务端返回结果
|
|
|
+ return Objects.requireNonNull(response.body()).string();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return "{}";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param appNo
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ * @author 李仁杰
|
|
|
+ * 从专利之星获取中国专利法律状态
|
|
|
+ */
|
|
|
+ public String getCnLegalApi(String appNo) {
|
|
|
+ String url = "https://api.patentstar.com.cn/api/Patent/CnLegal/" + appNo;
|
|
|
+ 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 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", appId)
|
|
|
+ .addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
+ .addHeader("_sign", signMd5)
|
|
|
+ .get().build();
|
|
|
+ // 发送请求获取响应
|
|
|
+ try {
|
|
|
+ Response response = okHttpClient.newCall(request).execute();
|
|
|
+ // 判断请求是否成功
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ // 打印服务端返回结果
|
|
|
+ return Objects.requireNonNull(response.body()).string();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return "{}";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param appNo
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ * @author 李仁杰
|
|
|
+ * 从专利之星获取中国专利全文图片
|
|
|
+ */
|
|
|
+ public String getCnPdfApi(String appNo) throws IOException {
|
|
|
+ String url = "https://api.patentstar.com.cn/api/Patent/CnPdf/" + appNo;
|
|
|
+ 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 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", appId)
|
|
|
+ .addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
+ .addHeader("_sign", signMd5)
|
|
|
+ .get().build();
|
|
|
+ // 发送请求获取响应
|
|
|
+ try {
|
|
|
+ Response response = okHttpClient.newCall(request).execute();
|
|
|
+ // 判断请求是否成功
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ // 打印服务端返回结果
|
|
|
+ return Objects.requireNonNull(response.body()).string();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return "{}";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param appNo
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ * @author 李仁杰
|
|
|
+ * 从专利之星获取中国专利全文文本
|
|
|
+ */
|
|
|
+
|
|
|
+ public String getCnFullXmlApi(String appNo) throws IOException {
|
|
|
+ String url = "https://api.patentstar.com.cn/api/Patent/CnFullXml/" + appNo;
|
|
|
+ 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 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", appId)
|
|
|
+ .addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
+ .addHeader("_sign", signMd5)
|
|
|
+ .get().build();
|
|
|
+ // 发送请求获取响应
|
|
|
+ try {
|
|
|
+ Response response = okHttpClient.newCall(request).execute();
|
|
|
+ // 判断请求是否成功
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ // 打印服务端返回结果
|
|
|
+ return Objects.requireNonNull(response.body()).string();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return "{}";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param patentNo
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ * @author 李仁杰
|
|
|
+ * 从专利之星获取世界专利pdf
|
|
|
+ */
|
|
|
+ public String getEnPdfApi(String patentNo) {
|
|
|
+ String url = " https://api.patentstar.com.cn/api/Patent/EnPdf/" + patentNo;
|
|
|
+ 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 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", appId)
|
|
|
+ .addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
+ .addHeader("_sign", signMd5)
|
|
|
+ .get().build();
|
|
|
+ // 发送请求获取响应
|
|
|
+ try {
|
|
|
+ Response response = okHttpClient.newCall(request).execute();
|
|
|
+ // 判断请求是否成功
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ // 打印服务端返回结果
|
|
|
+ return Objects.requireNonNull(response.body()).string();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return "{}";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param patentNo
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ * @author 李仁杰
|
|
|
+ * 从专利之星获取世界专利著录信息
|
|
|
+ */
|
|
|
+ public String getENBibApi(String patentNo) {
|
|
|
+ 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 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", appId)
|
|
|
+ .addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
+ .addHeader("_sign", signMd5)
|
|
|
+ .get().build();
|
|
|
+ // 发送请求获取响应
|
|
|
+ try {
|
|
|
+ Response response = okHttpClient.newCall(request).execute();
|
|
|
+ // 判断请求是否成功
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ // 打印服务端返回结果
|
|
|
+ return Objects.requireNonNull(response.body()).string();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return "{}";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param patentNo
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ * @author 李仁杰
|
|
|
+ * 从专利之星获取同族专利
|
|
|
+ */
|
|
|
+ public String getFamilyByPubNoApi(String patentNo) {
|
|
|
+ String url = "https://api.patentstar.com.cn/api/Patent/FamilyByPubNo/" + 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 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", appId)
|
|
|
+ .addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
+ .addHeader("_sign", signMd5)
|
|
|
+ .get().build();
|
|
|
+ // 发送请求获取响应
|
|
|
+ try {
|
|
|
+ Response response = okHttpClient.newCall(request).execute();
|
|
|
+ // 判断请求是否成功
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ // 打印服务端返回结果
|
|
|
+ return Objects.requireNonNull(response.body()).string();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return "{}";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param patentNo
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ * @author 李仁杰
|
|
|
+ * 获得专利被引用次数api
|
|
|
+ */
|
|
|
+ public String getCitedNumByPubNoApi(String patentNo) throws IOException {
|
|
|
+ String url = "https://api.patentstar.com.cn/api/Patent/CitedNumByPubNo/" + 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 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", appId)
|
|
|
+ .addHeader("_timestamp", currentTimeMillis.toString())
|
|
|
+ .addHeader("_sign", signMd5)
|
|
|
+ .get().build();
|
|
|
+ // 发送请求获取响应
|
|
|
+ try {
|
|
|
+ Response response = okHttpClient.newCall(request).execute();
|
|
|
+ // 判断请求是否成功
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ // 打印服务端返回结果
|
|
|
+ return Objects.requireNonNull(response.body()).string();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|