提交 a8c34c52 作者: yanxin

根据模板数据导入逻辑优化

上级 adc7c161
...@@ -777,7 +777,7 @@ class KnowledgeServiceImpl implements IKnowledgeService { ...@@ -777,7 +777,7 @@ class KnowledgeServiceImpl implements IKnowledgeService {
// 将MultipartFile的文件内容保存到字节数组 // 将MultipartFile的文件内容保存到字节数组
byte[] fileData = multipartFile.getBytes(); byte[] fileData = multipartFile.getBytes();
List<List<String>> lists = ExcelExportUtil.readExcel(new ByteArrayInputStream(fileData), 1, 5); List<List<String>> lists = ExcelExportUtil.readExcel(new ByteArrayInputStream(fileData), 1, 8);
//存入es //存入es
importInfo(lists, kbKnowledgeId, knowledgeProjectId, typeId, userId); importInfo(lists, kbKnowledgeId, knowledgeProjectId, typeId, userId);
} catch (Exception e) { } catch (Exception e) {
...@@ -892,15 +892,23 @@ class KnowledgeServiceImpl implements IKnowledgeService { ...@@ -892,15 +892,23 @@ class KnowledgeServiceImpl implements IKnowledgeService {
.verifyStatus(0) .verifyStatus(0)
.importData(1) .importData(1)
.build(); .build();
specialInformation.setId(codeGenerateUtil.geneIdNo(Constants.FINANCE, 8));
if (StringUtils.isNotEmpty(info.get(0))) { if (StringUtils.isNotEmpty(info.get(0))) {
specialInformation.setTitle(info.get(0)); specialInformation.setId(info.get(0));
}else{
specialInformation.setId(codeGenerateUtil.geneIdNo(Constants.FINANCE, 8));
}
if (StringUtils.isNotEmpty(info.get(1))) {
specialInformation.setTitle(info.get(1));
} else { } else {
log.error("上传的数据{}标题为空,此条数据忽略", info.get(0)); log.error("上传的数据{}标题为空,此条数据忽略", info.get(0));
continue; continue;
} }
if (StringUtils.isNotEmpty(info.get(1))) { String contentWithTag = info.get(3);
specialInformation.setContentWithTag(info.get(1)); if(StringUtils.isEmpty(contentWithTag)){
contentWithTag = info.get(2);
}
if (StringUtils.isNotEmpty(contentWithTag)) {
specialInformation.setContentWithTag(contentWithTag);
//片段切分 //片段切分
List<Content> contents = new ArrayList<>(); List<Content> contents = new ArrayList<>();
List<String> splitContents = HtmlUtil.splitContents(specialInformation.getContentWithTag()); List<String> splitContents = HtmlUtil.splitContents(specialInformation.getContentWithTag());
...@@ -914,17 +922,20 @@ class KnowledgeServiceImpl implements IKnowledgeService { ...@@ -914,17 +922,20 @@ class KnowledgeServiceImpl implements IKnowledgeService {
} }
specialInformation.setContents(contents); specialInformation.setContents(contents);
} else { } else {
log.error("上传的数据{}正文为空,此条数据忽略", info.get(0)); log.error("上传的数据{}正文为空,此条数据忽略", info.get(1));
continue; continue;
} }
if (StringUtils.isNotEmpty(info.get(2))) { if (info.size()>4&&StringUtils.isNotEmpty(info.get(4))) {
specialInformation.setAuthor(info.get(2)); specialInformation.setAuthor(info.get(4));
}
if (info.size()>5&&StringUtils.isNotEmpty(info.get(5))) {
specialInformation.setOrigin(info.get(5));
} }
if (StringUtils.isNotEmpty(info.get(3))) { if (info.size()>6&&StringUtils.isNotEmpty(info.get(6))) {
specialInformation.setOrigin(info.get(3)); specialInformation.setPublishDate(EsDateUtil.esFieldDateFormat(info.get(6)));
} }
if (StringUtils.isNotEmpty(info.get(4))) { if (info.size()>7&&StringUtils.isNotEmpty(info.get(7))) {
specialInformation.setPublishDate(EsDateUtil.esFieldDateFormat(info.get(4))); specialInformation.setSourceAddress(info.get(7));
} }
specialInformation.setDeleteFlag(0); specialInformation.setDeleteFlag(0);
specialInformation.setCreateTime(EsDateUtil.esFieldDateFormat(cn.hutool.core.date.DateUtil.formatDateTime(new Date()))); specialInformation.setCreateTime(EsDateUtil.esFieldDateFormat(cn.hutool.core.date.DateUtil.formatDateTime(new Date())));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论