|
@@ -3,15 +3,21 @@ package cn.cslg.pas.service.business;
|
|
import cn.cslg.pas.common.dto.ExportTaskDTO;
|
|
import cn.cslg.pas.common.dto.ExportTaskDTO;
|
|
import cn.cslg.pas.common.dto.PatentColumnDTO;
|
|
import cn.cslg.pas.common.dto.PatentColumnDTO;
|
|
import cn.cslg.pas.common.dto.PatentExport.PatentExportVO;
|
|
import cn.cslg.pas.common.dto.PatentExport.PatentExportVO;
|
|
|
|
+import cn.cslg.pas.common.dto.es.EsQueryPatentFieldsDTO;
|
|
|
|
+import cn.cslg.pas.common.dto.es.InnerFields;
|
|
import cn.cslg.pas.common.utils.*;
|
|
import cn.cslg.pas.common.utils.*;
|
|
import cn.cslg.pas.common.vo.ConfigVOS.PatentConfigVO;
|
|
import cn.cslg.pas.common.vo.ConfigVOS.PatentConfigVO;
|
|
|
|
+import cn.cslg.pas.common.vo.FieldValueVO;
|
|
import cn.cslg.pas.common.vo.WebSocketMessageVO;
|
|
import cn.cslg.pas.common.vo.WebSocketMessageVO;
|
|
import cn.cslg.pas.common.vo.business.PatentNoVO;
|
|
import cn.cslg.pas.common.vo.business.PatentNoVO;
|
|
import cn.cslg.pas.common.vo.es.EsCustomFieldBatchVO;
|
|
import cn.cslg.pas.common.vo.es.EsCustomFieldBatchVO;
|
|
|
|
+import cn.cslg.pas.common.vo.es.EsPatentFieldsVO;
|
|
|
|
+import cn.cslg.pas.common.vo.es.InnerPatentFieldsVO;
|
|
import cn.cslg.pas.domain.business.ImportTask;
|
|
import cn.cslg.pas.domain.business.ImportTask;
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
import cn.cslg.pas.factorys.PatentExportFactory.GetValueImp;
|
|
import cn.cslg.pas.factorys.PatentExportFactory.GetValueImp;
|
|
import cn.cslg.pas.factorys.PatentExportFactory.PatentExportFactory;
|
|
import cn.cslg.pas.factorys.PatentExportFactory.PatentExportFactory;
|
|
|
|
+import cn.cslg.pas.service.business.es.EsCustomFieldService;
|
|
import cn.cslg.pas.service.business.es.EsPatentService;
|
|
import cn.cslg.pas.service.business.es.EsPatentService;
|
|
import cn.cslg.pas.service.common.MessageService;
|
|
import cn.cslg.pas.service.common.MessageService;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -58,6 +64,9 @@ public class PatentExportService {
|
|
@Autowired
|
|
@Autowired
|
|
private ImportTaskService importTaskService;
|
|
private ImportTaskService importTaskService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private EsCustomFieldService esCustomFieldService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 导出专利
|
|
* 导出专利
|
|
*
|
|
*
|
|
@@ -79,12 +88,21 @@ public class PatentExportService {
|
|
}
|
|
}
|
|
|
|
|
|
//key的集合(标头:例如patentNo)
|
|
//key的集合(标头:例如patentNo)
|
|
- List<String> columns = selected.stream().filter(PatentExportVO::getSelected).map(PatentExportVO::getValue).distinct().collect(Collectors.toList());
|
|
|
|
|
|
+ List<PatentExportVO> patentExportVOS = selected.stream()
|
|
|
|
+ .filter(PatentExportVO::getSelected)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ List<String> types = Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
|
|
|
|
+ List<InnerFields> innerFieldsList = new ArrayList<>();
|
|
|
|
+ for (PatentExportVO patentExportVO : patentExportVOS) {
|
|
|
|
+ if (types.contains(patentExportVO.getType())) {
|
|
|
|
+ InnerFields innerFields = new InnerFields();
|
|
|
|
+ innerFields.setFieldId(patentExportVO.getValue());
|
|
|
|
+ innerFields.setFieldType(Integer.parseInt(patentExportVO.getType()));
|
|
|
|
+ innerFieldsList.add(innerFields);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
//name的集合
|
|
//name的集合
|
|
List<String> headers = selected.stream().filter(PatentExportVO::getSelected).map(PatentExportVO::getName).distinct().collect(Collectors.toList());
|
|
List<String> headers = selected.stream().filter(PatentExportVO::getSelected).map(PatentExportVO::getName).distinct().collect(Collectors.toList());
|
|
- if (columns.size() != headers.size()) {
|
|
|
|
- throw new XiaoShiException("数量不匹配");
|
|
|
|
- }
|
|
|
|
//新建工作簿
|
|
//新建工作簿
|
|
HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
|
|
HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
|
|
//新建sheet页
|
|
//新建sheet页
|
|
@@ -117,29 +135,68 @@ public class PatentExportService {
|
|
Integer total = patentNos.size();
|
|
Integer total = patentNos.size();
|
|
Integer defaultNum = 0;
|
|
Integer defaultNum = 0;
|
|
for (int i = 0; i < patentNos.size(); i++) {
|
|
for (int i = 0; i < patentNos.size(); i++) {
|
|
|
|
+ String patentNo = patentNos.get(i);
|
|
Map<String, Object> map = new LinkedHashMap<>();
|
|
Map<String, Object> map = new LinkedHashMap<>();
|
|
PatentNoVO patentNoVO = new PatentNoVO();
|
|
PatentNoVO patentNoVO = new PatentNoVO();
|
|
- patentNoVO.setPatentNo(patentNos.get(i));
|
|
|
|
|
|
+ patentNoVO.setPatentNo(patentNo);
|
|
patentNoVO.setProjectId(exportTask.getProjectId());
|
|
patentNoVO.setProjectId(exportTask.getProjectId());
|
|
PatentColumnDTO patent = patentService.selectPatentDetail(patentNoVO);
|
|
PatentColumnDTO patent = patentService.selectPatentDetail(patentNoVO);
|
|
if (patent == null) {
|
|
if (patent == null) {
|
|
defaultNum++;
|
|
defaultNum++;
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- for (int j = 0; j < columns.size(); j++) {
|
|
|
|
- String column = columns.get(j);
|
|
|
|
- PatentExportVO patentExportVO = selected.stream().filter(item -> item.getValue().equals(column)).findFirst().orElse(new PatentExportVO());
|
|
|
|
- // 使用反射获取属性值
|
|
|
|
- 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);
|
|
|
|
|
|
+
|
|
|
|
+ EsQueryPatentFieldsDTO esQueryPatentFieldsDTO = new EsQueryPatentFieldsDTO();
|
|
|
|
+ esQueryPatentFieldsDTO.setProjectId(exportTask.getProjectId());
|
|
|
|
+ esQueryPatentFieldsDTO.setTaskId(EsVO.getTaskId());
|
|
|
|
+ esQueryPatentFieldsDTO.setPatentNos(patentNos);
|
|
|
|
+ esQueryPatentFieldsDTO.setInnerFields(innerFieldsList);
|
|
|
|
+ List<EsPatentFieldsVO> list = esCustomFieldService.getPatentFields(esQueryPatentFieldsDTO);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ 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();
|
|
|
|
+
|
|
|
|
+ if (types.contains(type)) {
|
|
|
|
+ EsPatentFieldsVO esPatentFieldsVO = list.stream()
|
|
|
|
+ .filter(item -> item.getPatentNo().equals(patentNo))
|
|
|
|
+ .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);
|
|
|
|
+ }
|
|
|
|
+ map.put(name, sb.toString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 使用反射获取属性值
|
|
|
|
+ Object value = GenerateObjectUtil.getPropertyValue(patent, column);
|
|
|
|
+ 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(name, reValue);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -192,8 +249,11 @@ public class PatentExportService {
|
|
if (taskId == null) {
|
|
if (taskId == null) {
|
|
throw new XiaoShiException("导出记录失败");
|
|
throw new XiaoShiException("导出记录失败");
|
|
}
|
|
}
|
|
|
|
+
|
|
} catch (FileNotFoundException e) {
|
|
} catch (FileNotFoundException e) {
|
|
throw new FileNotFoundException();
|
|
throw new FileNotFoundException();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|