|
@@ -35,43 +35,47 @@ public class GetRightAndFullTextFromWebThread extends Thread {
|
|
|
private ApplicationContext applicationContext;
|
|
|
private ImportFromWebToEsService importFromWebToEsService;
|
|
|
private PatentStarApiService patentStarApiService;
|
|
|
- private List<UploadPatentWebDTO> uploadPatentWebDTOs =new ArrayList<>();
|
|
|
+ private List<UploadPatentWebDTO> uploadPatentWebDTOs = new ArrayList<>();
|
|
|
private final Lock taskLock = new ReentrantLock();
|
|
|
private final Condition taskCondition = taskLock.newCondition();
|
|
|
private Boolean ifProductAll = false;
|
|
|
private TaskThread taskThread;
|
|
|
+
|
|
|
@Override
|
|
|
public void run() {
|
|
|
|
|
|
- while ((!ifProductAll || uploadPatentWebDTOs.size() > 0) && importTaskAMVO.getState().equals(1)) {
|
|
|
-
|
|
|
- try {
|
|
|
- if (uploadPatentWebDTOs.size() == 0) {
|
|
|
- taskLock.lock();
|
|
|
- taskCondition.await();
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
+ while ((!ifProductAll || uploadPatentWebDTOs.size() > 0) && importTaskAMVO.getState().equals(1)) {
|
|
|
|
|
|
+ try {
|
|
|
+ if (uploadPatentWebDTOs.size() == 0) {
|
|
|
+ taskLock.lock();
|
|
|
+ taskCondition.await();
|
|
|
}
|
|
|
- UploadPatentWebDTO uploadPatentWebDTO = uploadPatentWebDTOs.remove(0);
|
|
|
- try {
|
|
|
- StarPatentVO starPatentVO =uploadPatentWebDTO.getStarPatentVO();
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ if(uploadPatentWebDTOs.size()==0){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ UploadPatentWebDTO uploadPatentWebDTO = uploadPatentWebDTOs.remove(0);
|
|
|
+ try {
|
|
|
+ StarPatentVO starPatentVO = uploadPatentWebDTO.getStarPatentVO();
|
|
|
|
|
|
if ((starPatentVO.getPublicNo() != null && starPatentVO.getPublicNo().contains("CN")) || (starPatentVO.getPublicNo() == null && starPatentVO.getPublicNo().contains("CN"))) {
|
|
|
- patentStarApiService =applicationContext.getBean(PatentStarApiService.class);
|
|
|
+ patentStarApiService = applicationContext.getBean(PatentStarApiService.class);
|
|
|
String cnFullXmlStr = patentStarApiService.getCnFullXmlApi(starPatentVO.getRowApplicationNo());
|
|
|
- this.loadClaim(uploadPatentWebDTO,cnFullXmlStr);
|
|
|
- this.loadFullText(uploadPatentWebDTO,cnFullXmlStr);
|
|
|
+ this.loadClaim(uploadPatentWebDTO, cnFullXmlStr);
|
|
|
+ this.loadFullText(uploadPatentWebDTO, cnFullXmlStr);
|
|
|
}
|
|
|
//加入es保存队列
|
|
|
- importFromWebToEsService.loadPatentMessageDone(uploadPatentWebDTO);
|
|
|
+ importFromWebToEsService.loadPatentMessageDone(uploadPatentWebDTO);
|
|
|
+ } catch (Exception e) {
|
|
|
+ importFromWebToEsService.loadPatentMessageDone(uploadPatentWebDTO);
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- catch (Exception e) {
|
|
|
- importFromWebToEsService.loadPatentMessageDone(uploadPatentWebDTO);
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ System.out.println("rightDone" + ifProductAll);
|
|
|
}
|
|
|
- importFromWebToEsService.setPatentToEsProductAll();
|
|
|
+ importFromWebToEsService.setPatentToEsProductAll("rightDone");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -79,25 +83,27 @@ public class GetRightAndFullTextFromWebThread extends Thread {
|
|
|
this.importTaskAMVO = taskThread.getImportTaskAMVO();
|
|
|
this.importFromWebToEsService = importFromWebToEsService;
|
|
|
this.applicationContext = taskThread.getApplicationContext();
|
|
|
- this.taskThread=taskThread;
|
|
|
+ this.taskThread = taskThread;
|
|
|
}
|
|
|
|
|
|
public void awakeTask(UploadPatentWebDTO uploadPatentWebDTO) {
|
|
|
- UploadPatentWebDTO uploadPatentWebDTO1=new UploadPatentWebDTO();
|
|
|
- BeanUtils.copyProperties(uploadPatentWebDTO,uploadPatentWebDTO1);
|
|
|
- uploadPatentWebDTOs.add(uploadPatentWebDTO1);
|
|
|
- if (taskLock.tryLock()) {
|
|
|
- taskCondition.signalAll();
|
|
|
- taskLock.unlock();
|
|
|
+ synchronized ("装载专利信息") {
|
|
|
+ UploadPatentWebDTO uploadPatentWebDTO1 = new UploadPatentWebDTO();
|
|
|
+ BeanUtils.copyProperties(uploadPatentWebDTO, uploadPatentWebDTO1);
|
|
|
+ uploadPatentWebDTOs.add(uploadPatentWebDTO1);
|
|
|
+ if (taskLock.tryLock()) {
|
|
|
+ taskCondition.signalAll();
|
|
|
+ taskLock.unlock();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//装载权利要求
|
|
|
- private void loadClaim(UploadPatentWebDTO uploadPatentWebDTO,String cnFullXmlStr) {
|
|
|
+ private void loadClaim(UploadPatentWebDTO uploadPatentWebDTO, String cnFullXmlStr) {
|
|
|
Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
try {
|
|
|
- if(cnFullXmlStr!=null&&cnFullXmlStr!="") {
|
|
|
+ if (cnFullXmlStr != null && cnFullXmlStr != "") {
|
|
|
SAXReader reader = new SAXReader();
|
|
|
reader.setEntityResolver(new IgnoreDTDEntityResolver());
|
|
|
Reader stringReader = new StringReader(cnFullXmlStr);
|
|
@@ -111,7 +117,7 @@ public class GetRightAndFullTextFromWebThread extends Thread {
|
|
|
List<String> reClaims = new ArrayList<>();
|
|
|
element.forEach(item -> {
|
|
|
String claim = item.getText();
|
|
|
- claim = claim.replaceAll("\r\n|\r|\n|\t| ", "");
|
|
|
+ claim = claim.replaceAll("\r\n|\r|\n|\t| ", "");
|
|
|
reClaims.add(claim);
|
|
|
|
|
|
});
|
|
@@ -133,13 +139,13 @@ public class GetRightAndFullTextFromWebThread extends Thread {
|
|
|
|
|
|
}
|
|
|
|
|
|
- //装载说明书文档
|
|
|
- private void loadFullText(UploadPatentWebDTO uploadPatentWebDTO,String cnFullXmlStr) {
|
|
|
+ //装载说明书文档
|
|
|
+ private void loadFullText(UploadPatentWebDTO uploadPatentWebDTO, String cnFullXmlStr) {
|
|
|
Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
try {
|
|
|
//若没有取到全文文本,即取不到说明书文本,则将当前申请号或专利号和备注信息记录到问题记录表
|
|
|
if (cnFullXmlStr.equals("")) {
|
|
|
- return ;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
SAXReader reader = new SAXReader();
|
|
@@ -153,41 +159,44 @@ public class GetRightAndFullTextFromWebThread extends Thread {
|
|
|
elements = (List<Element>) xpath.selectNodes(document);
|
|
|
}
|
|
|
List<String> fullTexts = new ArrayList<>();
|
|
|
- Integer count=1;
|
|
|
- for (Element item:elements){
|
|
|
+ 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("背景技术")
|
|
|
- &&!fullText.trim().equals("实用新型内容"))
|
|
|
-
|
|
|
- {String formattedNum = String.format("%04d", count);
|
|
|
- fullText ="["+formattedNum+"]"+fullText;
|
|
|
+ && !fullText.trim().equals("背景技术")
|
|
|
+ && !fullText.trim().equals("实用新型内容")) {
|
|
|
+ String formattedNum = String.format("%04d", count);
|
|
|
+ fullText = "[" + formattedNum + "]" + fullText;
|
|
|
count++;
|
|
|
}
|
|
|
- fullText = fullText.replaceAll("\r\n|\r|\n| ", "");
|
|
|
+ fullText = fullText.replaceAll("\r\n|\r|\n| ", "");
|
|
|
fullTexts.add(fullText);
|
|
|
}
|
|
|
String fullText = "";
|
|
|
if (fullTexts.size() != 0) {
|
|
|
fullText = cn.cslg.pas.common.utils.StringUtils.join(fullTexts, "\r");
|
|
|
}
|
|
|
- Text text =new Text();
|
|
|
+ Text text = new Text();
|
|
|
text.setIfOrigin(true);
|
|
|
text.setTextContent(fullText);
|
|
|
text.setLanguage(patent.getAppCountry());
|
|
|
patent.setPublicFullText(Arrays.asList(text));
|
|
|
|
|
|
- } catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
- public void setIfProductAll(Boolean ifProductAll) {
|
|
|
|
|
|
+ public void setIfProductAll(Boolean ifProductAll) {
|
|
|
+ if (taskLock.tryLock()) {
|
|
|
+ taskCondition.signalAll();
|
|
|
+ taskLock.unlock();
|
|
|
+ }
|
|
|
this.ifProductAll = ifProductAll;
|
|
|
|
|
|
}
|