|
@@ -358,6 +358,35 @@ public class PatentExportService {
|
|
|
return records;
|
|
|
}
|
|
|
|
|
|
+ public Records queryPatents1(EsPatentCommonVO esPatentCommonVO) throws Exception {
|
|
|
+ List<PatentColumnDTO> patentList = new ArrayList<>();
|
|
|
+ Records records = new Records();
|
|
|
+ SearchRequest.Builder builder = esService.getCommonPatent(esPatentCommonVO);
|
|
|
+ SearchResponse<Patent> response = null;
|
|
|
+ try {
|
|
|
+ response = client.search(builder.build(), Patent.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
|
|
|
+ }
|
|
|
+ List<Hit<Patent>> hits = response.hits().hits();
|
|
|
+ Long total = 0L;
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotEmpty(esPatentCommonVO.getEsField())) {
|
|
|
+ Aggregate aggregate = response.aggregations().get("count");
|
|
|
+ total = aggregate.cardinality().value();
|
|
|
+ } else {
|
|
|
+ total = response.hits().total().value();
|
|
|
+ }
|
|
|
+ records.setTotal(total);
|
|
|
+ for (Hit<Patent> hit : hits) {
|
|
|
+ String id = hit.id();
|
|
|
+ Patent patent = hit.source();
|
|
|
+ PatentColumnDTO columnDTO = esService.getPatentColumnDTO(patent, esPatentCommonVO.getProjectId(), id, "1");
|
|
|
+ patentList.add(columnDTO);
|
|
|
+ }
|
|
|
+ records.setData(patentList);
|
|
|
+ return records;
|
|
|
+ }
|
|
|
+
|
|
|
@Async
|
|
|
public void exportPatent2(ExportTaskDTO exportTask, ImportTaskAMVO importTaskAMVO) throws Exception {
|
|
|
|
|
@@ -424,7 +453,7 @@ public class PatentExportService {
|
|
|
EsPatentCommonVO esPatentCommonVO = esService.tranPatentRequestToComVO(queryRequest);
|
|
|
esPatentCommonVO.setStartNum(startNum);
|
|
|
esPatentCommonVO.setEndNum(toNum);
|
|
|
- Records firstRecords = this.queryPatents(esPatentCommonVO);
|
|
|
+ Records firstRecords = this.queryPatents1(esPatentCommonVO);
|
|
|
|
|
|
Long total = 0l;
|
|
|
if (startNum != null && endNum != null) {
|
|
@@ -442,14 +471,14 @@ public class PatentExportService {
|
|
|
}
|
|
|
|
|
|
this.updateTaskStateToDoing(taskId,total);
|
|
|
- List<Patent> firstPatentList = (List<Patent>) firstRecords.getData();
|
|
|
- List<String> firstPatentNos = firstPatentList.stream().map(Patent::getPatentNo).collect(Collectors.toList());
|
|
|
+ List<PatentColumnDTO> firstPatentList = (List<PatentColumnDTO>) firstRecords.getData();
|
|
|
+ List<String> firstPatentNos = firstPatentList.stream().map(PatentColumnDTO::getPatentNo).collect(Collectors.toList());
|
|
|
|
|
|
//查询自定义字段
|
|
|
esQueryPatentFieldsDTO.setPatentNos(firstPatentNos);
|
|
|
List<EsPatentFieldsVO> firstEsPatentFieldsVOS = esCustomFieldService.getPatentFields(esQueryPatentFieldsDTO);
|
|
|
for (int i = 0; i < firstPatentList.size(); i++) {
|
|
|
- Patent patent = firstPatentList.get(i);
|
|
|
+ PatentColumnDTO patent = firstPatentList.get(i);
|
|
|
if (notInNos != null && notInNos.contains(patent.getPatentNo())) {
|
|
|
continue;
|
|
|
}
|
|
@@ -476,16 +505,15 @@ public class PatentExportService {
|
|
|
|
|
|
esPatentCommonVO.setStartNum(startNum);
|
|
|
esPatentCommonVO.setEndNum(toNum);
|
|
|
- Records records = this.queryPatents(esPatentCommonVO);
|
|
|
+ Records records = this.queryPatents1(esPatentCommonVO);
|
|
|
|
|
|
- List<Patent> patentList = (List<Patent>) records.getData();
|
|
|
- List<String> patentNos = patentList.stream().map(Patent::getPatentNo).collect(Collectors.toList());
|
|
|
- ;
|
|
|
+ List<PatentColumnDTO> patentList = (List<PatentColumnDTO>) records.getData();
|
|
|
+ List<String> patentNos = patentList.stream().map(PatentColumnDTO::getPatentNo).collect(Collectors.toList());
|
|
|
//查询自定义字段
|
|
|
esQueryPatentFieldsDTO.setPatentNos(patentNos);
|
|
|
List<EsPatentFieldsVO> esPatentFieldsVOS = esCustomFieldService.getPatentFields(esQueryPatentFieldsDTO);
|
|
|
for (int i = 0; i < patentList.size(); i++) {
|
|
|
- Patent patent = patentList.get(i);
|
|
|
+ PatentColumnDTO patent = patentList.get(i);
|
|
|
if (notInNos != null && notInNos.contains(patent.getPatentNo())) {
|
|
|
continue;
|
|
|
}
|
|
@@ -503,10 +531,11 @@ public class PatentExportService {
|
|
|
|
|
|
esQueryPatentFieldsDTO.setPatentNos(inNos);
|
|
|
List<EsPatentFieldsVO> esPatentFieldsVOS = esCustomFieldService.getPatentFields(esQueryPatentFieldsDTO);
|
|
|
- List<Patent> patentList = esPatentService.getPatentsByNo(inNos, true, null, null);
|
|
|
+// List<Patent> patentList = esPatentService.getPatentsByNo(inNos, true, null, null);
|
|
|
+ List<PatentColumnDTO> patentList = esPatentService.getPatentsByNo1(inNos, true, null, null,projectId);
|
|
|
for (int i = 0; i < patentList.size(); i++) {
|
|
|
|
|
|
- Patent patent = patentList.get(i);
|
|
|
+ PatentColumnDTO patent = patentList.get(i);
|
|
|
if (notInNos != null && notInNos.contains(patent.getPatentNo())) {
|
|
|
continue;
|
|
|
}
|
|
@@ -575,6 +604,67 @@ e.printStackTrace();
|
|
|
return commonCellStyle;
|
|
|
}
|
|
|
|
|
|
+ public void loadPatentCell(PatentColumnDTO patent, List<PatentExportVO> patentExportVOS, List<PatentConfigVO> patentConfigVOS, List<EsPatentFieldsVO> esPatentFieldsVOs, HSSFSheet sheet, HSSFCellStyle commonCellStyle, Integer index) {
|
|
|
+
|
|
|
+ HSSFRow row = sheet.createRow(index + 1);
|
|
|
+ row.setHeight((short) 800);
|
|
|
+ for (int j = 0; j < patentExportVOS.size(); j++) {
|
|
|
+ String column = patentExportVOS.get(j).getValue();
|
|
|
+ String name = patentExportVOS.get(j).getName();
|
|
|
+ String type = patentExportVOS.get(j).getType();
|
|
|
+
|
|
|
+ List<String> types = Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
|
|
|
+
|
|
|
+ if (types.contains(type)) {
|
|
|
+ EsPatentFieldsVO esPatentFieldsVO = esPatentFieldsVOs.stream()
|
|
|
+ .filter(item -> item.getPatentNo().equals(patent.getPatentNo()))
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
+ if (esPatentFieldsVO != null) {
|
|
|
+ List<InnerPatentFieldsVO> innerClassFields = esPatentFieldsVO.getInnerClassFields();
|
|
|
+ if (!innerClassFields.isEmpty()) {
|
|
|
+ InnerPatentFieldsVO innerPatentFieldsVO = innerClassFields.stream()
|
|
|
+ .filter(item -> item.getField().equals(column) && item.getFieldType().equals(Integer.parseInt(type)))
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
+ if (innerPatentFieldsVO != null) {
|
|
|
+ List<FieldValueVO> fieldValueVOS = innerPatentFieldsVO.getFieldValueVOS();
|
|
|
+ if (!fieldValueVOS.isEmpty()) {
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for (FieldValueVO fieldValueVO : fieldValueVOS) {
|
|
|
+ String valueStr = fieldValueVO.getValue();
|
|
|
+ sb.append(valueStr);
|
|
|
+ }
|
|
|
+ HSSFCell cell = row.createCell(j);
|
|
|
+ ExcelUtils.setExcelCellStyle(commonCellStyle);
|
|
|
+ commonCellStyle.setVerticalAlignment(VerticalAlignment.TOP);
|
|
|
+ commonCellStyle.setWrapText(true);
|
|
|
+ cell.setCellStyle(commonCellStyle);
|
|
|
+ cell.setCellValue(sb.toString());
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 使用反射获取属性值
|
|
|
+ Object value = GenerateObjectUtil.getPropertyValue(patent, column);
|
|
|
+ if (value != null) {
|
|
|
+ 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);
|
|
|
+ HSSFCell cell = row.createCell(j);
|
|
|
+ cell.setCellStyle(commonCellStyle);
|
|
|
+ cell.setCellValue(reValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public void loadPatentCell(Patent patent, List<PatentExportVO> patentExportVOS, List<PatentConfigVO> patentConfigVOS, List<EsPatentFieldsVO> esPatentFieldsVOs, HSSFSheet sheet, HSSFCellStyle commonCellStyle, Integer index) {
|
|
|
|
|
|
HSSFRow row = sheet.createRow(index + 1);
|
|
@@ -635,4 +725,5 @@ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|