|
@@ -5,7 +5,9 @@ import cn.cslg.pas.common.dto.UploadPatentWebDTO;
|
|
|
import cn.cslg.pas.common.model.importTaskModel.PatentRight;
|
|
|
import cn.cslg.pas.common.vo.ChinaPatentZhuLu;
|
|
|
import cn.cslg.pas.common.vo.ImportTaskAMVO;
|
|
|
+import cn.cslg.pas.common.vo.StarPatentVO;
|
|
|
import cn.cslg.pas.domain.es.Patent;
|
|
|
+import cn.cslg.pas.domain.es.Text;
|
|
|
import cn.cslg.pas.service.common.PatentStarApiService;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import org.dom4j.Document;
|
|
@@ -15,16 +17,18 @@ import org.dom4j.io.SAXReader;
|
|
|
import org.springframework.beans.factory.annotation.Configurable;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.io.Reader;
|
|
|
import java.io.StringReader;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.locks.Condition;
|
|
|
import java.util.concurrent.locks.Lock;
|
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
|
|
@Configurable
|
|
|
-public class GetRightAndFullTextFromWebThread extends Thread{
|
|
|
+public class GetRightAndFullTextFromWebThread extends Thread {
|
|
|
private ImportTaskAMVO importTaskAMVO;
|
|
|
private ApplicationContext applicationContext;
|
|
|
private ImportFromWebToEsService importFromWebToEsService;
|
|
@@ -36,40 +40,18 @@ public class GetRightAndFullTextFromWebThread extends Thread{
|
|
|
@Override
|
|
|
public void run() {
|
|
|
try {
|
|
|
- while ( uploadPatentWebDTOs.size() > 0||importTaskAMVO.getProgressVO().equals(1)) {
|
|
|
+ while (uploadPatentWebDTOs.size() > 0 || importTaskAMVO.getProgressVO().equals(1)) {
|
|
|
UploadPatentWebDTO uploadPatentWebDTO = uploadPatentWebDTOs.remove(0);
|
|
|
- Patent patent =uploadPatentWebDTO.getPatent();
|
|
|
+ Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
+ StarPatentVO starPatentVO =uploadPatentWebDTO.getStarPatentVO();
|
|
|
if (uploadPatentWebDTOs.size() == 0) {
|
|
|
taskLock.lock();
|
|
|
taskCondition.await();
|
|
|
}
|
|
|
if ((patent.getPublicNo() != null && patent.getPublicNo().contains("CN")) || (patent.getPublicNo() == null && patent.getPatentNo().contains("CN"))) {
|
|
|
- //根据申请号调用"获得中国专利全文文本"接口,获得包含各种xml标签的专利全文内容的长字符串 cnFullXmlStr
|
|
|
- String cnFullXmlStr = patentStarApiService.getCnFullXmlApi(patent.getAppNo());
|
|
|
-
|
|
|
-
|
|
|
- SAXReader reader = new SAXReader();
|
|
|
- reader.setEntityResolver(new IgnoreDTDEntityResolver());
|
|
|
- Reader stringReader = new StringReader(cnFullXmlStr);
|
|
|
- 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> reStrs = new ArrayList<>();
|
|
|
- element.forEach(item -> {
|
|
|
- String claim = item.getText();
|
|
|
- reStrs.add(claim);
|
|
|
- });
|
|
|
- String reStr = "";
|
|
|
- if (reStrs.size() != 0) {
|
|
|
- reStr = cn.cslg.pas.common.utils.StringUtils.join(reStrs, "\r\n");
|
|
|
- }
|
|
|
- //装载权利要求原文
|
|
|
- PatentRight patentRight = new PatentRight();
|
|
|
-
|
|
|
+ String cnFullXmlStr = patentStarApiService.getCnFullXmlApi(starPatentVO.getRowApplicationNo());
|
|
|
+ this.loadClaim(uploadPatentWebDTO,cnFullXmlStr);
|
|
|
+ this.loadFullText(uploadPatentWebDTO,cnFullXmlStr);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -84,6 +66,7 @@ public class GetRightAndFullTextFromWebThread extends Thread{
|
|
|
this.importFromWebToEsService = importFromWebToEsService;
|
|
|
this.applicationContext = taskThread.getApplicationContext();
|
|
|
}
|
|
|
+
|
|
|
public void awakeTask(UploadPatentWebDTO uploadPatentWebDTO) {
|
|
|
uploadPatentWebDTOs.add(uploadPatentWebDTO);
|
|
|
if (taskLock.tryLock()) {
|
|
@@ -94,4 +77,90 @@ public class GetRightAndFullTextFromWebThread extends Thread{
|
|
|
|
|
|
|
|
|
//装载权利要求
|
|
|
+ private void loadClaim(UploadPatentWebDTO uploadPatentWebDTO,String cnFullXmlStr) {
|
|
|
+ Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
+ try {
|
|
|
+ if(cnFullXmlStr!=null&&cnFullXmlStr!="") {
|
|
|
+ SAXReader reader = new SAXReader();
|
|
|
+ reader.setEntityResolver(new IgnoreDTDEntityResolver());
|
|
|
+ Reader stringReader = new StringReader(cnFullXmlStr);
|
|
|
+ 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();
|
|
|
+ reClaims.add(claim);
|
|
|
+ });
|
|
|
+ String reClaim = "";
|
|
|
+ if (reClaims.size() != 0) {
|
|
|
+ reClaim = cn.cslg.pas.common.utils.StringUtils.join(reClaims, "\r\n");
|
|
|
+ }
|
|
|
+ //装载权利要求原文
|
|
|
+ Text text = new Text();
|
|
|
+ text.setLanguage(patent.getAppCountry());
|
|
|
+ text.setTextContent(reClaim);
|
|
|
+ text.setIfOrigin(true);
|
|
|
+ patent.setClaim(Arrays.asList(text));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //装载说明书文档
|
|
|
+ private void loadFullText(UploadPatentWebDTO uploadPatentWebDTO,String cnFullXmlStr) {
|
|
|
+ Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
+ try {
|
|
|
+ //若没有取到全文文本,即取不到说明书文本,则将当前申请号或专利号和备注信息记录到问题记录表
|
|
|
+ if (cnFullXmlStr.equals("")) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ SAXReader reader = new SAXReader();
|
|
|
+ reader.setEntityResolver(new IgnoreDTDEntityResolver());
|
|
|
+ Reader stringReader = new StringReader(cnFullXmlStr);
|
|
|
+ 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> fullTexts = new ArrayList<>();
|
|
|
+ Integer count=1;
|
|
|
+ for (Element item:elements){
|
|
|
+ String fullText = item.getText().replaceAll("<br/>", "");
|
|
|
+ if (!fullText.trim().equals("技术领域")
|
|
|
+ && !fullText.trim().equals("发明内容")
|
|
|
+ && !fullText.trim().equals("附图说明")
|
|
|
+ && !fullText.trim().equals("具体实施方式")
|
|
|
+ &&!fullText.trim().equals("背景技术"))
|
|
|
+ {String formattedNum = String.format("%04d", count);
|
|
|
+ fullText ="["+formattedNum+"]"+fullText;
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ fullTexts.add(fullText);
|
|
|
+ }
|
|
|
+ String fullText = "";
|
|
|
+ if (fullTexts.size() != 0) {
|
|
|
+ fullText = cn.cslg.pas.common.utils.StringUtils.join(fullTexts, "\r\n");
|
|
|
+ }
|
|
|
+ Text text =new Text();
|
|
|
+ text.setIfOrigin(true);
|
|
|
+ text.setTextContent(fullText);
|
|
|
+ text.setLanguage(patent.getAppCountry());
|
|
|
+ patent.setPublicFullText(Arrays.asList(text));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
}
|