Browse Source

修改同算法对接实时获取txt文本内容的接口

guanz 1 year ago
parent
commit
d9d9ad34a9
20 changed files with 149 additions and 150 deletions
  1. 41 12
      src/main/java/com/pavis/backend/slim/common/utils/CommonUtils.java
  2. 16 11
      src/main/java/com/pavis/backend/slim/project/system/client/AlgKgClient.java
  3. 4 3
      src/main/java/com/pavis/backend/slim/project/system/client/AlgKgTestClient.java
  4. 7 51
      src/main/java/com/pavis/backend/slim/project/system/controller/AnnotationController.java
  5. 1 1
      src/main/java/com/pavis/backend/slim/project/system/controller/EditorController.java
  6. 3 3
      src/main/java/com/pavis/backend/slim/project/system/controller/SysFileController.java
  7. 6 5
      src/main/java/com/pavis/backend/slim/project/system/controller/SysKgController.java
  8. 2 2
      src/main/java/com/pavis/backend/slim/project/system/domain/annotation/AnnotationEntityRelation.java
  9. 1 1
      src/main/java/com/pavis/backend/slim/project/system/domain/annotation/AnnotationListParam.java
  10. 2 0
      src/main/java/com/pavis/backend/slim/project/system/domain/annotation/EntityColor.java
  11. 1 1
      src/main/java/com/pavis/backend/slim/project/system/domain/annotation/SchemaImport.java
  12. 1 1
      src/main/java/com/pavis/backend/slim/project/system/domain/annotation/ToAnnotation.java
  13. 1 0
      src/main/java/com/pavis/backend/slim/project/system/service/AnnotationListService.java
  14. 6 5
      src/main/java/com/pavis/backend/slim/project/system/service/impl/AnnotationListServiceImpl.java
  15. 2 3
      src/main/java/com/pavis/backend/slim/project/system/service/impl/EntityLabelsRelationServiceImpl.java
  16. 13 13
      src/main/java/com/pavis/backend/slim/project/system/service/impl/EntityLabelsSpanServiceImpl.java
  17. 2 2
      src/main/java/com/pavis/backend/slim/project/system/service/impl/GenerateGraphServiceImpl.java
  18. 24 24
      src/main/java/com/pavis/backend/slim/project/system/service/impl/SysFileServiceImpl.java
  19. 1 0
      src/main/java/com/pavis/backend/slim/project/system/service/impl/SysKbServiceImpl.java
  20. 15 12
      src/main/java/com/pavis/backend/slim/project/system/service/impl/SysKgServiceImpl.java

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

@@ -124,24 +124,53 @@ public class CommonUtils {
      * @param colorStr
      * @return
      */
-    public static String dealTextFrontWithColor(String textFront, String entityName,String colorStr) {
+    public static String dealTextFrontWithColor(String textFront, String entityName,String colorStr,String nameStr) {
         String regex = "<span[^>]*data-before=\"" + entityName + "\"[^>]*>([^<]+)<\\/span>";
-        System.err.println("regex:" + regex);
+        log.info("regex:{}", regex);
         Pattern pattern = Pattern.compile(regex);
         Matcher matcher = pattern.matcher(textFront);
-        StringBuffer sb = new StringBuffer();
+        StringBuffer upTextFront = new StringBuffer();
         while (matcher.find()) {
             String matched = matcher.group(1);
-            System.err.println("matched****:" + matched);
-            String replaced = matcher.group(0).replaceAll("--color:#[0-9a-fA-F]{6}", "--color:" + colorStr);
-            System.err.println("*replaced---*:" + replaced);
-            // matcher.appendReplacement(sb, "<span" + matcher.group(0) F+ ">" + replaced + "</span>");
-            matcher.appendReplacement(sb, replaced);
-            System.err.println("*<>*:" + matcher.group(0));
+            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(sb);
-        System.out.println(sb.toString());
-        return sb.toString();
+        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();
+    }
 }

+ 16 - 11
src/main/java/com/pavis/backend/slim/project/system/client/AlgKgClient.java

@@ -24,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
      */
@@ -41,6 +41,7 @@ public interface AlgKgClient {
      * todo 调用此算法服务获取taskId。
      * 入参:{kgId、fielIds:[]、taskType[true 通用;false 标注。]}
      * 出参:{"taskId":""}
+     *
      * @param universalGgraphToAlg
      * @return
      */
@@ -52,6 +53,7 @@ public interface AlgKgClient {
      * todo 调用此算法服务获取taskId。
      * 入参:{kgId、entityList:实体属性、relationList:关系属性。}
      * 出参:ok。
+     *
      * @param schemaImport
      * @return
      */
@@ -60,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);
 
     /**
@@ -77,40 +79,43 @@ 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")
+            consumes = "application/json")
     String convertToTxtByRealTime(String data, Request.Options options);
 
     /**

+ 4 - 3
src/main/java/com/pavis/backend/slim/project/system/client/AlgKgTestClient.java

@@ -17,13 +17,14 @@ public interface AlgKgTestClient {
 
     /**
      * 发送文档需转换为txt的数据给算法服务。
-     *  入参:{"files":[{"fileId":"","objectKey":"","identifier":""}]}
-     *  出参:无需关注。
+     * 入参:{"files":[{"fileId":"","objectKey":"","identifier":""}]}
+     * 出参:无需关注。
+     *
      * @param data
      * @return
      */
     @PostMapping(value = "/testapi", produces = {MediaType.APPLICATION_JSON_VALUE},
-            consumes="application/json")
+            consumes = "application/json")
     String testConvertToTxt(String data, Request.Options options);
 
 

+ 7 - 51
src/main/java/com/pavis/backend/slim/project/system/controller/AnnotationController.java

@@ -1,7 +1,6 @@
 package com.pavis.backend.slim.project.system.controller;
 
 import com.alibaba.fastjson2.JSON;
-import com.pavis.backend.slim.common.utils.CommonUtils;
 import com.pavis.backend.slim.framework.web.domain.AjaxResult;
 import com.pavis.backend.slim.project.system.domain.annotation.AnnotationEntity;
 import com.pavis.backend.slim.project.system.domain.annotation.AnnotationEntityRelation;
@@ -133,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));
     }
 
