Quellcode durchsuchen

解决gz合enen分支图谱数据保存冲突

guanz vor 1 Jahr
Ursprung
Commit
0204519424
27 geänderte Dateien mit 432 neuen und 150 gelöschten Zeilen
  1. 71 12
      src/main/java/com/pavis/backend/slim/common/utils/CommonUtils.java
  2. 18 8
      src/main/java/com/pavis/backend/slim/framework/minio/MinioStorage.java
  3. 19 10
      src/main/java/com/pavis/backend/slim/project/system/client/AlgKgClient.java
  4. 31 0
      src/main/java/com/pavis/backend/slim/project/system/client/AlgKgTestClient.java
  5. 36 34
      src/main/java/com/pavis/backend/slim/project/system/controller/AnnotationController.java
  6. 1 1
      src/main/java/com/pavis/backend/slim/project/system/controller/EditorController.java
  7. 3 3
      src/main/java/com/pavis/backend/slim/project/system/controller/SysFileController.java
  8. 10 10
      src/main/java/com/pavis/backend/slim/project/system/controller/SysKgController.java
  9. 2 2
      src/main/java/com/pavis/backend/slim/project/system/domain/annotation/AnnotationEntityRelation.java
  10. 1 1
      src/main/java/com/pavis/backend/slim/project/system/domain/annotation/AnnotationListParam.java
  11. 26 0
      src/main/java/com/pavis/backend/slim/project/system/domain/annotation/CreateEntityKg.java
  12. 30 0
      src/main/java/com/pavis/backend/slim/project/system/domain/annotation/EntityColor.java
  13. 3 0
      src/main/java/com/pavis/backend/slim/project/system/domain/annotation/ExportAnnotationData.java
  14. 1 1
      src/main/java/com/pavis/backend/slim/project/system/domain/annotation/SchemaImport.java
  15. 1 1
      src/main/java/com/pavis/backend/slim/project/system/domain/annotation/ToAnnotation.java
  16. 10 0
      src/main/java/com/pavis/backend/slim/project/system/service/AnnotationListService.java
  17. 1 1
      src/main/java/com/pavis/backend/slim/project/system/service/EntityLablesRelationService.java
  18. 3 3
      src/main/java/com/pavis/backend/slim/project/system/service/SysKgService.java
  19. 19 1
      src/main/java/com/pavis/backend/slim/project/system/service/impl/AnnotationListServiceImpl.java
  20. 5 6
      src/main/java/com/pavis/backend/slim/project/system/service/impl/EntityLabelsRelationServiceImpl.java
  21. 13 13
      src/main/java/com/pavis/backend/slim/project/system/service/impl/EntityLabelsSpanServiceImpl.java
  22. 2 2
      src/main/java/com/pavis/backend/slim/project/system/service/impl/GenerateGraphServiceImpl.java
  23. 68 31
      src/main/java/com/pavis/backend/slim/project/system/service/impl/SysFileServiceImpl.java
  24. 1 0
      src/main/java/com/pavis/backend/slim/project/system/service/impl/SysKbServiceImpl.java
  25. 50 7
      src/main/java/com/pavis/backend/slim/project/system/service/impl/SysKgServiceImpl.java
  26. 5 1
      src/main/resources/application-ghj.yml
  27. 2 2
      src/main/resources/application.yml

+ 71 - 12
src/main/java/com/pavis/backend/slim/common/utils/CommonUtils.java

@@ -9,6 +9,8 @@ import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang3.StringUtils;
 
 import java.io.FileInputStream;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * @version: java version 1.8
@@ -78,18 +80,11 @@ public class CommonUtils {
         return false;
     }
 
