|
@@ -1,6 +1,7 @@
|
|
|
package cn.cslg.pas.service.importPatent;
|
|
|
|
|
|
import cn.cslg.pas.common.dto.UploadPatentWebDTO;
|
|
|
+import cn.cslg.pas.common.dto.es.EsCustomFieldDTO;
|
|
|
import cn.cslg.pas.common.utils.FormatUtil;
|
|
|
import cn.cslg.pas.common.vo.ImportTaskAMVO;
|
|
|
import cn.cslg.pas.common.vo.PatentWithIdVO;
|
|
@@ -10,6 +11,7 @@ import cn.cslg.pas.domain.es.Patent;
|
|
|
import cn.cslg.pas.domain.es.PatentJoin;
|
|
|
import cn.cslg.pas.service.business.CompareLiteratureService;
|
|
|
import cn.cslg.pas.service.business.ImportTaskService;
|
|
|
+import cn.cslg.pas.service.business.es.EsCustomFieldService;
|
|
|
import cn.cslg.pas.service.business.es.EsMergePersonService;
|
|
|
import cn.cslg.pas.service.business.es.EsProductPatentService;
|
|
|
import cn.cslg.pas.service.business.es.EsService;
|
|
@@ -30,25 +32,26 @@ import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
|
|
public class SavePatentToEsThread extends Thread {
|
|
|
private ApplicationContext applicationContext;
|
|
|
- private List<Patent> patents = new ArrayList<>();
|
|
|
+ private List<UploadPatentWebDTO> uploadPatentWebDTOS = new ArrayList<>();
|
|
|
private Lock taskLock = new ReentrantLock();
|
|
|
- private Condition taskCondition = taskLock.newCondition();
|
|
|
+ private Condition taskCondition = taskLock.newCondition();
|
|
|
private TaskThread taskThread;
|
|
|
private ImportTaskAMVO importTaskAMVO;
|
|
|
private Boolean ifProductAll = false;
|
|
|
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- while ((!ifProductAll || patents.size() > 0) && importTaskAMVO.getState().equals(1)) {
|
|
|
+ while ((!ifProductAll || uploadPatentWebDTOS.size() > 0) && importTaskAMVO.getState().equals(1)) {
|
|
|
try {
|
|
|
//判断任务队列是否有任务,若没有则线程等待唤醒
|
|
|
- if (patents.size() == 0) {
|
|
|
+ if (uploadPatentWebDTOS.size() == 0) {
|
|
|
taskLock.lock();
|
|
|
taskCondition.await();
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
}
|
|
|
- Patent patent = patents.remove(0);
|
|
|
+ UploadPatentWebDTO uploadPatentWebDTO = uploadPatentWebDTOS.remove(0);
|
|
|
+ Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
try {
|
|
|
//根据专利号查询专利
|
|
|
EsService esService = applicationContext.getBean(EsService.class);
|
|
@@ -122,6 +125,30 @@ public class SavePatentToEsThread extends Thread {
|
|
|
EsProductPatentService esProductPatentService = applicationContext.getBean(EsProductPatentService.class);
|
|
|
esProductPatentService.addProductPatent(patentId, importTaskAMVO.getProductId());
|
|
|
}
|
|
|
+
|
|
|
+ //保存和自定义字段关联
|
|
|
+ if (importTaskAMVO.getFieldDTOS() != null && importTaskAMVO.getFieldDTOS().size() > 0) {
|
|
|
+ for (EsCustomFieldDTO esCustomFieldDTO : importTaskAMVO.getFieldDTOS()
|
|
|
+ ) {
|
|
|
+ esCustomFieldDTO.setPatentId(patentId);
|
|
|
+ esCustomFieldDTO.setOptionType(2);
|
|
|
+ EsCustomFieldService esCustomFieldService = applicationContext.getBean(EsCustomFieldService.class);
|
|
|
+ esCustomFieldService.addCustomField(esCustomFieldDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (uploadPatentWebDTO.getEsCustomFieldDTOList() != null && uploadPatentWebDTO.getEsCustomFieldDTOList().size() != 0) {
|
|
|
+ for (EsCustomFieldDTO esCustomFieldDTO : uploadPatentWebDTO.getEsCustomFieldDTOList()
|
|
|
+ ) {
|
|
|
+ esCustomFieldDTO.setPatentId(patentId);
|
|
|
+ esCustomFieldDTO.setOptionType(2);
|
|
|
+ EsCustomFieldService esCustomFieldService = applicationContext.getBean(EsCustomFieldService.class);
|
|
|
+ esCustomFieldService.addCustomField(esCustomFieldDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//导入完成,通知前台
|
|
|
taskThread.updateProcess(false, 1, "");
|
|
|
} catch (Exception e) {
|
|
@@ -138,10 +165,10 @@ public class SavePatentToEsThread extends Thread {
|
|
|
this.importTaskAMVO = taskThread.getImportTaskAMVO();
|
|
|
}
|
|
|
|
|
|
- public void awakeTask(Patent patent) {
|
|
|
- Patent patent1 = new Patent();
|
|
|
- BeanUtils.copyProperties(patent, patent1);
|
|
|
- patents.add(patent1);
|
|
|
+ public void awakeTask(UploadPatentWebDTO uploadPatentWebDTO) {
|
|
|
+ UploadPatentWebDTO uploadPatentWebDTO1 = new UploadPatentWebDTO();
|
|
|
+ BeanUtils.copyProperties(uploadPatentWebDTO, uploadPatentWebDTO1);
|
|
|
+ uploadPatentWebDTOS.add(uploadPatentWebDTO1);
|
|
|
if (taskLock.tryLock()) {
|
|
|
taskCondition.signalAll();
|
|
|
taskLock.unlock();
|
|
@@ -151,9 +178,9 @@ public class SavePatentToEsThread extends Thread {
|
|
|
public void setIfProductAll(Boolean ifProductAll) {
|
|
|
|
|
|
this.ifProductAll = ifProductAll;
|
|
|
- System.out.println("专利导入全部结束"+ this.ifProductAll+importTaskAMVO.getId());
|
|
|
+ System.out.println("专利导入全部结束" + this.ifProductAll + importTaskAMVO.getId());
|
|
|
if (taskLock.tryLock()) {
|
|
|
- System.out.println("专利导入到es解锁"+importTaskAMVO.getId());
|
|
|
+ System.out.println("专利导入到es解锁" + importTaskAMVO.getId());
|
|
|
taskCondition.signalAll();
|
|
|
taskLock.unlock();
|
|
|
}
|