|
@@ -1,36 +1,24 @@
|
|
|
package cn.cslg.pas.service.upLoadPatent;
|
|
|
|
|
|
-import cn.cslg.pas.common.model.PatentCell;
|
|
|
-import cn.cslg.pas.common.model.dto.*;
|
|
|
+import cn.cslg.pas.common.model.outApi.PatentStarListDto;
|
|
|
import cn.cslg.pas.common.model.vo.UploadParamsVO;
|
|
|
-import cn.cslg.pas.common.utils.FileUtils;
|
|
|
-import cn.cslg.pas.common.utils.StringUtils;
|
|
|
-import cn.cslg.pas.common.utils.ThrowException;
|
|
|
+import cn.cslg.pas.common.model.vo.outApi.StarPatentVO;
|
|
|
import cn.cslg.pas.domain.*;
|
|
|
import cn.cslg.pas.domain.asso.AssoOsTaskQrtzTask;
|
|
|
-import cn.cslg.pas.exception.XiaoShiException;
|
|
|
-import cn.cslg.pas.service.*;
|
|
|
import cn.cslg.pas.service.asso.AssoOsTaskQrtzTaskService;
|
|
|
+import cn.cslg.pas.service.outApi.PatentStarApiService;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.spire.pdf.FileFormat;
|
|
|
-import com.spire.pdf.PdfDocument;
|
|
|
-import com.spire.pdf.PdfDocumentBase;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.fileupload.FileItem;
|
|
|
-import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
-import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
|
|
|
-import java.io.*;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 专利之星类型任务解析获取专利类
|
|
@@ -42,15 +30,8 @@ import java.util.List;
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
- private final FileUtils fileUtils;
|
|
|
- private final PantentQueueService pantentQueueService;
|
|
|
private final AssoOsTaskQrtzTaskService assoOsTaskQrtzTaskService;
|
|
|
- private final OutInterfaceService outInterfaceService;
|
|
|
- private final PatentInstructionService patentInstructionService;
|
|
|
- private final PatentAgencyService patentAgencyService;
|
|
|
- private final PatentAffairService patentAffairService;
|
|
|
- private final ProjectPatentLinkService projectPatentLinkService;
|
|
|
- private final PatentService patentService;
|
|
|
+ private final PatentStarApiService patentStarApiService;
|
|
|
|
|
|
/**
|
|
|
* 解析获取专利数据
|
|
@@ -60,11 +41,11 @@ public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
*/
|
|
|
@Override
|
|
|
public void startExcute(Task task) throws IOException {
|
|
|
- Integer taskId = task.getId();
|
|
|
- List<AssoOsTaskQrtzTask> assoOsTaskQrtzTasks = assoOsTaskQrtzTaskService.list(new LambdaQueryWrapper<AssoOsTaskQrtzTask>().eq(AssoOsTaskQrtzTask::getTaskId, taskId));
|
|
|
+ //从任务关联网站导入任务表中取出当前任务
|
|
|
+ List<AssoOsTaskQrtzTask> assoOsTaskQrtzTasks = assoOsTaskQrtzTaskService.list(new LambdaQueryWrapper<AssoOsTaskQrtzTask>().eq(AssoOsTaskQrtzTask::getTaskId, task.getId()));
|
|
|
AssoOsTaskQrtzTask assoOsTaskQrtzTask = assoOsTaskQrtzTasks.get(0);
|
|
|
|
|
|
- //从任务关联网站导入任务对象中取出下载字段、检索信息
|
|
|
+ //从任务数据中获取下载字段、检索式
|
|
|
String cellsStr = assoOsTaskQrtzTask.getConfigCells();
|
|
|
List<String> cells = Arrays.asList(cellsStr.split(","));
|
|
|
String conditions = assoOsTaskQrtzTask.getConditions();
|
|
@@ -75,487 +56,146 @@ public class ExcutePatentDataStar implements IExcutePatentData {
|
|
|
//获得专利总数量
|
|
|
Integer count = task.getTotal();
|
|
|
|
|
|
+ ArrayList<UploadParamsVO> uploadParamsVOs = new ArrayList<>();
|
|
|
//1.根据专利总数量count遍历检索专利
|
|
|
for (int i = 1; i <= count; i += size) {
|
|
|
- //根据检索式conditions、专利开始数i、专利最后数i + size - 1检索专利著录信息
|
|
|
- SerachBiblioData serachBiblioData = getSerachBiblioData(conditions, i, i + size - 1);
|
|
|
- //获取检索结果中的所有专利著录信息
|
|
|
- if (serachBiblioData == null || serachBiblioData.getTotals() == 0) {
|
|
|
+ PatentStarListDto patentStarListDto = new PatentStarListDto()
|
|
|
+ .setCurrentQuery(conditions)
|
|
|
+ .setOrderBy("AD")
|
|
|
+ .setOrderByType("DESC")
|
|
|
+ .setPageNum(1)
|
|
|
+ .setRowCount(size)
|
|
|
+ .setDBType("cN");
|
|
|
+ //调用一般接口
|
|
|
+ Map<String, Object> resultMap = patentStarApiService.patentStarSearchApi(patentStarListDto);
|
|
|
+ if (resultMap == null || (Integer) resultMap.get("total") == 0) {
|
|
|
continue;
|
|
|
}
|
|
|
- List<PatentZhuLu> patents = serachBiblioData.getPatents();
|
|
|
- //2.遍历专利
|
|
|
- for (PatentZhuLu patent : patents) {
|
|
|
- PatentCell patentCell = new PatentCell();
|
|
|
- patentCell.setProjectId(task.getProjectId());
|
|
|
- PubNo pubNO = new PubNo();
|
|
|
+ //调用一般接口返回专利相关数据
|
|
|
+ List<StarPatentVO> patents = (List<StarPatentVO>) resultMap.get("records");
|
|
|
+
|
|
|
+ //遍历50个专利
|
|
|
+ for (StarPatentVO starPatent : patents) {
|
|
|
+ UploadParamsVO uploadParamsVO = new UploadParamsVO();
|
|
|
+ Patent patent = new Patent();
|
|
|
//装载专利著录
|
|
|
if (cells.contains("1")) {
|
|
|
- setPatentZhuLu(patentCell, patent, pubNO);
|
|
|
- }
|
|
|
- //装载权要
|
|
|
- if (cells.contains("2")) {
|
|
|
- setPatentClaim(patentCell, pubNO);
|
|
|
+ setPatentZhuLu(uploadParamsVO, patent, starPatent);
|
|
|
}
|
|
|
- //装载说明书文本
|
|
|
- if (cells.contains("3")) {
|
|
|
- setPatentInstructionText(patentCell, pubNO);
|
|
|
- }
|
|
|
-
|
|
|
- //以下代码是在准备一会要调用拿取各种附图的接口所需的参数(FullDocument->说明书pdf、Drawing->其他附图、FirstPageClipping->摘要附图)
|
|
|
- String fullDocumentLink = "", fullDocumentType = "", drawingLink = "", drawingType = "", firstPageClippingLink = "", firstPageClippingType = "";
|
|
|
- Integer fullDocumentPage = 0, drawingPage = 0, firstPageClippingPage = 0;
|
|
|
- //根据当前专利号调用接口获取一会调用拿取各种附图的接口的参数
|
|
|
- try {
|
|
|
- ImageInfo imageInfo = getImage(pubNO);
|
|
|
- for (Image image : imageInfo.getImages()) {
|
|
|
- //如果附件类型是说明书
|
|
|
- if (image.getImageType().equals("FullDocument")) {
|
|
|
- fullDocumentLink = image.getUrlLink();
|
|
|
- fullDocumentPage = image.getNumberOfPages();
|
|
|
- for (String formatOption : image.getFormatOptions()) {
|
|
|
- if (formatOption.contains("pdf")) {
|
|
|
- fullDocumentType = formatOption;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //如果附件类型是其他附件
|
|
|
- if (image.getImageType().equals("Drawing")) {
|
|
|
- drawingLink = image.getUrlLink();
|
|
|
- drawingPage = image.getNumberOfPages();
|
|
|
- for (String formatOption : image.getFormatOptions()) {
|
|
|
- if (formatOption.contains("tiff")) {
|
|
|
- drawingType = formatOption;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //如果附件类型是摘要附图
|
|
|
- if (image.getImageType().equals("FirstPageClipping")) {
|
|
|
- firstPageClippingLink = image.getUrlLink();
|
|
|
- firstPageClippingPage = image.getNumberOfPages();
|
|
|
- for (String formatOption : image.getFormatOptions()) {
|
|
|
- if (formatOption.contains("jpeg")) {
|
|
|
- firstPageClippingType = formatOption;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- //装载说明书pdf
|
|
|
- if (cells.contains("4")) {
|
|
|
- setFuJian(fullDocumentLink, fullDocumentPage, fullDocumentType, patentCell, ".pdf");
|
|
|
- }
|
|
|
- //装载摘要附图
|
|
|
- if (cells.contains("6")) {
|
|
|
- setFuJian(firstPageClippingLink, firstPageClippingPage, firstPageClippingType, patentCell, ".jpeg");
|
|
|
- }
|
|
|
- //装载其他附图
|
|
|
- if (cells.contains("7")) {
|
|
|
- setFuJian(drawingLink, drawingPage, drawingType, patentCell, ".tiff");
|
|
|
- }
|
|
|
+ uploadParamsVOs.add(uploadParamsVO);
|
|
|
|
|
|
- //将专利发送到分析系统(保存专利入库)
|
|
|
- if (patentCell.getPatentNo() != null) {
|
|
|
- UploadParamsVO uploadParamsVO = new UploadParamsVO();
|
|
|
- Patent patent2 = new Patent();
|
|
|
- //设置专利号
|
|
|
- patent2.setPatentNo(patentCell.getPatentNo());
|
|
|
- //设置摘要
|
|
|
- patent2.setAbstractStr(patentCell.getAbstrText());
|
|
|
- //设置标题
|
|
|
- patent2.setName(patentCell.getTitle());
|
|
|
- //设置公开日
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- if (patentCell.getPubilcDate() != null) {
|
|
|
- Date date = simpleDateFormat.parse(patentCell.getPubilcDate());
|
|
|
- Integer ts = (int) date.getTime();
|
|
|
- patent2.setPublicDate(ts);
|
|
|
- }
|
|
|
- //设置申请号
|
|
|
- patent2.setApplicationNo(patentCell.getApplicationNo());
|
|
|
- //设置申请日
|
|
|
- if (patentCell.getApplicationDate() != null) {
|
|
|
- Date date = simpleDateFormat.parse(patentCell.getApplicationDate());
|
|
|
- Integer ts = (int) date.getTime();
|
|
|
- patent2.setApplicationDate(ts);
|
|
|
- }
|
|
|
- //设置摘要附图
|
|
|
- patent2.setAbstractPath(patentCell.getPicUrl());
|
|
|
- //设置pdf文档
|
|
|
- if (patentCell.getPdf() != null) {
|
|
|
- patentInstructionService.edit(patentCell.getPatentNo(), patentCell.getPdf());
|
|
|
- }
|
|
|
- //设置公开号
|
|
|
- patent2.setPublicNo(patentCell.getPublicNo());
|
|
|
- uploadParamsVO.setSimpleStatus(patentCell.getStatue());
|
|
|
- uploadParamsVO.setPatent(patent2);
|
|
|
- getOneOrInsertOne(uploadParamsVO);
|
|
|
- if (patentCell.getAgency() != null && !patentCell.getAgency().equals("")) {
|
|
|
- uploadParamsVO.getPatent().setAgencyId(patentAgencyService.getAgencyStringIdByName(patentCell.getAgency()));
|
|
|
- }
|
|
|
- uploadParamsVO.setPatentRight(new PatentRight());
|
|
|
- uploadParamsVO.getPatentRight().setContent(StringUtils.join(patentCell.getRights(), ""));
|
|
|
- uploadParamsVO.setSelfContent(patentCell.getMainRignt());
|
|
|
- uploadParamsVO.setPatentInstructionText(new PatentInstructionText());
|
|
|
- uploadParamsVO.getPatentInstructionText().setManual(patentCell.getPatentInstructionText());
|
|
|
- //发明人
|
|
|
- List<String> inventors = patentCell.getInventors();
|
|
|
- if (inventors != null && inventors.size() > 0) {
|
|
|
- ArrayList<PatentInventor> patentInventors = new ArrayList<>();
|
|
|
- for (String inventor : inventors) {
|
|
|
- PatentInventor patentInventor = new PatentInventor();
|
|
|
- patentInventor.setName(inventor);
|
|
|
- patentInventors.add(patentInventor);
|
|
|
- }
|
|
|
- uploadParamsVO.setPatentInventorList(patentInventors);
|
|
|
- }
|
|
|
- uploadParamsVO.setPatentApplicantCurrentName(patentCell.getApplicationCurrents());
|
|
|
- uploadParamsVO.setPatentApplicantOriginalName(patentCell.getApplicationPersons());
|
|
|
- uploadParamsVO.setPatentApplicantOriginalAddress(patentCell.getApplicationAddress());
|
|
|
- uploadParamsVO.setIpcList(patentCell.getIpc());
|
|
|
- uploadParamsVO.setMainIpc(patentCell.getMainIpc());
|
|
|
- //代理人
|
|
|
- List<String> agencyPersons = patentCell.getAgencyPersons();
|
|
|
- if (agencyPersons != null && agencyPersons.size() > 0) {
|
|
|
- ArrayList<PatentAgent> patentAgents = new ArrayList<>();
|
|
|
- for (String agencyPerson : agencyPersons) {
|
|
|
- PatentAgent patentAgent = new PatentAgent();
|
|
|
- patentAgent.setName(agencyPerson);
|
|
|
- patentAgents.add(patentAgent);
|
|
|
- }
|
|
|
- uploadParamsVO.setPatentAgentList(patentAgents);
|
|
|
- }
|
|
|
- //事务信息 OS_PATENT_AFFAIR
|
|
|
- if (patentCell.getPatentAffairs() != null && patentCell.getPatentAffairs().size() > 0) {
|
|
|
- patentAffairService.updatePatientAffairs(patentCell.getPatentAffairs(), uploadParamsVO.getPatent().getId());
|
|
|
- }
|
|
|
- //当专题库id不为null时添加专利到专题库
|
|
|
- if (patentCell.getProjectId() != null) {
|
|
|
- projectPatentLinkService.updateProjectPatent(patentCell.getProjectId(), uploadParamsVO.getPatent().getId());
|
|
|
- }
|
|
|
- pantentQueueService.patentToQueue(task, uploadParamsVO, null);
|
|
|
- }
|
|
|
|
|
|
- } catch (XiaoShiException e) {
|
|
|
- //虽然拿不到所有附图,但已经拿到了专利著录,能拿到啥是啥
|
|
|
- log.info(e.getMessage());
|
|
|
- } catch (Exception e) {
|
|
|
+ //装载权要
|
|
|
+// if (cells.contains("2")) {
|
|
|
+// setPatentClaim(patentCell, pubNO);
|
|
|
+// }
|
|
|
|
|
|
- }
|
|
|
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
+ System.out.println("专利总数量:" + uploadParamsVOs.size());
|
|
|
|
|
|
- }
|
|
|
|
|
|
- //调用外部接口获取一批专利著录信息
|
|
|
- public SerachBiblioData getSerachBiblioData(String conditions, Integer start, Integer size) throws IOException {
|
|
|
- GetSearchBiblioParamsDTO getSearchBiblioParamsDTO = new GetSearchBiblioParamsDTO()
|
|
|
- .setQuery(conditions)
|
|
|
- .setStart(start)
|
|
|
- .setEnd(size);
|
|
|
- String res = outInterfaceService.getSearchBiblio(getSearchBiblioParamsDTO);
|
|
|
- if (res == null || res.equals("")) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
- if (!jsonObject.get("status").toString().equals("200")) {
|
|
|
- //若发生类似400、500等异常(杰哥处理)
|
|
|
- return null;
|
|
|
- }
|
|
|
- //返回检索结果data
|
|
|
- return JSONObject.parseObject(jsonObject.get("data").toString(), SerachBiblioData.class);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 装载著录方法
|
|
|
*
|
|
|
- * @param patentCell 实体类对象
|
|
|
- * @param patent 专利对象
|
|
|
- * @param pubNo 公开号对象
|
|
|
+ * @param uploadParamsVO 专利实体类对象
|
|
|
+ * @param starPatent 专利之星著录对象
|
|
|
*/
|
|
|
- private void setPatentZhuLu(PatentCell patentCell, PatentZhuLu patent, PubNo pubNo) {
|
|
|
+ private void setPatentZhuLu(UploadParamsVO uploadParamsVO, Patent patent, StarPatentVO starPatent) {
|
|
|
+ //装载专利号
|
|
|
+ patent.setPatentNo(starPatent.getPatentNo());
|
|
|
//装载申请号
|
|
|
- for (AppNo appNo : patent.getAppNos()) {
|
|
|
- if (appNo.getType().equals("docdb")) {
|
|
|
- patentCell.setApplicationNo(appNo.getCountry() + appNo.getNumber() + appNo.getKind());
|
|
|
- }
|
|
|
- }
|
|
|
+ patent.setApplicationNo(starPatent.getApplicationNo());
|
|
|
//装载申请日
|
|
|
- patentCell.setApplicationDate(patent.getAppDate());
|
|
|
- //装载国家/省市
|
|
|
- patentCell.setCountry(patent.getAppCountry());
|
|
|
- //装载公开号
|
|
|
- for (PubNo n : patent.getPubNos()) {
|
|
|
- if (n.getType().equals("docdb")) {
|
|
|
- BeanUtils.copyProperties(n, pubNo);
|
|
|
- patentCell.setPublicNo(n.getCountry() + n.getNumber() + n.getKind());
|
|
|
- }
|
|
|
+ if (starPatent.getApplicationDate() != null && !starPatent.getApplicationDate().equals("")) {
|
|
|
+ patent.setApplicationDate(Integer.parseInt(starPatent.getApplicationDate()));
|
|
|
}
|
|
|
- //装载专利号
|
|
|
- patentCell.setPatentNo(patentCell.getPublicNo());
|
|
|
+ //装载公开号
|
|
|
+ patent.setPublicNo(starPatent.getPublicNo());
|
|
|
+
|
|
|
//装载公开日
|
|
|
- patentCell.setPubilcDate(patent.getPubDate());
|
|
|
- //装载授权公告号(未找到)
|
|
|
- //装载授权公告日(未找到)
|
|
|
- //装载主分类号
|
|
|
- List<String> ipCs = patent.getIpCs();
|
|
|
- List<String> cpCs = patent.getCpCs();
|
|
|
- ipCs.addAll(cpCs);
|
|
|
- if (ipCs != null && ipCs.size() > 0) {
|
|
|
- patentCell.setMainIpc(ipCs.get(0));
|
|
|
- }
|
|
|
- //装载分类号
|
|
|
- if (ipCs != null && ipCs.size() > 0) {
|
|
|
- patentCell.setIpc(ipCs);
|
|
|
- }
|
|
|
+ if (starPatent.getPublicDate() != null && !starPatent.getPublicDate().equals(""))
|
|
|
+ patent.setPublicDate(Integer.parseInt(starPatent.getPublicDate()));
|
|
|
//装载申请人
|
|
|
- ArrayList<String> applicationPersons = new ArrayList<>();
|
|
|
- for (Application application : patent.getApplications()) {
|
|
|
- if (application.getOriginalName().contains("(标:)")) {
|
|
|
- application.setOriginalName(application.getOriginalName().substring(0, application.getOriginalName().indexOf("(标:)")));
|
|
|
- }
|
|
|
- applicationPersons.add(application.getOriginalName());
|
|
|
- }
|
|
|
- patentCell.setApplicationPersons(applicationPersons);
|
|
|
- //装载申请人地址(未找到)
|
|
|
- //装载发明人
|
|
|
- ArrayList<String> inventors = new ArrayList<>();
|
|
|
- for (Inventor inventor : patent.getInventors()) {
|
|
|
- inventors.add(inventor.getOriginalName());
|
|
|
- }
|
|
|
- patentCell.setInventors(inventors);
|
|
|
- //装载当前权利人(未找到)
|
|
|
- //装载代理人(未找到)
|
|
|
- //装载代理机构(未找到)
|
|
|
- //装载范畴分类(未找到)
|
|
|
- //装载当前状态(未找到)
|
|
|
- //装载同族号
|
|
|
- patentCell.setFamilyId(patent.getFamilyId());
|
|
|
- //装载著录标题
|
|
|
- String olTitle = patent.getOlTitle();
|
|
|
- String enTitle = patent.getEnTitle();
|
|
|
- if (olTitle == null) {
|
|
|
- patentCell.setTitle(enTitle);
|
|
|
- } else {
|
|
|
- patentCell.setTitle(olTitle);
|
|
|
+ if (starPatent.getAbstractStr() != null && !starPatent.getAbstractStr().equals("")) {
|
|
|
+ uploadParamsVO.setPatentApplicantOriginalName(Arrays.asList(starPatent.getApplicantStr().split(";")));
|
|
|
}
|
|
|
//装载摘要
|
|
|
- String olAbstract = patent.getOlAbstract();
|
|
|
- String enAbstract = patent.getEnAbstract();
|
|
|
- if (olAbstract == null) {
|
|
|
- patentCell.setAbstrText(enAbstract);
|
|
|
- } else {
|
|
|
- patentCell.setAbstrText(olAbstract);
|
|
|
- }
|
|
|
- //装载优先权号、优先权国家、优先权日
|
|
|
- ArrayList<Priority> priorities = new ArrayList<>();
|
|
|
- List<Priorityy> priorties = patent.getPriorties();
|
|
|
- for (Priorityy priorty : priorties) {
|
|
|
- for (PriorityNumber number : priorty.getNumbers()) {
|
|
|
- if (number.getType().equals("epodoc")) {
|
|
|
- Priority priority = new Priority()
|
|
|
- .setPriorityNo(number.getNumber().substring(2))
|
|
|
- .setPriorityCountry(number.getNumber().substring(0, 2))
|
|
|
- .setPriorityDate(priorty.getDate());
|
|
|
- priorities.add(priority);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- patentCell.setPriorities(priorities);
|
|
|
- }
|
|
|
+ patent.setAbstractStr(starPatent.getAbstractStr());
|
|
|
+ //装载标题
|
|
|
+ patent.setName(starPatent.getName());
|
|
|
+ //装载IPC分类号
|
|
|
+ if (starPatent.getIpcListStr() != null && !starPatent.getIpcListStr().equals("")) {
|
|
|
+ String[] ipcArr = starPatent.getIpcListStr().split(";");
|
|
|
+ //装载IPC分类号
|
|
|
+ uploadParamsVO.setMainIpc(ipcArr[0]);
|
|
|
+ uploadParamsVO.setIpcList(Arrays.asList(ipcArr));
|
|
|
+ }
|
|
|
+ //以上 ↑装载的是调用一般接口返回的专利相关数据
|
|
|
+
|
|
|
+ //以下 ↓装载的是调用中国专利著录接口返回的专利相关数据
|
|
|
+ String appNo = starPatent.getApplicationNo().substring(0, starPatent.getApplicationNo().lastIndexOf("."));
|
|
|
+ //调用中国专利著录接口返回的专利相关数据最外层是一个集合"[]",但是集合中只有一个对象"{}",以下方式处理
|
|
|
+ String chinaPatentZhuLuStr = patentStarApiService.getCnBibApi(appNo);
|
|
|
+ //chinaPatentZhuLuStr = chinaPatentZhuLuStr.substring(chinaPatentZhuLuStr.indexOf("["), chinaPatentZhuLuStr.lastIndexOf("[")).trim();
|
|
|
+ //ChinaPatentZhuLu chinaPatentZhuLu = JSONObject.parseObject(chinaPatentZhuLuStr, ChinaPatentZhuLu.class);
|
|
|
+ //以上暂无需处理 ↑ 以下 ↓有现成的json数组字符串转为集合方法
|
|
|
+ List<ChinaPatentZhuLu> chinaPatentZhuLus = JSON.parseArray(chinaPatentZhuLuStr, ChinaPatentZhuLu.class);
|
|
|
+ ChinaPatentZhuLu chinaPatentZhuLu = chinaPatentZhuLus.get(0);
|
|
|
+
|
|
|
+ //装载申请人地址
|
|
|
+ ArrayList<String> patentApplicantOriginalAddresss = new ArrayList<>();
|
|
|
+ patentApplicantOriginalAddresss.add(chinaPatentZhuLu.getDZ().substring(chinaPatentZhuLu.getDZ().indexOf(" ") + 1));
|
|
|
+ uploadParamsVO.setPatentApplicantOriginalAddress(patentApplicantOriginalAddresss);
|
|
|
+
|
|
|
+ //装载代理人
|
|
|
+ List<String> patentAgents = Arrays.asList(chinaPatentZhuLu.getAT().split(";"));
|
|
|
+ ArrayList<PatentAgent> patentAgentList = new ArrayList<>();
|
|
|
+ for (String n : patentAgents) {
|
|
|
+ PatentAgent patentAgent = new PatentAgent();
|
|
|
+ patentAgent.setName(n);
|
|
|
+ patentAgentList.add(patentAgent);
|
|
|
+ }
|
|
|
+ uploadParamsVO.setPatentAgentList(patentAgentList);
|
|
|
+
|
|
|
+ //装载代理机构地址
|
|
|
+ String agencyAddress = chinaPatentZhuLu.getAGN().substring(0, chinaPatentZhuLu.getAGN().lastIndexOf(" "));
|
|
|
+ patent.setAgencyId(agencyAddress);
|
|
|
|
|
|
- /**
|
|
|
- * 装载权要方法
|
|
|
- *
|
|
|
- * @param patentCell 实体类对象
|
|
|
- * @param pubNo 公开号对象
|
|
|
- */
|
|
|
- private void setPatentClaim(PatentCell patentCell, PubNo pubNo) throws IOException {
|
|
|
- GetClaimsInfoParamsDTO getClaimsInfoParamsDTO = new GetClaimsInfoParamsDTO()
|
|
|
- .setCc(pubNo.getCountry())
|
|
|
- .setNumber(pubNo.getNumber())
|
|
|
- .setKind(pubNo.getKind());
|
|
|
- String res = outInterfaceService.getClaimsInfo(getClaimsInfoParamsDTO);
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
- if (!jsonObject.get("status").toString().equals("200")) {
|
|
|
- //若发生类似400、500等异常(杰哥处理)
|
|
|
- //ThrowException.throwXiaoShiException("权要接口无法检索该国家专利");
|
|
|
- log.info("权要接口无法检索该国家专利");
|
|
|
- return;
|
|
|
+ //装载发明人
|
|
|
+ List<String> patentInventorNames = Arrays.asList(chinaPatentZhuLu.getIV().split(";"));
|
|
|
+ ArrayList<PatentInventor> patentInventors = new ArrayList<>();
|
|
|
+ for (String patentInventorName : patentInventorNames) {
|
|
|
+ PatentInventor patentInventor = new PatentInventor();
|
|
|
+ patentInventor.setName(patentInventorName);
|
|
|
+ patentInventors.add(patentInventor);
|
|
|
}
|
|
|
- //拿到检索结果(未格式化的含有页面等标签的权要)并格式化权要
|
|
|
- //String unformatRight = JSONObject.parseObject(jsonObject.get("data").toString(), String.class);
|
|
|
- ArrayList<String> unformatRights = JSONObject.parseObject(jsonObject.get("data").toString(), ArrayList.class);
|
|
|
- //String[] rightArr = unformatRight.split("\n");
|
|
|
- //ArrayList<String> rights = new ArrayList<>(Arrays.asList(rightArr));
|
|
|
- patentCell.setRights(unformatRights);
|
|
|
- }
|
|
|
+ uploadParamsVO.setPatentInventorList(patentInventors);
|
|
|
|
|
|
- /**
|
|
|
- * 装载说明书方法
|
|
|
- *
|
|
|
- * @param patentCell 实体类对象
|
|
|
- * @param pubNo 公开号对象
|
|
|
- */
|
|
|
- private void setPatentInstructionText(PatentCell patentCell, PubNo pubNo) throws IOException {
|
|
|
- GetDescriptionInfoParamsDTO getDescriptionInfoParamsDTO = new GetDescriptionInfoParamsDTO()
|
|
|
- .setCc(pubNo.getCountry())
|
|
|
- .setNumber(pubNo.getNumber())
|
|
|
- .setKind(pubNo.getKind());
|
|
|
- String res = outInterfaceService.getDescriptionInfo(getDescriptionInfoParamsDTO);
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
- if (!jsonObject.get("status").toString().equals("200")) {
|
|
|
- //若发生类似400、500等异常(杰哥处理)
|
|
|
- //ThrowException.throwXiaoShiException("说明书接口无法检索该国家专利");
|
|
|
- log.info("说明书接口无法检索该国家专利");
|
|
|
- return;
|
|
|
- }
|
|
|
- //拿到检索结果(未格式化的含有页面等标签的说明书)
|
|
|
- //String unformatInstructionText = JSONObject.parseObject(jsonObject.get("data").toString(), String.class);
|
|
|
- List<String> unformatInstructionText = JSONObject.parseObject(jsonObject.get("data").toString(), List.class);
|
|
|
- StringBuilder builder = new StringBuilder();
|
|
|
- for (String n : unformatInstructionText) {
|
|
|
- builder.append(n);
|
|
|
- }
|
|
|
-// String regex = "<p>(.+?)</p>";
|
|
|
-// Matcher matcher = Pattern.compile(regex).matcher(unformatInstructionText);
|
|
|
-// if (matcher.find()) {
|
|
|
-// patentCell.setPatentInstructionText(matcher.group());
|
|
|
+ //装载同族号
|
|
|
+// patentCell.setFamilyId(patent.getFamilyId());
|
|
|
+// //装载优先权号、优先权国家、优先权日
|
|
|
+// ArrayList<Priority> priorities = new ArrayList<>();
|
|
|
+// List<Priorityy> priorties = patent.getPriorties();
|
|
|
+// for (Priorityy priorty : priorties) {
|
|
|
+// for (PriorityNumber number : priorty.getNumbers()) {
|
|
|
+// if (number.getType().equals("epodoc")) {
|
|
|
+// Priority priority = new Priority()
|
|
|
+// .setPriorityNo(number.getNumber().substring(2))
|
|
|
+// .setPriorityCountry(number.getNumber().substring(0, 2))
|
|
|
+// .setPriorityDate(priorty.getDate());
|
|
|
+// priorities.add(priority);
|
|
|
+// }
|
|
|
+// }
|
|
|
// }
|
|
|
- patentCell.setPatentInstructionText(builder + "");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取Image信息方法(从信息中获取三种附图的检索参数)
|
|
|
- *
|
|
|
- * @param pubNo 公开号对象
|
|
|
- */
|
|
|
- private ImageInfo getImage(PubNo pubNo) throws IOException {
|
|
|
- String res = outInterfaceService.getImagesInfo(pubNo);
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
- if (!jsonObject.get("status").toString().equals("200")) {
|
|
|
- //若发生类似400、500等异常(杰哥处理)
|
|
|
- ThrowException.throwXiaoShiException("Image信息接口无法检索该国家专利");
|
|
|
- }
|
|
|
- //拿到检索结果(未格式化的含有页面等标签的说明书)
|
|
|
- String unFormatData = jsonObject.get("data").toString();
|
|
|
- String data = unFormatData.substring(unFormatData.indexOf("[") + 1, unFormatData.lastIndexOf("]"));
|
|
|
- ImageInfo imageInfo = JSONObject.parseObject(data, ImageInfo.class);
|
|
|
- return imageInfo;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 装载说明书附件pdf方法
|
|
|
- *
|
|
|
- * @param link 附件链接
|
|
|
- * @param page 附件页数
|
|
|
- * @param type 附件类型
|
|
|
- * @param patentCell 实体类对象
|
|
|
- */
|
|
|
- private void setFuJian(String link, Integer page, String type, PatentCell patentCell, String FuJianSuffix) throws Exception {
|
|
|
- //合并说明书pdf文档时所需的读取流数组
|
|
|
- InputStream[] streams = new InputStream[page];
|
|
|
- //其他附图url数组
|
|
|
- ArrayList<String> otherUrls = new ArrayList<>();
|
|
|
- //遍历附件页数
|
|
|
- for (int i = 1; i <= page; i++) {
|
|
|
- GetFuTuParamsDTO getFuTuParamsDTO = new GetFuTuParamsDTO()
|
|
|
- .setLink(link)
|
|
|
- .setPage(i)
|
|
|
- .setType(type);
|
|
|
- byte[] buffer = outInterfaceService.getPatentFile(getFuTuParamsDTO);
|
|
|
- InputStream inputStream = new ByteArrayInputStream(buffer);
|
|
|
- streams[i - 1] = inputStream;
|
|
|
- //如果不是说明书pdf
|
|
|
- if (!FuJianSuffix.equals(".pdf")) {
|
|
|
- File file = File.createTempFile("new_url", FuJianSuffix);
|
|
|
- FileOutputStream out = new FileOutputStream(file);
|
|
|
- out.write(buffer);
|
|
|
- out.close();
|
|
|
- streams[i - 1] = new FileInputStream(file);
|
|
|
- DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(16, null);
|
|
|
- FileItem item = diskFileItemFactory.createItem(file.getName(), "text/plain", true, file.getName());
|
|
|
- int bytesRead = 0;
|
|
|
- buffer = new byte[8192];
|
|
|
- try {
|
|
|
- FileInputStream fis = new FileInputStream(file);
|
|
|
- OutputStream os = item.getOutputStream();
|
|
|
- int len = 8192;
|
|
|
- while ((bytesRead = fis.read(buffer, 0, len)) != -1) {
|
|
|
- os.write(buffer, 0, bytesRead);
|
|
|
- }
|
|
|
- os.close();
|
|
|
- fis.close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- MultipartFile multipartFile = new CommonsMultipartFile(item);
|
|
|
- UploadFileDTO fileDTO = fileUtils.uploadFile(multipartFile);
|
|
|
- //如果是摘要附图
|
|
|
- if (FuJianSuffix.equals(".jpeg")) {
|
|
|
- patentCell.setPicUrl(fileDTO.getPath());
|
|
|
- }
|
|
|
- //如果是其他附图
|
|
|
- if (FuJianSuffix.equals(".tiff")) {
|
|
|
- otherUrls.add(fileDTO.getPath());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //如果是说明书pdf
|
|
|
- if (FuJianSuffix.equals(".pdf")) {
|
|
|
- //合并说明书多个pdf文件
|
|
|
- PdfDocumentBase doc = PdfDocument.mergeFiles(streams);
|
|
|
- //保存结果文件
|
|
|
- doc.save("merge.pdf", FileFormat.PDF);
|
|
|
- doc.close();
|
|
|
+// patentCell.setPriorities(priorities);
|
|
|
+ uploadParamsVO.setPatent(patent);
|
|
|
|
|
|
- //手动将合并后的pdf文件转成MultipartFile,上传文件并获取path装载到patentCell
|
|
|
- File file = new File("merge.pdf");
|
|
|
- DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(16, null);
|
|
|
- FileItem item = diskFileItemFactory.createItem(file.getName(), "text/plain", true, file.getName());
|
|
|
- int bytesRead = 0;
|
|
|
- byte[] buffer = new byte[8192];
|
|
|
- try {
|
|
|
- FileInputStream fis = new FileInputStream(file);
|
|
|
- OutputStream os = item.getOutputStream();
|
|
|
- int len = 8192;
|
|
|
- while ((bytesRead = fis.read(buffer, 0, len)) != -1) {
|
|
|
- os.write(buffer, 0, bytesRead);
|
|
|
- }
|
|
|
- os.close();
|
|
|
- fis.close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- MultipartFile multipartFile = new CommonsMultipartFile(item);
|
|
|
- UploadFileDTO fileDTO = fileUtils.uploadFile(multipartFile);
|
|
|
- patentCell.setPdf(fileDTO);
|
|
|
- } else if (FuJianSuffix.equals(".tiff")) {
|
|
|
- patentCell.setOtherUrls(otherUrls);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param uploadParamsVO 全局类
|
|
|
- * @date 2022-7-11
|
|
|
- * @name 工具方法
|
|
|
- * @description 查询数据是否存在 如果存在 返回该条数据 如果不存在 新增一条数据
|
|
|
- */
|
|
|
- public void getOneOrInsertOne(UploadParamsVO uploadParamsVO) {
|
|
|
- if (uploadParamsVO.getPatent() != null) {
|
|
|
- uploadParamsVO.getPatent().setPatentNo(uploadParamsVO.getPatent().getPatentNo().trim());
|
|
|
- //用专利号查询该条数据是否存在
|
|
|
- Patent patent = patentService.getByPatentNo(uploadParamsVO.getPatent().getPatentNo());
|
|
|
- //如果不存在就新增一条
|
|
|
- if (patent == null) {
|
|
|
- uploadParamsVO.getPatent().insert();
|
|
|
- } else {
|
|
|
- uploadParamsVO.getPatent().setId(patent.getId());
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
}
|