123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218 |
- 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, "\r\n");
- }
- 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());
- //装载专利状态
- 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();
- 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();
- patentStarListDTO.setCurrentQuery(condition);
- patentStarListDTO.setDBType("CN");
- 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)) {
- 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;
- }
- }
|