|
@@ -37,33 +37,51 @@ public class GetPatentPictureFromWebService {
|
|
|
private OPSService opsService;
|
|
|
|
|
|
public void getPatentPicture(UploadPatentWebDTO uploadPatentWebDTO) {
|
|
|
- String appNo=uploadPatentWebDTO.getPatent().getAppNo();
|
|
|
- if(appNo.contains("CN")){
|
|
|
- this.getCNPatentPicture(uploadPatentWebDTO);
|
|
|
- }
|
|
|
- else {
|
|
|
- this.getWdPatentPicture(uploadPatentWebDTO);
|
|
|
- }
|
|
|
+ String appNo = uploadPatentWebDTO.getPatent().getAppNo();
|
|
|
+
|
|
|
+ if (appNo == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (appNo.contains("CN")) {
|
|
|
+ this.getCNPatentPicture(uploadPatentWebDTO);
|
|
|
+ } else {
|
|
|
+ this.getWdPatentPicture(uploadPatentWebDTO);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void getCNPatentPicture(UploadPatentWebDTO uploadPatentWebDTO) {
|
|
|
try {
|
|
|
-
|
|
|
+ Long startMillis = System.currentTimeMillis();
|
|
|
List<String> pictureUrls = patentStarApiService.getExternalFigure(uploadPatentWebDTO.getStarPatentVO().getRowApplicationNo());
|
|
|
+ Long endMillis = System.currentTimeMillis();
|
|
|
+
|
|
|
+ System.out.println("获取图片时间"+(endMillis-startMillis));
|
|
|
Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
- if (pictureUrls != null && pictureUrls.size()>0) {
|
|
|
- for (int i=0;i<pictureUrls.size();i++){
|
|
|
+ if (pictureUrls != null && pictureUrls.size() > 0) {
|
|
|
+ for (int i = 0; i < pictureUrls.size(); i++) {
|
|
|
PatentVector patentVectorOrg = esService.getVectorByIndex(patent.getAppNo(), i);
|
|
|
- if(patentVectorOrg!=null){
|
|
|
- continue;
|
|
|
- }
|
|
|
- String pictureUrl =pictureUrls.get(i);
|
|
|
+ Long s1 = System.currentTimeMillis();
|
|
|
+ String pictureUrl = pictureUrls.get(i);
|
|
|
+ Long s4 = System.currentTimeMillis();
|
|
|
File file = FileUtils.getPictureFileByUrl(pictureUrl);
|
|
|
- String guid = FormatUtil.getPictureFormat(patent.getAppNo())+i;
|
|
|
+ Long e4 = System.currentTimeMillis();
|
|
|
+ System.out.println("下载文件耗时"+(e4-s4));
|
|
|
+ String guid = FormatUtil.getPictureFormat(patent.getAppNo()) + i;
|
|
|
fileManagerService.uploadFileWithGuid(file, guid);
|
|
|
-
|
|
|
- this.addPatentVector(uploadPatentWebDTO, file, i,patentVectorOrg);
|
|
|
- org.apache.commons.io.FileUtils.deleteQuietly(file);
|
|
|
+ Long e1 = System.currentTimeMillis();
|
|
|
+ System.out.println("上传文件耗时"+(e1-s1));
|
|
|
+ System.out.println("P" + i);
|
|
|
+ if (patentVectorOrg != null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Long s2 = System.currentTimeMillis();
|
|
|
+ this.addPatentVector(uploadPatentWebDTO, file, i, patentVectorOrg);
|
|
|
+ Long e2 = System.currentTimeMillis();
|
|
|
+ System.out.println("向量部分耗时"+(e2-s2));
|
|
|
+ Long s3 =System.currentTimeMillis();
|
|
|
+ file.delete();
|
|
|
+ Long e3 =System.currentTimeMillis();
|
|
|
+ System.out.println("删除文件耗时"+(e3-s3));
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -82,12 +100,12 @@ public class GetPatentPictureFromWebService {
|
|
|
List<File> files = opsService.getImageFiles(infoVO, appNo);
|
|
|
if (files != null && files.size() > 0) {
|
|
|
for (int i = 0; i < files.size(); i++) {
|
|
|
- String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getPatent().getAppNo())+i;
|
|
|
+ String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getPatent().getAppNo()) + i;
|
|
|
File file = files.get(i);
|
|
|
fileManagerService.uploadFileWithGuid(file, guid);
|
|
|
PatentVector patentVectorOrg = esService.getVectorByIndex(patent.getAppNo(), i);
|
|
|
|
|
|
- this.addPatentVector(uploadPatentWebDTO, file, i,patentVectorOrg);
|
|
|
+ this.addPatentVector(uploadPatentWebDTO, file, i, patentVectorOrg);
|
|
|
|
|
|
org.apache.commons.io.FileUtils.deleteQuietly(file);
|
|
|
}
|
|
@@ -99,10 +117,9 @@ public class GetPatentPictureFromWebService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void addPatentVector(UploadPatentWebDTO uploadPatentWebDTO, File file, Integer index,PatentVector patentVectorOrg) throws Exception {
|
|
|
-
|
|
|
+ public void addPatentVector(UploadPatentWebDTO uploadPatentWebDTO, File file, Integer index, PatentVector patentVectorOrg) throws Exception {
|
|
|
|
|
|
- String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getPatent().getAppNo())+index;
|
|
|
+ String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getPatent().getAppNo()) + index;
|
|
|
|
|
|
Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
PatentVector patentVector = new PatentVector();
|
|
@@ -115,7 +132,10 @@ public class GetPatentPictureFromWebService {
|
|
|
patentVector.setLoc(uploadPatentWebDTO.getPatent().getIpc());
|
|
|
patentVector.setImageIndex(index);
|
|
|
patentVector.setGuid(guid);
|
|
|
+ Long s1= System.currentTimeMillis();
|
|
|
List<String> stringList = getVectorService.getVectorByFile(file);
|
|
|
+ Long e1 =System.currentTimeMillis();
|
|
|
+ System.out.println("获取向量耗时"+(e1-s1));
|
|
|
List<Float> floats = new ArrayList<>();
|
|
|
stringList.forEach(item -> {
|
|
|
Float a = Float.parseFloat(item);
|
|
@@ -123,11 +143,13 @@ public class GetPatentPictureFromWebService {
|
|
|
|
|
|
});
|
|
|
patentVector.setMyVector(floats);
|
|
|
- if(patentVectorOrg!=null){
|
|
|
- esService.updatePatentVector(patentVector,patentVectorOrg.getId());
|
|
|
- }
|
|
|
- else {
|
|
|
+ if (patentVectorOrg != null) {
|
|
|
+ esService.updatePatentVector(patentVector, patentVectorOrg.getId());
|
|
|
+ } else {
|
|
|
+ Long s2= System.currentTimeMillis();
|
|
|
esService.addPatentVector(patentVector);
|
|
|
+ Long e2 =System.currentTimeMillis();
|
|
|
+ System.out.println("保存向量耗时"+(e2-s2));
|
|
|
}
|
|
|
|
|
|
}
|