|
@@ -5,6 +5,7 @@ import cn.cslg.pas.common.utils.FormatUtil;
|
|
|
import cn.cslg.pas.common.vo.ImportTaskAMVO;
|
|
|
import cn.cslg.pas.common.vo.PatentWithIdVO;
|
|
|
import cn.cslg.pas.domain.business.ImportTask;
|
|
|
+import cn.cslg.pas.domain.es.ESImportTask;
|
|
|
import cn.cslg.pas.domain.es.Patent;
|
|
|
import cn.cslg.pas.domain.es.PatentJoin;
|
|
|
import cn.cslg.pas.service.business.ImportTaskService;
|
|
@@ -35,30 +36,33 @@ public class SavePatentToEsThread extends Thread {
|
|
|
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- while ((!ifProductAll || uploadPatentWebDTOS.size() > 0)&&importTaskAMVO.getState().equals(1)) {
|
|
|
+ while ((!ifProductAll || uploadPatentWebDTOS.size() > 0) && importTaskAMVO.getState().equals(1)) {
|
|
|
try {
|
|
|
//判断任务队列是否有任务,若没有则线程等待唤醒
|
|
|
if (uploadPatentWebDTOS.size() == 0) {
|
|
|
taskLock.lock();
|
|
|
taskCondition.await();
|
|
|
}
|
|
|
- UploadPatentWebDTO uploadPatentWebDTO = uploadPatentWebDTOS.remove(0);
|
|
|
- Patent patent =uploadPatentWebDTO.getPatent();
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ UploadPatentWebDTO uploadPatentWebDTO = uploadPatentWebDTOS.remove(0);
|
|
|
+ try {
|
|
|
+ Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
//根据专利号查询专利
|
|
|
EsService esService = applicationContext.getBean(EsService.class);
|
|
|
PatentWithIdVO patentWithIdVO = esService.getIdByPatentNo(patent.getPatentNo());
|
|
|
- String patentId =null;
|
|
|
+ String patentId = null;
|
|
|
// 若查出专利则更新
|
|
|
if (patentWithIdVO != null) {
|
|
|
- patentId =patentWithIdVO.getId();
|
|
|
+ patentId = patentWithIdVO.getId();
|
|
|
Patent orgPatent = patentWithIdVO.getPatent();
|
|
|
BeanUtils.copyProperties(patent, orgPatent, FormatUtil.getNullPropertyNames(patent));
|
|
|
esService.updateDocument(orgPatent, patentWithIdVO.getId());
|
|
|
} else {
|
|
|
- PatentJoin patentJoin =new PatentJoin();
|
|
|
+ PatentJoin patentJoin = new PatentJoin();
|
|
|
patentJoin.setName("patent");
|
|
|
patent.setPatentJoin(patentJoin);
|
|
|
- patentId = esService.addPatent(patent);
|
|
|
+ patentId = esService.addPatent(patent);
|
|
|
}
|
|
|
//判断是否和专题库或报告关联
|
|
|
ImportTaskAMVO importTaskAMVO = taskThread.getImportTaskAMVO();
|
|
@@ -66,35 +70,58 @@ public class SavePatentToEsThread extends Thread {
|
|
|
//和专题库或报告进行关联
|
|
|
if (importTaskAMVO.getProjectId() != null) {
|
|
|
//根据projectId和专利id查询
|
|
|
- if(patentId!=null){
|
|
|
- Boolean ifInproject= esService.searchPatent(patentId,importTaskAMVO.getProjectId());
|
|
|
- if(!ifInproject) {
|
|
|
- Patent patentChild = new Patent();
|
|
|
- PatentJoin patentJoin = new PatentJoin();
|
|
|
- patentJoin.setParent(patentId);
|
|
|
- patentJoin.setName("project");
|
|
|
- patentChild.setPatentJoin(patentJoin);
|
|
|
- patentChild.setProjectId(importTaskAMVO.getProjectId());
|
|
|
- esService.addChildPatent(patentChild, patentId);
|
|
|
- }
|
|
|
+ if (patentId != null) {
|
|
|
+ Boolean ifInproject = esService.searchPatent(patentId, importTaskAMVO.getProjectId());
|
|
|
+ if (!ifInproject) {
|
|
|
+ Patent patentChild = new Patent();
|
|
|
+ PatentJoin patentJoin = new PatentJoin();
|
|
|
+ patentJoin.setParent(patentId);
|
|
|
+ patentJoin.setName("project");
|
|
|
+ patentChild.setPatentJoin(patentJoin);
|
|
|
+ patentChild.setProjectId(importTaskAMVO.getProjectId());
|
|
|
+ esService.addChildPatent(patentChild, patentId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //和任务关联
|
|
|
+ if(importTaskAMVO.getId()!=null){
|
|
|
+
|
|
|
+ if (patentId != null) {
|
|
|
+ Boolean ifInTask = esService.ifInTask(patentId, importTaskAMVO.getProjectId(),importTaskAMVO.getId());
|
|
|
+ if (!ifInTask) {
|
|
|
+ Patent patentChild = new Patent();
|
|
|
+ PatentJoin patentJoin = new PatentJoin();
|
|
|
+ patentJoin.setParent(patentId);
|
|
|
+ patentJoin.setName("import_task");
|
|
|
+ patentChild.setPatentJoin(patentJoin);
|
|
|
+ ESImportTask esImportTask =new ESImportTask();
|
|
|
+ esImportTask.setProjectId(importTaskAMVO.getProjectId());
|
|
|
+ esImportTask.setTaskId(importTaskAMVO.getId());
|
|
|
+ patentChild.setImportTask(esImportTask);
|
|
|
+ esService.addChildPatent(patentChild, patentId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//导入完成,通知前台
|
|
|
MessageService messageService = applicationContext.getBean(MessageService.class);
|
|
|
- messageService.sendWebsocketMessage(importTaskAMVO,1);
|
|
|
- importTaskAMVO.setMessageDoneNum(importTaskAMVO.getMessageDoneNum()+1);
|
|
|
+ messageService.sendWebsocketMessage(importTaskAMVO, 1);
|
|
|
+ importTaskAMVO.setMessageDoneNum(importTaskAMVO.getMessageDoneNum() + 1);
|
|
|
taskThread.ifPatentDone(uploadPatentWebDTO);
|
|
|
} catch (Exception e) {
|
|
|
- System.out.println(e);
|
|
|
+ importTaskAMVO.setMessageDoneNum(importTaskAMVO.getMessageDoneNum() + 1);
|
|
|
+ taskThread.ifPatentDone(uploadPatentWebDTO);
|
|
|
}
|
|
|
}
|
|
|
taskThread.awakeTaskThread();
|
|
|
+ System.out.println("done");
|
|
|
}
|
|
|
|
|
|
public SavePatentToEsThread(TaskThread taskThread, ApplicationContext applicationContext) {
|
|
|
this.taskThread = taskThread;
|
|
|
this.applicationContext = applicationContext;
|
|
|
- this.importTaskAMVO =taskThread.getImportTaskAMVO();
|
|
|
+ this.importTaskAMVO = taskThread.getImportTaskAMVO();
|
|
|
}
|
|
|
|
|
|
public void awakeTask(UploadPatentWebDTO uploadPatentWebDTO) {
|
|
@@ -112,21 +139,4 @@ public class SavePatentToEsThread extends Thread {
|
|
|
}
|
|
|
|
|
|
|
|
|
- //保存同族专利信息
|
|
|
-
|
|
|
-public void saveFamilyMessage(List<String> patentNos,String type){
|
|
|
- //根据专利号查询同族信息
|
|
|
- PatentStarApiService patentStarApiService = applicationContext.getBean(PatentStarApiService.class);
|
|
|
- String familyStr = patentStarApiService.getFamilyByPubNoApi("CN116825114A");
|
|
|
- //根据专利号查询同族
|
|
|
- EsService esService =applicationContext.getBean(EsService.class);
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
- //保存专利事务信息
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|