|
@@ -31,10 +31,7 @@ import java.io.ByteArrayInputStream;
|
|
|
import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.InputStream;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -149,50 +146,57 @@ public class ImportFromWebToEsService implements PatentImportImp {
|
|
|
}
|
|
|
|
|
|
//当专利为专利号导入时
|
|
|
- else if (importTaskAMVO.getType().equals(2)) {
|
|
|
+ if (importTaskAMVO.getType().equals(2) || importTaskAMVO.getType().equals(3)) {
|
|
|
+
|
|
|
+ Map<String, List<String>> map=new HashMap<>();
|
|
|
PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
|
|
|
patentStarListDTO.setCurrentQuery(conditions)
|
|
|
.setOrderBy(orderBy)
|
|
|
.setOrderByType(orderByType)
|
|
|
.setDBType(dbType);
|
|
|
- Map<String, List<String>> map = BusinessUtil.getPatentNosMap(conditions);
|
|
|
- List<PatentStarListDTO> patentStarListDtos1 = patentStarApiService.splitPatentNoByType(map.get(BusinessUtil.PUBLIC_NO), patentStarListDTO, 1);
|
|
|
- List<PatentStarListDTO> patentStarListDtos2 = patentStarApiService.splitPatentNoByType(map.get(BusinessUtil.APP_NO), patentStarListDTO, 0);
|
|
|
- patentStarListDtos.addAll(patentStarListDtos1);
|
|
|
- patentStarListDtos.addAll(patentStarListDtos2);
|
|
|
- }
|
|
|
+ if (importTaskAMVO.getType().equals(2)) {
|
|
|
+ map = BusinessUtil.getPatentNosMap(conditions);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //当专利为专利号文件导入时
|
|
|
+ else if (importTaskAMVO.getType().equals(3)) {
|
|
|
+ FileManagerService fileManagerService = applicationContext.getBean(FileManagerService.class);
|
|
|
+
|
|
|
+ String res = fileManagerService.getSystemFileFromFMS(Arrays.asList(importTaskAMVO.getFileGuid()));
|
|
|
+ List<SystemFile> systemFiles = JSONArray.parseArray(res, SystemFile.class);
|
|
|
+ SystemFile systemFile = systemFiles.get(0);
|
|
|
+ String suffix = systemFile.getFileName().substring(systemFile.getFileName().lastIndexOf("."));
|
|
|
+ //调用文件系统取出文件接口,获得文件流
|
|
|
+ byte[] bytes = fileManagerService.downloadSystemFileFromFMS(importTaskAMVO.getFileGuid());
|
|
|
+ //创建临时文件tempFile,并将文件读取到tempFile
|
|
|
+ File tempFile = File.createTempFile(systemFile.getFileName() + "temp", suffix);
|
|
|
+ try (
|
|
|
+ InputStream inputStream = new ByteArrayInputStream(bytes);
|
|
|
+ FileOutputStream outputStream = new FileOutputStream(tempFile)
|
|
|
+ ) {
|
|
|
+ IOUtils.copy(inputStream, outputStream); // 将输入流复制到临时文件
|
|
|
+ }
|
|
|
+ Sheet sheet = ReadExcelUtils.readExcel(tempFile);
|
|
|
+ map = ReadExcelUtils.getPatentNoFromExcel(sheet);
|
|
|
|
|
|
- //当专利为专利号文件导入时
|
|
|
- else if (importTaskAMVO.getType().equals(3)) {
|
|
|
- FileManagerService fileManagerService = applicationContext.getBean(FileManagerService.class);
|
|
|
-
|
|
|
- String res = fileManagerService.getSystemFileFromFMS(Arrays.asList(importTaskAMVO.getFileGuid()));
|
|
|
- List<SystemFile> systemFiles = JSONArray.parseArray(res, SystemFile.class);
|
|
|
- SystemFile systemFile = systemFiles.get(0);
|
|
|
- String suffix = systemFile.getFileName().substring(systemFile.getFileName().lastIndexOf("."));
|
|
|
- //调用文件系统取出文件接口,获得文件流
|
|
|
- byte[] bytes = fileManagerService.downloadSystemFileFromFMS(importTaskAMVO.getFileGuid());
|
|
|
- //创建临时文件tempFile,并将文件读取到tempFile
|
|
|
- File tempFile = File.createTempFile(systemFile.getFileName() + "temp", suffix);
|
|
|
- try (
|
|
|
- InputStream inputStream = new ByteArrayInputStream(bytes);
|
|
|
- FileOutputStream outputStream = new FileOutputStream(tempFile)
|
|
|
- ) {
|
|
|
- IOUtils.copy(inputStream, outputStream); // 将输入流复制到临时文件
|
|
|
}
|
|
|
- Sheet sheet = ReadExcelUtils.readExcel(tempFile);
|
|
|
- Map<String, List<String>> map = ReadExcelUtils.getPatentNoFromExcel(sheet);
|
|
|
List<String> appNos = map.get(BusinessUtil.APP_NO);
|
|
|
List<String> publicNos = map.get(BusinessUtil.PUBLIC_NO);
|
|
|
- PatentStarListDTO patentStarListDTO = new PatentStarListDTO();
|
|
|
- patentStarListDTO.setCurrentQuery(conditions)
|
|
|
- .setOrderBy(orderBy)
|
|
|
- .setOrderByType(orderByType)
|
|
|
- .setDBType(dbType);
|
|
|
- List<PatentStarListDTO> patentStarListDtos1 = patentStarApiService.splitPatentNoByType(appNos, patentStarListDTO, 0);
|
|
|
- List<PatentStarListDTO> patentStarListDtos2 = patentStarApiService.splitPatentNoByType(publicNos, patentStarListDTO, 1);
|
|
|
- patentStarListDtos.addAll(patentStarListDtos1);
|
|
|
- patentStarListDtos.addAll(patentStarListDtos2);
|
|
|
+ List<String> patentNos =map.get(BusinessUtil.PATENT_NO);
|
|
|
+ if(appNos!=null&&appNos.size()>0){
|
|
|
+ List<PatentStarListDTO> patentStarListDtos1 = patentStarApiService.splitPatentNoByType(appNos, patentStarListDTO, 0);
|
|
|
+ patentStarListDtos.addAll(patentStarListDtos1);
|
|
|
+ }
|
|
|
+ if(publicNos!=null&&publicNos.size()>0){
|
|
|
+ List<PatentStarListDTO> patentStarListDtos2 = patentStarApiService.splitPatentNoByType(publicNos, patentStarListDTO, 1);
|
|
|
+ patentStarListDtos.addAll(patentStarListDtos2);
|
|
|
+ }
|
|
|
+ if(patentNos!=null&&patentNos.size()>0){
|
|
|
+ List<PatentStarListDTO> patentStarListDtos3 = patentStarApiService.splitPatentNoByType(map.get(BusinessUtil.PATENT_NO), patentStarListDTO, 3);
|
|
|
+ patentStarListDtos.addAll(patentStarListDtos3);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
char ifCataloguing = importTaskAMVO.getIfAddCatalogue();
|