|
@@ -112,27 +112,10 @@ public class DocInfoServiceImpl implements IDocInfoService {
|
|
//读取文件内容存储至ES数据库 START
|
|
//读取文件内容存储至ES数据库 START
|
|
String localFilePath = remoteFileService.localFilePath4RemoteFilePath(docInfo.getDocPath()).getData();
|
|
String localFilePath = remoteFileService.localFilePath4RemoteFilePath(docInfo.getDocPath()).getData();
|
|
File file = new File(localFilePath);
|
|
File file = new File(localFilePath);
|
|
-
|
|
|
|
//获取文件扩展名
|
|
//获取文件扩展名
|
|
int dot = localFilePath.lastIndexOf(".");
|
|
int dot = localFilePath.lastIndexOf(".");
|
|
String ext = localFilePath.substring(dot + 1);
|
|
String ext = localFilePath.substring(dot + 1);
|
|
- Map<String, Function<File, String>> handlerMap = new HashMap<>(16);
|
|
|
|
- handlerMap.put("docx", FileContentUtils::getContentDocx);
|
|
|
|
- handlerMap.put("doc", FileContentUtils::getContentDoc);
|
|
|
|
- handlerMap.put("wps", FileContentUtils::getContentWps);
|
|
|
|
- handlerMap.put("txt", FileContentUtils::getContentTxt);
|
|
|
|
-
|
|
|
|
- Function<File, String> handler = handlerMap.get(ext);
|
|
|
|
- if (handler != null) {
|
|
|
|
- String content = handler.apply(file);
|
|
|
|
- System.err.println(content);
|
|
|
|
- EsDocInfo esDocInfo = new EsDocInfo();
|
|
|
|
- esDocInfo.setId(docInfo.getDocId());
|
|
|
|
- esDocInfo.setYear(docInfo.getCreateYear());
|
|
|
|
- esDocInfo.setContent(content);
|
|
|
|
- esDocInfoService.save(esDocInfo);
|
|
|
|
- }
|
|
|
|
- System.err.println(file.length());
|
|
|
|
|
|
+ insertEs(file, ext, docInfo.getDocId(), docInfo.getCreateYear());
|
|
//读取文件内容存储至ES数据库 END
|
|
//读取文件内容存储至ES数据库 END
|
|
|
|
|
|
//文件大小,以KB保存
|
|
//文件大小,以KB保存
|
|
@@ -150,6 +133,31 @@ public class DocInfoServiceImpl implements IDocInfoService {
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 文件内容入es库
|
|
|
|
+ */
|
|
|
|
+ private void insertEs(File file, String ext, Long docId, Long year) {
|
|
|
|
+
|
|
|
|
+ Map<String, Function<File, String>> handlerMap = new HashMap<>(16);
|
|
|
|
+ handlerMap.put("docx", FileContentUtils::getContentDocx);
|
|
|
|
+ handlerMap.put("doc", FileContentUtils::getContentDoc);
|
|
|
|
+ handlerMap.put("wps", FileContentUtils::getContentWps);
|
|
|
|
+ handlerMap.put("txt", FileContentUtils::getContentTxt);
|
|
|
|
+
|
|
|
|
+ Function<File, String> handler = handlerMap.get(ext);
|
|
|
|
+ if (handler != null) {
|
|
|
|
+ String content = handler.apply(file);
|
|
|
|
+ System.err.println(content);
|
|
|
|
+ EsDocInfo esDocInfo = new EsDocInfo();
|
|
|
|
+ esDocInfo.setId(docId);
|
|
|
|
+ esDocInfo.setYear(year);
|
|
|
|
+ esDocInfo.setContent(content);
|
|
|
|
+ esDocInfoService.save(esDocInfo);
|
|
|
|
+ }
|
|
|
|
+ System.err.println(file.length());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
//插入文档标签
|
|
//插入文档标签
|
|
private void insertDocTag(DocInfo docInfo) {
|
|
private void insertDocTag(DocInfo docInfo) {
|
|
//先删除文档标签再重新插入
|
|
//先删除文档标签再重新插入
|
|
@@ -273,6 +281,9 @@ public class DocInfoServiceImpl implements IDocInfoService {
|
|
docInfo.setDocPath(docPath);
|
|
docInfo.setDocPath(docPath);
|
|
docInfo.setUpdateBy(name);
|
|
docInfo.setUpdateBy(name);
|
|
docInfo.setUpdateTime(DateUtils.getNowDate());
|
|
docInfo.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
+
|
|
|
|
+ File file = new File(path + "/" + fileName);
|
|
|
|
+ insertEs(file, ext, docInfo.getDocId(), docInfo.getCreateYear());
|
|
docInfoMapper.updateDocInfo(docInfo);
|
|
docInfoMapper.updateDocInfo(docInfo);
|
|
|
|
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|