|
@@ -15,6 +15,7 @@ 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;
|
|
|
+import com.pavis.backend.slim.project.system.service.SysFileService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
@@ -61,6 +62,9 @@ public class AnnotationController {
|
|
|
@Autowired
|
|
|
private GenerateGraphService generateGraphService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysFileService sysFileService;
|
|
|
+
|
|
|
@ApiOperation("获取标注数据列表接口")
|
|
|
@PostMapping("/getAnnotationLists")
|
|
|
public AjaxResult getAnnotationLists(@RequestBody AnnotationListParam annotationListParam) {
|
|
@@ -68,7 +72,7 @@ public class AnnotationController {
|
|
|
if (null != annotationListParam.getKgId() && StringUtils.isNotEmpty(annotationListParam.getKgId()) && null != annotationListParam.getPageNum() && null != annotationListParam.getPageSize()) {
|
|
|
return AjaxResult.success("获取数据标注列表成功", annotationListService.getAnnotationLists(annotationListParam));
|
|
|
}
|
|
|
- return AjaxResult.error(1001,"参数不能为空");
|
|
|
+ return AjaxResult.error(1001, "参数不能为空");
|
|
|
}
|
|
|
|
|
|
@ApiOperation("删除标注数据列表接口")
|
|
@@ -83,7 +87,7 @@ public class AnnotationController {
|
|
|
return AjaxResult.error("删除标注数据列表失败", delRes);
|
|
|
}
|
|
|
}
|
|
|
- return AjaxResult.error(1001,"参数不能为空");
|
|
|
+ return AjaxResult.error(1001, "参数不能为空");
|
|
|
}
|
|
|
|
|
|
@ApiOperation("数据集导入之知识库文档导入接口")
|
|
@@ -98,7 +102,7 @@ public class AnnotationController {
|
|
|
return AjaxResult.error("数据集导入失败", saveRes);
|
|
|
}
|
|
|
}
|
|
|
- return AjaxResult.error(1001,"参数不能为空");
|
|
|
+ return AjaxResult.error(1001, "参数不能为空");
|
|
|
}
|
|
|
|
|
|
@ApiOperation("数据集导入之本地文件导入接口")
|
|
@@ -107,14 +111,14 @@ public class AnnotationController {
|
|
|
})
|
|
|
@PostMapping(value = "/importLocalAnnotationDataset")
|
|
|
public AjaxResult importLocalAnnotationDataset(String kgId, @RequestParam("file") MultipartFile file) throws Exception {
|
|
|
- if (null != kgId && StringUtils.isNotEmpty(kgId)){
|
|
|
- if (!file.isEmpty()){
|
|
|
- return AjaxResult.success("数据集导入之本地文件导入成功!", annotationListService.importLocalAnnotationDataset(kgId,file));
|
|
|
- }else {
|
|
|
+ if (null != kgId && StringUtils.isNotEmpty(kgId)) {
|
|
|
+ if (!file.isEmpty()) {
|
|
|
+ return AjaxResult.success("数据集导入之本地文件导入成功!", annotationListService.importLocalAnnotationDataset(kgId, file));
|
|
|
+ } else {
|
|
|
return AjaxResult.error("文件不能为空");
|
|
|
}
|
|
|
- }else {
|
|
|
- return AjaxResult.error(1001,"参数不能为空");
|
|
|
+ } else {
|
|
|
+ return AjaxResult.error(1001, "参数不能为空");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -128,7 +132,7 @@ public class AnnotationController {
|
|
|
@ApiOperation("文档标注实体数据存储接口")
|
|
|
@PostMapping("/save/entity")
|
|
|
public AjaxResult saveAnnotationEntity(@RequestBody AnnotationEntity entity) {
|
|
|
- log.info("文档标注实体数据存储接口entity:{}", JSON.toJSONString(entity));
|
|
|
+ // log.info("文档标注实体数据存储接口entity:{}", JSON.toJSONString(entity));
|
|
|
return AjaxResult.success("实体信息保存成功", entityLablesSpanService.saveAnnotationEntity(entity));
|
|
|
}
|
|
|
|
|
@@ -142,13 +146,14 @@ public class AnnotationController {
|
|
|
@ApiOperation("文档标注实体间关系数据存储接口")
|
|
|
@PostMapping("/save/rel")
|
|
|
public AjaxResult saveAnnotationRelation(@RequestBody AnnotationEntityRelation relation) {
|
|
|
- log.info("文档标注实体关系数据存储接口entity:{}", JSON.toJSONString(relation));
|
|
|
+ // log.info("文档标注实体关系数据存储接口entity:{}", JSON.toJSONString(relation));
|
|
|
return AjaxResult.success("实体间关系保存成功", entityLablesRelationService.saveAnnotationRelation(relation));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 文档标注实体数据删除接口,传主键ID。
|
|
|
* 文档标注实体间关系数据删除接口,传主键ID。
|
|
|
+ *
|
|
|
* @param delAnnotation
|
|
|
* @return
|
|
|
*/
|
|
@@ -165,17 +170,17 @@ public class AnnotationController {
|
|
|
if (null != annotationFront.getKgId() && null != annotationFront.getFileId() && StringUtils.isNotEmpty(annotationFront.getKgId()) && StringUtils.isNotEmpty(annotationFront.getFileId())) {
|
|
|
return AjaxResult.success("文档标注最终实体数据保存成功", annotationListService.saveAnnotation(annotationFront));
|
|
|
}
|
|
|
- return AjaxResult.error(1001,"参数不能为空");
|
|
|
+ return AjaxResult.error(1001, "参数不能为空");
|
|
|
}
|
|
|
|
|
|
|
|
|
@ApiOperation("去标注接口")
|
|
|
@ApiImplicitParam(name = "fileId", value = "文档id")
|
|
|
@GetMapping("/toAnnotation")
|
|
|
- public AjaxResult toAnnotation(@RequestParam("kgId") String kgId, @RequestParam("fileId") String fileId) {
|
|
|
- if (null != kgId && null != fileId && StringUtils.isNotEmpty(kgId) && StringUtils.isNotEmpty(fileId)) {
|
|
|
+ public AjaxResult toAnnotation(@RequestParam("id") String id, @RequestParam("kgId") String kgId, @RequestParam("fileId") String fileId) {
|
|
|
+ if (null != id && null != id && StringUtils.isNotEmpty(id) && null != kgId && null != fileId && StringUtils.isNotEmpty(kgId) && StringUtils.isNotEmpty(fileId)) {
|
|
|
log.info("kgId:{},fileId:{}", kgId, fileId);
|
|
|
- return AjaxResult.success("标注数据获取成功", entityLablesRelationService.toAnnotation(kgId, fileId));
|
|
|
+ return AjaxResult.success("标注数据获取成功", entityLablesRelationService.toAnnotation(id, kgId, fileId));
|
|
|
}
|
|
|
return AjaxResult.error(1001, "参数不能为空");
|
|
|
}
|
|
@@ -192,7 +197,7 @@ public class AnnotationController {
|
|
|
@GetMapping("/generateKgGraph")
|
|
|
public AjaxResult generateKgGraph(@RequestParam("kgId") String kgId) {
|
|
|
if (null != kgId && StringUtils.isNotEmpty(kgId)) {
|
|
|
- log.info("---> kgId:{}", kgId);
|
|
|
+ log.info("生成图谱 kgId:{}", kgId);
|
|
|
return AjaxResult.success("生成图谱中", entityLablesRelationService.generateKgGraph(kgId));
|
|
|
}
|
|
|
return AjaxResult.error(1001, "参数不能为空");
|
|
@@ -201,9 +206,9 @@ public class AnnotationController {
|
|
|
@ApiOperation("算法通知后端更新生成图谱结果接口")
|
|
|
@PostMapping("/generateKgGraphResult")
|
|
|
public AjaxResult generateKgGraphResult(@RequestBody GenerateGraphResult genGraphResult) {
|
|
|
- log.info("算法通知后端更新生成图谱结果genGraphResult:{}",JSON.toJSONString(genGraphResult));
|
|
|
+ log.info("算法通知后端更新生成图谱结果genGraphResult:{}", JSON.toJSONString(genGraphResult));
|
|
|
if (null != genGraphResult.getTaskId() && StringUtils.isNotEmpty(genGraphResult.getTaskId())) {
|
|
|
- log.info("---> taskId:{}", genGraphResult.getTaskId());
|
|
|
+ log.info("算法通知后端更新生成图谱结果 taskId:{}", genGraphResult.getTaskId());
|
|
|
generateGraphService.generateKgGraphResult(genGraphResult);
|
|
|
return AjaxResult.success("算法通知后端更新生成图谱结果成功");
|
|
|
}
|
|
@@ -218,7 +223,7 @@ public class AnnotationController {
|
|
|
@ApiOperation("标注数据导出")
|
|
|
@ResponseBody
|
|
|
public void exportDatabase(@RequestBody ExportAnnotationData exportAnnotationData, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
- log.info("export annotationToAlg param--->:{}",JSON.toJSONString(exportAnnotationData));
|
|
|
+ log.info("export annotationToAlg param:{}", JSON.toJSONString(exportAnnotationData));
|
|
|
entityLablesRelationService.exportDataBase(exportAnnotationData, request, response);
|
|
|
}
|
|
|
|
|
@@ -229,19 +234,18 @@ public class AnnotationController {
|
|
|
@ApiOperation("标注数据导导入")
|
|
|
@ResponseBody
|
|
|
public AjaxResult importDatabase(String kgId, @RequestParam("file") MultipartFile file) throws IOException {
|
|
|
- log.info("import annotationToAlg param--->kgId:{},fileName:{}",JSON.toJSONString(kgId),file.getOriginalFilename());
|
|
|
- if (null != kgId && StringUtils.isNotEmpty(kgId)){
|
|
|
- if (!file.isEmpty()){
|
|
|
- return AjaxResult.success("标注数据导入成功!", entityLablesRelationService.importDataBase(kgId,file));
|
|
|
- }else {
|
|
|
+ log.info("import annotationToAlg param ---> kgId:{},fileName:{}", JSON.toJSONString(kgId), file.getOriginalFilename());
|
|
|
+ if (null != kgId && StringUtils.isNotEmpty(kgId)) {
|
|
|
+ if (!file.isEmpty()) {
|
|
|
+ return AjaxResult.success("标注数据导入成功!", entityLablesRelationService.importDataBase(kgId, file));
|
|
|
+ } else {
|
|
|
return AjaxResult.error("文件不能为空");
|
|
|
}
|
|
|
- }else {
|
|
|
- return AjaxResult.error(1001,"参数不能为空");
|
|
|
+ } else {
|
|
|
+ return AjaxResult.error(1001, "参数不能为空");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 停止生成图谱。
|
|
|
/**
|
|
|
* 前端传入知识库id,后端调用算法停止生成图谱。
|
|
|
* 后端请求算法--->入参taskId。
|
|
@@ -253,7 +257,7 @@ public class AnnotationController {
|
|
|
@GetMapping("/stopKgGraph")
|
|
|
public AjaxResult stopKgGraph(@RequestParam("kgId") String kgId) {
|
|
|
if (null != kgId && StringUtils.isNotEmpty(kgId)) {
|
|
|
- log.info("---> kgId:{}", kgId);
|
|
|
+ log.info("停止生成图谱 kgId:{}", kgId);
|
|
|
return AjaxResult.success("停止生成图谱", generateGraphService.stopGraphByTaskId(kgId));
|
|
|
}
|
|
|
return AjaxResult.error(1001, "参数不能为空");
|
|
@@ -262,7 +266,7 @@ public class AnnotationController {
|
|
|
@ApiOperation("算法通知后端更新文本内容接口")
|
|
|
@PostMapping("/toUpText")
|
|
|
public AjaxResult toUpText(@RequestBody ConvertAlgRes convertAlgRes) {
|
|
|
- log.info("算法通知后端更新文本内容 convertAlgRes:{}",JSON.toJSONString(convertAlgRes));
|
|
|
+ log.info("算法通知后端更新文本内容 convertAlgRes:{}", JSON.toJSONString(convertAlgRes));
|
|
|
if (null != convertAlgRes && null != convertAlgRes.getFileId() && null != convertAlgRes.getErrorCode()) {
|
|
|
log.info("---> fileId:{}", convertAlgRes.getFileId());
|
|
|
entityLablesRelationService.toUpText(convertAlgRes);
|
|
@@ -273,16 +277,14 @@ public class AnnotationController {
|
|
|
|
|
|
@ApiOperation("用户手动解析txt文本内容接口")
|
|
|
@GetMapping("/handsToParseTxt")
|
|
|
- public AjaxResult handsToParseTxt(@RequestParam("kgId") String kgId,@RequestParam("fileId") String fileId) {
|
|
|
- log.info("用户手动解析txt文本内容 kgId:{},fileId:{}",kgId,fileId);
|
|
|
+ public AjaxResult handsToParseTxt(@RequestParam("kgId") String kgId, @RequestParam("fileId") String fileId) {
|
|
|
+ log.info("用户手动解析txt文本内容 kgId:{},fileId:{}", kgId, fileId);
|
|
|
if (null != kgId && StringUtils.isNotEmpty(kgId) && null != fileId && StringUtils.isNotEmpty(fileId)) {
|
|
|
-
|
|
|
- return AjaxResult.success("算法通知后端更新文本内容成功");
|
|
|
+ return AjaxResult.success("算法通知后端更新文本内容成功", sysFileService.handsToParseTxt(kgId, fileId));
|
|
|
}
|
|
|
return AjaxResult.error(1001, "参数不能为空");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// todo ----------------------------以下接口均为模拟算法测试接口,后续可删除下列接口------------------------------------。
|
|
|
|
|
|
// @ApiOperation("算法 接收标注信息接口 结束后可删除")
|