ソースを参照

图模型保存接口增加逻辑,如果实体的颜色变化则同步修改已标注数据的实体的颜色,写正则表达式进行匹配后进行颜色的替换;新增实时调用算法获取解析txt内容接口

guanz 1 年間 前
コミット
a6be4bc231

+ 39 - 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,31 @@ public class CommonUtils {
         return jsonArray;
     }
 
+    /**
+     * 处理前端标注数据的颜色。
+     * @param textFront
+     * @param entityName
+     * @param colorStr
+     * @return
+     */
+    public static String dealTextFrontWithColor(String textFront, String entityName,String colorStr) {
+        String regex = "<span[^>]*data-before=\"" + entityName + "\"[^>]*>([^<]+)<\\/span>";
+        System.err.println("regex:" + regex);
+        Pattern pattern = Pattern.compile(regex);
+        Matcher matcher = pattern.matcher(textFront);
+        StringBuffer sb = 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));
+        }
+        matcher.appendTail(sb);
+        System.out.println(sb.toString());
+        return sb.toString();
+    }
+
 }

+ 4 - 0
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;
@@ -108,6 +109,9 @@ public interface AlgKgClient {
     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 通用知识图谱构建,即图谱下无实体、关系数据。-----> 暂未对接。

+ 66 - 23
src/main/java/com/pavis/backend/slim/project/system/controller/AnnotationController.java

@@ -1,6 +1,7 @@
 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;
@@ -72,7 +73,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("删除标注数据列表接口")
@@ -87,7 +88,7 @@ public class AnnotationController {
                 return AjaxResult.error("删除标注数据列表失败", delRes);
             }
         }
-        return AjaxResult.error(1001,"参数不能为空");
+        return AjaxResult.error(1001, "参数不能为空");
     }
 
     @ApiOperation("数据集导入之知识库文档导入接口")
@@ -102,7 +103,7 @@ public class AnnotationController {
                 return AjaxResult.error("数据集导入失败", saveRes);
             }
         }
-        return AjaxResult.error(1001,"参数不能为空");
+        return AjaxResult.error(1001, "参数不能为空");
     }
 
     @ApiOperation("数据集导入之本地文件导入接口")
@@ -111,14 +112,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, "参数不能为空");
         }
     }
 
@@ -153,6 +154,7 @@ public class AnnotationController {
     /**
      * 文档标注实体数据删除接口,传主键ID。
      * 文档标注实体间关系数据删除接口,传主键ID。
+     *
      * @param delAnnotation
      * @return
      */
@@ -169,7 +171,7 @@ 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, "参数不能为空");
     }
 
 
@@ -205,7 +207,7 @@ 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());
             generateGraphService.generateKgGraphResult(genGraphResult);
@@ -222,7 +224,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);
     }
 
@@ -233,19 +235,20 @@ 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。
@@ -266,7 +269,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);
@@ -277,14 +280,54 @@ 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("算法通知后端更新文本内容成功",sysFileService.handsToParseTxt(kgId,fileId));
+            return AjaxResult.success("算法通知后端更新文本内容成功", sysFileService.handsToParseTxt(kgId, fileId));
         }
         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 ----------------------------以下接口均为模拟算法测试接口,后续可删除下列接口------------------------------------。
 

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

@@ -0,0 +1,28 @@
+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;
+}

+ 9 - 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,12 @@ public interface AnnotationListService extends IService<AnnotationList> {
      * @return
      */
     Boolean saveAnnotation(AnnotationFront annotationFront);
+
+    /**
+     * 根据图谱和文档id更新标注数据的textFront值。
+     * @param kgId
+     * @param entityColor
+     * @return
+     */
+    void upTextFrontByColor(String kgId, EntityColor entityColor);
 }

+ 16 - 0
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;
@@ -166,6 +167,21 @@ 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());
+                    annotationList.setTextFront(upTextFront);
+                    int upRes = baseMapper.updateById(annotationList);
+                    log.info("实体颜色变更后,更新textFront结果 upRes:{},colorAfter:{}",upRes,entityColor.getColor());
+                }
+            }
+        }
+    }
+
     /**
      * 调用算法实时获取txt文本内容。
      *

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

@@ -453,7 +453,7 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFile> impl
                     // dealAlgTxtRes(convertToTxtResTmp);
 
                     // todo ghjghj 需要和志超对接 实时调用算法获取解析得txt文本内容,。
-                    String convertToTxtResTmp = algKgTestClient.testConvertToTxt(JSON.toJSONString(algMap),new Request.Options(30, TimeUnit.SECONDS, 30, TimeUnit.SECONDS, true));
+                    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){

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

@@ -26,6 +26,7 @@ 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.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 +46,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;
@@ -118,6 +120,9 @@ public class SysKgServiceImpl extends ServiceImpl<SysKgMapper, SysKg> implements
     @Value("${pavis.profile}")
     private String filePath;
 
+    @Autowired
+    private AnnotationListService annotationListService;
+
     @Override
     public SysKg create(SysKg kg) {
         kg.setCreateBy(SecurityUtils.getUsername());
@@ -423,6 +428,19 @@ 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);
+            if (!CollectionUtils.isEmpty(entityColors)){
+                for (EntityColor entityColor : entityColors) {
+                    SysEntity sysEntity = sysEntityMapper.selectById(entityColor.getEntityId());
+                    if (null != sysEntity && !sysEntity.getColor().equals(entityColor.getColor())){
+                        // 颜色发生变化,则更新标注的数据中的颜色,。
+                        annotationListService.upTextFrontByColor(sysEntityAll.getKgId(),entityColor);
+                    }
+                }
+            }
+        }
         return null;
     }