-    public static void main(String[] args) {
-        String entityStr = "[{\"name\":\"运动员\",\"id\":\"2adb14be-0e9e-456c-9554-99e917223b4c\",\"defaultName\":0,\"color\":\"#448DFF\",\"describe\":[{\"describeName\":\"名字\",\"describeType\":\"STRING\",\"notes\":\"\",\"compressedStorage\":false,\"creatingAnIndex\":false},{\"describeName\":\"国籍\",\"describeType\":\"STRING\",\"notes\":\"\",\"compressedStorage\":false,\"creatingAnIndex\":false},{\"describeName\":\"身高\",\"describeType\":\"STRING\",\"notes\":\"\",\"compressedStorage\":false,\"creatingAnIndex\":false},{\"describeName\":\"出生地\",\"describeType\":\"STRING\",\"notes\":\"\",\"compressedStorage\":false,\"creatingAnIndex\":false},{\"describeName\":\"获得\",\"describeType\":\"STRING\",\"notes\":\"\",\"compressedStorage\":false,\"creatingAnIndex\":false}],\"entityId\":\"65d28abb076b84bc9b384bce57ab28ea\",\"createTime\":1701323995933}, {\"name\":\"比赛\",\"id\":\"d25c39f7-4c6e-4155-8e9b-34a8cfca7ed2\",\"defaultName\":0,\"color\":\"#6517EB\",\"describe\":[{\"describeName\":\"名字\",\"describeType\":\"STRING\",\"notes\":\"\",\"compressedStorage\":false,\"creatingAnIndex\":false},{\"describeName\":\"赛事级别\",\"describeType\":\"STRING\",\"notes\":\"\",\"compressedStorage\":false,\"creatingAnIndex\":false},{\"describeName\":\"时间\",\"describeType\":\"STRING\",\"notes\":\"\",\"compressedStorage\":false,\"creatingAnIndex\":false}],\"entityId\":\"87561e713eac62fa4ae14aea3c84c89e\",\"createTime\":1701323995933}, {\"name\":\"荣誉\",\"id\":\"96d30cd1-474b-4a4c-9f7f-cb12714ff4ac\",\"defaultName\":0,\"color\":\"#EF0C0C\",\"describe\":[{\"describeName\":\"名字\",\"describeType\":\"STRING\",\"notes\":\"\",\"compressedStorage\":false,\"creatingAnIndex\":false},{\"describeName\":\"级别\",\"describeType\":\"STRING\",\"notes\":\"\",\"compressedStorage\":false,\"creatingAnIndex\":false}],\"entityId\":\"716af5482d843823cffb120e8af0aa17\",\"createTime\":1701324123988}]";
-        JSONArray entity = JSONArray.parseArray(entityStr);
-        // 处理前端传输的实体数据。
-        JSONArray entityFinal = dealEntityId(entity);
-        log.info("entityFinal:{}",JSON.toJSONString(entityFinal));
-
-        String relStr = "[{\"id\":\"624e0255-4d4a-4e53-9724-af979c7a9d3f\",\"relation\":\"参加\",\"start\":\"2adb14be-0e9e-456c-9554-99e917223b4c\",\"startName\":\"运动员\",\"end\":\"d25c39f7-4c6e-4155-8e9b-34a8cfca7ed2\",\"endName\":\"比赛\",\"direction\":0,\"styleEntity\":\"#EF3D3D\",\"describe\":[],\"isAt\":0,\"relationId\":\"f45e6316d258e96b733ada28df424f46\"}, {\"id\":\"c405f16e-a606-4404-bc2a-1807c1473bd9\",\"relation\":\"获得\",\"start\":\"2adb14be-0e9e-456c-9554-99e917223b4c\",\"startName\":\"运动员\",\"end\":\"96d30cd1-474b-4a4c-9f7f-cb12714ff4ac\",\"endName\":\"荣誉\",\"direction\":0,\"styleEntity\":\"#EA2182\",\"describe\":[],\"isAt\":0,\"relationId\":\"195f55d774e9b9adda80325f9a95a86b\"}]";
-        JSONArray relation = JSONArray.parseArray(relStr);
-        // 处理前端传输的实体关系数据。
-
-    }
+    /**
+     * 处理导入导出图谱schema时实体id的值设置为NULL.
+     * @param jsonArray
+     * @return
+     */
     public static JSONArray dealEntityId(JSONArray jsonArray){
         // 处理所有的实体ID,设置null。
         for (int i = 0; i < jsonArray.size(); i++) {
@@ -104,6 +99,11 @@ public class CommonUtils {
         return jsonArray;
     }
 
+    /**
+     * 处理导入导出图谱schema时实体关系id的值设置为NULL.
+     * @param jsonArray
+     * @return
+     */
     public static JSONArray dealRelationId(JSONArray jsonArray){
         // 处理所有的实体ID,设置null。
         for (int i = 0; i < jsonArray.size(); i++) {
@@ -117,4 +117,63 @@ public class CommonUtils {
         return jsonArray;
     }
 
+    /**
+     * 处理前端标注数据的颜色。
+     * @param textFront
+     * @param entityName
+     * @param colorStr
+     * @return
+     */
+    public static String dealTextFrontWithColor(String textFront, String entityName,String colorStr,String nameStr) {
+        log.info("正则匹配替换颜色或名称 sourceName:{},upName:{}",entityName,nameStr);
+        String regex = "<span[^>]*data-before=\"" + entityName + "\"[^>]*>([^<]+)<\\/span>";
+        log.info("regex:{}", regex);
+        Pattern pattern = Pattern.compile(regex);
+        Matcher matcher = pattern.matcher(textFront);
+        StringBuffer upTextFront = new StringBuffer();
+        while (matcher.find()) {
+            String matched = matcher.group(1);
+            log.info("matched:{}",matched);
+            log.info("matcher[0]:{}",matcher.group(0));
+            String replacedStr = matcher.group(0).replaceAll("--color: #[0-9a-fA-F]{6}", "--color:" + colorStr);
+            replacedStr = replacedStr.replaceAll("--color:#[0-9a-fA-F]{6}", "--color:" + colorStr);
+            if (null != nameStr && StringUtils.isNotEmpty(nameStr)){
+                replacedStr = replacedStr.replaceAll("data-before=\"" + entityName + "\"", "data-before=\"" + nameStr + "\"");
+            }
+            log.info("replacedStr:{}",replacedStr);
+            matcher.appendReplacement(upTextFront, replacedStr);
+        }
+        matcher.appendTail(upTextFront);
+        log.info("最终替换后的标注数据 upTextFront:{}",upTextFront.toString());
+        return upTextFront.toString();
+    }
+
+    public static void main(String[] args) {
+        String textFront = "<span class=\"entityhig\" style=\"border-bottom: 8px solid rgb(68, 141, 255); --data-wih: translate(0px,30px); line-height: 30px; --color: #448DFF; background: none; box-shadow: none;\" data-before=\"运动员\" id=\"10\">王曼昱</span>";
+        String entityName = "运动员";
+        String colorStr = "#ffffff";
+        String upTextFront = dealTextFrontWithColorName(textFront, entityName, colorStr,entityName + "哈哈哈");
+        log.info("upTextFront:{}",upTextFront);
+    }
+
+    public static String dealTextFrontWithColorName(String textFront, String entityName,String colorStr,String nameStr) {
+        String regex = "<span[^>]*data-before=\"" + entityName + "\"[^>]*>([^<]+)<\\/span>";
+        log.info("regex:{}", regex);
+        Pattern pattern = Pattern.compile(regex);
+        Matcher matcher = pattern.matcher(textFront);
+        StringBuffer upTextFront = new StringBuffer();
+        while (matcher.find()) {
+            String matched = matcher.group(1);
+            log.info("matched:{}",matched);
+            log.info("matcher[0]:{}",matcher.group(0));
+            String replacedStr = matcher.group(0).replaceAll("--color: #[0-9a-fA-F]{6}", "--color:" + colorStr);
+            replacedStr = replacedStr.replaceAll("--color:#[0-9a-fA-F]{6}", "--color:" + colorStr);
+            replacedStr = replacedStr.replaceAll("data-before=\"" + entityName + "\"", "data-before=\"" + nameStr + "\"");
+            log.info("replacedStr:{}",replacedStr);
+            matcher.appendReplacement(upTextFront, replacedStr);
+        }
+        matcher.appendTail(upTextFront);
+        log.info("最终替换后的标注数据 upTextFront:{}",upTextFront.toString());
+        return upTextFront.toString();
+    }
 }

+ 18 - 8
src/main/java/com/pavis/backend/slim/framework/minio/MinioStorage.java

@@ -4,14 +4,13 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import com.pavis.backend.slim.common.constant.Constant;
 import com.pavis.backend.slim.common.exception.UtilException;
-import io.minio.*;
-import io.minio.errors.ErrorResponseException;
-import io.minio.errors.InsufficientDataException;
-import io.minio.errors.InternalException;
-import io.minio.errors.InvalidResponseException;
+import io.minio.BucketExistsArgs;
+import io.minio.GetPresignedObjectUrlArgs;
+import io.minio.MakeBucketArgs;
+import io.minio.MinioClient;
+import io.minio.PutObjectArgs;
+import io.minio.RemoveObjectArgs;
 import io.minio.errors.MinioException;
-import io.minio.errors.ServerException;
-import io.minio.errors.XmlParserException;
 import io.minio.http.Method;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -79,13 +78,24 @@ public class MinioStorage {
      * @param file  文件input流
      */
     public void putObject(String key, MultipartFile file) throws IOException, NoSuchAlgorithmException, InvalidKeyException {
+        InputStream is = null;
         try {
             // 1. 创建bucket
             createBucket(bucketName);
             // 2. 存储文件
-            client.putObject(PutObjectArgs.builder().bucket(bucketName).object(key).stream(file.getInputStream(), file.getSize(), -1).build());
+            is = file.getInputStream();
+            client.putObject(PutObjectArgs.builder().bucket(bucketName).object(key).stream(is, file.getSize(), -1).build());
         } catch (MinioException e) {
             throw new UtilException(e.getMessage());
+        }finally {
+            if (is != null){
+                try {
+                    is.close();
+                }catch (IOException ex){
+                    ex.printStackTrace();
+                    log.info("上传文件至指定bucket或指定文件夹 ex:{}",ex);
+                }
+            }
         }
     }
 

+ 19 - 10
src/main/java/com/pavis/backend/slim/project/system/client/AlgKgClient.java

@@ -6,6 +6,7 @@ import com.pavis.backend.slim.framework.config.AlgKgConfig;
 import com.pavis.backend.slim.project.system.domain.annotation.AnnotationToAlg;
 import com.pavis.backend.slim.project.system.domain.annotation.SchemaImport;
 import com.pavis.backend.slim.project.system.domain.annotation.UniversalGgraphToAlg;
+import feign.Request;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -23,12 +24,12 @@ import java.util.Map;
 public interface AlgKgClient {
 
 
-
     /**
      * 发送标注数据给算法服务,生成图谱。状态为200,调用下一个接口:入参kgId、fileIds等。
      * url: http://192.168.1.150:12000/labels/import
-     *  入参:{"kgId":"","annotationDatas":[{"text":"","textFront":"","entities":[{}],"relations":[{}]}]}
-     *  出参:ok。
+     * 入参:{"kgId":"","annotationDatas":[{"text":"","textFront":"","entities":[{}],"relations":[{}]}]}
+     * 出参:ok。
+     *
      * @param annotationToAlg
      * @return
      */
@@ -40,6 +41,7 @@ public interface AlgKgClient {
      * todo 调用此算法服务获取taskId。
      * 入参:{kgId、fielIds:[]、taskType[true 通用;false 标注。]}
      * 出参:{"taskId":""}
+     *
      * @param universalGgraphToAlg
      * @return
      */
@@ -51,6 +53,7 @@ public interface AlgKgClient {
      * todo 调用此算法服务获取taskId。
      * 入参:{kgId、entityList:实体属性、relationList:关系属性。}
      * 出参:ok。
+     *
      * @param schemaImport
      * @return
      */
@@ -59,16 +62,16 @@ public interface AlgKgClient {
     String sendEntityRelationToAlg(@RequestBody SchemaImport schemaImport);
 
 
-
     /**
      * 发送文档需转换为txt的数据给算法服务。
-     *  入参:{"files":[{"fileId":"","objectKey":"","identifier":""}]}
-     *  出参:无需关注。
+     * 入参:{"files":[{"fileId":"","objectKey":"","identifier":""}]}
+     * 出参:无需关注。
+     *
      * @param data
      * @return
      */
     @PostMapping(value = "/data_import/data_access", produces = {MediaType.APPLICATION_JSON_VALUE},
-            consumes="application/json")
+            consumes = "application/json")
     String convertToTxt(String data);
 
     /**
@@ -76,38 +79,44 @@ public interface AlgKgClient {
      * 根据fileIds获取算法解析的txt文本内容。即去标注时,选择文档去标注时,调用。
      * 入参:{"fileIds":[]}
      * 出参:[{"errorCode":"","fileId":"","text":""}]
+     *
      * @param data
      * @return
      */
     @PostMapping(value = "/data_import/batch_read", produces = {MediaType.APPLICATION_JSON_VALUE},
-            consumes="application/json")
+            consumes = "application/json")
     JSONArray getAlgTxt(String data);
 
     /**
      * 传本地上传的文件,调用算法实时获取文本内容。
      * 入参:{"file":"","fileId":""}
      * 出参:[{"errorCode":"","fileId":"","text":""}]
+     *
      * @param params
      * @return
      */
     @PostMapping(value = "/data_import/upload_file",
             consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
             // produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
-    produces = MediaType.APPLICATION_JSON_VALUE)
+            produces = MediaType.APPLICATION_JSON_VALUE)
     JSONArray getAlgTxtByFile(Map<String, ?> params);
 
     /**
      * 通知算法停止生成图谱。
      * 入参:{"taskId":""}
      * 出参:{'status': boolean}。true 取消成功;false 取消失败。
+     *
      * @param data
      * @return
      */
     @PostMapping(value = "/graph/stop_graph", produces = {MediaType.APPLICATION_JSON_VALUE},
-            consumes="application/json")
+            consumes = "application/json")
     JSONObject stopGraphToAlg(String data);
 
 
+    @PostMapping(value = "/data_import/real_time_read", produces = {MediaType.APPLICATION_JSON_VALUE},
+            consumes = "application/json")
+    String convertToTxtByRealTime(String data, Request.Options options);
 
     /**
      * todo 通用知识图谱构建,即图谱下无实体、关系数据。-----> 暂未对接。

+ 31 - 0
src/main/java/com/pavis/backend/slim/project/system/client/AlgKgTestClient.java

@@ -0,0 +1,31 @@
+package com.pavis.backend.slim.project.system.client;
+
+import com.pavis.backend.slim.framework.config.AlgKgConfig;
+import feign.Request;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+
+/**
+ * @version: java version 1.8
+ * @Author: Guan H.J.
+ * @description: 调用算法接口服务
+ * @date: 2023-10-26 9:47
+ */
+@FeignClient(value = "algKgTestClient", url = "${algorithm.test.url}", configuration = AlgKgConfig.class)
+public interface AlgKgTestClient {
+
+    /**
+     * 发送文档需转换为txt的数据给算法服务。
+     * 入参:{"files":[{"fileId":"","objectKey":"","identifier":""}]}
+     * 出参:无需关注。
+     *
+     * @param data
+     * @return
+     */
+    @PostMapping(value = "/testapi", produces = {MediaType.APPLICATION_JSON_VALUE},
+            consumes = "application/json")
+    String testConvertToTxt(String data, Request.Options options);
+
+
+}

+ 36 - 34
src/main/java/com/pavis/backend/slim/project/system/controller/AnnotationController.java

@@ -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("算法 接收标注信息接口 结束后可删除")

+ 1 - 1
src/main/java/com/pavis/backend/slim/project/system/controller/EditorController.java

@@ -63,7 +63,7 @@ public class EditorController {
     public void save(@RequestParam("fileId") String fileId, @RequestParam("path") String path, HttpServletResponse response, HttpServletRequest request) {
         log.info("/office/save comming...");
         log.info("fileId:{},path:{}", fileId, path);
-        fileService.onlyOfficeToMinio(fileId,path, response, request);
+        fileService.onlyOfficeToMinio(fileId, path, response, request);
     }
 
     @RequestMapping("/EditorServlet")

+ 3 - 3
src/main/java/com/pavis/backend/slim/project/system/controller/SysFileController.java

@@ -94,14 +94,14 @@ public class SysFileController {
      * 文件下载,通过路径直接下载到本地
      *
      * @param objectName 文件在oss中的key值
-     * @param name minIo中的名字
+     * @param name       minIo中的名字
      * @throws Exception
      */
     @ApiOperation("下载文件接口")
     @GetMapping("/down")
-    public AjaxResult downloadPath(@RequestParam("objectName")String objectName,@RequestParam("originalName")String name ) throws Exception {
+    public AjaxResult downloadPath(@RequestParam("objectName") String objectName, @RequestParam("originalName") String name) throws Exception {
         MinioClient client = minioFileUtil.client();
-        minioFileUtil.downloadPath(urlLocal, bucketName,objectName,name);
+        minioFileUtil.downloadPath(urlLocal, bucketName, objectName, name);
         return AjaxResult.success();
     }
 

+ 10 - 10
src/main/java/com/pavis/backend/slim/project/system/controller/SysKgController.java

@@ -3,12 +3,11 @@ package com.pavis.backend.slim.project.system.controller;
 import com.alibaba.fastjson2.JSON;
 import com.pavis.backend.slim.framework.web.domain.AjaxResult;
 import com.pavis.backend.slim.project.system.domain.SysEntity;
-import com.pavis.backend.slim.project.system.domain.SysEntityAll;
 import com.pavis.backend.slim.project.system.domain.SysEntityInstance;
 import com.pavis.backend.slim.project.system.domain.SysEntityRelation;
-import com.pavis.backend.slim.project.system.domain.SysFile;
 import com.pavis.backend.slim.project.system.domain.SysKg;
 import com.pavis.backend.slim.project.system.domain.algorithm.AlgSpO;
+import com.pavis.backend.slim.project.system.domain.annotation.CreateEntityKg;
 import com.pavis.backend.slim.project.system.domain.annotation.ExportSchemaData;
 import com.pavis.backend.slim.project.system.domain.front.FileKey;
 import com.pavis.backend.slim.project.system.service.SysEntityService;
@@ -91,8 +90,7 @@ public class SysKgController {
     @ApiOperation("接收算法返回数据接口")
     @PostMapping("/algorithm")
     public AjaxResult algorithm(@RequestBody AlgSpO algSpO) {
-        kgService.algorithm(algSpO);
-        return AjaxResult.success();
+        return AjaxResult.success(kgService.algorithm(algSpO));
     }
 
     @ApiOperation("删除图谱")
@@ -138,7 +136,8 @@ public class SysKgController {
 
     @ApiOperation("实体,实体关系创建(前段所传纹丝不动保存)")
     @PostMapping("/createEntityKg")
-    public AjaxResult createEntityKg(@RequestBody SysEntity sysEntityAll) {
+    // public AjaxResult createEntityKg(@RequestBody SysEntity sysEntityAll) {
+    public AjaxResult createEntityKg(@RequestBody CreateEntityKg sysEntityAll) {
         return AjaxResult.success(kgService.createEntityKg(sysEntityAll));
     }
 
@@ -196,35 +195,36 @@ public class SysKgController {
             return AjaxResult.error(1001, "参数不能为空");
         }
     }
+
     @ApiOperation("实例新增或更新")
     @PostMapping("/insOrUpdEnIce")
-    public AjaxResult insOrUpdEnIce(@RequestBody SysEntityInstance sysEntityInstance){
+    public AjaxResult insOrUpdEnIce(@RequestBody SysEntityInstance sysEntityInstance) {
         return AjaxResult.success(kgService.insOrUpdEnIce(sysEntityInstance));
     }
 
     @ApiOperation("实例删除")
     @PostMapping("/delEnIce")
-    public AjaxResult delEnIce(@RequestBody FileKey fileKey){
+    public AjaxResult delEnIce(@RequestBody FileKey fileKey) {
         kgService.delEnIce(fileKey);
         return AjaxResult.success();
     }
 
     @ApiOperation("删除实例关系")
     @PostMapping("/delEntRlation")
-    public AjaxResult delEntRlation(@RequestBody FileKey fileKey){
+    public AjaxResult delEntRlation(@RequestBody FileKey fileKey) {
         kgService.delEntRlation(fileKey);
         return AjaxResult.success();
     }
 
     @ApiOperation("查询实体关系下的实例关系")
     @PostMapping("/selEntAndEntRela")
-    public AjaxResult selEntAndEntRela(@RequestBody FileKey fileKey){
+    public AjaxResult selEntAndEntRela(@RequestBody FileKey fileKey) {
         return AjaxResult.success(kgService.selEntAndEntRela(fileKey));
     }
 
     @ApiOperation("新增或更新实例关系")
     @PostMapping("/insOrUpdRelation")
-    public AjaxResult insOrUpdRelation(@RequestBody SysEntityRelation sysEntityRelation){
+    public AjaxResult insOrUpdRelation(@RequestBody SysEntityRelation sysEntityRelation) {
         kgService.insOrUpdRelation(sysEntityRelation);
         return AjaxResult.success();
     }

+ 2 - 2
src/main/java/com/pavis/backend/slim/project/system/domain/annotation/AnnotationEntityRelation.java

@@ -34,7 +34,7 @@ public class AnnotationEntityRelation {
     // 开始实体ID。
     @ApiModelProperty("开始实体名称")
     private String fromName;
-    @ApiModelProperty(value = "start标注类型,必填",required = true)
+    @ApiModelProperty(value = "start标注类型,必填", required = true)
     private String fromType;
     // 结束实体ID。
     @ApiModelProperty("结束实体ID")
@@ -42,7 +42,7 @@ public class AnnotationEntityRelation {
     // 结束实体ID。
     @ApiModelProperty("结束实体名称")
     private String toName;
-    @ApiModelProperty(value = "end标注类型,必填",required = true)
+    @ApiModelProperty(value = "end标注类型,必填", required = true)
     private String toType;
     // 标签实体关系的类型即id,如:13。
     @ApiModelProperty("标签实体关系的类型即id,如:13。")

+ 1 - 1
src/main/java/com/pavis/backend/slim/project/system/domain/annotation/AnnotationListParam.java

@@ -18,7 +18,7 @@ import lombok.experimental.SuperBuilder;
 @Setter
 @AllArgsConstructor
 @NoArgsConstructor
-public class AnnotationListParam{
+public class AnnotationListParam {
     // 图谱ID
     @ApiModelProperty("图谱ID")
     private String kgId;

+ 26 - 0
src/main/java/com/pavis/backend/slim/project/system/domain/annotation/CreateEntityKg.java

@@ -0,0 +1,26 @@
+package com.pavis.backend.slim.project.system.domain.annotation;
+
+import com.pavis.backend.slim.project.system.domain.SysEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * @version: java version 1.8
+ * @Author: Guan H.J.
+ * @description:
+ * @date: 2023-12-12 11:20
+ */
+// @SuperBuilder
+@Builder
+@Getter
+@Setter
+@AllArgsConstructor
+@NoArgsConstructor
+public class CreateEntityKg extends SysEntity {
+    @ApiModelProperty("实体名称更新")
+    private String upName;
+}

+ 30 - 0
src/main/java/com/pavis/backend/slim/project/system/domain/annotation/EntityColor.java

@@ -0,0 +1,30 @@
+package com.pavis.backend.slim.project.system.domain.annotation;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * @version: java version 1.8
+ * @Author: Guan H.J.
+ * @description: 实体的颜色。
+ * @date: 2023-12-07 14:04
+ */
+@Builder
+@Getter
+@Setter
+@NoArgsConstructor
+@AllArgsConstructor
+public class EntityColor {
+    @ApiModelProperty("实体ID")
+    private String entityId;
+    @ApiModelProperty("实体名称")
+    private String name;
+    @ApiModelProperty("实体颜色")
+    private String color;
+    @ApiModelProperty("实体名称变更后的值")
+    private String upName;
+}

+ 3 - 0
src/main/java/com/pavis/backend/slim/project/system/domain/annotation/ExportAnnotationData.java

@@ -21,6 +21,9 @@ import java.util.List;
 @AllArgsConstructor
 @NoArgsConstructor
 public class ExportAnnotationData {
+    // 图谱ID。
+    @ApiModelProperty("主键ID")
+    private String id;
     // 图谱ID。
     @ApiModelProperty("图谱ID")
     private String kgId;

+ 1 - 1
src/main/java/com/pavis/backend/slim/project/system/domain/annotation/SchemaImport.java

@@ -21,7 +21,7 @@ import java.util.List;
 @Setter
 @AllArgsConstructor
 @NoArgsConstructor
-public class SchemaImport{
+public class SchemaImport {
     @ApiModelProperty("图谱ID")
     private String kgId;
     // 该知识库下的所有实体信息。

+ 1 - 1
src/main/java/com/pavis/backend/slim/project/system/domain/annotation/ToAnnotation.java

@@ -22,7 +22,7 @@ import java.util.List;
 @Setter
 @AllArgsConstructor
 @NoArgsConstructor
-public class ToAnnotation extends AnnotationData{
+public class ToAnnotation extends AnnotationData {
     // 该知识库下的所有实体信息。
     @ApiModelProperty("该知识库下的所有实体信息")
     private List<SysEntity> entityList;

+ 10 - 0
src/main/java/com/pavis/backend/slim/project/system/service/AnnotationListService.java

@@ -5,6 +5,7 @@ import com.github.pagehelper.PageInfo;
 import com.pavis.backend.slim.project.system.domain.AnnotationList;
 import com.pavis.backend.slim.project.system.domain.annotation.AnnotationFront;
 import com.pavis.backend.slim.project.system.domain.annotation.AnnotationListParam;
+import com.pavis.backend.slim.project.system.domain.annotation.EntityColor;
 import com.pavis.backend.slim.project.system.domain.annotation.ImportAnnotationDataset;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -57,4 +58,13 @@ public interface AnnotationListService extends IService<AnnotationList> {
      * @return
      */
     Boolean saveAnnotation(AnnotationFront annotationFront);
+
+    /**
+     * 根据图谱和文档id更新标注数据的textFront值。
+     *
+     * @param kgId
+     * @param entityColor
+     * @return
+     */
+    void upTextFrontByColor(String kgId, EntityColor entityColor);
 }

+ 1 - 1
src/main/java/com/pavis/backend/slim/project/system/service/EntityLablesRelationService.java

@@ -38,7 +38,7 @@ public interface EntityLablesRelationService extends IService<EntityLabelsRelati
      * @param fileId
      * @return
      */
-    ToAnnotation toAnnotation(String kgId, String fileId);
+    ToAnnotation toAnnotation(String id, String kgId, String fileId);
 
     /**
      * 根据图谱id和文档id获取历史标注实体关系信息数据列表。

+ 3 - 3
src/main/java/com/pavis/backend/slim/project/system/service/SysKgService.java

@@ -2,12 +2,12 @@ package com.pavis.backend.slim.project.system.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.github.pagehelper.PageInfo;
-import com.pavis.backend.slim.project.system.domain.SysEntity;
 import com.pavis.backend.slim.project.system.domain.SysEntityAll;
 import com.pavis.backend.slim.project.system.domain.SysEntityInstance;
 import com.pavis.backend.slim.project.system.domain.SysEntityRelation;
 import com.pavis.backend.slim.project.system.domain.SysKg;
 import com.pavis.backend.slim.project.system.domain.algorithm.AlgSpO;
+import com.pavis.backend.slim.project.system.domain.annotation.CreateEntityKg;
 import com.pavis.backend.slim.project.system.domain.annotation.ExportSchemaData;
 import com.pavis.backend.slim.project.system.domain.front.ClutterReturn;
 import com.pavis.backend.slim.project.system.domain.front.FileKey;
@@ -50,7 +50,7 @@ public interface SysKgService extends IService<SysKg> {
      */
     List<TreeFile> listKg();
 
-    void algorithm(AlgSpO algSpO);
+    Boolean algorithm(AlgSpO algSpO);
 
     /**
      * 删除图谱,可批量
@@ -81,7 +81,7 @@ public interface SysKgService extends IService<SysKg> {
      * @param sysEntityAll 前端传参数据
      * @return 前端所需要的返参数据
      */
-    SysEntityAll createEntityKg(SysEntity sysEntityAll);
+    SysEntityAll createEntityKg(CreateEntityKg sysEntityAll);
 
 
     /**

+ 19 - 1
src/main/java/com/pavis/backend/slim/project/system/service/impl/AnnotationListServiceImpl.java

@@ -15,6 +15,7 @@ import com.pavis.backend.slim.project.system.domain.AnnotationList;
 import com.pavis.backend.slim.project.system.domain.annotation.AnnotationFront;
 import com.pavis.backend.slim.project.system.domain.annotation.AnnotationListParam;
 import com.pavis.backend.slim.project.system.domain.annotation.ConvertAlgRes;
+import com.pavis.backend.slim.project.system.domain.annotation.EntityColor;
 import com.pavis.backend.slim.project.system.domain.annotation.ImportAnnotationDataset;
 import com.pavis.backend.slim.project.system.domain.annotation.ImportDataset;
 import com.pavis.backend.slim.project.system.mapper.AnnotationListMapper;
@@ -107,7 +108,7 @@ public class AnnotationListServiceImpl extends ServiceImpl<AnnotationListMapper,
         // 获取算法txt文本内容.
         toAlgTxt(annotationLists);
         // 返回数据。
-        log.info("saveResLists:{}", JSON.toJSONString(saveResLists));
+        log.info("saveResLists:{}", saveResLists.size());
         if (saveResLists.contains(0)) {
             return false;
         } else {
@@ -166,6 +167,22 @@ public class AnnotationListServiceImpl extends ServiceImpl<AnnotationListMapper,
         return false;
     }
 
+    @Override
+    public void upTextFrontByColor(String kgId, EntityColor entityColor) {
+        List<AnnotationList> annotationLists = baseMapper.selectList(new QueryWrapper<AnnotationList>().lambda().eq(AnnotationList::getKgId, kgId));
+        if (null != annotationLists && !CollectionUtils.isEmpty(annotationLists)) {
+            for (AnnotationList annotationList : annotationLists) {
+                if (null != annotationList.getTextFront() && StringUtils.isNotEmpty(annotationList.getTextFront())) {
+                    String upTextFront = CommonUtils.dealTextFrontWithColor(annotationList.getTextFront(), entityColor.getName(), entityColor.getColor(), entityColor.getUpName());
+                    // String upTextFront = CommonUtils.dealTextFrontWithColor(annotationList.getTextFront(), entityColor.getName(), entityColor.getColor(),"");
+                    annotationList.setTextFront(upTextFront);
+                    int upRes = baseMapper.updateById(annotationList);
+                    log.info("实体名称OR颜色变更后,更新textFront结果 upRes:{},colorAfter:{}", upRes, entityColor.getColor());
+                }
+            }
+        }
+    }
+
     /**
      * 调用算法实时获取txt文本内容。
      *
@@ -221,6 +238,7 @@ public class AnnotationListServiceImpl extends ServiceImpl<AnnotationListMapper,
                         } else {
                             if (null != algRes.getErrorCode() && "-1".equals(algRes.getErrorCode()) && false == upFlag) {
                                 for (AnnotationList hasNullText : hasNullTexts) {
+                                    hasNullText.setTextContent("");
                                     hasNullText.setParseStatus(-1);
                                     hasNullText.setCreateBy(SecurityUtils.getUsername());
                                     int saveRes = baseMapper.insert(hasNullText);

+ 5 - 6
src/main/java/com/pavis/backend/slim/project/system/service/impl/EntityLabelsRelationServiceImpl.java

@@ -116,12 +116,12 @@ public class EntityLabelsRelationServiceImpl extends ServiceImpl<EntityLabelsRel
     }
 
     @Override
-    public ToAnnotation toAnnotation(String kgId, String fileId) {
+    public ToAnnotation toAnnotation(String id, 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));
+        List<AnnotationList> annotationLists = annotationListMapper.selectList(new QueryWrapper<AnnotationList>().lambda().eq(AnnotationList::getId, id).eq(AnnotationList::getKgId, kgId).eq(AnnotationList::getFileId, fileId));
         // log.info("fileTextContent:{}",fileTextContent);
         if (!CollectionUtils.isEmpty(annotationLists) && null != annotationLists.get(0).getTextContent() && StringUtils.isNotBlank(annotationLists.get(0).getTextContent())) {
             // log.info("文本内容不为空:{}", annotationLists.get(0).getTextContent());
@@ -200,8 +200,7 @@ public class EntityLabelsRelationServiceImpl extends ServiceImpl<EntityLabelsRel
                 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("标注数据待发送至算法数据结构 annotationToAlg:{}", JSON.toJSONString(annotationToAlg));
                 log.info("----------------------------------------------------");
                 if (!CollectionUtils.isEmpty(annotationDatas) && annotationDatas.get(0).getEntities().size() > 0) {
                     log.info("有图schema 有标注数据");
@@ -264,7 +263,7 @@ public class EntityLabelsRelationServiceImpl extends ServiceImpl<EntityLabelsRel
             // 查询前端存储的文本内容给算法。
             List<AnnotationList> annotationLists = annotationListMapper.selectList(new QueryWrapper<AnnotationList>().lambda().eq(AnnotationList::getKgId, kgId).eq(AnnotationList::getFileId, fileId));
             String textFront = "";
-            if (!CollectionUtils.isEmpty(annotationLists)){
+            if (!CollectionUtils.isEmpty(annotationLists)) {
                 textFront = annotationLists.get(0).getTextFront();
             }
             if (null != fileTextContent && StringUtils.isNotBlank(fileTextContent)) {
@@ -301,7 +300,7 @@ public class EntityLabelsRelationServiceImpl extends ServiceImpl<EntityLabelsRel
         log.info("待导出的标注数据 annotationDatas:{}", JSON.toJSONString(annotationDatas));
         List<ToAnnotation> annotations = new ArrayList<>();
         for (String fileId : exportAnnotationData.getFileIds()) {
-            annotations.add(toAnnotation(exportAnnotationData.getKgId(), fileId));
+            annotations.add(toAnnotation(exportAnnotationData.getId(), exportAnnotationData.getKgId(), fileId));
         }
         log.info("待导出的标注数据 annotations:{}", JSON.toJSONString(annotations));
 

+ 13 - 13
src/main/java/com/pavis/backend/slim/project/system/service/impl/EntityLabelsSpanServiceImpl.java

@@ -46,7 +46,7 @@ public class EntityLabelsSpanServiceImpl extends ServiceImpl<EntityLabelsSpanMap
     public EntityLabelsSpan saveAnnotationEntity(AnnotationEntity entity) {
         // 将前端传过来的实体信息进行存储,备注:不对实体信息做判重信息。
         EntityLabelsSpan entityLabelsSpan = new EntityLabelsSpan();
-        BeanUtils.copyProperties(entity,entityLabelsSpan);
+        BeanUtils.copyProperties(entity, entityLabelsSpan);
         // 设置基本信息,创建人、创建时间等。
         entityLabelsSpan.setUserId(SecurityUtils.getUserId());
         entityLabelsSpan.setCreateBy(SecurityUtils.getUsername());
@@ -55,13 +55,13 @@ public class EntityLabelsSpanServiceImpl extends ServiceImpl<EntityLabelsSpanMap
         // log.info("标注的实体信息存储结果res:{},entityLabelsSpan:{}",insertRes, JSON.toJSONString(entityLabelsSpan));
         // 存在id更新,无id新增。
         boolean modRes = saveOrUpdate(entityLabelsSpan);
-        log.info("标注的实体信息存储结果res:{},entityLabelsSpan:{}",modRes, JSON.toJSONString(entityLabelsSpan));
+        log.info("标注的实体信息存储结果 res:{},entityLabelsSpan:{}", modRes, JSON.toJSONString(entityLabelsSpan));
         // 更新标注状态。
         SysKg sysKg = sysKgMapper.selectById(entity.getKgId());
-        if (null != sysKg){
+        if (null != sysKg) {
             sysKg.setAnnotationStatus(1);
             int upRes = sysKgMapper.updateById(sysKg);
-            log.info("更新图谱的标注状态annotationStatus:{}",upRes);
+            log.info("更新图谱的标注状态 annotationStatus:{}", upRes);
         }
         // // 更新标注数据。todo 前端反馈暂时先不在此处加逻辑了。
         // log.info("开始更新前端标注textFront数据");
@@ -73,14 +73,14 @@ public class EntityLabelsSpanServiceImpl extends ServiceImpl<EntityLabelsSpanMap
     }
 
     @Override
-    public List<AnnotationEntity> getAnnotationEntityByKgIdAndFileId(String kgId,String fileId) {
+    public List<AnnotationEntity> getAnnotationEntityByKgIdAndFileId(String kgId, String fileId) {
         List<EntityLabelsSpan> entityLabelsSpans = baseMapper.selectList(new QueryWrapper<EntityLabelsSpan>().lambda()
-                .eq(EntityLabelsSpan::getKgId, kgId).eq(EntityLabelsSpan::getFileId,fileId));
+                .eq(EntityLabelsSpan::getKgId, kgId).eq(EntityLabelsSpan::getFileId, fileId));
         List<AnnotationEntity> annotationEntities = new ArrayList<>();
         AnnotationEntity annotationEntity;
         for (EntityLabelsSpan entityLabelsSpan : entityLabelsSpans) {
             annotationEntity = new AnnotationEntity();
-            BeanUtils.copyProperties(entityLabelsSpan,annotationEntity);
+            BeanUtils.copyProperties(entityLabelsSpan, annotationEntity);
             annotationEntity.setId(Long.valueOf(entityLabelsSpan.getId()));
             annotationEntities.add(annotationEntity);
         }
@@ -90,7 +90,7 @@ public class EntityLabelsSpanServiceImpl extends ServiceImpl<EntityLabelsSpanMap
     @Override
     public Boolean delAnnotation(DelAnnotation delAnnotation) {
         // 删除实体之前,判断是否存在关系,若存在先删除关系,在删除实体。
-        if ("0".equals(delAnnotation.getDelType())){
+        if ("0".equals(delAnnotation.getDelType())) {
             // 0 删除关系,检索到可直接删除该关系。
             List<Integer> dels = new ArrayList<>();
             for (String id : delAnnotation.getIds()) {
@@ -98,25 +98,25 @@ public class EntityLabelsSpanServiceImpl extends ServiceImpl<EntityLabelsSpanMap
                 dels.add(delRes);
             }
             return dels.contains(0) ? false : true;
-        }else if ("1".equals(delAnnotation.getDelType())){
+        } else if ("1".equals(delAnnotation.getDelType())) {
             // 1 删除实体,判断是否存在关系,若存在先删除关系,在删除实体。
             List<Integer> delRels = new ArrayList<>();
             List<Integer> delEntities = new ArrayList<>();
             for (String id : delAnnotation.getIds()) {
                 List<EntityLabelsRelation> entityLabelsRelations = entityLabelsRelationMapper.selectList(new QueryWrapper<EntityLabelsRelation>().lambda().eq(EntityLabelsRelation::getKgId, delAnnotation.getKgId()).eq(EntityLabelsRelation::getFileId, delAnnotation.getFileId()).eq(EntityLabelsRelation::getFromId, id).or().eq(EntityLabelsRelation::getToId, id));
-                log.info("***entityLabelsRelations:{}",JSON.toJSONString(entityLabelsRelations));
-                if (!CollectionUtils.isEmpty(entityLabelsRelations)){
+                log.info("entityLabelsRelations:{}", JSON.toJSONString(entityLabelsRelations));
+                if (!CollectionUtils.isEmpty(entityLabelsRelations)) {
                     // 存在关系,先删除关系,在删除实体。
                     for (EntityLabelsRelation entityLabelsRelation : entityLabelsRelations) {
                         int delRes = entityLabelsRelationMapper.deleteById(entityLabelsRelation.getId());
                         delRels.add(delRes);
                     }
-                    if (!delRels.contains(0)){
+                    if (!delRels.contains(0)) {
                         // 删除实体。
                         int delEntitieRes = baseMapper.deleteById(id);
                         delEntities.add(delEntitieRes);
                     }
-                }else {
+                } else {
                     // 不存在关系,直接删除实体。
                     int delEntitieRes = baseMapper.deleteById(id);
                     delEntities.add(delEntitieRes);

+ 2 - 2
src/main/java/com/pavis/backend/slim/project/system/service/impl/GenerateGraphServiceImpl.java

@@ -55,7 +55,7 @@ public class GenerateGraphServiceImpl extends ServiceImpl<GenerateGraphMapper, G
                         graph = toUpExtract(graph, genGraphResult);
                     }
                     int upRes = baseMapper.updateById(graph);
-                    log.info("算法生成知识图谱-:{},更新结果:{}", genGraphResult.getTaskName(), upRes);
+                    log.info("算法生成知识图谱 taskName:{},更新结果 upRes:{}", genGraphResult.getTaskName(), upRes);
                     // 更新图谱的状态:图模型状态 0 无图模型 1 有图模型;是否标注状态 0 未标注  1 已标注;生成图谱的状态 0 未生成 1 已生成。
                     if (graph.getParseTaskStatus() == -1) {
                         sysKgService.updateGrapgStatus(graph.getKgId(), null, null, graph.getParseTaskStatus(), "解析失败");
@@ -79,7 +79,7 @@ public class GenerateGraphServiceImpl extends ServiceImpl<GenerateGraphMapper, G
         generateGraph.setCreateBy(SecurityUtils.getUsername());
         generateGraph.setUpdateBy(SecurityUtils.getUsername());
         int insert = baseMapper.insert(generateGraph);
-        log.info("算法新增生成图谱记录:{}", insert);
+        log.info("算法新增生成图谱记录 insert:{}", insert);
         return insert > 0 ? true : false;
     }
 

+ 68 - 31
src/main/java/com/pavis/backend/slim/project/system/service/impl/SysFileServiceImpl.java

@@ -15,6 +15,7 @@ import com.pavis.backend.slim.common.utils.FileUtils;
 import com.pavis.backend.slim.common.utils.SecurityUtils;
 import com.pavis.backend.slim.framework.minio.MinioStorage;
 import com.pavis.backend.slim.project.system.client.AlgKgClient;
+import com.pavis.backend.slim.project.system.client.AlgKgTestClient;
 import com.pavis.backend.slim.project.system.domain.AnnotationList;
 import com.pavis.backend.slim.project.system.domain.SysFile;
 import com.pavis.backend.slim.project.system.domain.annotation.ConvertAlgRes;
@@ -23,6 +24,7 @@ import com.pavis.backend.slim.project.system.domain.vo.TreeFile;
 import com.pavis.backend.slim.project.system.mapper.AnnotationListMapper;
 import com.pavis.backend.slim.project.system.mapper.SysFileMapper;
 import com.pavis.backend.slim.project.system.service.SysFileService;
+import feign.Request;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -49,6 +51,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 /**
@@ -68,6 +71,9 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
     @Resource
     private AnnotationListMapper annotationListMapper;
 
+    @Autowired
+    private AlgKgTestClient algKgTestClient;
+
     @Override
     public SysFile uploadFile(MultipartFile file) {
         SysFile sysFile = uploadFile(file, "", Constant.DIR_SEP, false);
@@ -134,6 +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);
                 throw new ServiceException("文件流获取失败!");
             }
             // 存储到minio
@@ -299,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<>();
@@ -345,6 +352,25 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
                                 int updateText = baseMapper.updateById(sysFile);
                                 log.info("更新文本内容结果updateText:{}", updateText);
                             }
+                            // 更新标注数据。
+                            List<AnnotationList> annotationLists = annotationListMapper.selectList(new QueryWrapper<AnnotationList>().lambda().eq(AnnotationList::getFileId, algRes.getFileId()));
+                            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())) {
+                            log.info("算法解析txt文本内容出错,无法解析。");
+                            List<AnnotationList> annotationLists = annotationListMapper.selectList(new QueryWrapper<AnnotationList>().lambda().eq(AnnotationList::getFileId, algRes.getFileId()));
+                            if (!CollectionUtils.isEmpty(annotationLists)) {
+                                for (AnnotationList annotationList : annotationLists) {
+                                    annotationList.setParseStatus(-1);
+                                    annotationList.setTextContent("");
+                                    annotationListMapper.updateById(annotationList);
+                                }
+                            }
                         } else {
                             log.info("算法文档转换txt接口 TXT未解析成功:{}", JSON.toJSONString(algRes));
                         }
@@ -362,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()) {
@@ -374,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("暂未使用该文档进行标注,无需更新。");
             }
         }
@@ -405,25 +431,36 @@ 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));
-        String objectKey = "";
-        String identifier = "";
-        if (!CollectionUtils.isEmpty(sysFiles)){
-            objectKey = sysFiles.get(0).getObjectKey();
-            identifier = sysFiles.get(0).getIdentifier();
-        }
-        List<ConvertDocToTxt> convertDocToTxts = new ArrayList<>();
-        convertDocToTxts.add(ConvertDocToTxt.builder().fileId(fileId).objectKey(objectKey).identifier(identifier).isNew(false).build());
-        if (!CollectionUtils.isEmpty(convertDocToTxts)) {
-            Map<String, Object> algMap = new HashMap<>();
-            algMap.put("files", convertDocToTxts);
-            try {
-                // 调用算法,获取文档转换为txt的文本内容。
-                String convertToTxtResTmp = algKgClient.convertToTxt(JSON.toJSONString(algMap));
-                dealAlgTxtRes(convertToTxtResTmp);
-            }catch (Exception ex){
-                ex.printStackTrace();
-                log.info("手动调用算法获取txt文本内容返回结果 ex:{}",ex);
-                return false;
+        if (!CollectionUtils.isEmpty(sysFiles) && null == sysFiles.get(0).getTextContent()) {
+            String objectKey = "";
+            String identifier = "";
+            if (!CollectionUtils.isEmpty(sysFiles)) {
+                objectKey = sysFiles.get(0).getObjectKey();
+                identifier = sysFiles.get(0).getIdentifier();
+            }
+            List<ConvertDocToTxt> convertDocToTxts = new ArrayList<>();
+            // convertDocToTxts.add(ConvertDocToTxt.builder().fileId(fileId).objectKey(objectKey).identifier(identifier).isNew(false).build());
+            convertDocToTxts.add(ConvertDocToTxt.builder().fileId(fileId).objectKey(objectKey).identifier(identifier).isNew(true).build());
+            if (!CollectionUtils.isEmpty(convertDocToTxts)) {
+                Map<String, Object> algMap = new HashMap<>();
+                algMap.put("files", convertDocToTxts);
+                log.info("实时请求算法获取txt内容入参 convertDocToTxts:{}", JSON.toJSONString(algMap));
+                try {
+                    // 调用算法,获取文档转换为txt的文本内容。
+                    // String convertToTxtResTmp = algKgClient.convertToTxt(JSON.toJSONString(algMap));
+                    // Thread.sleep(20000);
+                    // log.info("实时请求算法获取解析结果 convertToTxtResTmp:{}",convertToTxtResTmp);
+                    // 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);
+                    dealAlgTxtRes(convertToTxtResTmp);
+                } catch (Exception ex) {
+                    ex.printStackTrace();
+                    log.info("手动调用算法获取txt文本内容返回结果 ex:{}", ex);
+                    return false;
+                }
             }
         }
         return true;

+ 1 - 0
src/main/java/com/pavis/backend/slim/project/system/service/impl/SysKbServiceImpl.java

@@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StreamUtils;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.ByteArrayOutputStream;

+ 50 - 7
src/main/java/com/pavis/backend/slim/project/system/service/impl/SysKgServiceImpl.java

@@ -26,6 +26,8 @@ import com.pavis.backend.slim.project.system.domain.SysKgEntity;
 import com.pavis.backend.slim.project.system.domain.SysKgRelation;
 import com.pavis.backend.slim.project.system.domain.SysRelation;
 import com.pavis.backend.slim.project.system.domain.algorithm.AlgSpO;
+import com.pavis.backend.slim.project.system.domain.annotation.CreateEntityKg;
+import com.pavis.backend.slim.project.system.domain.annotation.EntityColor;
 import com.pavis.backend.slim.project.system.domain.annotation.ExportSchemaData;
 import com.pavis.backend.slim.project.system.domain.annotation.ExportSysEntity;
 import com.pavis.backend.slim.project.system.domain.front.ClutterReturn;
@@ -45,6 +47,7 @@ import com.pavis.backend.slim.project.system.mapper.SysKgEntityMapper;
 import com.pavis.backend.slim.project.system.mapper.SysKgMapper;
 import com.pavis.backend.slim.project.system.mapper.SysKgRelationMapper;
 import com.pavis.backend.slim.project.system.mapper.SysRelationMapper;
+import com.pavis.backend.slim.project.system.service.AnnotationListService;
 import com.pavis.backend.slim.project.system.service.SysEntityService;
 import com.pavis.backend.slim.project.system.service.SysFileService;
 import com.pavis.backend.slim.project.system.service.SysKgService;
@@ -112,12 +115,15 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
 
     @Autowired
     private SysEntityAllMapper sysEntityAllMapper;
-    @Value("${algorithm.creat.url}")
+    @Value("${algorithm.create.url}")
     private String url;
 
     @Value("${pavis.profile}")
     private String filePath;
 
+    @Autowired
+    private AnnotationListService annotationListService;
+
     @Override
     public SysKg create(SysKg kg) {
         kg.setCreateBy(SecurityUtils.getUsername());
@@ -201,7 +207,7 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
     }
 
     @Override
-    public void algorithm(AlgSpO algSpO) {
+    public Boolean algorithm(AlgSpO algSpO) {
         log.info("算法传参map:{}", JSON.toJSONString(algSpO));
         // 二次更新时,先删除抽出来的数据,然后在进行保存
         sysEntityInstanceMapper.delete(new QueryWrapper<SysEntityInstance>()
@@ -216,6 +222,7 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
         String oCopy = "";
         String sCopy = "";
         if (integer == 0) {
+            List<Integer> upLists = new ArrayList<>();
             for (Map map : algSpO.getSpo()) {
                 if (map.get("s") != null) {
                     // check库里是否存在此值
@@ -234,7 +241,8 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
                         sysEntityInstanceS.setEntityName((String) map.get("sType"));
                         // 区别(0算法抽取,1手动添加)
                         sysEntityInstanceS.setDifference(Hodgepodge.DIFFERENCE_EXTRACT);
-                        sysEntityInstanceMapper.insert(sysEntityInstanceS);
+                        int insertRes = sysEntityInstanceMapper.insert(sysEntityInstanceS);
+                        upLists.add(insertRes);
                         sCopy = MD5.create().digestHex16((String) map.get("s"));
                     } else {
                         sCopy = s;
@@ -255,7 +263,8 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
                         sysEntityInstanceO.setEntityName((String) map.get("oType"));
                         // 区别(0算法抽取,1手动添加)
                         sysEntityInstanceO.setDifference(Hodgepodge.DIFFERENCE_EXTRACT);
-                        sysEntityInstanceMapper.insert(sysEntityInstanceO);
+                        int insertRes = sysEntityInstanceMapper.insert(sysEntityInstanceO);
+                        upLists.add(insertRes);
                         oCopy = MD5.create().digestHex16((String) map.get("o"));
                     } else {
                         oCopy = o;
@@ -283,11 +292,15 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
                         sysEntityRelation.setCreateTime(DateUtil.date());
                         // 区别(0算法抽取,1手动添加)
                         sysEntityRelation.setDifference(Hodgepodge.DIFFERENCE_EXTRACT);
-                        sysEntityRelationMapper.insert(sysEntityRelation);
+                        int insertRes = sysEntityRelationMapper.insert(sysEntityRelation);
+                        upLists.add(insertRes);
                     }
                 }
             }
+            log.info("后端存储算法图数据 upLists:{}",JSON.toJSONString(upLists));
+            return upLists.contains(0) ? false : true;
         }
+        return false;
     }
 
     /**
@@ -422,7 +435,7 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
     }
 
     @Override
-    public SysEntityAll createEntityKg(SysEntity sysEntityAll) {
+    public SysEntityAll createEntityKg(CreateEntityKg sysEntityAll) {
         log.info("*********接口(createEntityKg)------>入参(sysEntityAll):{}", JSON.toJSONString(sysEntityAll));
 
         // zez 根据前端传参先进行删除需要删除的关系和实体
@@ -435,6 +448,36 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
         List<Map> relationAlList = JSON.parseObject(sysEntityAll.getRelationAll(), List.class);
         // zez 对实体实例进行更新和保存
         this.relationInsOrUpd(relationAlList, sysEntityAll);
+        // 处理前端标注数据的颜色随实体颜色的变化而更新值。
+        if (null != sysEntityAll && null != sysEntityAll.getRemark() && StringUtils.isNotEmpty(sysEntityAll.getRemark()) && CommonUtils.isJsonArray(sysEntityAll.getRemark())) {
+            List<EntityColor> entityColors = JSONArray.parseArray(sysEntityAll.getRemark(), EntityColor.class);
+            log.info("实体颜色发生变化,需要处理 entityColors:{}", JSON.toJSONString(entityColors));
+            if (!CollectionUtils.isEmpty(entityColors)) {
+                for (EntityColor entityColor : entityColors) {
+                    SysEntity sysEntity = sysEntityMapper.selectById(entityColor.getEntityId());
+                    if (null != sysEntity) {
+                        // 颜色发生变化,则更新标注的数据中的颜色,。
+                        // entityColor.setUpName(sysEntity.getName());
+                        annotationListService.upTextFrontByColor(sysEntityAll.getKgId(), entityColor);
+                    }
+                }
+            }
+        }
+        // 处理前端标注数据的实体名称随实体名称的更新而更新值。
+        if (null != sysEntityAll && null != sysEntityAll.getUpName() && StringUtils.isNotEmpty(sysEntityAll.getUpName()) && CommonUtils.isJsonArray(sysEntityAll.getUpName())) {
+            List<EntityColor> entityColors = JSONArray.parseArray(sysEntityAll.getUpName(), EntityColor.class);
+            log.info("实体名称发生变化,需要处理 entityColors:{}", JSON.toJSONString(entityColors));
+            if (!CollectionUtils.isEmpty(entityColors)) {
+                for (EntityColor entityColor : entityColors) {
+                    SysEntity sysEntity = sysEntityMapper.selectById(entityColor.getEntityId());
+                    if (null != sysEntity) {
+                        // 颜色发生变化,则更新标注的数据中的颜色,。
+                        // entityColor.setUpName(sysEntity.getName());
+                        annotationListService.upTextFrontByColor(sysEntityAll.getKgId(), entityColor);
+                    }
+                }
+            }
+        }
         return null;
     }
 
@@ -793,7 +836,7 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
         }
 
         if (null != sysEntityAll) {
-            SysEntity sysEntity = new SysEntity();
+            CreateEntityKg sysEntity = new CreateEntityKg();
             BeanUtils.copyProperties(sysEntityAll, sysEntity);
             // // 处理前端存储的实体和关系数据。
             ExportSysEntity exportSysEntity = new ExportSysEntity();

+ 5 - 1
src/main/resources/application-ghj.yml

@@ -74,10 +74,12 @@ feign:
     max-connections: 200
     # 每个路径的最大连接数
     max-connections-per-route: 50
+    ok-http:
+      read-timeout: 30000
 
 #调用算法接口
 algorithm:
-  creat:
+  create:
     # 将所需要生成图谱的文件,传给算法的接口
     url: http://192.168.1.150:8900/data_access
     # 文档转换为txt文本内容接口。
@@ -87,6 +89,8 @@ algorithm:
     # 通用图谱调用算法接口。即未创建实体和关系。
   universalGraph:
     url: http://192.168.1.127:8068
+  test:
+    url: http://192.168.1.202:19003
 #PageHelper 分页插件配置
 pagehelper:
   helperDialect: mysql

+ 2 - 2
src/main/resources/application.yml

@@ -1,7 +1,7 @@
 spring:
   profiles:
-#    active: ghj
-    active: local
+    active: ghj
+#    active: local
   # 国际化资源文件路径
   messages:
     basename: i18n/messages