@@ -147,7 +146,7 @@ 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));
     }
 
@@ -198,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, "参数不能为空");
@@ -209,7 +208,7 @@ public class AnnotationController {
     public AjaxResult generateKgGraphResult(@RequestBody GenerateGraphResult 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("算法通知后端更新生成图谱结果成功");
         }
@@ -224,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);
     }
 
@@ -235,7 +234,7 @@ 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());
+        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));
@@ -247,8 +246,6 @@ public class AnnotationController {
         }
     }
 
-    // 停止生成图谱。
-
     /**
      * 前端传入知识库id,后端调用算法停止生成图谱。
      * 后端请求算法--->入参taskId。
@@ -260,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, "参数不能为空");
@@ -288,47 +285,6 @@ public class AnnotationController {
         return AjaxResult.error(1001, "参数不能为空");
     }
 
-    public static void main(String[] args) {
-        // String str = "2021年11月,获得2021年休斯敦世界乒乓球锦标赛女单冠军、女双冠军。&nbsp;[113]2022年12月,获得2022赛季乒超联赛女团冠军。&nbsp;[219]2023年4月,获得2023年WTT冠军赛澳门站<span class=\"entityhig\" style=\"border-bottom: 8px #E73B28 solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#E73B28\" data-before=\"荣誉\" id=\"10\">女单冠军</span>&nbsp;[232];9月,获得亚洲乒乓球锦标赛女单、女双冠军&nbsp;[251]&nbsp;[254]&nbsp;[264];9月26日,王曼昱帮助中国队获得杭州第19届亚运会乒乓球女子团体冠军。";
-        //
-        // Pattern pattern = Pattern.compile("<span class=\"entityhig\"(.*?)--color:(.*?)(?=;)");
-        // Matcher matcher = pattern.matcher(str);
-        //
-        // StringBuffer sb = new StringBuffer();
-        // while (matcher.find()) {
-        //     String replacement = "<span class=\"entityhig\"" + matcher.group(1) + "--color:#ffffff";
-        //     matcher.appendReplacement(sb, replacement);
-        // }
-        // matcher.appendTail(sb);
-        //
-        // String modifiedStr = sb.toString();
-        // System.out.println(modifiedStr);
-
-
-        String str = "<span class=\"entityhig\" style=\"border-bottom: 8px var(--color) solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#448DFF\" data-before=\"运动员\" id=\"59\">王曼昱</span> 身高176cm 生于1999年02月09日 出生地<span class=\"entityhig\" style=\"border-bottom: 8px var(--color) solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#E62BCA\" data-before=\"出生地\" id=\"60\">黑龙江省齐齐哈尔</span>。2008年入选<span class=\"entityhig\" style=\"border-bottom: 8px var(--color) solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#BF11D6\" data-before=\"队伍\" id=\"61\">黑龙江省集训队</span>,2013年进入<span class=\"entityhig\" style=\"border-bottom: 8px var(--color) solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#BF11D6\" data-before=\"队伍\" id=\"62\">国家青年队</span>。2016年进入<span class=\"entityhig\" style=\"border-bottom: 8px var(--color) solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#BF11D6\" data-before=\"队伍\" id=\"63\">国家一队</span>。2021年,获得<span class=\"entityhig\" style=\"border-bottom: 8px var(--color) solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#1DEB19\" data-before=\"比赛\" id=\"64\">2021赛季中国乒乓球俱乐部超级联赛</span><span class=\"entityhig\" style=\"border-bottom: 8px var(--color) solid; --data-wih:translate(0px,30px);line-height: 30px;--color:#E73B28\" data-before=\"荣誉\" id=\"65\">女团冠军</span>。\n";
-
-        // // Pattern pattern = Pattern.compile("<span class=\"entityhig\"(.*?)--color:(.*?)(?=;)(.*?)");
-        // Pattern pattern = Pattern.compile("<span class=\"entityhig\"(.*?)--color:(.*?)(?=;)(.*?data-before=\"运动员\".*?)(.*?)>");
-        // // Pattern pattern = Pattern.compile("<span class=\"entityhig\"(.*?)--color:(.*?)(?=;)");
-        // Matcher matcher = pattern.matcher(str);
-        //
-        // StringBuffer sb = new StringBuffer();
-        // while (matcher.find()) {
-        //     String replacement = "<span class=\"entityhig\"" + matcher.group(1) + "--color:#ffffff";
-        //     matcher.appendReplacement(sb, replacement);
-        // }
-        // matcher.appendTail(sb);
-
-        // String modifiedStr = str.toString();
-        // System.out.println(modifiedStr);
-
-        String regex = "<span[^>]*data-before=\"队伍\"[^>]*>([^<]+)<\\/span>";
-        CommonUtils.dealTextFrontWithColor(str,"队伍","#f28500");
-
-    }
-
-
-
     // 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();
     }
 

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

@@ -196,35 +196,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;

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

@@ -25,4 +25,6 @@ public class EntityColor {
     private String name;
     @ApiModelProperty("实体颜色")
     private String color;
+    @ApiModelProperty("实体名称变更后的值")
+    private String upName;
 }

+ 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;

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

@@ -61,6 +61,7 @@ public interface AnnotationListService extends IService<AnnotationList> {
 
     /**
      * 根据图谱和文档id更新标注数据的textFront值。
+     *
      * @param kgId
      * @param entityColor
      * @return

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

@@ -108,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 {
@@ -170,13 +170,14 @@ public class AnnotationListServiceImpl extends ServiceImpl<AnnotationListMapper,
     @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)){
+        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());
+                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("实体颜色变更后,更新textFront结果 upRes:{},colorAfter:{}",upRes,entityColor.getColor());
+                    log.info("实体颜色变更后,更新textFront结果 upRes:{},colorAfter:{}", upRes, entityColor.getColor());
                 }
             }
         }

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

@@ -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)) {

+ 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;
     }
 

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

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

+ 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;

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

@@ -194,7 +194,7 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
 
     @Override
     public PageInfo list(FileKey kgKey) {
-        log.info("******接口(list)--->入参(kg):{}",JSON.toJSONString(kgKey));
+        log.info("******接口(list)--->入参(kg):{}", JSON.toJSONString(kgKey));
         PageHelper.startPage(kgKey.getPageNum(), kgKey.getPageSize());
         List<SysKg> sysKgs = baseMapper.selectList(new QueryWrapper<SysKg>()
                 .eq("user_id", SecurityUtils.getUserId())
@@ -263,7 +263,7 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
                             .eq("start_id", sCopy)
                             .eq("end_id", oCopy)
                     );
-                    if (list.size() == Hodgepodge.NUMBER) { 
+                    if (list.size() == Hodgepodge.NUMBER) {
                         // 插入实例关系
                         SysEntityRelation sysEntityRelation = new SysEntityRelation();
                         sysEntityRelation.setKgId(algSpO.getKgId());
@@ -429,14 +429,16 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
         // zez 对实体实例进行更新和保存
         this.relationInsOrUpd(relationAlList, sysEntityAll);
         // 处理前端标注数据的颜色随实体颜色的变化而更新值。
-        if (null != sysEntityAll && null != sysEntityAll.getRemark() && StringUtils.isNotEmpty(sysEntityAll.getRemark()) && CommonUtils.isJsonArray(sysEntityAll.getRemark())){
+        if (null != sysEntityAll && null != sysEntityAll.getRemark() && StringUtils.isNotEmpty(sysEntityAll.getRemark()) && CommonUtils.isJsonArray(sysEntityAll.getRemark())) {
             List<EntityColor> entityColors = JSONArray.parseArray(sysEntityAll.getRemark(), EntityColor.class);
-            if (!CollectionUtils.isEmpty(entityColors)){
+            log.info("实体颜色发生变化,需要处理 entityColors:{}", JSON.toJSONString(entityColors));
+            if (!CollectionUtils.isEmpty(entityColors)) {
                 for (EntityColor entityColor : entityColors) {
                     SysEntity sysEntity = sysEntityMapper.selectById(entityColor.getEntityId());
-                    if (null != sysEntity && !sysEntity.getColor().equals(entityColor.getColor())){
+                    if (null != sysEntity) {
                         // 颜色发生变化,则更新标注的数据中的颜色,。
-                        annotationListService.upTextFrontByColor(sysEntityAll.getKgId(),entityColor);
+                        entityColor.setUpName(sysEntity.getName());
+                        annotationListService.upTextFrontByColor(sysEntityAll.getKgId(), entityColor);
                     }
                 }
             }
@@ -755,9 +757,9 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
         SysEntityAll sysEntityAll = selEntityAll(exportSchemaData.getKgId());
         sysEntityAll.setKgId(exportSchemaData.getKgId());
         log.info("待导出的图谱schema数据 sysEntityAll:{}", JSON.toJSONString(sysEntityAll));
-        if (null != sysEntityAll){
+        if (null != sysEntityAll) {
             ExportSysEntity exportSysEntity = new ExportSysEntity();
-            BeanUtils.copyProperties(sysEntityAll,exportSysEntity);
+            BeanUtils.copyProperties(sysEntityAll, exportSysEntity);
             exportSysEntity.setEntityAll(CommonUtils.dealEntityId(JSONArray.parseArray(sysEntityAll.getEntityAll())));
             exportSysEntity.setEntityKgAll(JSONArray.parseArray(sysEntityAll.getEntityKgAll()));
             exportSysEntity.setRelationAll(CommonUtils.dealRelationId(JSONArray.parseArray(sysEntityAll.getRelationAll())));
@@ -794,7 +796,7 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
             BeanUtils.copyProperties(sysEntityAll, sysEntity);
             // // 处理前端存储的实体和关系数据。
             ExportSysEntity exportSysEntity = new ExportSysEntity();
-            BeanUtils.copyProperties(sysEntityAll,exportSysEntity);
+            BeanUtils.copyProperties(sysEntityAll, exportSysEntity);
             exportSysEntity.setEntityAll(JSONArray.parseArray(sysEntityAll.getEntityAll()));
             exportSysEntity.setEntityKgAll(JSONArray.parseArray(sysEntityAll.getEntityKgAll()));
             exportSysEntity.setRelationAll(JSONArray.parseArray(sysEntityAll.getRelationAll()));
@@ -806,7 +808,7 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
             sysEntity.setUserId(SecurityUtils.getUserId());
             sysEntity.setCreateTime(DateUtil.date());
             sysEntity.setEntityId("-1");
-            log.info("待导入schema的kgId:{}",kgId);
+            log.info("待导入schema的kgId:{}", kgId);
             log.info("待导入的图谱shcema数据 sysEntity:{}", JSON.toJSONString(sysEntity));
             SysEntityAll entityKg = createEntityKg(sysEntity);
             // int insert = sysEntityMapper.insert(sysEntity);
@@ -819,6 +821,7 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
         }
         return null;
     }
+
     @Override
     public SysEntityInstance insOrUpdEnIce(SysEntityInstance sysEntityInstance) {
         log.info("******接口(insOrUpdEnIce)--->入参(sysEntityInstance):{}", JSON.toJSONString(sysEntityInstance));
@@ -910,8 +913,8 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
         List<SysEntityRelation> sysEntityRelations = sysEntityRelationMapper.selectList(new QueryWrapper<SysEntityRelation>()
                 .eq("start", sysEntityRelation.getStart())
                 .eq("end", sysEntityRelation.getEnd())
-                .eq("relation",sysEntityRelation.getRelation())
-                .eq("kg_id",sysEntityRelation.getKgId())
+                .eq("relation", sysEntityRelation.getRelation())
+                .eq("kg_id", sysEntityRelation.getKgId())
         );
         if (sysEntityRelations.size() == 0) {
             if (sysEntityRelation.getId() != null && !"".equals(sysEntityRelation.getId())) {