|
@@ -2,16 +2,22 @@ package com.example.xiaoshiweixinback.service.importPatent;
|
|
|
|
|
|
import com.example.xiaoshiweixinback.business.utils.FileUtils;
|
|
|
import com.example.xiaoshiweixinback.business.utils.FormatUtil;
|
|
|
+import com.example.xiaoshiweixinback.business.utils.ImageUtil;
|
|
|
import com.example.xiaoshiweixinback.domain.es.Patent;
|
|
|
import com.example.xiaoshiweixinback.domain.es.PatentClassify;
|
|
|
import com.example.xiaoshiweixinback.domain.es.PatentVector;
|
|
|
import com.example.xiaoshiweixinback.entity.dto.patent.UploadPatentWebDTO;
|
|
|
+import com.example.xiaoshiweixinback.entity.ops.GetFuTuParamsDTO;
|
|
|
+import com.example.xiaoshiweixinback.entity.ops.ImagesInfoVO;
|
|
|
import com.example.xiaoshiweixinback.service.common.FileManagerService;
|
|
|
import com.example.xiaoshiweixinback.service.common.GetVectorService;
|
|
|
+import com.example.xiaoshiweixinback.service.common.OPSService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
import java.io.File;
|
|
|
+import java.io.FileFilter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
@@ -27,42 +33,62 @@ public class GetPatentPictureFromWebService {
|
|
|
private EsService esService;
|
|
|
@Autowired
|
|
|
private GetVectorService getVectorService;
|
|
|
+ @Autowired
|
|
|
+ private OPSService opsService;
|
|
|
|
|
|
public void getPatentPicture(UploadPatentWebDTO uploadPatentWebDTO) {
|
|
|
+ String appNo=uploadPatentWebDTO.getPatent().getAppNo();
|
|
|
+ if(appNo.contains("CN")){
|
|
|
+ this.getCNPatentPicture(uploadPatentWebDTO);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.getWdPatentPicture(uploadPatentWebDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getCNPatentPicture(UploadPatentWebDTO uploadPatentWebDTO) {
|
|
|
try {
|
|
|
|
|
|
- String pictureUrl = patentStarApiService.getPictureApi(uploadPatentWebDTO.getStarPatentVO().getRowApplicationNo());
|
|
|
+ List<String> pictureUrls = patentStarApiService.getExternalFigure(uploadPatentWebDTO.getStarPatentVO().getRowApplicationNo());
|
|
|
+ Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
+ if (pictureUrls != null && pictureUrls.size()>0) {
|
|
|
+ for (int i=0;i<pictureUrls.size();i++){
|
|
|
+ String pictureUrl =pictureUrls.get(i);
|
|
|
+ File file = FileUtils.getPictureFileByUrl(pictureUrl);
|
|
|
+ String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getStarPatentVO().getApplicationNo());
|
|
|
+ fileManagerService.uploadFileWithGuid(file, guid);
|
|
|
+ PatentVector patentVectorOrg = esService.getVectorByIndex(patent.getAppNo(), 0);
|
|
|
+ if (patentVectorOrg != null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.addPatentVector(uploadPatentWebDTO, file, i);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getWdPatentPicture(UploadPatentWebDTO uploadPatentWebDTO) {
|
|
|
+ try {
|
|
|
Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
- if (pictureUrl != null && !pictureUrl.contains("408")) {
|
|
|
- File file = FileUtils.getPictureFileByUrl(pictureUrl);
|
|
|
- String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getStarPatentVO().getApplicationNo());
|
|
|
- fileManagerService.uploadFileWithGuid(file, guid);
|
|
|
- PatentVector patentVectorOrg = esService.getVectorByIndex(patent.getAppNo(),0);
|
|
|
- if(patentVectorOrg!=null){
|
|
|
- return;
|
|
|
+ String appNo = patent.getAppNo();
|
|
|
+ List<ImagesInfoVO> imagesInfoVOS = opsService.getImageInfos(patent.getPublicNo());
|
|
|
+ ImagesInfoVO infoVO = imagesInfoVOS.stream().filter(item -> item.getImageType().equals("Drawing")).findFirst().orElse(null);
|
|
|
+ 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.getStarPatentVO().getApplicationNo());
|
|
|
+ File file = files.get(i);
|
|
|
+ fileManagerService.uploadFileWithGuid(file, guid);
|
|
|
+ PatentVector patentVectorOrg = esService.getVectorByIndex(patent.getAppNo(), 0);
|
|
|
+ if (patentVectorOrg != null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.addPatentVector(uploadPatentWebDTO, file, i);
|
|
|
}
|
|
|
- PatentVector patentVector = new PatentVector();
|
|
|
- patentVector.setAppNo(patent.getAppNo());
|
|
|
- patentVector.setTitle(patent.getTitle());
|
|
|
- patentVector.setRightHolder(patent.getRightHolder());
|
|
|
- patentVector.setAppDate(patent.getAppDate());
|
|
|
- patentVector.setAbstractStr(patent.getAbstractStr());
|
|
|
- patentVector.setAppCountry(patent.getAppCountry());
|
|
|
- PatentClassify patentClassify =new PatentClassify();
|
|
|
- patentClassify.setLevel1(uploadPatentWebDTO.getStarPatentVO().getMainIpc());
|
|
|
- patentVector.setLoc(Arrays.asList(patentClassify));
|
|
|
- patentVector.setImageIndex(0);
|
|
|
- patentVector.setGuid(guid);
|
|
|
- List<String> stringList = getVectorService.getVectorByFile(file);
|
|
|
- List<Float> floats =new ArrayList<>();
|
|
|
- stringList.forEach(item->{
|
|
|
- Float a =Float.parseFloat(item);
|
|
|
- floats.add(a);
|
|
|
-
|
|
|
- });
|
|
|
- org.apache.commons.io.FileUtils.deleteQuietly(file);
|
|
|
- patentVector.setMyVector(floats);
|
|
|
- esService.addPatentVector(patentVector);
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
@@ -71,4 +97,32 @@ public class GetPatentPictureFromWebService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public void addPatentVector(UploadPatentWebDTO uploadPatentWebDTO, File file, Integer index) throws Exception {
|
|
|
+ String guid = FormatUtil.getPictureFormat(uploadPatentWebDTO.getStarPatentVO().getApplicationNo());
|
|
|
+
|
|
|
+ Patent patent = uploadPatentWebDTO.getPatent();
|
|
|
+ PatentVector patentVector = new PatentVector();
|
|
|
+ patentVector.setAppNo(patent.getAppNo());
|
|
|
+ patentVector.setTitle(patent.getTitle());
|
|
|
+ patentVector.setRightHolder(patent.getRightHolder());
|
|
|
+ patentVector.setAppDate(patent.getAppDate());
|
|
|
+ patentVector.setAbstractStr(patent.getAbstractStr());
|
|
|
+ patentVector.setAppCountry(patent.getAppCountry());
|
|
|
+ PatentClassify patentClassify = new PatentClassify();
|
|
|
+ patentClassify.setLevel1(uploadPatentWebDTO.getStarPatentVO().getMainIpc());
|
|
|
+ patentVector.setLoc(Arrays.asList(patentClassify));
|
|
|
+ patentVector.setImageIndex(index);
|
|
|
+ patentVector.setGuid(guid);
|
|
|
+ List<String> stringList = getVectorService.getVectorByFile(file);
|
|
|
+ List<Float> floats = new ArrayList<>();
|
|
|
+ stringList.forEach(item -> {
|
|
|
+ Float a = Float.parseFloat(item);
|
|
|
+ floats.add(a);
|
|
|
+
|
|
|
+ });
|
|
|
+ org.apache.commons.io.FileUtils.deleteQuietly(file);
|
|
|
+ patentVector.setMyVector(floats);
|
|
|
+ esService.addPatentVector(patentVector);
|
|
|
+ }
|
|
|
+
|
|
|
}
|