|
@@ -11,9 +11,7 @@ import com.example.xiaoshiweixinback.domain.es.Patent;
|
|
|
import com.example.xiaoshiweixinback.domain.es.PatentVector;
|
|
|
import com.example.xiaoshiweixinback.entity.dto.importTaskModel.ImportTaskText;
|
|
|
import com.example.xiaoshiweixinback.entity.dto.patent.UploadPatentWebDTO;
|
|
|
-import com.example.xiaoshiweixinback.service.importPatent.GetPatentFromExcelService;
|
|
|
-import com.example.xiaoshiweixinback.service.importPatent.GetPatentPictureFromExcelService;
|
|
|
-import com.example.xiaoshiweixinback.service.importPatent.SavePatentToEsService;
|
|
|
+import com.example.xiaoshiweixinback.service.importPatent.*;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
|
import org.apache.poi.ss.usermodel.Drawing;
|
|
|
import org.apache.poi.ss.usermodel.PictureData;
|
|
@@ -37,20 +35,24 @@ public class GetPatentFromSzService {
|
|
|
private GetPatentPictureFromExcelService getPatentPictureFromExcelService;
|
|
|
@Autowired
|
|
|
private SavePatentToEsService savePatentToEsService;
|
|
|
+ @Autowired
|
|
|
+ private GetPatentPictureFromWebService getPatentPictureFromWebService;
|
|
|
|
|
|
public void test(String pathStr) throws Exception {
|
|
|
- String[] paths = pathStr.split(",");
|
|
|
- for (int t = 0; t < paths.length; t++) {
|
|
|
- String path = paths[t];
|
|
|
-
|
|
|
- File tempFile = new File(path);
|
|
|
+ File file= CommonService.getFile("importFile");
|
|
|
+ if(file==null||file.listFiles().length==0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ File[] files =file.listFiles();
|
|
|
+ for (int t = 0; t < files.length; t++) {
|
|
|
+ File tempFile = files[t];
|
|
|
|
|
|
Sheet sheet = ReadExcelUtils.readExcel(tempFile);
|
|
|
int total = sheet.getPhysicalNumberOfRows() - 1;
|
|
|
Row firstRow = sheet.getRow(0);
|
|
|
int columns = firstRow.getLastCellNum();
|
|
|
|
|
|
- List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "",null);
|
|
|
+ List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "", null);
|
|
|
|
|
|
for (int r = 0; r < total; r++) {
|
|
|
Row needRow = sheet.getRow(r + 1);
|
|
@@ -60,29 +62,19 @@ public class GetPatentFromSzService {
|
|
|
}
|
|
|
UploadParamsVO uploadParamsVO = UploadPatentBatchUtil.processData(map, jsonData);
|
|
|
getPatentFromExcelService.loadPatent(uploadParamsVO);
|
|
|
-
|
|
|
- List<PictureData> pictureDatas = ReadExcelUtils.getPictures((XSSFSheet) sheet, r + 1);
|
|
|
-
|
|
|
- for (int i = 0; i < pictureDatas.size(); i++) {
|
|
|
- PictureData pictureData = pictureDatas.get(i);
|
|
|
- String ext = pictureData.suggestFileExtension();
|
|
|
- byte[] data = pictureData.getData();
|
|
|
- String picName = IdUtil.simpleUUID();
|
|
|
- File file = FileUtils.getFileByBytes(data, picName, "." + ext);
|
|
|
- getPatentPictureFromExcelService.tem(file, uploadParamsVO.getPatent(), i);
|
|
|
- }
|
|
|
UploadPatentWebDTO uploadPatentWebDTO = new UploadPatentWebDTO();
|
|
|
uploadPatentWebDTO.setPatent(uploadParamsVO.getPatent());
|
|
|
+ getPatentPictureFromWebService.getWdPatentPicture(uploadPatentWebDTO);
|
|
|
savePatentToEsService.saveOrUpdate(uploadPatentWebDTO);
|
|
|
System.out.println(r);
|
|
|
}
|
|
|
System.out.println("完成" + t);
|
|
|
//获得总列数
|
|
|
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public void test2(String pathStr) throws Exception {
|
|
|
String[] paths = pathStr.split(",");
|
|
|
for (int t = 0; t < paths.length; t++) {
|
|
@@ -94,7 +86,7 @@ public class GetPatentFromSzService {
|
|
|
Row firstRow = sheet.getRow(0);
|
|
|
int columns = firstRow.getLastCellNum();
|
|
|
|
|
|
- List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "",null);
|
|
|
+ List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "", null);
|
|
|
|
|
|
for (int r = 0; r < total; r++) {
|
|
|
Row needRow = sheet.getRow(r + 1);
|
|
@@ -128,21 +120,21 @@ public class GetPatentFromSzService {
|
|
|
for (int t = 0; t < paths.length; t++) {
|
|
|
String path = paths[t];
|
|
|
String rootPath = "D:\\usa_patent\\202205-3498\\";
|
|
|
- String a =path.replace(".xlsx","");
|
|
|
- path =rootPath+path;
|
|
|
+ String a = path.replace(".xlsx", "");
|
|
|
+ path = rootPath + path;
|
|
|
File tempFile = new File(path);
|
|
|
|
|
|
Sheet sheet = ReadExcelUtils.readExcel(tempFile);
|
|
|
int total = sheet.getPhysicalNumberOfRows() - 1;
|
|
|
Row firstRow = sheet.getRow(0);
|
|
|
int columns = firstRow.getLastCellNum();
|
|
|
- List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "",null);
|
|
|
+ List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting(5 + "", null);
|
|
|
|
|
|
- String picturePath= "D:\\patentImage\\";
|
|
|
+ String picturePath = "D:\\patentImage\\";
|
|
|
|
|
|
- File temFile =new File(picturePath+a);
|
|
|
+ File temFile = new File(picturePath + a);
|
|
|
File[] files = temFile.listFiles();
|
|
|
- for (int r =0; r < total; r++) {
|
|
|
+ for (int r = 0; r < total; r++) {
|
|
|
Row needRow = sheet.getRow(r + 1);
|
|
|
Map<Object, Object> map = new HashMap<>();
|
|
|
for (int i = 0; i < columns; i++) {
|
|
@@ -151,13 +143,13 @@ public class GetPatentFromSzService {
|
|
|
UploadParamsVO uploadParamsVO = UploadPatentBatchUtil.processData(map, jsonData);
|
|
|
getPatentFromExcelService.loadPatent(uploadParamsVO);
|
|
|
String appNo = uploadParamsVO.getPatent().getAppNo();
|
|
|
- List<File> files1= Arrays.stream(files).filter(item -> item.getName().contains(appNo)).collect(Collectors.toList());
|
|
|
+ List<File> files1 = Arrays.stream(files).filter(item -> item.getName().contains(appNo)).collect(Collectors.toList());
|
|
|
|
|
|
for (int i = 0; i < files1.size(); i++) {
|
|
|
File file = files1.get(i);
|
|
|
- String numStr= file.getName().substring(file.getName().indexOf("_")+1,file.getName().indexOf("."));
|
|
|
- Integer index =Integer.parseInt(numStr);
|
|
|
- getPatentPictureFromExcelService.tem(file, uploadParamsVO.getPatent(),index+1 );
|
|
|
+ String numStr = file.getName().substring(file.getName().indexOf("_") + 1, file.getName().indexOf("."));
|
|
|
+ Integer index = Integer.parseInt(numStr);
|
|
|
+ getPatentPictureFromExcelService.tem(file, uploadParamsVO.getPatent(), index + 1);
|
|
|
}
|
|
|
UploadPatentWebDTO uploadPatentWebDTO = new UploadPatentWebDTO();
|
|
|
uploadPatentWebDTO.setPatent(uploadParamsVO.getPatent());
|