|
@@ -140,7 +140,7 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
|
|
try (InputStream is = file.getInputStream()) {
|
|
|
sysFile.setIdentifier(MD5.create().digestHex16(is));
|
|
|
} catch (IOException e) {
|
|
|
- log.info("文件流获取异常 e:{}",e);
|
|
|
+ log.info("文件流获取异常 e:{}", e);
|
|
|
throw new ServiceException("文件流获取失败!");
|
|
|
}
|
|
|
// 存储到minio
|
|
@@ -306,14 +306,14 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
|
|
public String getFileTextContent(String fileId) {
|
|
|
SysFile sysFile = baseMapper.selectById(fileId);
|
|
|
if (null != sysFile && null != sysFile.getTextContent() && StringUtils.isNotEmpty(sysFile.getTextContent())) {
|
|
|
- log.info("文本内容不为空:{}",sysFile.getFileId());
|
|
|
+ log.info("文本内容不为空:{}", sysFile.getFileId());
|
|
|
return sysFile.getTextContent();
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void convertToTxt(List<String> fileIds,Boolean isNew) {
|
|
|
+ public void convertToTxt(List<String> fileIds, Boolean isNew) {
|
|
|
List<SysFile> sysFiles = baseMapper.selectList(new QueryWrapper<SysFile>().lambda().in(SysFile::getFileId, fileIds));
|
|
|
if (!CollectionUtils.isEmpty(sysFiles)) {
|
|
|
List<ConvertDocToTxt> convertDocToTxts = new ArrayList<>();
|
|
@@ -354,24 +354,24 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
|
|
}
|
|
|
// 更新标注数据。
|
|
|
List<AnnotationList> annotationLists = annotationListMapper.selectList(new QueryWrapper<AnnotationList>().lambda().eq(AnnotationList::getFileId, algRes.getFileId()));
|
|
|
- if (!CollectionUtils.isEmpty(annotationLists)){
|
|
|
+ if (!CollectionUtils.isEmpty(annotationLists)) {
|
|
|
for (AnnotationList annotationList : annotationLists) {
|
|
|
annotationList.setParseStatus(1);
|
|
|
annotationList.setTextContent(algRes.getText());
|
|
|
annotationListMapper.updateById(annotationList);
|
|
|
}
|
|
|
}
|
|
|
- }else if (null != algRes.getErrorCode() && "-1".equals(algRes.getErrorCode())){
|
|
|
+ } else if (null != algRes.getErrorCode() && "-1".equals(algRes.getErrorCode())) {
|
|
|
log.info("算法解析txt文本内容出错,无法解析。");
|
|
|
List<AnnotationList> annotationLists = annotationListMapper.selectList(new QueryWrapper<AnnotationList>().lambda().eq(AnnotationList::getFileId, algRes.getFileId()));
|
|
|
- if (!CollectionUtils.isEmpty(annotationLists)){
|
|
|
+ if (!CollectionUtils.isEmpty(annotationLists)) {
|
|
|
for (AnnotationList annotationList : annotationLists) {
|
|
|
annotationList.setParseStatus(-1);
|
|
|
annotationList.setTextContent("");
|
|
|
annotationListMapper.updateById(annotationList);
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
log.info("算法文档转换txt接口 TXT未解析成功:{}", JSON.toJSONString(algRes));
|
|
|
}
|
|
|
}
|
|
@@ -388,7 +388,7 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
|
|
|
|
|
@Async
|
|
|
@Override
|
|
|
- public void convertfileToTxtByAlg(SysFile sysFile,Boolean isNew) {
|
|
|
+ public void convertfileToTxtByAlg(SysFile sysFile, Boolean isNew) {
|
|
|
List<ConvertDocToTxt> convertDocToTxts = new ArrayList<>();
|
|
|
// 三个条件均不为空时,才调用算法获取文档转换成txt结果。
|
|
|
if (null != sysFile && null != sysFile.getObjectKey() && null != sysFile.getIdentifier()) {
|
|
@@ -400,29 +400,29 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
|
|
// 调用算法,获取文档转换为txt的文本内容。
|
|
|
try {
|
|
|
String convertToTxtResTmp = algKgClient.convertToTxt(JSON.toJSONString(algMap));
|
|
|
- log.info("调用算法获取txt文本内容返回结果convertToTxtResTmp:{}",convertToTxtResTmp);
|
|
|
- }catch (Exception ex){
|
|
|
- log.info("调用算法获取txt文本内容返回结果convertToTxtResTmp ex:{}",ex);
|
|
|
+ log.info("调用算法获取txt文本内容返回结果convertToTxtResTmp:{}", convertToTxtResTmp);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.info("调用算法获取txt文本内容返回结果convertToTxtResTmp ex:{}", ex);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void upFileTextContentByFileId(String fileId,String textContent) {
|
|
|
+ public void upFileTextContentByFileId(String fileId, String textContent) {
|
|
|
SysFile sysFile = baseMapper.selectById(fileId);
|
|
|
- if (null != sysFile){
|
|
|
+ if (null != sysFile) {
|
|
|
sysFile.setTextContent(textContent);
|
|
|
int upRes = baseMapper.updateById(sysFile);
|
|
|
- log.info("更新文档解析txt的文本内容:{}",upRes);
|
|
|
+ log.info("更新文档解析txt的文本内容:{}", upRes);
|
|
|
List<AnnotationList> annotationLists = annotationListMapper.selectList(new QueryWrapper<AnnotationList>().lambda().eq(AnnotationList::getFileId, fileId));
|
|
|
- if (!CollectionUtils.isEmpty(annotationLists)){
|
|
|
+ if (!CollectionUtils.isEmpty(annotationLists)) {
|
|
|
for (AnnotationList annotationList : annotationLists) {
|
|
|
annotationList.setTextContent(textContent);
|
|
|
annotationList.setParseStatus(1);
|
|
|
int upAnnotationRes = annotationListMapper.updateById(annotationList);
|
|
|
- log.info("更新标注列表的文本内容 upAnnotationRes:{}",JSON.toJSONString(upAnnotationRes));
|
|
|
+ log.info("更新标注列表的文本内容 upAnnotationRes:{}", JSON.toJSONString(upAnnotationRes));
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
log.info("暂未使用该文档进行标注,无需更新。");
|
|
|
}
|
|
|
}
|
|
@@ -431,10 +431,10 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
|
|
@Override
|
|
|
public Boolean handsToParseTxt(String kgId, String fileId) {
|
|
|
List<SysFile> sysFiles = baseMapper.selectList(new QueryWrapper<SysFile>().lambda().eq(SysFile::getFileId, fileId));
|
|
|
- if (!CollectionUtils.isEmpty(sysFiles) && null == sysFiles.get(0).getTextContent()){
|
|
|
+ if (!CollectionUtils.isEmpty(sysFiles) && null == sysFiles.get(0).getTextContent()) {
|
|
|
String objectKey = "";
|
|
|
String identifier = "";
|
|
|
- if (!CollectionUtils.isEmpty(sysFiles)){
|
|
|
+ if (!CollectionUtils.isEmpty(sysFiles)) {
|
|
|
objectKey = sysFiles.get(0).getObjectKey();
|
|
|
identifier = sysFiles.get(0).getIdentifier();
|
|
|
}
|
|
@@ -444,7 +444,7 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
|
|
if (!CollectionUtils.isEmpty(convertDocToTxts)) {
|
|
|
Map<String, Object> algMap = new HashMap<>();
|
|
|
algMap.put("files", convertDocToTxts);
|
|
|
- log.info("实时请求算法获取txt内容入参 convertDocToTxts:{}",JSON.toJSONString(algMap));
|
|
|
+ log.info("实时请求算法获取txt内容入参 convertDocToTxts:{}", JSON.toJSONString(algMap));
|
|
|
try {
|
|
|
// 调用算法,获取文档转换为txt的文本内容。
|
|
|
// String convertToTxtResTmp = algKgClient.convertToTxt(JSON.toJSONString(algMap));
|
|
@@ -453,12 +453,12 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
|
|
|
// dealAlgTxtRes(convertToTxtResTmp);
|
|
|
|
|
|
// todo ghjghj 需要和志超对接 实时调用算法获取解析得txt文本内容,。
|
|
|
- String convertToTxtResTmp = algKgClient.convertToTxtByRealTime(JSON.toJSONString(algMap),new Request.Options(30, TimeUnit.SECONDS, 30, TimeUnit.SECONDS, true));
|
|
|
- log.info("实时请求算法获取解析结果 convertToTxtResTmp:{}",convertToTxtResTmp);
|
|
|
+ String convertToTxtResTmp = algKgClient.convertToTxtByRealTime(JSON.toJSONString(algMap), new Request.Options(30, TimeUnit.SECONDS, 30, TimeUnit.SECONDS, true));
|
|
|
+ log.info("实时请求算法获取解析结果 convertToTxtResTmp:{}", convertToTxtResTmp);
|
|
|
dealAlgTxtRes(convertToTxtResTmp);
|
|
|
- }catch (Exception ex){
|
|
|
+ } catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
- log.info("手动调用算法获取txt文本内容返回结果 ex:{}",ex);
|
|
|
+ log.info("手动调用算法获取txt文本内容返回结果 ex:{}", ex);
|
|
|
return false;
|
|
|
}
|
|
|
}
|