|
@@ -1,6 +1,9 @@
|
|
package cn.cslg.pas.service.business.es;
|
|
package cn.cslg.pas.service.business.es;
|
|
|
|
|
|
|
|
+import cn.cslg.pas.common.dto.PatentColumnDTO;
|
|
|
|
+import cn.cslg.pas.common.dto.PatentDTO;
|
|
import cn.cslg.pas.common.model.es.GetVectorVO;
|
|
import cn.cslg.pas.common.model.es.GetVectorVO;
|
|
|
|
+import cn.cslg.pas.common.model.request.QueryRequest;
|
|
import cn.cslg.pas.domain.es.Patent;
|
|
import cn.cslg.pas.domain.es.Patent;
|
|
import cn.cslg.pas.domain.es.PatentJoin;
|
|
import cn.cslg.pas.domain.es.PatentJoin;
|
|
import cn.cslg.pas.domain.es.Text;
|
|
import cn.cslg.pas.domain.es.Text;
|
|
@@ -26,9 +29,10 @@ public class EsPatentVectorService {
|
|
private final ElasticsearchClient client;
|
|
private final ElasticsearchClient client;
|
|
private final PythonApiService pythonApiService;
|
|
private final PythonApiService pythonApiService;
|
|
private final EsService esService;
|
|
private final EsService esService;
|
|
-
|
|
|
|
|
|
+ private final EsPatentService esPatentService;
|
|
public void addPatentVector(Patent patent, String id) throws Exception {
|
|
public void addPatentVector(Patent patent, String id) throws Exception {
|
|
Boolean ifHaveVector = this.searchIfHaveVector(id);
|
|
Boolean ifHaveVector = this.searchIfHaveVector(id);
|
|
|
|
+ System.out.println(id);
|
|
if (!ifHaveVector) {
|
|
if (!ifHaveVector) {
|
|
this.addPatentVectorToEs(patent, id);
|
|
this.addPatentVectorToEs(patent, id);
|
|
}
|
|
}
|
|
@@ -61,6 +65,7 @@ public class EsPatentVectorService {
|
|
GetVectorVO getVectorVO = new GetVectorVO();
|
|
GetVectorVO getVectorVO = new GetVectorVO();
|
|
getVectorVO.setText(abStr);
|
|
getVectorVO.setText(abStr);
|
|
List<Float> floatList = pythonApiService.getStrVector(getVectorVO);
|
|
List<Float> floatList = pythonApiService.getStrVector(getVectorVO);
|
|
|
|
+ System.out.println("向量"+floatList.size());
|
|
Patent patent1 = new Patent();
|
|
Patent patent1 = new Patent();
|
|
PatentJoin patentJoin = new PatentJoin();
|
|
PatentJoin patentJoin = new PatentJoin();
|
|
patentJoin.setParent(patentId);
|
|
patentJoin.setParent(patentId);
|
|
@@ -79,9 +84,32 @@ public class EsPatentVectorService {
|
|
}
|
|
}
|
|
|
|
|
|
public void refreshPatentVector(Integer id) {
|
|
public void refreshPatentVector(Integer id) {
|
|
- if (id != null) {
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ long total = 1l;
|
|
|
|
+ long size = 10l;
|
|
|
|
+ long current = 0l;
|
|
|
|
|
|
|
|
|
|
|
|
+ while (size * current < total) {
|
|
|
|
+ current += 1;
|
|
|
|
+ QueryRequest queryRequest = new QueryRequest();
|
|
|
|
+ queryRequest.setProjectId(id);
|
|
|
|
+ queryRequest.setSize(size);
|
|
|
|
+ queryRequest.setCurrent(current);
|
|
|
|
+ try {
|
|
|
|
+ PatentDTO patentDTO = esPatentService.getPatentforVector(queryRequest);
|
|
|
|
+ total = patentDTO.getTotal();
|
|
|
|
+ System.out.println("总数"+total);
|
|
|
|
+ for (PatentColumnDTO patentColumnDTO : patentDTO.getPatents()) {
|
|
|
|
+ Patent patent =new Patent();
|
|
|
|
+ patent.setAbstractStr(patentColumnDTO.getAbstractStr());
|
|
|
|
+ this.addPatentVector(patent,patentColumnDTO.getPatentId());
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|