|
|
@@ -12,6 +12,7 @@ import com.doc.common.utils.StringUtils;
|
|
|
import com.doc.common.utils.file.FileUtils;
|
|
|
import com.doc.common.utils.file.PdfUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.core.env.Environment;
|
|
|
import org.springframework.data.elasticsearch.NoSuchIndexException;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -46,6 +47,8 @@ public class ElasticSearchServiceImpl implements IElasticSearchService {
|
|
|
private IDocInfoService docInfoService;
|
|
|
@Resource
|
|
|
private IDocIndexService indexService;
|
|
|
+ @Resource
|
|
|
+ private Environment environment;
|
|
|
|
|
|
/**
|
|
|
* 文件内容入es库
|
|
|
@@ -65,14 +68,12 @@ public class ElasticSearchServiceImpl implements IElasticSearchService {
|
|
|
|
|
|
Map<String, Function<byte[], String>> handlerMap = createHandlerMap(fileType);
|
|
|
String content = getContent(handlerMap, fileType, info.getFileId());
|
|
|
-
|
|
|
-// if (Constants.PDF_EXTENSION.contains(fileType) && StringUtils.isEmpty(content)) {
|
|
|
-// //如果是PDF未解析成功,则另外进行解析工作
|
|
|
-// //TODO 暂时取消该功能
|
|
|
-//// DocIndex di = new DocIndex(info);
|
|
|
-//// indexService.insertDocIndex(di);
|
|
|
-// return;
|
|
|
-// }
|
|
|
+ boolean pdfOcr = Boolean.parseBoolean(environment.getProperty("ruoyi.pdfOcr"));
|
|
|
+ if (pdfOcr && Constants.PDF_EXTENSION.contains(fileType) && StringUtils.isEmpty(content)) {
|
|
|
+ //如果是PDF未解析成功,则另外进行解析工作
|
|
|
+ indexService.insertDocIndex(new DocIndex(info));
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
if (StringUtils.isNotEmpty(content)) {
|
|
|
comboIndex(info.getSpaceId());
|