|
@@ -51,7 +51,7 @@ public class PatentExportService {
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
@Async
|
|
@Async
|
|
- public byte[] exportPatent(List<String> patentNos) throws IOException {
|
|
|
|
|
|
+ public String exportPatent(List<String> patentNos) throws IOException {
|
|
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
|
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
|
String patentExportJson = ExcuteConfigUtils.excuteConfigJson();
|
|
String patentExportJson = ExcuteConfigUtils.excuteConfigJson();
|
|
//selected字符串转PatentExportVO集合
|
|
//selected字符串转PatentExportVO集合
|
|
@@ -93,39 +93,38 @@ public class PatentExportService {
|
|
//遍历专利号数量
|
|
//遍历专利号数量
|
|
for (int i = 0; i < patentNos.size(); i++) {
|
|
for (int i = 0; i < patentNos.size(); i++) {
|
|
Map<String, Object> map = new LinkedHashMap<>();
|
|
Map<String, Object> map = new LinkedHashMap<>();
|
|
-
|
|
|
|
//获取专利信息
|
|
//获取专利信息
|
|
PatentColumnDTO patent = esPatentService.selectPatentByAppNo(patentNos.get(i));
|
|
PatentColumnDTO patent = esPatentService.selectPatentByAppNo(patentNos.get(i));
|
|
- if (patent == null) {
|
|
|
|
- defaultNum++;
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //遍历字段 配置map集合
|
|
|
|
- for (int j = 0; j < columns.size(); j++) {
|
|
|
|
- String column = columns.get(j);
|
|
|
|
- //解析出的patentExportVOS根据value匹配column字段,拿出对应字段的配置
|
|
|
|
- PatentExportVO patentExportVO = patentExportVOS.stream().filter(item -> item.getValue().equals(column)).findFirst().orElse(new PatentExportVO());
|
|
|
|
- //使用反射获取属性值 (例如:title->patent.getTitile())
|
|
|
|
- Object value = GenerateObjectUtil.getPropertyValue(patent, patentExportVO.getValue());
|
|
|
|
- if (value != null) {
|
|
|
|
- //解析专利配置文件
|
|
|
|
- String json = CommonService.readJsonFile("patent.json");
|
|
|
|
- List<PatentConfigVO> patentConfigVOS = JSON.parseArray(json, PatentConfigVO.class);
|
|
|
|
- PatentConfigVO patentConfigVO = patentConfigVOS.stream().filter(item -> item.getValue().equals(column)).findFirst().orElse(null);
|
|
|
|
- String exportClass = patentConfigVO.getExportClass();
|
|
|
|
- GetValueImp getValueImp = patentExportFactory.getClass(exportClass);
|
|
|
|
- if (getValueImp != null) {
|
|
|
|
- String reValue = getValueImp.getValue(value);
|
|
|
|
- map.put(patentExportVO.getName(), reValue);
|
|
|
|
|
|
+ if (patent != null) {
|
|
|
|
+ //遍历字段 配置map集合
|
|
|
|
+ for (int j = 0; j < columns.size(); j++) {
|
|
|
|
+ String column = columns.get(j);
|
|
|
|
+ //解析出的patentExportVOS根据value匹配column字段,拿出对应字段的配置
|
|
|
|
+ PatentExportVO patentExportVO = patentExportVOS.stream().filter(item -> item.getValue().equals(column)).findFirst().orElse(new PatentExportVO());
|
|
|
|
+ //使用反射获取属性值 (例如:title->patent.getTitile())
|
|
|
|
+ Object value = GenerateObjectUtil.getPropertyValue(patent, patentExportVO.getValue());
|
|
|
|
+ if (value != null) {
|
|
|
|
+ //解析专利配置文件
|
|
|
|
+ String json = CommonService.readJsonFile("patent.json");
|
|
|
|
+ List<PatentConfigVO> patentConfigVOS = JSON.parseArray(json, PatentConfigVO.class);
|
|
|
|
+ PatentConfigVO patentConfigVO = patentConfigVOS.stream().filter(item -> item.getValue().equals(column)).findFirst().orElse(null);
|
|
|
|
+ if (patentConfigVO != null) {
|
|
|
|
+ String exportClass = patentConfigVO.getExportClass();
|
|
|
|
+ if (exportClass != null) {
|
|
|
|
+ GetValueImp getValueImp = patentExportFactory.getClass(exportClass);
|
|
|
|
+ if (getValueImp != null) {
|
|
|
|
+ String reValue = getValueImp.getValue(value);
|
|
|
|
+ map.put(patentExportVO.getName(), reValue);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ map.put("专利号", patentNos.get(i));
|
|
}
|
|
}
|
|
-
|
|
|
|
HSSFRow row = sheet.createRow(i + 1);//新建一普通行
|
|
HSSFRow row = sheet.createRow(i + 1);//新建一普通行
|
|
row.setHeight((short) 800);
|
|
row.setHeight((short) 800);
|
|
-
|
|
|
|
-
|
|
|
|
//填入数据
|
|
//填入数据
|
|
for (String key : map.keySet()) {
|
|
for (String key : map.keySet()) {
|
|
int index = headers.indexOf(key);
|
|
int index = headers.indexOf(key);
|
|
@@ -137,14 +136,20 @@ public class PatentExportService {
|
|
cell.setCellStyle(commonCellStyle);
|
|
cell.setCellStyle(commonCellStyle);
|
|
if (StringUtils.isNotNull(map.get(key))) {
|
|
if (StringUtils.isNotNull(map.get(key))) {
|
|
cell.setCellValue(String.valueOf(map.get(key)));
|
|
cell.setCellValue(String.valueOf(map.get(key)));
|
|
|
|
+ } else {
|
|
|
|
+ cell.setCellValue("");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
hssfWorkbook.write(out);
|
|
hssfWorkbook.write(out);
|
|
- return out.toByteArray();
|
|
|
|
|
|
+ String fileGuid = "";
|
|
|
|
+ if (out.toByteArray() != null && out.toByteArray().length != 0) {
|
|
|
|
+ fileGuid = parseByteToFileUtils.uploadFile(out.toByteArray(), 1);
|
|
|
|
+ }
|
|
|
|
+ return fileGuid;
|
|
} catch (FileNotFoundException e) {
|
|
} catch (FileNotFoundException e) {
|
|
throw new FileNotFoundException();
|
|
throw new FileNotFoundException();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|