PatentStarApiService.java 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140
  1. package cn.cslg.pas.service.common;
  2. import cn.cslg.pas.common.config.XDns;
  3. import cn.cslg.pas.common.core.IgnoreDTDEntityResolver;
  4. import cn.cslg.pas.common.dto.*;
  5. import cn.cslg.pas.common.dto.business.SelectClaimDTO;
  6. import cn.cslg.pas.common.model.cronModel.PersonnelVO;
  7. import cn.cslg.pas.common.model.cronModel.Records;
  8. import cn.cslg.pas.common.model.importTaskModel.PatentApplicant;
  9. import cn.cslg.pas.common.utils.*;
  10. import cn.cslg.pas.common.vo.ContentVO;
  11. import cn.cslg.pas.common.vo.QueryExternalFamilyVO;
  12. import cn.cslg.pas.common.vo.StarPatentVO;
  13. import cn.cslg.pas.common.vo.business.PatentNoVO;
  14. import cn.cslg.pas.domain.WebLoginConfig;
  15. import cn.cslg.pas.domain.business.RetrieveRecord;
  16. import cn.cslg.pas.domain.es.PatentClassify;
  17. import cn.cslg.pas.domain.es.PatentPerson;
  18. import cn.cslg.pas.domain.es.PersonAddress;
  19. import cn.cslg.pas.domain.es.Text;
  20. import cn.cslg.pas.service.WebLoginConfigService;
  21. import cn.cslg.pas.service.importPatent.ImportFromWebToEsService;
  22. import cn.cslg.pas.service.query.FormatQueryService;
  23. import com.alibaba.fastjson.JSONArray;
  24. import com.alibaba.fastjson.JSONObject;
  25. import lombok.RequiredArgsConstructor;
  26. import lombok.experimental.Accessors;
  27. import lombok.extern.slf4j.Slf4j;
  28. import okhttp3.FormBody;
  29. import okhttp3.OkHttpClient;
  30. import okhttp3.Request;
  31. import okhttp3.Response;
  32. import org.dom4j.Document;
  33. import org.dom4j.DocumentException;
  34. import org.dom4j.Element;
  35. import org.dom4j.XPath;
  36. import org.dom4j.io.SAXReader;
  37. import org.joda.time.DateTime;
  38. import org.joda.time.format.DateTimeFormat;
  39. import org.joda.time.format.DateTimeFormatter;
  40. import org.springframework.beans.BeanUtils;
  41. import org.springframework.beans.factory.annotation.Autowired;
  42. import org.springframework.context.ApplicationContext;
  43. import org.springframework.stereotype.Service;
  44. import org.springframework.util.CollectionUtils;
  45. import java.io.File;
  46. import java.io.IOException;
  47. import java.io.Reader;
  48. import java.io.StringReader;
  49. import java.util.*;
  50. import java.util.concurrent.TimeUnit;
  51. import java.util.regex.Matcher;
  52. import java.util.regex.Pattern;
  53. /**
  54. * 调用外部接口的Service类 PCS:权限系统
  55. *
  56. * @Author chenyu
  57. * @Date 2023/4/25
  58. */
  59. @RequiredArgsConstructor
  60. @Slf4j
  61. @Service
  62. public class PatentStarApiService {
  63. private ApplicationContext applicationContext;
  64. private PatentStarApiService patentStarApiService;
  65. @Autowired
  66. private RetrieveRecordService retrieveRecordService;
  67. @Autowired
  68. private CacheUtils cacheUtils;
  69. @Autowired
  70. private LoginUtils loginUtils;
  71. @Autowired
  72. private WebLoginConfigService webLoginConfigService;
  73. @Autowired
  74. private FormatQueryService formatQueryService;
  75. public Records patentStarSearchLocal(PatentStarListDTO patentStarListDTO) throws IOException {
  76. RetrieveRecord retrieveRecord = new RetrieveRecord();
  77. retrieveRecord.setConditions(patentStarListDTO.getCurrentQuery());
  78. if (patentStarListDTO.getRetrieveRecordId() != null) {
  79. retrieveRecord = retrieveRecordService.getById(patentStarListDTO.getRetrieveRecordId());
  80. patentStarListDTO.setCurrentQuery(retrieveRecord.getConditions());
  81. patentStarListDTO.setDBType(retrieveRecord.getDbType());
  82. }
  83. Map<String, Object> map = this.patentStarSearchApi(patentStarListDTO);
  84. if (map == null) {
  85. ThrowException.throwXiaoShiException("检索失败,请检查检索式");
  86. }
  87. //记录检索历史
  88. retrieveRecord.setRetrieveTime(new Date());
  89. retrieveRecord.setTotalNum(Integer.parseInt(map.get("total").toString()));
  90. retrieveRecord.setDbType(patentStarListDTO.getDBType());
  91. // if (patentStarListDTO.getRetrieveRecordId() == null) {
  92. // //获取创建人信息
  93. // PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
  94. // retrieveRecord.setCreateTime(new Date());
  95. // retrieveRecord.setCreateId(personnelVO.getId());
  96. // retrieveRecord.setTenantId(personnelVO.getTenantId());
  97. // retrieveRecord.insert();
  98. // }
  99. // else {
  100. // retrieveRecord.updateById();
  101. // }
  102. List<StarPatentVO> starPatentVOS = (List<StarPatentVO>) map.get("records");
  103. //装载starPatentVOS到 PatentColumnDTO
  104. Records records = new Records();
  105. records.setRetrieveRecordId(retrieveRecord.getId());
  106. records.setCurrent(Long.parseLong(map.get("current").toString()));
  107. records.setSize(Long.parseLong(map.get("size").toString()));
  108. records.setData(this.loadPatent(starPatentVOS));
  109. records.setTotal(Long.parseLong(map.get("total").toString()));
  110. return records;
  111. }
  112. public Map<String, Object> patentStarSearchApi(PatentStarListDTO PatentStarListDTO) throws IOException {
  113. try {
  114. if (PatentStarListDTO.getFormed() == null || PatentStarListDTO.getFormed() == false) {
  115. String formQuery = PatentStarListDTO.getCurrentQuery();
  116. PatentStarListDTO.setCurrentQuery(formatQueryService.reQuery(formQuery, "webSearchConfig"));
  117. if (PatentStarListDTO.getDBType().equals("WD")) {
  118. StringBuilder stringBuilder = new StringBuilder(PatentStarListDTO.getCurrentQuery());
  119. stringBuilder.insert(PatentStarListDTO.getCurrentQuery().length() - 1, "-CN/GJ");
  120. PatentStarListDTO.setCurrentQuery(stringBuilder.toString());
  121. }
  122. }
  123. } catch (Exception e) {
  124. return null;
  125. }
  126. JSONObject configObject = this.getConfigObject(4, 1);
  127. String appId = configObject.getString("appId");
  128. String appKey = configObject.getString("appKey");
  129. PatentStarDTO patentStarDto = new PatentStarDTO();
  130. BeanUtils.copyProperties(PatentStarListDTO, patentStarDto);
  131. String json = JSONObject.toJSONString(patentStarDto);
  132. String url = "http://s.patentstar.com.cn/SearchAPI/PatentSearch/ResultGet";
  133. Long currentTimeMillis = System.currentTimeMillis() / 1000;
  134. String Sign = appKey + currentTimeMillis.toString();
  135. String signMd5 = FormatUtil.MD5(Sign);
  136. // 创建一个OkHttpClient对象
  137. OkHttpClient okHttpClient = new OkHttpClient.Builder()
  138. .connectTimeout(60, TimeUnit.SECONDS)
  139. .writeTimeout(60, TimeUnit.SECONDS)
  140. .readTimeout(60, TimeUnit.SECONDS)
  141. .dns(new XDns(100000))
  142. .build();
  143. // 创建一个RequestBody(参数1:数据类型 参数2传递的json串)
  144. FormBody.Builder builder = new FormBody.Builder();
  145. builder.add("AppID", appId);
  146. builder.add("Stamp", currentTimeMillis.toString());
  147. builder.add("Sign", signMd5);
  148. builder.add("QueryJson", json);
  149. FormBody requestBody = builder.build();
  150. // 创建一个请求对象
  151. Request request = new Request.Builder().url(url).post(requestBody).build();
  152. // 发送请求获取响应
  153. try {
  154. Response response = okHttpClient.newCall(request).execute();
  155. // 判断请求是否成功
  156. if (response.isSuccessful()) {
  157. JSONObject jsonObject = JSONObject.parseObject(Objects.requireNonNull(response.body()).string());
  158. if (jsonObject.get("Ret").equals(500) || jsonObject.get("Data") == null) {
  159. return null;
  160. }
  161. JSONObject Data = (JSONObject) jsonObject.get("Data");
  162. List<StarPatentVO> starPatentVOS = JSONArray.parseArray(Data.get("List").toString(), StarPatentVO.class);
  163. Map<String, Object> reMap = new HashMap<>();
  164. reMap.put("size", PatentStarListDTO.getRowCount());
  165. reMap.put("current", PatentStarListDTO.getPageNum());
  166. reMap.put("records", starPatentVOS);
  167. reMap.put("total", Data.get("HitCount"));
  168. return reMap;
  169. }
  170. } catch (IOException e) {
  171. e.printStackTrace();
  172. return null;
  173. }
  174. return null;
  175. }
  176. public List<PatentStarListDTO> getSplitedConditions(PatentStarListDTO patentStarListDTO, int patentNum) throws IOException {
  177. DateTime nowDate = new DateTime();
  178. DateTime date = DateUtils2.formStrToDateTime("1900-01-01");
  179. //超过1万的列表
  180. List<PatentStarListDTO> PatentStarListDTOs = new ArrayList<>();
  181. //返回的列表
  182. List<PatentStarListDTO> reDtos = new ArrayList<>();
  183. patentStarListDTO.setStartTime(date);
  184. patentStarListDTO.setEndTime(nowDate);
  185. String formQuery = patentStarListDTO.getCurrentQuery();
  186. // patentStarListDTO.setOrginCondition(PatentStarApiService.formatQuery(formQuery));
  187. PatentStarListDTOs.add(patentStarListDTO);
  188. while (PatentStarListDTOs.size() > 0) {
  189. PatentStarListDTO dto = PatentStarListDTOs.get(0);
  190. PatentStarListDTOs.remove(dto);
  191. Map<String, Object> map1 = this.patentStarSearchApi(dto);
  192. Integer total1 = Integer.parseInt(map1.get("total").toString());
  193. dto.setTotal(total1);
  194. patentStarListDTO.setFormed(true);
  195. if (total1 > patentNum) {
  196. DateTime startTime1 = dto.getStartTime();
  197. DateTime endTime1 = dto.getEndTime();
  198. List<DateTime> dateTimes = DateUtils2.formStrToDateTime(startTime1, endTime1);
  199. PatentStarListDTO dto1 = new PatentStarListDTO();
  200. BeanUtils.copyProperties(dto, dto1);
  201. dto1.setStartTime(dateTimes.get(0));
  202. dto1.setEndTime(dateTimes.get(1));
  203. this.setConditions(dto1);
  204. PatentStarListDTO dto2 = new PatentStarListDTO();
  205. BeanUtils.copyProperties(dto, dto2);
  206. dto2.setStartTime(dateTimes.get(2));
  207. dto2.setEndTime(dateTimes.get(3));
  208. this.setConditions(dto2);
  209. PatentStarListDTOs.add(dto1);
  210. PatentStarListDTOs.add(dto2);
  211. } else if (total1 != 0) {
  212. reDtos.add(dto);
  213. }
  214. }
  215. return reDtos;
  216. }
  217. public void setConditions(PatentStarListDTO PatentStarListDTO) {
  218. DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMMdd");
  219. String startStr = formatter.print(PatentStarListDTO.getStartTime());
  220. String endStr = formatter.print(PatentStarListDTO.getEndTime());
  221. String cond = "*(" + startStr + ">" + endStr + "/" + "AD)";
  222. Integer len = PatentStarListDTO.getOrginCondition().length();
  223. StringBuilder stringBuilder = new StringBuilder(PatentStarListDTO.getOrginCondition());
  224. stringBuilder.insert(len - 1, cond);
  225. PatentStarListDTO.setCurrentQuery(stringBuilder.toString());
  226. }
  227. /**
  228. * @param appNo
  229. * @return
  230. * @throws IOException
  231. * @author 李仁杰
  232. * 从专利之星获取中国专利著录
  233. */
  234. public String getCnBibApi(String appNo) {
  235. String url = "https://api.patentstar.com.cn/api/Patent/CnBibo/" + appNo;
  236. JSONObject configObject = this.getConfigObject(4, 2);
  237. String appId = configObject.getString("appId");
  238. String appKey = configObject.getString("appKey");
  239. Long currentTimeMillis = System.currentTimeMillis() / 1000;
  240. String Sign = appId + appKey + currentTimeMillis.toString();
  241. String signMd5 = FormatUtil.MD5(Sign);
  242. // 创建一个OkHttpClient对象
  243. OkHttpClient okHttpClient = new OkHttpClient.Builder()
  244. .connectTimeout(60, TimeUnit.SECONDS)
  245. .writeTimeout(60, TimeUnit.SECONDS)
  246. .readTimeout(60, TimeUnit.SECONDS)
  247. .dns(new XDns(100000))
  248. .build();
  249. // 创建一个请求对象
  250. Request request = new Request.Builder().url(url)
  251. .addHeader("_appid", appId)
  252. .addHeader("_timestamp", currentTimeMillis.toString())
  253. .addHeader("_sign", signMd5)
  254. .get().build();
  255. // 发送请求获取响应
  256. try {
  257. Response response = okHttpClient.newCall(request).execute();
  258. // 判断请求是否成功
  259. if (response.isSuccessful()) {
  260. // 打印服务端返回结果
  261. return Objects.requireNonNull(response.body()).string();
  262. }
  263. } catch (IOException e) {
  264. e.printStackTrace();
  265. }
  266. return "{}";
  267. }
  268. /**
  269. * @param
  270. * @return
  271. * @throws IOException
  272. * @author 李仁杰
  273. * 从专利之星获取中国专利摘要附图
  274. */
  275. public String getPictureApi(String appNo) {
  276. String url = "https://api.patentstar.com.cn/api/Patent/CnMainImage/" + appNo;
  277. JSONObject configObject = this.getConfigObject(4, 2);
  278. String appId = configObject.getString("appId");
  279. String appKey = configObject.getString("appKey");
  280. Long currentTimeMillis = System.currentTimeMillis() / 1000;
  281. String Sign = appId + appKey + currentTimeMillis.toString();
  282. String signMd5 = FormatUtil.MD5(Sign);
  283. // 创建一个OkHttpClient对象
  284. OkHttpClient okHttpClient = new OkHttpClient.Builder()
  285. .connectTimeout(60, TimeUnit.SECONDS)
  286. .writeTimeout(60, TimeUnit.SECONDS)
  287. .readTimeout(60, TimeUnit.SECONDS)
  288. .dns(new XDns(100000))
  289. .build();
  290. // 创建一个请求对象
  291. Request request = new Request.Builder().url(url)
  292. .addHeader("_appid", appId)
  293. .addHeader("_timestamp", currentTimeMillis.toString())
  294. .addHeader("_sign", signMd5)
  295. .get().build();
  296. // 发送请求获取响应
  297. try {
  298. Response response = okHttpClient.newCall(request).execute();
  299. // 判断请求是否成功
  300. if (response.isSuccessful() && response.code() == 200) {
  301. // 打印服务端返回结果
  302. return Objects.requireNonNull(response.body()).string();
  303. }
  304. } catch (IOException e) {
  305. e.printStackTrace();
  306. return null;
  307. }
  308. return "{}";
  309. }
  310. /**
  311. * @param appNo
  312. * @return
  313. * @throws IOException
  314. * @author 李仁杰
  315. * 从专利之星获取中国专利外观图
  316. */
  317. public String getWGPictureApi(String appNo) throws IOException {
  318. String url = "https://api.patentstar.com.cn/api/Patent/CnWGImage/" + appNo;
  319. JSONObject configObject = this.getConfigObject(4, 2);
  320. String appId = configObject.getString("appId");
  321. String appKey = configObject.getString("appKey");
  322. Long currentTimeMillis = System.currentTimeMillis() / 1000;
  323. String Sign = appId + appKey + currentTimeMillis.toString();
  324. String signMd5 = FormatUtil.MD5(Sign);
  325. // 创建一个OkHttpClient对象
  326. OkHttpClient okHttpClient = new OkHttpClient.Builder()
  327. .connectTimeout(60, TimeUnit.SECONDS)
  328. .writeTimeout(60, TimeUnit.SECONDS)
  329. .readTimeout(60, TimeUnit.SECONDS)
  330. .dns(new XDns(100000))
  331. .build();
  332. // 创建一个请求对象
  333. Request request = new Request.Builder().url(url)
  334. .addHeader("_appid", appId)
  335. .addHeader("_timestamp", currentTimeMillis.toString())
  336. .addHeader("_sign", signMd5)
  337. .get().build();
  338. // 发送请求获取响应
  339. try {
  340. Response response = okHttpClient.newCall(request).execute();
  341. // 判断请求是否成功
  342. if (response.isSuccessful()) {
  343. // 打印服务端返回结果
  344. return Objects.requireNonNull(response.body()).string();
  345. }
  346. } catch (IOException e) {
  347. e.printStackTrace();
  348. }
  349. return "{}";
  350. }
  351. /**
  352. * @param appNo
  353. * @return
  354. * @throws IOException
  355. * @author 李仁杰
  356. * 从专利之星获取中国专利法律状态
  357. */
  358. public String getCnLegalApi(String appNo) {
  359. String url = "https://api.patentstar.com.cn/api/Patent/CnLegal/" + appNo;
  360. JSONObject configObject = this.getConfigObject(4, 2);
  361. String appId = configObject.getString("appId");
  362. String appKey = configObject.getString("appKey");
  363. Long currentTimeMillis = System.currentTimeMillis() / 1000;
  364. String Sign = appId + appKey + currentTimeMillis.toString();
  365. String signMd5 = FormatUtil.MD5(Sign);
  366. // 创建一个OkHttpClient对象
  367. OkHttpClient okHttpClient = new OkHttpClient.Builder()
  368. .connectTimeout(60, TimeUnit.SECONDS)
  369. .writeTimeout(60, TimeUnit.SECONDS)
  370. .readTimeout(60, TimeUnit.SECONDS)
  371. .dns(new XDns(100000))
  372. .build();
  373. // 创建一个请求对象
  374. Request request = new Request.Builder().url(url)
  375. .addHeader("_appid", appId)
  376. .addHeader("_timestamp", currentTimeMillis.toString())
  377. .addHeader("_sign", signMd5)
  378. .get().build();
  379. // 发送请求获取响应
  380. try {
  381. Response response = okHttpClient.newCall(request).execute();
  382. // 判断请求是否成功
  383. if (response.isSuccessful()) {
  384. // 打印服务端返回结果
  385. return Objects.requireNonNull(response.body()).string();
  386. }
  387. } catch (IOException e) {
  388. e.printStackTrace();
  389. }
  390. return "{}";
  391. }
  392. /**
  393. * @param appNo
  394. * @return
  395. * @throws IOException
  396. * @author 李仁杰
  397. * 从专利之星获取中国专利全文图片
  398. */
  399. public String getCnPdfApi(String appNo) throws IOException {
  400. String url = "https://api.patentstar.com.cn/api/Patent/CnPdf/" + appNo;
  401. JSONObject configObject = this.getConfigObject(4, 2);
  402. String appId = configObject.getString("appId");
  403. String appKey = configObject.getString("appKey");
  404. Long currentTimeMillis = System.currentTimeMillis() / 1000;
  405. String Sign = appId + appKey + currentTimeMillis.toString();
  406. String signMd5 = FormatUtil.MD5(Sign);
  407. // 创建一个OkHttpClient对象
  408. OkHttpClient okHttpClient = new OkHttpClient.Builder()
  409. .connectTimeout(60, TimeUnit.SECONDS)
  410. .writeTimeout(60, TimeUnit.SECONDS)
  411. .readTimeout(60, TimeUnit.SECONDS)
  412. .dns(new XDns(100000))
  413. .build();
  414. // 创建一个请求对象
  415. Request request = new Request.Builder().url(url)
  416. .addHeader("_appid", appId)
  417. .addHeader("_timestamp", currentTimeMillis.toString())
  418. .addHeader("_sign", signMd5)
  419. .get().build();
  420. // 发送请求获取响应
  421. try {
  422. Response response = okHttpClient.newCall(request).execute();
  423. // 判断请求是否成功
  424. if (response.isSuccessful()) {
  425. // 打印服务端返回结果
  426. return Objects.requireNonNull(response.body()).string();
  427. }
  428. } catch (IOException e) {
  429. e.printStackTrace();
  430. }
  431. return "{}";
  432. }
  433. /**
  434. * @param appNo
  435. * @return
  436. * @throws IOException
  437. * @author 李仁杰
  438. * 从专利之星获取中国专利全文文本
  439. */
  440. public String getCnFullXmlApi(String appNo) throws IOException {
  441. String url = "https://api.patentstar.com.cn/api/Patent/CnFullXml/" + appNo;
  442. JSONObject configObject = this.getConfigObject(4, 2);
  443. String appId = configObject.getString("appId");
  444. String appKey = configObject.getString("appKey");
  445. Long currentTimeMillis = System.currentTimeMillis() / 1000;
  446. String Sign = appId + appKey + currentTimeMillis.toString();
  447. String signMd5 = FormatUtil.MD5(Sign);
  448. // 创建一个OkHttpClient对象
  449. OkHttpClient okHttpClient = new OkHttpClient.Builder()
  450. .connectTimeout(60, TimeUnit.SECONDS)
  451. .writeTimeout(60, TimeUnit.SECONDS)
  452. .readTimeout(60, TimeUnit.SECONDS)
  453. .dns(new XDns(100000))
  454. .build();
  455. // 创建一个请求对象
  456. Request request = new Request.Builder().url(url)
  457. .addHeader("_appid", appId)
  458. .addHeader("_timestamp", currentTimeMillis.toString())
  459. .addHeader("_sign", signMd5)
  460. .get().build();
  461. // 发送请求获取响应
  462. try {
  463. Response response = okHttpClient.newCall(request).execute();
  464. // 判断请求是否成功
  465. if (response.isSuccessful()) {
  466. // 打印服务端返回结果
  467. return Objects.requireNonNull(response.body()).string();
  468. }
  469. } catch (IOException e) {
  470. e.printStackTrace();
  471. }
  472. return "{}";
  473. }
  474. //获取说明书文本
  475. public String getFullText(String str) throws DocumentException {
  476. SAXReader reader = new SAXReader();
  477. reader.setEntityResolver(new IgnoreDTDEntityResolver());
  478. Reader stringReader = new StringReader(str);
  479. Document document = reader.read(stringReader);
  480. XPath xpath = document.createXPath("//description//p");
  481. List<Element> elements = (List<Element>) xpath.selectNodes(document);
  482. if (elements.size() == 0) {
  483. xpath = document.createXPath("//business:Description//base:Paragraphs");
  484. elements = (List<Element>) xpath.selectNodes(document);
  485. }
  486. List<String> reStrs = new ArrayList<>();
  487. Integer count = 1;
  488. for (Element item : elements) {
  489. String claim = item.getText().replaceAll("<br/>", "");
  490. if (!claim.trim().equals("技术领域")
  491. && !claim.trim().equals("发明内容")
  492. && !claim.trim().equals("附图说明")
  493. && !claim.trim().equals("具体实施方式")
  494. && !claim.trim().equals("背景技术")) {
  495. String formattedNum = String.format("%04d", count);
  496. claim = "[" + formattedNum + "]" + claim;
  497. count++;
  498. }
  499. reStrs.add(claim);
  500. }
  501. String reStr = "";
  502. if (reStrs.size() != 0) {
  503. reStr = StringUtils.join(reStrs, "\r\n");
  504. }
  505. return reStr;
  506. }
  507. /**
  508. * @param patentNo
  509. * @return
  510. * @throws IOException
  511. * @author 李仁杰
  512. * 从专利之星获取世界专利pdf
  513. */
  514. public String getEnPdfApi(String patentNo) {
  515. String url = " https://api.patentstar.com.cn/api/Patent/EnPdf/" + patentNo;
  516. JSONObject configObject = this.getConfigObject(4, 2);
  517. String appId = configObject.getString("appId");
  518. String appKey = configObject.getString("appKey");
  519. // String appId = "1000046";
  520. // String appkey = "6AE6D4DC6AF94F26862501EDEE9E27A2";
  521. Long currentTimeMillis = System.currentTimeMillis() / 1000;
  522. String Sign = appId + appKey + currentTimeMillis.toString();
  523. String signMd5 = FormatUtil.MD5(Sign);
  524. // 创建一个OkHttpClient对象
  525. OkHttpClient okHttpClient = new OkHttpClient.Builder()
  526. .connectTimeout(60, TimeUnit.SECONDS)
  527. .writeTimeout(60, TimeUnit.SECONDS)
  528. .readTimeout(60, TimeUnit.SECONDS)
  529. .dns(new XDns(100000))
  530. .build();
  531. // 创建一个请求对象
  532. Request request = new Request.Builder().url(url)
  533. .addHeader("_appid", appId)
  534. .addHeader("_timestamp", currentTimeMillis.toString())
  535. .addHeader("_sign", signMd5)
  536. .get().build();
  537. // 发送请求获取响应
  538. try {
  539. Response response = okHttpClient.newCall(request).execute();
  540. // 判断请求是否成功
  541. if (response.isSuccessful()) {
  542. // 打印服务端返回结果
  543. return Objects.requireNonNull(response.body()).string();
  544. }
  545. } catch (IOException e) {
  546. e.printStackTrace();
  547. }
  548. return "{}";
  549. }
  550. /**
  551. * @param patentNo
  552. * @return
  553. * @throws IOException
  554. * @author 李仁杰
  555. * 从专利之星获取世界专利著录信息
  556. */
  557. public String getENBibApi(String patentNo) {
  558. String url = "https://api.patentstar.com.cn/api/Patent/EnBib/" + patentNo;
  559. JSONObject configObject = this.getConfigObject(4, 2);
  560. String appId = configObject.getString("appId");
  561. String appKey = configObject.getString("appKey");
  562. Long currentTimeMillis = System.currentTimeMillis() / 1000;
  563. String Sign = appId + appKey + currentTimeMillis.toString();
  564. String signMd5 = FormatUtil.MD5(Sign);
  565. // 创建一个OkHttpClient对象
  566. OkHttpClient okHttpClient = new OkHttpClient.Builder()
  567. .connectTimeout(60, TimeUnit.SECONDS)
  568. .writeTimeout(60, TimeUnit.SECONDS)
  569. .readTimeout(60, TimeUnit.SECONDS)
  570. .dns(new XDns(100000))
  571. .build();
  572. // 创建一个请求对象
  573. Request request = new Request.Builder().url(url)
  574. .addHeader("_appid", appId)
  575. .addHeader("_timestamp", currentTimeMillis.toString())
  576. .addHeader("_sign", signMd5)
  577. .get().build();
  578. // 发送请求获取响应
  579. try {
  580. Response response = okHttpClient.newCall(request).execute();
  581. // 判断请求是否成功
  582. if (response.isSuccessful()) {
  583. // 打印服务端返回结果
  584. return Objects.requireNonNull(response.body()).string();
  585. }
  586. } catch (IOException e) {
  587. e.printStackTrace();
  588. }
  589. return "{}";
  590. }
  591. /**
  592. * @param patentNo
  593. * @return
  594. * @throws IOException
  595. * @author 李仁杰
  596. * 从专利之星获取同族专利
  597. */
  598. public String getFamilyByPubNoApi(String patentNo) {
  599. String url = "https://api.patentstar.com.cn/api/Patent/FamilyByPubNo/" + patentNo;
  600. JSONObject configObject = this.getConfigObject(4, 2);
  601. String appId = configObject.getString("appId");
  602. String appKey = configObject.getString("appKey");
  603. Long currentTimeMillis = System.currentTimeMillis() / 1000;
  604. String Sign = appId + appKey + currentTimeMillis.toString();
  605. String signMd5 = FormatUtil.MD5(Sign);
  606. // 创建一个OkHttpClient对象
  607. OkHttpClient okHttpClient = new OkHttpClient.Builder()
  608. .connectTimeout(60, TimeUnit.SECONDS)
  609. .writeTimeout(60, TimeUnit.SECONDS)
  610. .readTimeout(60, TimeUnit.SECONDS)
  611. .dns(new XDns(100000))
  612. .build();
  613. // 创建一个请求对象
  614. Request request = new Request.Builder().url(url)
  615. .addHeader("_appid", appId)
  616. .addHeader("_timestamp", currentTimeMillis.toString())
  617. .addHeader("_sign", signMd5)
  618. .get().build();
  619. // 发送请求获取响应
  620. try {
  621. Response response = okHttpClient.newCall(request).execute();
  622. // 判断请求是否成功
  623. if (response.isSuccessful()) {
  624. // 打印服务端返回结果
  625. return Objects.requireNonNull(response.body()).string();
  626. }
  627. } catch (IOException e) {
  628. e.printStackTrace();
  629. }
  630. return "{}";
  631. }
  632. /**
  633. * @param patentNo
  634. * @return
  635. * @throws IOException
  636. * @author 李仁杰
  637. * 获得专利被引用次数api
  638. */
  639. public String getCitedNumByPubNoApi(String patentNo) throws IOException {
  640. String url = "https://api.patentstar.com.cn/api/Patent/CitedNumByPubNo/" + patentNo;
  641. JSONObject configObject = this.getConfigObject(4, 2);
  642. String appId = configObject.getString("appId");
  643. String appKey = configObject.getString("appKey");
  644. Long currentTimeMillis = System.currentTimeMillis() / 1000;
  645. String Sign = appId + appKey + currentTimeMillis.toString();
  646. String signMd5 = FormatUtil.MD5(Sign);
  647. // 创建一个OkHttpClient对象
  648. OkHttpClient okHttpClient = new OkHttpClient.Builder()
  649. .connectTimeout(60, TimeUnit.SECONDS)
  650. .writeTimeout(60, TimeUnit.SECONDS)
  651. .readTimeout(60, TimeUnit.SECONDS)
  652. .dns(new XDns(100000))
  653. .build();
  654. // 创建一个请求对象
  655. Request request = new Request.Builder().url(url)
  656. .addHeader("_appid", appId)
  657. .addHeader("_timestamp", currentTimeMillis.toString())
  658. .addHeader("_sign", signMd5)
  659. .get().build();
  660. // 发送请求获取响应
  661. try {
  662. Response response = okHttpClient.newCall(request).execute();
  663. // 判断请求是否成功
  664. if (response.isSuccessful()) {
  665. // 打印服务端返回结果
  666. return Objects.requireNonNull(response.body()).string();
  667. }
  668. } catch (IOException e) {
  669. e.printStackTrace();
  670. }
  671. return "{}";
  672. }
  673. public JSONObject getConfigObject(Integer webId, Integer webGroup) {
  674. WebLoginConfig webLoginConfig = webLoginConfigService.getConfig(webId, webGroup);
  675. if (webLoginConfig == null) {
  676. return null;
  677. }
  678. String config = webLoginConfig.getWebConfig();
  679. JSONObject jsonObject = JSONObject.parseObject(config);
  680. return jsonObject;
  681. }
  682. public List<PatentStarListDTO> splitPatentNoByType(List<String> originalList, PatentStarListDTO patentStarListDTO) {
  683. List<String> cnStrings = new ArrayList<>();
  684. List<String> wdStrings = new ArrayList<>();
  685. List<List<String>> result = new ArrayList<>();
  686. result.add(cnStrings);
  687. result.add(wdStrings);
  688. // 记录CN类型的字符串数量
  689. int cnCount = 0;
  690. // 记录WD类型的字符串数量
  691. int wdCount = 0;
  692. List<PatentStarListDTO> patentStarListDTOS = new ArrayList<>();
  693. //遍历初始集合
  694. for (String str : originalList) {
  695. if (str.startsWith("CN")) {
  696. cnStrings.add(str);
  697. cnCount++;
  698. if (cnCount >= 100) {
  699. cnStrings = new ArrayList<>();
  700. result.add(cnStrings);
  701. cnCount = 0;
  702. }
  703. } else {
  704. wdStrings.add(str);
  705. wdCount++;
  706. if (wdCount >= 100) {
  707. wdStrings = new ArrayList<>();
  708. result.add(wdStrings);
  709. wdCount = 0;
  710. }
  711. }
  712. }
  713. result.forEach(item -> {
  714. if (item.size() > 0) {
  715. String dbType = "CN";
  716. String patentNo = item.get(0);
  717. if (!patentNo.startsWith("CN")) {
  718. dbType = "WD";
  719. }
  720. String join = StringUtils.join(item, " OR ");
  721. String conditions = "AN=(" + join + ") OR PN=(" + join + ") OR GN=(" + join + ")";
  722. PatentStarListDTO patentStarListDTO1 = new PatentStarListDTO();
  723. patentStarListDTO1.setOrderByType(patentStarListDTO.getOrderByType());
  724. patentStarListDTO1.setCurrentQuery(conditions);
  725. patentStarListDTO1.setPageNum(patentStarListDTO.getPageNum());
  726. patentStarListDTO1.setDBType(dbType);
  727. patentStarListDTO1.setCurrentQuery(conditions);
  728. patentStarListDTO1.setRowCount(50);
  729. patentStarListDTO1.setTotal(item.size());
  730. patentStarListDTOS.add(patentStarListDTO1);
  731. }
  732. });
  733. return patentStarListDTOS;
  734. }
  735. public StarPatentVO getPatentByNo(String patentNo) {
  736. StarPatentVO starPatentVO = null;
  737. String condition = "AN=(" + patentNo + ") OR PN=(" + patentNo + ") OR GN=(" + patentNo + ")";
  738. String dbType = "CN";
  739. if (!patentNo.startsWith("CN")) {
  740. dbType = "WD";
  741. }
  742. PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
  743. patentStarListDTO.setCurrentQuery(condition);
  744. patentStarListDTO.setPageNum(1);
  745. patentStarListDTO.setRowCount(50);
  746. patentStarListDTO.setDBType(dbType);
  747. try {
  748. Map<String, Object> resultMap = this.patentStarSearchApi(patentStarListDTO);
  749. if (resultMap == null || (Integer) resultMap.get("total") == 0) {
  750. return starPatentVO;
  751. }
  752. List<StarPatentVO> starPatents = (List<StarPatentVO>) resultMap.get("records");
  753. starPatentVO = starPatents.get(0);
  754. } catch (Exception e) {
  755. }
  756. return starPatentVO;
  757. }
  758. private List<PatentColumnDTO> loadPatent(List<StarPatentVO> starPatentVOS) {
  759. List<PatentColumnDTO> patentColumnDTOS = new ArrayList<>();
  760. starPatentVOS.forEach(item -> {
  761. PatentColumnDTO patentColumnDTO = new PatentColumnDTO();
  762. //申请号
  763. patentColumnDTO.setAppNo(item.getApplicationNo());
  764. //装载公开号
  765. patentColumnDTO.setPublicNo(item.getPublicNo());
  766. //装载公告号
  767. patentColumnDTO.setGrantNo(item.getPublicAccreditNo());
  768. //装载专利状态
  769. patentColumnDTO.setSimpleStatus(item.getLG().toString());
  770. //装载摘要
  771. List<Text> abstractList = new ArrayList<>();
  772. Text text = new Text();
  773. text.setTextContent(item.getAbstractStr());
  774. text.setIfOrigin(true);
  775. abstractList.add(text);
  776. patentColumnDTO.setAbstractStr(abstractList);
  777. //装载标题
  778. List<Text> titleList = new ArrayList<>();
  779. Text title = new Text();
  780. title.setTextContent(item.getName());
  781. title.setIfOrigin(true);
  782. titleList.add(title);
  783. // text.setLanguage(patent.getAppCountry());
  784. patentColumnDTO.setTitle(titleList);
  785. //装载权利要求
  786. List<Text> claimList = new ArrayList<>();
  787. Text claim = new Text();
  788. claim.setTextContent(item.getClaimStr());
  789. claim.setIfOrigin(true);
  790. claimList.add(claim);
  791. patentColumnDTO.setClaim(claimList);
  792. //装载专利号
  793. if (patentColumnDTO.getAppNo() != null) {
  794. if (patentColumnDTO.getAppNo().trim().startsWith("CN")) {
  795. patentColumnDTO.setPatentNo(patentColumnDTO.getAppNo());
  796. } else {
  797. if (patentColumnDTO.getPublicNo() != null) {
  798. patentColumnDTO.setPatentNo(patentColumnDTO.getPublicNo());
  799. } else if (patentColumnDTO.getGrantNo() != null) {
  800. patentColumnDTO.setPatentNo(patentColumnDTO.getGrantNo());
  801. } else {
  802. patentColumnDTO.setPatentNo(patentColumnDTO.getAppNo());
  803. }
  804. }
  805. }
  806. //装载申请日
  807. if (item.getApplicationDate() != null && !item.getApplicationDate().trim().equals("")) {
  808. patentColumnDTO.setAppDate(DateUtils.strToDate(item.getApplicationDate()));
  809. }
  810. //装载申请人地址
  811. PersonAddress appAddress = new PersonAddress();
  812. appAddress.setAddress(item.getApplicationAddress());
  813. appAddress.setProvince(item.getProvinceStr());
  814. patentColumnDTO.setApplicantAddr(appAddress);
  815. //装载ipc(主)分类号
  816. PatentClassify mipcClassify = new PatentClassify();
  817. mipcClassify.setLevel5(item.getMainIpc());
  818. patentColumnDTO.setMipc(mipcClassify);
  819. //装载ipc分类号
  820. List<PatentClassify> classifies = new ArrayList<>();
  821. String[] split = item.getIpcListStr().split(";");
  822. for (String ipc : split) {
  823. PatentClassify ipcClassify = new PatentClassify();
  824. ipcClassify.setLevel5(ipc);
  825. }
  826. patentColumnDTO.setIpc(classifies);
  827. //获取摘要附图
  828. String pictureApi = this.getPictureApi(item.getRowApplicationNo());
  829. patentColumnDTO.setPictureGuid(pictureApi);
  830. //获取外部专利原始申请号
  831. patentColumnDTO.setRowApplicationNo(item.getRowApplicationNo());
  832. //获取法律状态
  833. String cnLegalApi = this.getCnLegalApi(item.getRowApplicationNo());
  834. patentColumnDTO.setLegalStatus(Arrays.asList(cnLegalApi));
  835. //获取被引用次数
  836. //装载公开日
  837. if (item.getPublicDate() != null && !item.getPublicDate().trim().equals("")) {
  838. patentColumnDTO.setPublicDate(DateUtils.strToDate(item.getPublicDate()));
  839. }
  840. //装载申请人
  841. if (item.getApplicantStr() != null && !item.getApplicantStr().trim().equals("")) {
  842. List<String> names = Arrays.asList(item.getApplicantStr().split(";"));
  843. patentColumnDTO.setApplicant(names);
  844. }
  845. //装载发明人
  846. if (item.getInventorStr() != null && !item.getInventorStr().trim().equals("")) {
  847. List<String> names = Arrays.asList(item.getInventorStr().split(";"));
  848. patentColumnDTO.setInventor(names);
  849. }
  850. //装载权利人
  851. if (item.getCurrentApplicantStr() != null && !item.getCurrentApplicantStr().trim().equals("")) {
  852. List<String> names = Arrays.asList(item.getCurrentApplicantStr().split(";"));
  853. patentColumnDTO.setRightHolder(names);
  854. }
  855. //装载代理人
  856. if (item.getAgentStr() != null && !item.getAgentStr().trim().equals("")) {
  857. List<String> names = Arrays.asList(item.getAgentStr().split(";"));
  858. patentColumnDTO.setAgent(names);
  859. }
  860. //装载代理机构
  861. if (item.getAgencyStr() != null && !item.getAgencyStr() .trim().equals("")) {
  862. patentColumnDTO.setAgency(item.getAgencyStr() );
  863. }
  864. patentColumnDTOS.add(patentColumnDTO);
  865. });
  866. return patentColumnDTOS;
  867. }
  868. /**
  869. * 根据专利号查询外部权利要求
  870. * @param vo
  871. * @return
  872. * @throws IOException
  873. */
  874. public SelectClaimDTO selectClaim(QueryExternalFamilyVO vo) throws IOException {
  875. PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
  876. String condition = "AN=" + vo.getPatentNo();
  877. patentStarListDTO.setCurrentQuery(condition);
  878. patentStarListDTO.setDBType("CN");
  879. patentStarListDTO.setOrderBy("AD");
  880. patentStarListDTO.setOrderByType("DESC");
  881. patentStarListDTO.setPageNum(1);
  882. patentStarListDTO.setRowCount(10);
  883. Records records = this.patentStarSearchLocal(patentStarListDTO);
  884. Object data = records.getData();
  885. String s = JSONArray.toJSONString(data);
  886. List<PatentColumnDTO> list = JSONArray.parseArray(s, PatentColumnDTO.class);
  887. SelectClaimDTO dto = new SelectClaimDTO();
  888. if (!CollectionUtils.isEmpty(list)) {
  889. for (PatentColumnDTO columnDTO : list) {
  890. dto.setClaimContent(columnDTO.getClaim());
  891. }
  892. }
  893. return dto;
  894. }
  895. /**
  896. * 根据专利号查询外部权利要求
  897. * @param vo
  898. * @return
  899. * @throws IOException
  900. */
  901. public PatentColumnDTO queryExternalDetail(QueryExternalFamilyVO vo) throws IOException {
  902. PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
  903. String condition = "AN=" + vo.getPatentNo();
  904. patentStarListDTO.setCurrentQuery(condition);
  905. patentStarListDTO.setDBType("CN");
  906. patentStarListDTO.setOrderBy("AD");
  907. patentStarListDTO.setOrderByType("DESC");
  908. patentStarListDTO.setPageNum(1);
  909. patentStarListDTO.setRowCount(10);
  910. Records records = this.patentStarSearchLocal(patentStarListDTO);
  911. Object data = records.getData();
  912. String s = JSONArray.toJSONString(data);
  913. List<PatentColumnDTO> list = JSONArray.parseArray(s, PatentColumnDTO.class);
  914. PatentColumnDTO dto = new PatentColumnDTO();
  915. if (!CollectionUtils.isEmpty(list)) {
  916. for (PatentColumnDTO columnDTO : list) {
  917. BeanUtils.copyProperties(columnDTO, dto);
  918. }
  919. }
  920. return dto;
  921. }
  922. /**
  923. * 查询外部专利同族专利
  924. * @param vo
  925. * @return
  926. * @throws IOException
  927. */
  928. public Records queryExternalFamily(QueryExternalFamilyVO vo) throws IOException {
  929. Records records = new Records();
  930. String family = this.getFamilyByPubNoApi(vo.getPatentNo());
  931. QueryExternalFamilyDTO familyDTO = JSONObject.parseObject(family, QueryExternalFamilyDTO.class);
  932. String familyInfos = familyDTO.getFamilyinfo();
  933. List<String> publicNos = Arrays.asList(familyInfos.split(";"));
  934. String pubNo = "";
  935. if (!CollectionUtils.isEmpty(publicNos)) {
  936. int count = publicNos.size() - 1;
  937. for (int i = 0; i < publicNos.size(); i++) {
  938. String s = publicNos.get(i);
  939. if (i == count) {
  940. pubNo = pubNo + s;
  941. } else {
  942. pubNo = pubNo + s + " " + "OR" + " ";
  943. }
  944. }
  945. }
  946. if (StringUtils.isNotEmpty(pubNo)) {
  947. PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
  948. String condition = "PN=" + "(" + pubNo + ")";
  949. patentStarListDTO.setCurrentQuery(condition);
  950. patentStarListDTO.setDBType("CN");
  951. patentStarListDTO.setOrderBy("AD");
  952. patentStarListDTO.setOrderByType("DESC");
  953. patentStarListDTO.setPageNum(vo.getPageNum());
  954. patentStarListDTO.setRowCount(vo.getPageSize());
  955. records = this.patentStarSearchLocal(patentStarListDTO);
  956. }
  957. return records;
  958. }
  959. /**
  960. * 获取公开说明书
  961. * @param appNo
  962. * @return
  963. */
  964. public List<Text> getCnFullText(String appNo) {
  965. List<Text> pubTextList = new ArrayList<>();
  966. //获取公开说明书
  967. String cnFullXmlApi = null;
  968. try {
  969. cnFullXmlApi = this.getCnFullXmlApi(appNo);
  970. } catch (IOException e) {
  971. e.printStackTrace();
  972. }
  973. try {
  974. String fullText = this.getFullText(cnFullXmlApi);
  975. Text pubText = new Text();
  976. pubText.setTextContent(fullText);
  977. pubText.setIfOrigin(true);
  978. pubTextList.add(pubText);
  979. } catch (DocumentException e) {
  980. e.printStackTrace();
  981. }
  982. return pubTextList;
  983. }
  984. /**
  985. * 获得中国专利pdf全文
  986. *
  987. * @param appNo
  988. * @return
  989. * @throws IOException
  990. */
  991. public List<InnerPatentPdfDTO> getExternalTextPdf(String appNo, String rowApplicationNo) throws IOException {
  992. List<InnerPatentPdfDTO> list = new ArrayList<>();
  993. String pdfUrl = "", pdfUrl1 = "", pdfUrl2 = "";
  994. if (StringUtils.isNotEmpty(appNo) && appNo.contains("CN")) {
  995. String pdfUrlStr = this.getCnPdfApi(rowApplicationNo);
  996. //若没有取到说明书pdf,则将当前申请号和备注信息存入问题记录表,并返回空对象
  997. if (StringUtils.isNotEmpty(pdfUrlStr)) {
  998. if (pdfUrlStr.contains("|http")) { //若包含公开和授权两个pdf
  999. String[] pdfUrlArr = pdfUrlStr.split("\\|http");
  1000. pdfUrl1 = pdfUrlArr[0].substring(pdfUrlArr[0].indexOf("http"), pdfUrlArr[0].indexOf("|"));
  1001. pdfUrlArr[1] = "http" + pdfUrlArr[1];
  1002. pdfUrl2 = pdfUrlArr[1].substring(pdfUrlArr[1].indexOf("http"), pdfUrlArr[1].indexOf("|"));
  1003. if (pdfUrl1.contains("0A_CN_0.pdf")) {
  1004. String guid1 = FormatUtil.getPDFFormat(appNo, 0);
  1005. if (StringUtils.isNotEmpty(guid1)) {
  1006. InnerPatentPdfDTO dto = new InnerPatentPdfDTO();
  1007. dto.setPdfGuid(guid1);
  1008. dto.setType(0);
  1009. list.add(dto);
  1010. }
  1011. //授权说明书pdf
  1012. String guid2 = FormatUtil.getPDFFormat(appNo, 1);
  1013. if (StringUtils.isNotEmpty(guid2)) {
  1014. InnerPatentPdfDTO dto1 = new InnerPatentPdfDTO();
  1015. dto1.setPdfGuid(guid2);
  1016. dto1.setType(1);
  1017. list.add(dto1);
  1018. }
  1019. } else {
  1020. String guid1 = FormatUtil.getPDFFormat(appNo, 1);
  1021. if (StringUtils.isNotEmpty(guid1)) {
  1022. InnerPatentPdfDTO dto1 = new InnerPatentPdfDTO();
  1023. dto1.setPdfGuid(guid1);
  1024. dto1.setType(1);
  1025. list.add(dto1);
  1026. }
  1027. String guid2 = FormatUtil.getPDFFormat(appNo, 0);
  1028. if (StringUtils.isNotEmpty(guid2)) {
  1029. InnerPatentPdfDTO dto = new InnerPatentPdfDTO();
  1030. dto.setPdfGuid(guid2);
  1031. dto.setType(0);
  1032. list.add(dto);
  1033. }
  1034. }
  1035. } else { //若只有一个
  1036. pdfUrl1 = pdfUrlStr.substring(pdfUrlStr.indexOf("http"));
  1037. // pdfUrl1 = pdfUrlStr.substring(pdfUrlStr.indexOf("http"), pdfUrlStr.indexOf("?"));
  1038. if (pdfUrl1.contains("0A_CN_0.pdf")) {
  1039. String guid1 = FormatUtil.getPDFFormat(appNo, 0);
  1040. if (StringUtils.isNotEmpty(guid1)) {
  1041. InnerPatentPdfDTO dto = new InnerPatentPdfDTO();
  1042. dto.setPdfGuid(guid1);
  1043. dto.setType(0);
  1044. list.add(dto);
  1045. }
  1046. } else {
  1047. String guid1 = FormatUtil.getPDFFormat(appNo, 1);
  1048. if (StringUtils.isNotEmpty(guid1)) {
  1049. InnerPatentPdfDTO dto = new InnerPatentPdfDTO();
  1050. dto.setPdfGuid(guid1);
  1051. dto.setType(1);
  1052. list.add(dto);
  1053. }
  1054. }
  1055. }
  1056. }
  1057. }
  1058. return list;
  1059. }
  1060. /**
  1061. * 获取附图
  1062. * @param appNo
  1063. * @return
  1064. */
  1065. public List<String> getExternalFigure(String appNo) throws IOException {
  1066. List<String> list = new ArrayList<>();
  1067. String wgPictureApi = this.getWGPictureApi(appNo);
  1068. if (StringUtils.isNotEmpty(wgPictureApi)) {
  1069. if (wgPictureApi.contains("|http")) {
  1070. String[] urlArr = wgPictureApi.split("\\|");
  1071. list.addAll(Arrays.asList(urlArr));
  1072. } else {
  1073. list.add(wgPictureApi);
  1074. }
  1075. }
  1076. return list;
  1077. }
  1078. }