1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261 |
- package cn.cslg.pas.service.common;
- import cn.cslg.pas.common.config.XDns;
- import cn.cslg.pas.common.core.IgnoreDTDEntityResolver;
- import cn.cslg.pas.common.dto.*;
- import cn.cslg.pas.common.dto.business.SelectClaimDTO;
- import cn.cslg.pas.common.model.cronModel.PersonnelVO;
- import cn.cslg.pas.common.model.cronModel.Records;
- import cn.cslg.pas.common.model.importTaskModel.PatentApplicant;
- import cn.cslg.pas.common.utils.*;
- import cn.cslg.pas.common.vo.ContentVO;
- import cn.cslg.pas.common.vo.QueryExternalFamilyVO;
- import cn.cslg.pas.common.vo.StarPatentVO;
- import cn.cslg.pas.common.vo.business.PatentNoVO;
- import cn.cslg.pas.domain.WebLoginConfig;
- import cn.cslg.pas.domain.business.RetrieveRecord;
- import cn.cslg.pas.domain.es.*;
- import cn.cslg.pas.service.WebLoginConfigService;
- import cn.cslg.pas.service.importPatent.ImportFromWebToEsService;
- import cn.cslg.pas.service.query.FormatQueryService;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import lombok.RequiredArgsConstructor;
- import lombok.experimental.Accessors;
- import lombok.extern.slf4j.Slf4j;
- import okhttp3.FormBody;
- import okhttp3.OkHttpClient;
- import okhttp3.Request;
- import okhttp3.Response;
- import org.dom4j.Document;
- import org.dom4j.DocumentException;
- import org.dom4j.Element;
- import org.dom4j.XPath;
- import org.dom4j.io.SAXReader;
- 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.beans.factory.annotation.Autowired;
- import org.springframework.context.ApplicationContext;
- import org.springframework.stereotype.Service;
- import org.springframework.util.CollectionUtils;
- import java.io.File;
- import java.io.IOException;
- import java.io.Reader;
- import java.io.StringReader;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.*;
- import java.util.concurrent.TimeUnit;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- import java.util.stream.Collectors;
- /**
- * 调用外部接口的Service类 PCS:权限系统
- *
- * @Author chenyu
- * @Date 2023/4/25
- */
- @RequiredArgsConstructor
- @Slf4j
- @Service
- public class PatentStarApiService {
- private ApplicationContext applicationContext;
- private PatentStarApiService patentStarApiService;
- @Autowired
- private RetrieveRecordService retrieveRecordService;
- @Autowired
- private CacheUtils cacheUtils;
- @Autowired
- private LoginUtils loginUtils;
- @Autowired
- private WebLoginConfigService webLoginConfigService;
- @Autowired
- private FormatQueryService formatQueryService;
- public Records 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();
- // }
- List<StarPatentVO> starPatentVOS = (List<StarPatentVO>) map.get("records");
- //装载starPatentVOS到 PatentColumnDTO
- Records records = new Records();
- records.setRetrieveRecordId(retrieveRecord.getId());
- records.setCurrent(Long.parseLong(map.get("current").toString()));
- records.setSize(Long.parseLong(map.get("size").toString()));
- records.setData(this.loadPatent(starPatentVOS));
- records.setTotal(Long.parseLong(map.get("total").toString()));
- return records;
- }
- public Map<String, Object> patentStarSearchApi(PatentStarListDTO PatentStarListDTO) throws IOException {
- try {
- if (PatentStarListDTO.getFormed() == null || PatentStarListDTO.getFormed() == false) {
- String formQuery = PatentStarListDTO.getCurrentQuery();
- PatentStarListDTO.setCurrentQuery(formatQueryService.reQuery(formQuery, "webSearchConfig"));
- 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);
- 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() && response.code() == 200) {
- // 打印服务端返回结果
- 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 "{}";
- }
- //获取权利要求文本
- public String getExternalClaim(String str) throws DocumentException {
- SAXReader reader = new SAXReader();
- reader.setEntityResolver(new IgnoreDTDEntityResolver());
- Reader stringReader = new StringReader(str);
- Document document = reader.read(stringReader);
- XPath xpath = document.createXPath("//claim-text");
- List<Element> element = (List<Element>) xpath.selectNodes(document);
- if (element.size() == 0) {
- xpath = document.createXPath("//business:ClaimText");
- element = (List<Element>) xpath.selectNodes(document);
- }
- List<String> reClaims = new ArrayList<>();
- element.forEach(item -> {
- String claim = item.getText();
- claim = claim.replaceAll("\r\n|\r|\n| ", "");
- reClaims.add(claim);
- });
- String reClaim = "";
- if (reClaims.size() != 0) {
- reClaim = cn.cslg.pas.common.utils.StringUtils.join(reClaims, "");
- }
- return reClaim;
- }
- //获取说明书文本
- public String getFullText(String str) throws DocumentException {
- SAXReader reader = new SAXReader();
- reader.setEntityResolver(new IgnoreDTDEntityResolver());
- Reader stringReader = new StringReader(str);
- Document document = reader.read(stringReader);
- XPath xpath = document.createXPath("//description//p");
- List<Element> elements = (List<Element>) xpath.selectNodes(document);
- if (elements.size() == 0) {
- xpath = document.createXPath("//business:Description//base:Paragraphs");
- elements = (List<Element>) xpath.selectNodes(document);
- }
- List<String> reStrs = new ArrayList<>();
- Integer count = 1;
- for (Element item : elements) {
- String claim = item.getText().replaceAll("<br/>", "");
- if (!claim.trim().equals("技术领域")
- && !claim.trim().equals("发明内容")
- && !claim.trim().equals("附图说明")
- && !claim.trim().equals("具体实施方式")
- && !claim.trim().equals("背景技术")) {
- String formattedNum = String.format("%04d", count);
- claim = "[" + formattedNum + "]" + claim;
- count++;
- }
- reStrs.add(claim);
- }
- String reStr = "";
- if (reStrs.size() != 0) {
- reStr = StringUtils.join(reStrs, "\r\n");
- }
- return reStr;
- }
- /**
- * @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;
- }
- public List<PatentStarListDTO> splitPatentNoByType(List<String> originalList, PatentStarListDTO patentStarListDTO) {
- List<String> cnStrings = new ArrayList<>();
- List<String> wdStrings = new ArrayList<>();
- List<List<String>> result = new ArrayList<>();
- result.add(cnStrings);
- result.add(wdStrings);
- // 记录CN类型的字符串数量
- int cnCount = 0;
- // 记录WD类型的字符串数量
- int wdCount = 0;
- List<PatentStarListDTO> patentStarListDTOS = new ArrayList<>();
- //遍历初始集合
- for (String str : originalList) {
- if (str.startsWith("CN")) {
- cnStrings.add(str);
- cnCount++;
- if (cnCount >= 100) {
- cnStrings = new ArrayList<>();
- result.add(cnStrings);
- cnCount = 0;
- }
- } else {
- wdStrings.add(str);
- wdCount++;
- if (wdCount >= 100) {
- wdStrings = new ArrayList<>();
- result.add(wdStrings);
- wdCount = 0;
- }
- }
- }
- result.forEach(item -> {
- if (item.size() > 0) {
- String dbType = "CN";
- String patentNo = item.get(0);
- if (!patentNo.startsWith("CN")) {
- dbType = "WD";
- }
- String join = StringUtils.join(item, " OR ");
- String conditions = "AN=(" + join + ") OR PN=(" + join + ") OR GN=(" + join + ")";
- PatentStarListDTO patentStarListDTO1 = new PatentStarListDTO();
- patentStarListDTO1.setOrderByType(patentStarListDTO.getOrderByType());
- patentStarListDTO1.setCurrentQuery(conditions);
- patentStarListDTO1.setPageNum(patentStarListDTO.getPageNum());
- patentStarListDTO1.setDBType(dbType);
- patentStarListDTO1.setCurrentQuery(conditions);
- patentStarListDTO1.setRowCount(50);
- patentStarListDTO1.setTotal(item.size());
- patentStarListDTOS.add(patentStarListDTO1);
- }
- });
- return patentStarListDTOS;
- }
- public StarPatentVO getPatentByNo(String patentNo) {
- StarPatentVO starPatentVO = null;
- String condition = "AN=(" + patentNo + ") OR PN=(" + patentNo + ") OR GN=(" + patentNo + ")";
- String dbType = "CN";
- if (!patentNo.startsWith("CN")) {
- dbType = "WD";
- }
- PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
- patentStarListDTO.setCurrentQuery(condition);
- patentStarListDTO.setPageNum(1);
- patentStarListDTO.setRowCount(50);
- patentStarListDTO.setDBType(dbType);
- try {
- Map<String, Object> resultMap = this.patentStarSearchApi(patentStarListDTO);
- if (resultMap == null || (Integer) resultMap.get("total") == 0) {
- return starPatentVO;
- }
- List<StarPatentVO> starPatents = (List<StarPatentVO>) resultMap.get("records");
- starPatentVO = starPatents.get(0);
- } catch (Exception e) {
- }
- return starPatentVO;
- }
- private List<PatentColumnDTO> loadPatent(List<StarPatentVO> starPatentVOS) {
- List<PatentColumnDTO> patentColumnDTOS = new ArrayList<>();
- starPatentVOS.forEach(item -> {
- PatentColumnDTO patentColumnDTO = new PatentColumnDTO();
- //申请号
- patentColumnDTO.setAppNo(item.getApplicationNo());
- //装载公开号
- patentColumnDTO.setPublicNo(item.getPublicNo());
- //装载公告号
- patentColumnDTO.setGrantNo(item.getPublicAccreditNo());
- //装载专利状态
- if (item.getLG() != null) {
- patentColumnDTO.setSimpleStatus(item.getLG().toString());
- }
- //装载摘要
- List<Text> abstractList = new ArrayList<>();
- Text text = new Text();
- text.setTextContent(item.getAbstractStr());
- text.setIfOrigin(true);
- abstractList.add(text);
- patentColumnDTO.setAbstractStr(abstractList);
- //装载标题
- List<Text> titleList = new ArrayList<>();
- Text title = new Text();
- title.setTextContent(item.getName());
- title.setIfOrigin(true);
- titleList.add(title);
- // text.setLanguage(patent.getAppCountry());
- patentColumnDTO.setTitle(titleList);
- //装载权利要求
- List<Text> claimList = new ArrayList<>();
- Text claim = new Text();
- claim.setTextContent(item.getClaimStr());
- claim.setIfOrigin(true);
- claimList.add(claim);
- patentColumnDTO.setClaim(claimList);
- //装载专利号
- if (patentColumnDTO.getAppNo() != null) {
- if (patentColumnDTO.getAppNo().trim().startsWith("CN")) {
- patentColumnDTO.setPatentNo(patentColumnDTO.getAppNo());
- } else {
- if (patentColumnDTO.getPublicNo() != null) {
- patentColumnDTO.setPatentNo(patentColumnDTO.getPublicNo());
- } else if (patentColumnDTO.getGrantNo() != null) {
- patentColumnDTO.setPatentNo(patentColumnDTO.getGrantNo());
- } else {
- patentColumnDTO.setPatentNo(patentColumnDTO.getAppNo());
- }
- }
- }
- //装载申请日
- if (item.getApplicationDate() != null && !item.getApplicationDate().trim().equals("")) {
- patentColumnDTO.setAppDate(DateUtils.strToDate(item.getApplicationDate()));
- }
- //装载申请人地址
- PersonAddress appAddress = new PersonAddress();
- appAddress.setAddress(item.getApplicationAddress());
- appAddress.setProvince(item.getProvinceStr());
- patentColumnDTO.setApplicantAddr(appAddress);
- //装载ipc(主)分类号
- PatentClassify mipcClassify = new PatentClassify();
- mipcClassify.setLevel5(item.getMainIpc());
- patentColumnDTO.setMipc(mipcClassify);
- //装载ipc分类号
- List<PatentClassify> classifies = new ArrayList<>();
- String[] split = item.getIpcListStr().split(";");
- for (String ipc : split) {
- PatentClassify ipcClassify = new PatentClassify();
- ipcClassify.setLevel5(ipc);
- }
- patentColumnDTO.setIpc(classifies);
- //获取摘要附图
- // String pictureApi = this.getPictureApi(item.getRowApplicationNo());
- // patentColumnDTO.setPictureGuid(pictureApi);
- //获取外部专利原始申请号
- patentColumnDTO.setRowApplicationNo(item.getRowApplicationNo());
- //获取法律状态
- // String cnLegalApi = this.getCnLegalApi(item.getRowApplicationNo());
- // patentColumnDTO.setLegalStatus(Arrays.asList(cnLegalApi));
- //获取被引用次数
- //装载公开日
- if (item.getPublicDate() != null && !item.getPublicDate().trim().equals("")) {
- patentColumnDTO.setPublicDate(DateUtils.strToDate(item.getPublicDate()));
- }
- //装载申请人
- if (item.getApplicantStr() != null && !item.getApplicantStr().trim().equals("")) {
- List<String> names = Arrays.asList(item.getApplicantStr().split(";"));
- patentColumnDTO.setApplicant(names);
- }
- //装载发明人
- if (item.getInventorStr() != null && !item.getInventorStr().trim().equals("")) {
- List<String> names = Arrays.asList(item.getInventorStr().split(";"));
- patentColumnDTO.setInventor(names);
- }
- //装载权利人
- if (item.getCurrentApplicantStr() != null && !item.getCurrentApplicantStr().trim().equals("")) {
- List<String> names = Arrays.asList(item.getCurrentApplicantStr().split(";"));
- patentColumnDTO.setRightHolder(names);
- }
- //装载代理人
- if (item.getAgentStr() != null && !item.getAgentStr().trim().equals("")) {
- List<String> names = Arrays.asList(item.getAgentStr().split(";"));
- patentColumnDTO.setAgent(names);
- }
- //装载代理机构
- if (item.getAgencyStr() != null && !item.getAgencyStr().trim().equals("")) {
- patentColumnDTO.setAgency(item.getAgencyStr());
- }
- patentColumnDTOS.add(patentColumnDTO);
- });
- return patentColumnDTOS;
- }
- /**
- * 根据专利号查询外部权利要求
- *
- * @param appNo
- * @return
- * @throws IOException
- */
- public SelectClaimDTO queryExternalClaim(String appNo) throws IOException {
- List<Text> claimList = new ArrayList<>();
- //获取公开说明书
- String cnFullXmlApi = null;
- try {
- cnFullXmlApi = this.getCnFullXmlApi(appNo);
- } catch (IOException e) {
- e.printStackTrace();
- }
- try {
- String fullText = this.getExternalClaim(cnFullXmlApi);
- Text pubText = new Text();
- if (fullText != null && !fullText.trim().equals("")) {
- fullText = PatentRightUtils.getFormatClaim(fullText, "CN");
- }
- pubText.setTextContent(fullText);
- pubText.setIfOrigin(true);
- claimList.add(pubText);
- } catch (DocumentException e) {
- e.printStackTrace();
- }
- SelectClaimDTO dto = new SelectClaimDTO();
- if (!CollectionUtils.isEmpty(claimList)) {
- dto.setClaimContent(claimList);
- }
- return dto;
- }
- /**
- * 根据专利号查询外部权利要求
- *
- * @param vo
- * @return
- * @throws IOException
- */
- public PatentColumnDTO queryExternalDetail(QueryExternalFamilyVO vo) throws IOException {
- PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
- String condition = "AN=" + vo.getPatentNo() + " OR " + "PN=" + vo.getPatentNo();
- patentStarListDTO.setCurrentQuery(condition);
- String index = vo.getPatentNo().substring(0, 2);
- if (index.equals("CN")) {
- patentStarListDTO.setDBType("CN");
- } else {
- patentStarListDTO.setDBType("WD");
- }
- patentStarListDTO.setOrderBy("AD");
- patentStarListDTO.setOrderByType("DESC");
- patentStarListDTO.setPageNum(1);
- patentStarListDTO.setRowCount(10);
- Records records = this.patentStarSearchLocal(patentStarListDTO);
- Object data = records.getData();
- String s = JSONArray.toJSONString(data);
- List<PatentColumnDTO> list = JSONArray.parseArray(s, PatentColumnDTO.class);
- PatentColumnDTO dto = new PatentColumnDTO();
- if (!CollectionUtils.isEmpty(list)) {
- for (PatentColumnDTO columnDTO : list) {
- BeanUtils.copyProperties(columnDTO, dto);
- }
- }
- return dto;
- }
- /**
- * 查询外部专利同族专利
- *
- * @param vo
- * @return
- * @throws IOException
- */
- public Records queryExternalFamily(QueryExternalFamilyVO vo) throws IOException {
- Records records = new Records();
- String family = this.getFamilyByPubNoApi(vo.getPatentNo());
- QueryExternalFamilyDTO familyDTO = JSONObject.parseObject(family, QueryExternalFamilyDTO.class);
- String familyInfos = familyDTO.getFamilyinfo();
- List<String> publicNos = new ArrayList<>();
- if (StringUtils.isNotEmpty(familyInfos) && familyInfos.equals("{}")) {
- publicNos = Arrays.asList(familyInfos.split(";"));
- }
- String pubNo = "";
- if (!CollectionUtils.isEmpty(publicNos)) {
- int count = publicNos.size() - 1;
- for (int i = 0; i < publicNos.size(); i++) {
- String s = publicNos.get(i);
- if (i == count) {
- pubNo = pubNo + s;
- } else {
- pubNo = pubNo + s + " " + "OR" + " ";
- }
- }
- }
- if (StringUtils.isNotEmpty(pubNo)) {
- PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
- String condition = "PN=" + "(" + pubNo + ")";
- patentStarListDTO.setCurrentQuery(condition);
- patentStarListDTO.setDBType("CN");
- patentStarListDTO.setOrderBy("AD");
- patentStarListDTO.setOrderByType("DESC");
- patentStarListDTO.setPageNum(vo.getPageNum());
- patentStarListDTO.setRowCount(vo.getPageSize());
- records = this.patentStarSearchLocal(patentStarListDTO);
- }
- return records;
- }
- /**
- * 获取公开说明书
- *
- * @param appNo
- * @return
- */
- public List<Text> getCnFullText(String appNo) {
- List<Text> pubTextList = new ArrayList<>();
- //获取公开说明书
- String cnFullXmlApi = null;
- try {
- cnFullXmlApi = this.getCnFullXmlApi(appNo);
- } catch (IOException e) {
- e.printStackTrace();
- }
- try {
- String fullText = this.getFullText(cnFullXmlApi);
- Text pubText = new Text();
- pubText.setTextContent(fullText);
- pubText.setIfOrigin(true);
- pubTextList.add(pubText);
- } catch (DocumentException e) {
- e.printStackTrace();
- }
- return pubTextList;
- }
- /**
- * 获得中国专利pdf全文
- *
- * @param appNo
- * @return
- * @throws IOException
- */
- public List<InnerPatentPdfDTO> getExternalTextPdf(String appNo, String rowApplicationNo) throws IOException {
- List<InnerPatentPdfDTO> list = new ArrayList<>();
- String pdfUrl = "", pdfUrl1 = "", pdfUrl2 = "";
- if (StringUtils.isNotEmpty(appNo) && appNo.contains("CN")) {
- String pdfUrlStr = this.getCnPdfApi(rowApplicationNo);
- //若没有取到说明书pdf,则将当前申请号和备注信息存入问题记录表,并返回空对象
- if (StringUtils.isNotEmpty(pdfUrlStr)) {
- if (pdfUrlStr.contains("|http")) { //若包含公开和授权两个pdf
- String[] pdfUrlArr = pdfUrlStr.split("\\|http");
- pdfUrl1 = pdfUrlArr[0].substring(pdfUrlArr[0].indexOf("http"), pdfUrlArr[0].indexOf("|"));
- pdfUrlArr[1] = "http" + pdfUrlArr[1];
- pdfUrl2 = pdfUrlArr[1].substring(pdfUrlArr[1].indexOf("http"), pdfUrlArr[1].indexOf("|"));
- if (pdfUrl1.contains("0A_CN_0.pdf")) {
- String guid1 = FormatUtil.getPDFFormat(appNo, 0);
- if (StringUtils.isNotEmpty(guid1)) {
- InnerPatentPdfDTO dto = new InnerPatentPdfDTO();
- dto.setPdfGuid(guid1);
- dto.setType(0);
- list.add(dto);
- }
- //授权说明书pdf
- String guid2 = FormatUtil.getPDFFormat(appNo, 1);
- if (StringUtils.isNotEmpty(guid2)) {
- InnerPatentPdfDTO dto1 = new InnerPatentPdfDTO();
- dto1.setPdfGuid(guid2);
- dto1.setType(1);
- list.add(dto1);
- }
- } else {
- String guid1 = FormatUtil.getPDFFormat(appNo, 1);
- if (StringUtils.isNotEmpty(guid1)) {
- InnerPatentPdfDTO dto1 = new InnerPatentPdfDTO();
- dto1.setPdfGuid(guid1);
- dto1.setType(1);
- list.add(dto1);
- }
- String guid2 = FormatUtil.getPDFFormat(appNo, 0);
- if (StringUtils.isNotEmpty(guid2)) {
- InnerPatentPdfDTO dto = new InnerPatentPdfDTO();
- dto.setPdfGuid(guid2);
- dto.setType(0);
- list.add(dto);
- }
- }
- } else { //若只有一个
- pdfUrl1 = pdfUrlStr.substring(pdfUrlStr.indexOf("http"));
- // pdfUrl1 = pdfUrlStr.substring(pdfUrlStr.indexOf("http"), pdfUrlStr.indexOf("?"));
- if (pdfUrl1.contains("0A_CN_0.pdf")) {
- String guid1 = FormatUtil.getPDFFormat(appNo, 0);
- if (StringUtils.isNotEmpty(guid1)) {
- InnerPatentPdfDTO dto = new InnerPatentPdfDTO();
- dto.setPdfGuid(guid1);
- dto.setType(0);
- list.add(dto);
- }
- } else {
- String guid1 = FormatUtil.getPDFFormat(appNo, 1);
- if (StringUtils.isNotEmpty(guid1)) {
- InnerPatentPdfDTO dto = new InnerPatentPdfDTO();
- dto.setPdfGuid(guid1);
- dto.setType(1);
- list.add(dto);
- }
- }
- }
- }
- }
- return list;
- }
- /**
- * 获取附图
- *
- * @param appNo
- * @return
- */
- public List<String> getExternalFigure(String appNo) throws IOException {
- List<String> list = new ArrayList<>();
- String wgPictureApi = this.getWGPictureApi(appNo);
- if (StringUtils.isNotEmpty(wgPictureApi)) {
- if (wgPictureApi.contains("|http")) {
- String[] urlArr = wgPictureApi.split("\\|");
- list.addAll(Arrays.asList(urlArr));
- } else {
- list.add(wgPictureApi);
- }
- }
- return list;
- }
- /**
- * 获取摘要附图
- *
- * @param appNo
- * @return
- */
- public String getPictureGuid(String appNo) {
- return this.getPictureApi(appNo);
- }
- /**
- * @param appNo
- * @return
- */
- public ExternalLegalInfoDTO getLegalStatus(String appNo) throws ParseException {
- ExternalLegalInfoDTO infoDTO = new ExternalLegalInfoDTO();
- List<String> list = new ArrayList<>();
- List<LegalEvent> legalEvents = new ArrayList<>();
- String cnLegalApi = this.getCnLegalApi(appNo);
- if (StringUtils.isNotEmpty(cnLegalApi) && !cnLegalApi.equals("{}") && !cnLegalApi.contains("408")) {
- List<ExternalLegalStatusDTO> statusDTOS = JSONArray.parseArray(cnLegalApi, ExternalLegalStatusDTO.class);
- if (!CollectionUtils.isEmpty(statusDTOS)) {
- List<ExternalLegalStatusDTO> statusList = statusDTOS.stream().sorted(Comparator.comparing(ExternalLegalStatusDTO::getLegalDate).reversed()).collect(Collectors.toList());
- if (!CollectionUtils.isEmpty(statusList)) {
- ExternalLegalStatusDTO statusDTO = statusList.get(0);
- list.add(statusDTO.getLegalStatus());
- }
- for (ExternalLegalStatusDTO dto : statusDTOS) {
- LegalEvent event = new LegalEvent();
- event.setCode(dto.getLegalCode());
- event.setName(dto.getLegalStatus());
- event.setDescription(dto.getLegalStatusInfo());
- if (StringUtils.isNotEmpty(dto.getLegalDate())) {
- SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
- Date date = format.parse(dto.getLegalDate());
- event.setEventDate(date);
- }
- legalEvents.add(event);
- }
- }
- }
- infoDTO.setLegalStatus(list);
- infoDTO.setLegalEvents(legalEvents);
- return infoDTO;
- }
- public SelectClaimDTO getOrginCalim(String appNo) throws IOException {
- List<Text> claimList = new ArrayList<>();
- //获取公开说明书
- String cnFullXmlApi = null;
- try {
- cnFullXmlApi = this.getCnFullXmlApi(appNo);
- } catch (IOException e) {
- e.printStackTrace();
- }
- try {
- String fullText = this.getExternalClaim(cnFullXmlApi);
- Text pubText = new Text();
- pubText.setTextContent(fullText);
- pubText.setIfOrigin(true);
- claimList.add(pubText);
- } catch (DocumentException e) {
- e.printStackTrace();
- }
- SelectClaimDTO dto = new SelectClaimDTO();
- if (!CollectionUtils.isEmpty(claimList)) {
- dto.setClaimContent(claimList);
- }
- return dto;
- }
- }
|