|
@@ -1,29 +1,33 @@
|
|
|
package com.pavis.backend.slim.project.system.service.impl;
|
|
|
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.pavis.backend.slim.common.utils.CommonUtils;
|
|
|
+import com.pavis.backend.slim.common.utils.FileUtils;
|
|
|
import com.pavis.backend.slim.common.utils.SecurityUtils;
|
|
|
import com.pavis.backend.slim.project.system.client.AlgKgClient;
|
|
|
import com.pavis.backend.slim.project.system.domain.AnnotationList;
|
|
|
import com.pavis.backend.slim.project.system.domain.EntityForAlg;
|
|
|
import com.pavis.backend.slim.project.system.domain.EntityLabelsRelation;
|
|
|
+import com.pavis.backend.slim.project.system.domain.EntityLabelsSpan;
|
|
|
import com.pavis.backend.slim.project.system.domain.SysEntity;
|
|
|
import com.pavis.backend.slim.project.system.domain.SysRelation;
|
|
|
import com.pavis.backend.slim.project.system.domain.annotation.AnnotationData;
|
|
|
import com.pavis.backend.slim.project.system.domain.annotation.AnnotationEntity;
|
|
|
import com.pavis.backend.slim.project.system.domain.annotation.AnnotationEntityRelation;
|
|
|
import com.pavis.backend.slim.project.system.domain.annotation.AnnotationToAlg;
|
|
|
+import com.pavis.backend.slim.project.system.domain.annotation.ConvertAlgRes;
|
|
|
+import com.pavis.backend.slim.project.system.domain.annotation.ExportAnnotationData;
|
|
|
import com.pavis.backend.slim.project.system.domain.annotation.RelationForAlg;
|
|
|
import com.pavis.backend.slim.project.system.domain.annotation.SchemaImport;
|
|
|
import com.pavis.backend.slim.project.system.domain.annotation.ToAnnotation;
|
|
|
import com.pavis.backend.slim.project.system.domain.annotation.UniversalGgraphToAlg;
|
|
|
import com.pavis.backend.slim.project.system.mapper.AnnotationListMapper;
|
|
|
import com.pavis.backend.slim.project.system.mapper.EntityLabelsRelationMapper;
|
|
|
+import com.pavis.backend.slim.project.system.service.AnnotationListService;
|
|
|
import com.pavis.backend.slim.project.system.service.EntityLablesRelationService;
|
|
|
import com.pavis.backend.slim.project.system.service.EntityLablesSpanService;
|
|
|
import com.pavis.backend.slim.project.system.service.GenerateGraphService;
|
|
@@ -35,11 +39,18 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @version: java version 1.8
|
|
@@ -75,29 +86,43 @@ public class EntityLabelsRelationServiceImpl extends ServiceImpl<EntityLabelsRel
|
|
|
@Autowired
|
|
|
private AnnotationListMapper annotationListMapper;
|
|
|
|
|
|
+ @Value("${pavis.profile}")
|
|
|
+ private String filePath;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AnnotationListService annotationListService;
|
|
|
+
|
|
|
@Override
|
|
|
public EntityLabelsRelation saveAnnotationRelation(AnnotationEntityRelation relation) {
|
|
|
+ log.info("新增关系数据:{}", JSON.toJSONString(relation));
|
|
|
EntityLabelsRelation entityLabelsRelation = new EntityLabelsRelation();
|
|
|
BeanUtils.copyProperties(relation, entityLabelsRelation);
|
|
|
// 设置基本信息,创建人、创建时间等。
|
|
|
entityLabelsRelation.setUserId(SecurityUtils.getUserId());
|
|
|
entityLabelsRelation.setCreateBy(SecurityUtils.getUsername());
|
|
|
- entityLabelsRelation.setCreateTime(DateUtil.date());
|
|
|
- int insert = baseMapper.insert(entityLabelsRelation);
|
|
|
- log.info("标注的实体信息存储结果res:{},entityLabelsRelation:{}", insert, JSON.toJSONString(entityLabelsRelation));
|
|
|
+ // 新增。
|
|
|
+ // int insertRes = baseMapper.insert(entityLabelsRelation);
|
|
|
+ // log.info("标注的实体信息存储结果res:{},entityLabelsRelation:{}", insertRes, JSON.toJSONString(entityLabelsRelation));
|
|
|
+ // 存在id更新,无id新增。todo 家辉需要调整,才修改逻辑的。
|
|
|
+ boolean modRes = saveOrUpdate(entityLabelsRelation);
|
|
|
+ log.info("标注的实体信息存储结果res:{},entityLabelsRelation:{}", modRes, JSON.toJSONString(entityLabelsRelation));
|
|
|
+ // // 更新标注数据。todo 前端反馈暂时先不在此处加逻辑了。
|
|
|
+ // log.info("结束更新前端标注textFront数据");
|
|
|
+ // AnnotationFront annotationFront = AnnotationFront.builder().kgId(relation.getKgId()).fileId(relation.getFileId()).textFront(relation.getTextFront()).build();
|
|
|
+ // log.info("关系:{}",JSON.toJSONString(annotationFront));
|
|
|
+ // Boolean upAnnotation = annotationListService.saveAnnotation(annotationFront);
|
|
|
+ // log.info("结束更新前端标注textFront数据 upAnnotation:{}",upAnnotation);
|
|
|
return entityLabelsRelation;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ToAnnotation toAnnotation(String kgId, String fileId) {
|
|
|
-
|
|
|
// 1.根据fileId获取文本信息text、历史标注的实体信息列表、历史标注的实体间关系信息列表。
|
|
|
// List<TreeFile> treeFiles = sysFileService.listTreeFiles(kgId);
|
|
|
// log.info("获取知识库下的文档信息treeFiles:{}",JSON.toJSONString(treeFiles));
|
|
|
// String fileTextContent = sysFileService.getFileTextContent(fileId);
|
|
|
List<AnnotationList> annotationLists = annotationListMapper.selectList(new QueryWrapper<AnnotationList>().lambda().eq(AnnotationList::getKgId, kgId).eq(AnnotationList::getFileId, fileId));
|
|
|
// log.info("fileTextContent:{}",fileTextContent);
|
|
|
- // if (null != fileTextContent && StringUtils.isNotBlank(fileTextContent)) {
|
|
|
if (!CollectionUtils.isEmpty(annotationLists) && null != annotationLists.get(0).getTextContent() && StringUtils.isNotBlank(annotationLists.get(0).getTextContent())) {
|
|
|
// log.info("文本内容不为空:{}", annotationLists.get(0).getTextContent());
|
|
|
// 1.1 获取历史标注实体信息数据列表。
|
|
@@ -109,11 +134,11 @@ public class EntityLabelsRelationServiceImpl extends ServiceImpl<EntityLabelsRel
|
|
|
List<SysEntity> entityLists = sysEntityService.getEntityByKgId(kgId);
|
|
|
// 3.根据kgId获取知识库下的所有实体间关系信息列表。
|
|
|
List<SysRelation> relationLists = sysRelationService.getRelationByKgId(kgId);
|
|
|
- ToAnnotation toAnnotation = ToAnnotation.builder().text(annotationLists.get(0).getTextContent()).entities(entities).relations(relations)
|
|
|
+ ToAnnotation toAnnotation = ToAnnotation.builder().text(annotationLists.get(0).getTextContent()).textFront(annotationLists.get(0).getTextFront()).entities(entities).relations(relations)
|
|
|
.entityList(entityLists).relationList(relationLists).build();
|
|
|
return toAnnotation;
|
|
|
}
|
|
|
- return null;
|
|
|
+ return new ToAnnotation();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -126,7 +151,8 @@ public class EntityLabelsRelationServiceImpl extends ServiceImpl<EntityLabelsRel
|
|
|
annotationEntityRelation = new AnnotationEntityRelation();
|
|
|
BeanUtils.copyProperties(entityLabelsRelation, annotationEntityRelation);
|
|
|
annotationEntityRelation.setId(Long.valueOf(entityLabelsRelation.getId()));
|
|
|
- // 处理个别字段,fileId是string类型的。
|
|
|
+ annotationEntityRelation.setFromId(entityLabelsRelation.getFromId());
|
|
|
+ annotationEntityRelation.setToId(entityLabelsRelation.getToId());
|
|
|
annotationEntityRelations.add(annotationEntityRelation);
|
|
|
}
|
|
|
return annotationEntityRelations;
|
|
@@ -141,7 +167,6 @@ public class EntityLabelsRelationServiceImpl extends ServiceImpl<EntityLabelsRel
|
|
|
// 2. 判断该图谱是否创建实体和关系数据。即是否有图schema.
|
|
|
if (CollectionUtils.isEmpty(selEntityByKgId)) {
|
|
|
// 2.1 如果该图谱的未创建实体和关系数据,则调用算法另一个服务,入参为:fileIds列表、kgId。
|
|
|
- // String universalGgraphToAlgRes = "";
|
|
|
try {
|
|
|
// todo 临时弃用,改用下面的接口,直接调用获取taskId。
|
|
|
// universalGgraphToAlgRes = algKgClient.universalGgraphToAlg(JSON.toJSONString(universalGgraphToAlg));
|
|
@@ -161,22 +186,22 @@ public class EntityLabelsRelationServiceImpl extends ServiceImpl<EntityLabelsRel
|
|
|
log.info("生成图谱接口 ---->有图schema 判断是否存在标注数据...");
|
|
|
// 2.2 用户在图模型创建了实体和关系,即存在图schema数据。先请求schema/import,返回OK,再判断是否有标注数据。
|
|
|
List<EntityForAlg> entityForAlgs = JSONArray.parseArray(selEntityByKgId.get(0).getEntityAll(), EntityForAlg.class);
|
|
|
- log.info("有图schema的实体信息:{}",JSON.toJSONString(entityForAlgs));
|
|
|
+ log.info("有图schema的实体信息:{}", JSON.toJSONString(entityForAlgs));
|
|
|
String relationAll = selEntityByKgId.get(0).getRelationAll();
|
|
|
List<RelationForAlg> relationForAlgs = JSONArray.parseArray(relationAll, RelationForAlg.class);
|
|
|
- log.info("有图schema的实体间关系信息:{}",JSON.toJSONString(relationForAlgs));
|
|
|
+ log.info("有图schema的实体间关系信息:{}", JSON.toJSONString(relationForAlgs));
|
|
|
SchemaImport schemaImport = SchemaImport.builder().kgId(kgId).entityList(entityForAlgs).relationList(relationForAlgs).build();
|
|
|
- log.info("调用算法服务的schemaImport服务发送实体和关系属性数据:{}",JSON.toJSONString(schemaImport));
|
|
|
+ log.info("调用算法服务的schemaImport服务发送实体和关系属性数据:{}", JSON.toJSONString(schemaImport));
|
|
|
String schemaImportRes = algKgClient.sendEntityRelationToAlg(schemaImport);
|
|
|
- log.info("调用算法服务的schemaImport服务发送实体和关系属性数据结果 schemaImportRes:{}",JSON.toJSONString(schemaImportRes));
|
|
|
- if ("ok".equals(schemaImportRes)){
|
|
|
+ log.info("调用算法服务的schemaImport服务发送实体和关系属性数据结果 schemaImportRes:{}", JSON.toJSONString(schemaImportRes));
|
|
|
+ if ("ok".equals(schemaImportRes)) {
|
|
|
// 2.2 todo 当前版本已弃用: 如果该图谱的创建了实体和关系数据,则调用算法的生成图谱服务,即入参为:text、实体标注数据列表、实体关系标注数据列表。
|
|
|
// 获取标注数据: 如果图谱有实体关系数据,且标注了数据,则发送标注的数据给算法;如果该文档未被标注则不发送。如果仅有实体关系数据,所有文档均未被标注,也发送,只不过标注数据为空。
|
|
|
- List<AnnotationData> annotationDatas = getAnnotationDatas(fileIds,kgId);
|
|
|
+ List<AnnotationData> annotationDatas = getAnnotationDatas(fileIds, kgId);
|
|
|
// 3.判断是否存在标注数据:有标注数据:请求labels/import,返回OK,继续调用获取taskId;
|
|
|
AnnotationToAlg annotationToAlg = AnnotationToAlg.builder().kgId(kgId).annotationDatas(annotationDatas).build();// 算法所需数据结构。
|
|
|
+ log.info("is json annotationToAlg:{}", CommonUtils.isJson(JSON.toJSONString(annotationToAlg)));
|
|
|
log.info("标注数据待发送至算法数据结构annotationToAlg:{}", JSON.toJSONString(annotationToAlg));
|
|
|
- log.info("is json annotationToAlg:{}",CommonUtils.isJson(JSON.toJSONString(annotationToAlg)));
|
|
|
log.info("----------------------------------------------------");
|
|
|
if (!CollectionUtils.isEmpty(annotationDatas) && annotationDatas.get(0).getEntities().size() > 0) {
|
|
|
log.info("有图schema 有标注数据");
|
|
@@ -185,7 +210,7 @@ public class EntityLabelsRelationServiceImpl extends ServiceImpl<EntityLabelsRel
|
|
|
String algRes = null;
|
|
|
try {
|
|
|
// algRes = algKgClient.sendToAlgForGenerateKgGraph(JSON.toJSONString(annotationToAlg));
|
|
|
- log.info("调用算法标注服务前入参:{}",JSONArray.toJSONString(annotationToAlg));
|
|
|
+ log.info("调用算法标注服务前入参:{}", JSONArray.toJSONString(annotationToAlg));
|
|
|
// algRes = algKgClient.sendToAlgForGenerateKgGraph(JSONArray.toJSONString(annotationToAlg));
|
|
|
algRes = algKgClient.sendToAlgForGenerateKgGraph(annotationToAlg);
|
|
|
|
|
@@ -213,17 +238,29 @@ public class EntityLabelsRelationServiceImpl extends ServiceImpl<EntityLabelsRel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean delRelById(Long id) {
|
|
|
+ EntityLabelsRelation entityLabelsRelation = baseMapper.selectById(id);
|
|
|
+ if (null != entityLabelsRelation) {
|
|
|
+ int del = baseMapper.deleteById(id);
|
|
|
+ return del > 0 ? true : false;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取标注数据。
|
|
|
+ *
|
|
|
* @param fileIds
|
|
|
+ * @param kgId
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<AnnotationData> getAnnotationDatas(List<String> fileIds,String kgId){
|
|
|
+ @Override
|
|
|
+ public List<AnnotationData> getAnnotationDatas(List<String> fileIds, String kgId) {
|
|
|
List<AnnotationData> annotationDatas = new ArrayList<>();// 图谱下的所有文档标注信息。
|
|
|
for (String fileId : fileIds) {
|
|
|
String fileTextContent = sysFileService.getFileTextContent(fileId);
|
|
|
- // List<AnnotationList> annotationLists = annotationListMapper.selectList(new QueryWrapper<AnnotationList>().lambda().eq(AnnotationList::getKgId, kgId).eq(AnnotationList::getFileId, fileId));
|
|
|
- // fileTextContent = !CollectionUtils.isEmpty(annotationLists) ? annotationLists.get
|
|
|
if (null != fileTextContent && StringUtils.isNotBlank(fileTextContent)) {
|
|
|
// log.info("文本内容不为空:{}", fileTextContent);
|
|
|
log.info("--->fileId:{}", fileId);
|
|
@@ -244,13 +281,128 @@ public class EntityLabelsRelationServiceImpl extends ServiceImpl<EntityLabelsRel
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean delRelById(Long id) {
|
|
|
- EntityLabelsRelation entityLabelsRelation = baseMapper.selectById(id);
|
|
|
- if (null != entityLabelsRelation) {
|
|
|
- int del = baseMapper.deleteById(id);
|
|
|
- return del > 0 ? true : false;
|
|
|
+ public void exportDataBase(ExportAnnotationData exportAnnotationData, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
+ // 1. 首先根据kgId获取图谱构建的实体、关系数据。
|
|
|
+ List<SysEntity> selEntityByKgId = sysEntityService.getEntityByKgId(exportAnnotationData.getKgId());
|
|
|
+ List<String> fileIds = exportAnnotationData.getFileIds();
|
|
|
+ // 2.2 用户在图模型创建了实体和关系,即存在图schema数据。先请求schema/import,返回OK,再判断是否有标注数据。
|
|
|
+ List<EntityForAlg> entityForAlgs = JSONArray.parseArray(selEntityByKgId.get(0).getEntityAll(), EntityForAlg.class);
|
|
|
+ log.info("有图schema的实体信息:{}", JSON.toJSONString(entityForAlgs));
|
|
|
+ String relationAll = selEntityByKgId.get(0).getRelationAll();
|
|
|
+ List<RelationForAlg> relationForAlgs = JSONArray.parseArray(relationAll, RelationForAlg.class);
|
|
|
+ log.info("有图schema的实体间关系信息:{}", JSON.toJSONString(relationForAlgs));
|
|
|
+ List<AnnotationData> annotationDatas = getAnnotationDatas(fileIds, exportAnnotationData.getKgId());
|
|
|
+ log.info("待导出的标注数据 annotationDatas:{}", JSON.toJSONString(annotationDatas));
|
|
|
+ List<ToAnnotation> annotations = new ArrayList<>();
|
|
|
+ for (String fileId : exportAnnotationData.getFileIds()) {
|
|
|
+ annotations.add(toAnnotation(exportAnnotationData.getKgId(), fileId));
|
|
|
+ }
|
|
|
+ log.info("待导出的标注数据 annotations:{}", JSON.toJSONString(annotations));
|
|
|
+
|
|
|
+ String fileType = ".json";
|
|
|
+ String fileName = FileUtils.genFileName(exportAnnotationData.getKgId() + "-" + System.currentTimeMillis()) + fileType;
|
|
|
+ String finalPath = filePath + fileName;
|
|
|
+ finalPath = FileUtils.annotationDataToJson(annotations, fileName, finalPath, request, response);
|
|
|
+ log.info("写入文件路径 path:{}", finalPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean importDataBase(String kgId, MultipartFile file) {
|
|
|
+ String finalPath = filePath + file.getOriginalFilename();
|
|
|
+ try {
|
|
|
+ file.transferTo(new File(finalPath));
|
|
|
+ } catch (Exception ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ log.info("标注数据导入写入文件异常 ex:{}", ex);
|
|
|
+ }
|
|
|
+ String readJsonStr = FileUtils.readJson(finalPath);
|
|
|
+ List<ToAnnotation> annotationDatas = new ArrayList<>();
|
|
|
+ if (null != readJsonStr && CommonUtils.isJsonArray(readJsonStr)) {
|
|
|
+ annotationDatas = JSONArray.parseArray(readJsonStr, ToAnnotation.class);
|
|
|
+ }
|
|
|
+ log.info("read res:{}", JSON.toJSONString(annotationDatas));
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(annotationDatas)) {
|
|
|
+ // 数据不为空,执行导入操作。
|
|
|
+ List<AnnotationList> annotationLists = new ArrayList<>();
|
|
|
+ AnnotationList annotationList;
|
|
|
+ for (ToAnnotation annotationData : annotationDatas) {
|
|
|
+ // 解析entities、relations数据写入entity_labels_span、entity_labels_relation表中。
|
|
|
+ List<AnnotationEntity> entities = annotationData.getEntities();
|
|
|
+ if (!CollectionUtils.isEmpty(entities)) {
|
|
|
+ EntityLabelsSpan entityLabelsSpan;
|
|
|
+ List<EntityLabelsSpan> entityLabelsSpans = new ArrayList<>();
|
|
|
+ for (AnnotationEntity entity : entities) {
|
|
|
+ entityLabelsSpan = new EntityLabelsSpan();
|
|
|
+ BeanUtils.copyProperties(entity, entityLabelsSpan);
|
|
|
+ entityLabelsSpan.setKgId(kgId);
|
|
|
+ entityLabelsSpans.add(entityLabelsSpan);
|
|
|
+ }
|
|
|
+ log.info("导入标注的实体数据:{}", entityLabelsSpans.size());
|
|
|
+ // todo 暂时搁置:保存实体数据至数据库。
|
|
|
+
|
|
|
+ } else {
|
|
|
+ log.info("暂无标注的实体数据需要导入。");
|
|
|
+ }
|
|
|
+ List<AnnotationEntityRelation> relations = annotationData.getRelations();
|
|
|
+ if (!CollectionUtils.isEmpty(relations)) {
|
|
|
+ List<EntityLabelsRelation> entityLabelsRelations = new ArrayList<>();
|
|
|
+ EntityLabelsRelation entityLabelsRelation;
|
|
|
+ for (AnnotationEntityRelation relation : relations) {
|
|
|
+ entityLabelsRelation = new EntityLabelsRelation();
|
|
|
+ BeanUtils.copyProperties(relation, entityLabelsRelation);
|
|
|
+ entityLabelsRelation.setKgId(kgId);
|
|
|
+ entityLabelsRelations.add(entityLabelsRelation);
|
|
|
+ }
|
|
|
+ log.info("导入标注的实体关系数据:{}", entityLabelsRelations.size());
|
|
|
+ // todo 暂时搁置:保存实体关系数据至数据库。
|
|
|
+
|
|
|
+ } else {
|
|
|
+ log.info("暂无标注的实体关系数据需要导入。");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 解析entityList、relationList数据,根据kgId获取实体数据写入sys_entity;根据kgId获取实体关系数据写入sys_relation表中。kgId记得更新为当前图谱ID。
|
|
|
+ if (!CollectionUtils.isEmpty(annotationData.getEntityList())) {
|
|
|
+ String selKgId = annotationData.getEntityList().get(0).getKgId();
|
|
|
+ List<SysEntity> selEntities = sysEntityService.getEntityByKgId(selKgId);
|
|
|
+ List<SysEntity> upSelEntities = selEntities.stream().map(wmy -> {
|
|
|
+ wmy.setKgId(kgId);
|
|
|
+ wmy.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ return wmy;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ // todo 暂时搁置:插入实体数据。
|
|
|
+
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(annotationData.getRelationList())) {
|
|
|
+ String selKgId = annotationData.getRelationList().get(0).getKgId();
|
|
|
+ List<SysRelation> selRelations = sysRelationService.getRelationByKgId(selKgId);
|
|
|
+ List<SysRelation> upSelRelations = selRelations.stream().map(wmy -> {
|
|
|
+ wmy.setKgId(kgId);
|
|
|
+ wmy.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ return wmy;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ // todo 暂时搁置:插入实体关系数据。
|
|
|
+
|
|
|
+ }
|
|
|
+ // 解析text、textfront写入annotitionlist表。
|
|
|
+ annotationList = AnnotationList.builder().textContent(annotationData.getText()).textFront(annotationData.getTextFront())
|
|
|
+ .build();
|
|
|
+ annotationLists.add(annotationList);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.info("待导入数据为空,不执行导入操作");
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void toUpText(ConvertAlgRes convertAlgRes) {
|
|
|
+ if (null != convertAlgRes.getText() && StringUtils.isNotBlank(convertAlgRes.getText())) {
|
|
|
+ sysFileService.upFileTextContentByFileId(convertAlgRes.getFileId(), convertAlgRes.getText());
|
|
|
+ log.info("收到算法解析的text内容,并进行更新。");
|
|
|
+ } else {
|
|
|
+ log.info("算法解析的text文本内容为空,不做更新操作。");
|
|
|
}
|
|
|
- return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -264,8 +416,7 @@ public class EntityLabelsRelationServiceImpl extends ServiceImpl<EntityLabelsRel
|
|
|
public Boolean createGenerateGraph(String getTaskIdRes, String kgId, Boolean isGenerate, Integer graphStatus, Integer annotationStatus) {
|
|
|
// 更新图谱的状态为进行中。
|
|
|
Boolean upRes = sysKgService.updateGrapgStatus(kgId, graphStatus, annotationStatus, 2, "进行中");
|
|
|
- log.info("更新图谱的状态为进行中:{}", upRes);
|
|
|
- log.info("调用算法获取taskId:{}", getTaskIdRes);
|
|
|
+ log.info("更新图谱的状态为进行中 upRes:{},任务ID getTaskIdRes:{}", upRes, getTaskIdRes);
|
|
|
if (CommonUtils.isJson(getTaskIdRes)) {
|
|
|
JSONObject taskObj = JSON.parseObject(getTaskIdRes);
|
|
|
if (taskObj.containsKey("taskId")) {
|