|
|
@@ -2,10 +2,7 @@ package com.doc.biz.service.impl;
|
|
|
|
|
|
import com.doc.biz.domain.DocInfo;
|
|
|
import com.doc.biz.domain.EsDocInfo;
|
|
|
-import com.doc.biz.service.IElasticSearchService;
|
|
|
-import com.doc.biz.service.IEsDocInfoService;
|
|
|
-import com.doc.biz.service.IMongoService;
|
|
|
-import com.doc.biz.service.IOcrService;
|
|
|
+import com.doc.biz.service.*;
|
|
|
import com.doc.biz.vo.DocumentVO;
|
|
|
import com.doc.common.config.EsConfig;
|
|
|
import com.doc.common.constant.Constants;
|
|
|
@@ -14,6 +11,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.data.elasticsearch.NoSuchIndexException;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
@@ -23,6 +21,7 @@ import java.io.File;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Optional;
|
|
|
import java.util.function.Function;
|
|
|
|
|
|
/**
|
|
|
@@ -42,6 +41,8 @@ public class ElasticSearchServiceImpl implements IElasticSearchService {
|
|
|
private IMongoService mongoService;
|
|
|
@Resource
|
|
|
private IOcrService ocrService;
|
|
|
+ @Resource
|
|
|
+ private IDocInfoService docInfoService;
|
|
|
|
|
|
/**
|
|
|
* 文件内容入es库
|
|
|
@@ -76,7 +77,42 @@ public class ElasticSearchServiceImpl implements IElasticSearchService {
|
|
|
@Override
|
|
|
public void delete(DocInfo info) {
|
|
|
comboIndex(info.getSpaceId());
|
|
|
- esDocInfoService.deleteById(info.getDocId());
|
|
|
+ //删除ES记录
|
|
|
+ try {
|
|
|
+ esDocInfoService.deleteById(info.getDocId());
|
|
|
+ } catch (NoSuchIndexException e) {
|
|
|
+ //不用管,表示没这个索引
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过ID删除ES内容
|
|
|
+ *
|
|
|
+ * @param docId id
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void delete(Long docId) {
|
|
|
+ DocInfo docInfo = docInfoService.selectDocInfoByDocId(docId);
|
|
|
+ delete(docInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据docId 查询文本内容
|
|
|
+ *
|
|
|
+ * @param docId id
|
|
|
+ * @return 文本
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public EsDocInfo getEsDocInfo(Long docId) {
|
|
|
+ DocInfo docInfo = docInfoService.selectDocInfoByDocId(docId);
|
|
|
+ comboIndex(docInfo.getSpaceId());
|
|
|
+ Optional<EsDocInfo> optional = esDocInfoService.findById(docId);
|
|
|
+ if (optional.isPresent()) {
|
|
|
+ EsDocInfo info = optional.get();
|
|
|
+ info.setDocInfo(docInfo);
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|