allen před 2 roky
rodič
revize
9fc9da2b62

+ 1 - 1
kgraph-admin/src/main/resources/application.yml

@@ -9,7 +9,7 @@ kgraph:
   # 实例演示开关
   demoEnabled: true
   # 文件路径 示例( Windows配置D:/kgraph/uploadPath,Linux配置 /home/kgraph/uploadPath)
-  profile: /home/kgraph/uploadPath
+  profile: C:/kgraph/uploadPath
   # 获取ip地址开关
   addressEnabled: false
   # 验证码类型 math 数组计算 char 字符验证

+ 26 - 0
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/VO/EntityVO.java

@@ -0,0 +1,26 @@
+package com.kgraph.graph.neo4j.VO;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@Data
+@AllArgsConstructor
+public class EntityVO {
+    private Long id;
+    private String name;
+    private String content;
+    private String attachmentUrl;
+    public Long getEntId(){
+        return id;
+    }
+    public Long getEntClsID(){
+        return id;
+    }
+    public String getLabel(){
+        return name;
+    }
+    public String getEntName(){
+        return name;
+    }
+
+}

+ 15 - 0
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/VO/GraphVO.java

@@ -0,0 +1,15 @@
+package com.kgraph.graph.neo4j.VO;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author allen
+ */
+@Data
+public class GraphVO {
+    List<EntityVO> data = new ArrayList<>(0);
+    List<RelationVO> links = new ArrayList<>(0);
+}

+ 20 - 0
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/VO/RelationVO.java

@@ -0,0 +1,20 @@
+package com.kgraph.graph.neo4j.VO;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+@Data
+@AllArgsConstructor
+public class RelationVO {
+    private Long id;
+    private String name;
+    private String content;
+    private Long from;
+    private Long to;
+    public Long getRelID(){
+        return id;
+    }
+    public String getRelClsName(){
+        return name;
+    }
+}

+ 26 - 4
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/controller/KgController.java

@@ -3,7 +3,9 @@ package com.kgraph.graph.neo4j.controller;
 import com.kgraph.common.core.controller.BaseController;
 import com.kgraph.common.core.domain.AjaxResult;
 import com.kgraph.graph.neo4j.DTO.KgDTO;
+import com.kgraph.graph.neo4j.VO.GraphVO;
 import com.kgraph.graph.neo4j.seavice.IKgService;
+import com.kgraph.graph.neo4j.uitils.Neo4j2VOUtils;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -18,8 +20,8 @@ public class KgController extends BaseController {
     IKgService kgService;
 
     @PostMapping("/create")
-    public AjaxResult create(@RequestBody List<KgDTO> kgDTOList){
-        if(CollectionUtils.isEmpty(kgDTOList)){
+    public AjaxResult create(@RequestBody List<KgDTO> kgDTOList) {
+        if (CollectionUtils.isEmpty(kgDTOList)) {
             return AjaxResult.error("没有数据");
         }
         kgService.create(kgDTOList);
@@ -27,13 +29,33 @@ public class KgController extends BaseController {
     }
 
     @GetMapping("/getAllEntityList")
-    public AjaxResult getAllEntityList(){
+    public AjaxResult getAllEntityList() {
         return AjaxResult.success(kgService.getAllEntityList());
     }
 
     @GetMapping("/getAllRelationList")
-    public AjaxResult getAllRelationList(){
+    public AjaxResult getAllRelationList() {
         return AjaxResult.success(kgService.getAllRelationList());
     }
 
+    @GetMapping("/getRelationByName")
+    public AjaxResult getRelationByName(String firstName, String secondName, int length) {
+        // TODO length 的最大最小值,从数据字典获取
+        if (length < 0 || length > 5) {
+            throw new RuntimeException("步长不能小于0或大于5");
+        }
+        GraphVO graphVO;
+        if (length == 0) {
+            graphVO = Neo4j2VOUtils.relation2GraphVO(kgService.getShortestRelationByName(firstName, secondName));
+        } else {
+            graphVO = Neo4j2VOUtils.relation2GraphVO(kgService.getRelationByName(firstName, secondName, length));
+        }
+        return AjaxResult.success(graphVO);
+    }
+
+    @GetMapping("/getShortestRelationByName")
+    public AjaxResult getShortestRelationByName(String firstName, String secondName) {
+        GraphVO graphVO = Neo4j2VOUtils.relation2GraphVO(kgService.getShortestRelationByName(firstName, secondName));
+        return AjaxResult.success(graphVO);
+    }
 }

+ 16 - 0
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/mapper/EntityRepository.java

@@ -1,7 +1,23 @@
 package com.kgraph.graph.neo4j.mapper;
 
 import com.kgraph.graph.neo4j.domain.Neo4jEntity;
+import org.springframework.data.neo4j.annotation.Query;
 import org.springframework.data.neo4j.repository.Neo4jRepository;
+import org.springframework.data.repository.query.Param;
+
+import java.util.List;
 
 public interface EntityRepository extends Neo4jRepository<Neo4jEntity, Long> {
+    @Query("match data=(e1:Entity{name: $firstName})-[*1..$length]-(e2:Entity{name: $secondName}) return data")
+    List<Neo4jEntity> getRelationByName(@Param("firstName") String firstName, @Param("name2") String secondName, @Param("length") int length);
+
+    @Query("match data=shortestPath((e1:Entity{name: $firstName})-[*]-(e2:Entity{name: $secondName})) return data")
+    List<Neo4jEntity> getShortestRelationByName(@Param("firstName") String firstName, @Param("secondName") String secondName);
+
+    /**
+     * 通过name查找实体
+     * @param name name
+     * @return 实体
+     */
+    Neo4jEntity findByName(String name);
 }

+ 23 - 0
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/mapper/RelationRepository.java

@@ -1,7 +1,30 @@
 package com.kgraph.graph.neo4j.mapper;
 
 import com.kgraph.graph.neo4j.domain.Neo4jRelation;
+import org.springframework.data.neo4j.annotation.Query;
 import org.springframework.data.neo4j.repository.Neo4jRepository;
+import org.springframework.data.repository.query.Param;
+
+import java.util.List;
 
 public interface RelationRepository extends Neo4jRepository<Neo4jRelation, Long> {
+//    TODO 看了很多资料 length这块貌似传参无法解析,要使用CQL拼接的模式,以后再优化
+//    @Query("match data=(e1:Entity{name: $firstName})-[*..{length}]-(e2:Entity{name: $secondName}) return data")
+//    List<Neo4jRelation> getRelationByName(@Param("firstName") String firstName, @Param("secondName") String secondName, @Param("length") Integer length);
+    @Query("match data=(e1:Entity{name: $firstName})-[*..1]-(e2:Entity{name: $secondName}) return data")
+    List<Neo4jRelation> getRelationByNameLength1(@Param("firstName") String firstName, @Param("secondName") String secondName);
+    @Query("match data=(e1:Entity{name: $firstName})-[*..2]-(e2:Entity{name: $secondName}) return data")
+    List<Neo4jRelation> getRelationByNameLength2(@Param("firstName") String firstName, @Param("secondName") String secondName);
+    @Query("match data=(e1:Entity{name: $firstName})-[*..3]-(e2:Entity{name: $secondName}) return data")
+    List<Neo4jRelation> getRelationByNameLength3(@Param("firstName") String firstName, @Param("secondName") String secondName);
+    @Query("match data=(e1:Entity{name: $firstName})-[*..4]-(e2:Entity{name: $secondName}) return data")
+    List<Neo4jRelation> getRelationByNameLength4(@Param("firstName") String firstName, @Param("secondName") String secondName);
+    @Query("match data=(e1:Entity{name: $firstName})-[*..5]-(e2:Entity{name: $secondName}) return data")
+    List<Neo4jRelation> getRelationByNameLength5(@Param("firstName") String firstName, @Param("secondName") String secondName);
+
+    @Query("match data=shortestPath((e1:Entity{name: $firstName})-[*]-(e2:Entity{name: $secondName})) return data")
+    List<Neo4jRelation> getShortestRelationByName(@Param("firstName") String firstName, @Param("secondName") String secondName);
+
+    @Query("MATCH data=(es:Entity)-[r]->(ee:Entity) WHERE id(es)= $startId AND id(ee)= $endId AND r.name = $name RETURN data")
+    Neo4jRelation findRelation(@Param("startId") Long startId, @Param("endId") Long endId, @Param("name") String name);
 }

+ 4 - 0
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/seavice/IKgService.java

@@ -2,6 +2,7 @@ package com.kgraph.graph.neo4j.seavice;
 
 import com.kgraph.graph.neo4j.DTO.KgDTO;
 import com.kgraph.graph.neo4j.DTO.KgDocDTO;
+import com.kgraph.graph.neo4j.domain.Neo4jRelation;
 
 import java.util.List;
 
@@ -12,4 +13,7 @@ public interface IKgService {
 
     Iterable getAllRelationList();
 
+    List<Neo4jRelation> getRelationByName(String firstName, String secondName, int length);
+
+    List<Neo4jRelation> getShortestRelationByName(String firstName, String secondName);
 }

+ 49 - 4
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/seavice/impl/KgServiceImpl.java

@@ -1,7 +1,6 @@
 package com.kgraph.graph.neo4j.seavice.impl;
 
 import com.kgraph.graph.neo4j.DTO.KgDTO;
-import com.kgraph.graph.neo4j.DTO.KgDocDTO;
 import com.kgraph.graph.neo4j.domain.Neo4jEntity;
 import com.kgraph.graph.neo4j.domain.Neo4jRelation;
 import com.kgraph.graph.neo4j.mapper.EntityRepository;
@@ -9,7 +8,6 @@ import com.kgraph.graph.neo4j.mapper.RelationRepository;
 import com.kgraph.graph.neo4j.seavice.IKgService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
 import java.util.stream.Collectors;
@@ -30,13 +28,30 @@ public class KgServiceImpl implements IKgService {
 
         Map<String, Neo4jEntity> entityMap = entityList.stream().collect(Collectors.toMap(Neo4jEntity::getName, Neo4jEntity -> Neo4jEntity));
 
+        for (Neo4jEntity entity : entityMap.values()) {
+            Neo4jEntity newEntity = entityRepository.findByName(entity.getName());
+            if (newEntity != null) {
+                // 如果已经在db中则替换
+                entityMap.put(entity.getName(), newEntity);
+            }
+        }
+
         // build relation
         List<Neo4jRelation> relationList = buildRelation(kgDTOList, entityMap);
-        // save entity
-        // save relation
+        // 剔除已有的关系
+        relationList.removeIf(this::relationExist);
+        // save entity and relation
         relationRepository.saveAll(relationList);
     }
 
+    private boolean relationExist(Neo4jRelation relation) {
+        if(relation.getStartNode().getId() != null || relation.getEndNode().getId() != null){
+            Neo4jRelation relationDb = relationRepository.findRelation(relation.getStartNode().getId(), relation.getEndNode().getId(), relation.getName());
+            return relationDb != null;
+        }
+        return false;
+    }
+
     @Override
     public Iterable getAllEntityList() {
         return entityRepository.findAll();
@@ -73,4 +88,34 @@ public class KgServiceImpl implements IKgService {
         }
         return relationList;
     }
+
+    @Override
+    public List<Neo4jRelation> getRelationByName(String firstName, String secondName, int length) {
+        List<Neo4jRelation> relationList;
+        switch (length) {
+            case 1:
+                relationList = relationRepository.getRelationByNameLength1(firstName, secondName);
+                break;
+            case 2:
+                relationList = relationRepository.getRelationByNameLength2(firstName, secondName);
+                break;
+            case 3:
+                relationList = relationRepository.getRelationByNameLength3(firstName, secondName);
+                break;
+            case 4:
+                relationList = relationRepository.getRelationByNameLength4(firstName, secondName);
+                break;
+            case 5:
+                relationList = relationRepository.getRelationByNameLength5(firstName, secondName);
+                break;
+            default:
+                relationList = null;
+        }
+        return relationList;
+    }
+
+    @Override
+    public List<Neo4jRelation> getShortestRelationByName(String firstName, String secondName) {
+        return relationRepository.getShortestRelationByName(firstName, secondName);
+    }
 }

+ 53 - 0
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/uitils/Neo4j2VOUtils.java

@@ -0,0 +1,53 @@
+package com.kgraph.graph.neo4j.uitils;
+
+import com.kgraph.graph.neo4j.VO.EntityVO;
+import com.kgraph.graph.neo4j.VO.GraphVO;
+import com.kgraph.graph.neo4j.VO.RelationVO;
+import com.kgraph.graph.neo4j.domain.Neo4jEntity;
+import com.kgraph.graph.neo4j.domain.Neo4jRelation;
+import org.apache.commons.collections4.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author allen
+ */
+public class Neo4j2VOUtils {
+    public static GraphVO relation2GraphVO(List<Neo4jRelation> relationList) {
+        GraphVO graphVO = new GraphVO();
+        if (CollectionUtils.isEmpty(relationList)) {
+            return graphVO;
+        }
+        // process data
+        Set<Neo4jEntity> entitySet = new HashSet<>(relationList.size() * 2);
+        relationList.forEach(neo4jRelation -> {
+            entitySet.add(neo4jRelation.getStartNode());
+            entitySet.add(neo4jRelation.getEndNode());
+        });
+        List<EntityVO> entityVOList = new ArrayList<>(entitySet.size());
+        entitySet.forEach(neo4jEntity -> {
+            entityVOList.add(entity2VO(neo4jEntity));
+        });
+        graphVO.setData(entityVOList);
+
+        // processLinks
+        List<RelationVO> links = new ArrayList<>(relationList.size());
+        relationList.forEach(neo4jRelation -> {
+            links.add(relation2VO(neo4jRelation));
+        });
+        graphVO.setLinks(links);
+
+        return graphVO;
+    }
+
+    private static RelationVO relation2VO(Neo4jRelation neo4jRelation) {
+        return new RelationVO(neo4jRelation.getId(), neo4jRelation.getName(), neo4jRelation.getContent(), neo4jRelation.getStartNode().getId(), neo4jRelation.getEndNode().getId());
+    }
+
+    public static EntityVO entity2VO(Neo4jEntity entity) {
+        return new EntityVO(entity.getId(), entity.getName(), entity.getContent(), entity.getAttachmentUrl());
+    }
+}

+ 3 - 1
kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/ExtractKnowledgeSubTaskController.java

@@ -107,6 +107,7 @@ public class ExtractKnowledgeSubTaskController extends BaseController
 
     @PostMapping("/saveKnowledge")
     public AjaxResult saveKnowledge(@RequestBody KgDocDTO kgDocDTO){
+        logger.info("saveKnowledge 方法调用成功,kgDocDTO: {}", kgDocDTO);
         if(kgDocDTO == null){
             return AjaxResult.error("无效payload");
         }
@@ -116,7 +117,8 @@ public class ExtractKnowledgeSubTaskController extends BaseController
         }
 
         if(CollectionUtils.isEmpty(kgDocDTO.getKnowledgeList())){
-            return AjaxResult.error("没有数据");
+//            return AjaxResult.error("没有数据");
+            logger.info("kgDocDTO 没有数据.");
         }
         extractKnowledgeSubTaskService.saveKnowledge(kgDocDTO);
         return AjaxResult.success();

+ 48 - 40
kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/ExtractKnowledgeSubTaskServiceImpl.java

@@ -1,6 +1,7 @@
 package com.kgraph.graph.suport.service.impl;
 
 import com.kgraph.common.core.domain.BaseResponse;
+import com.kgraph.common.core.domain.entity.SysDictData;
 import com.kgraph.common.utils.DateUtils;
 import com.kgraph.graph.neo4j.DTO.DocInfo;
 import com.kgraph.graph.neo4j.DTO.KgDTO;
@@ -12,9 +13,12 @@ import com.kgraph.graph.suport.domain.TripletInfo;
 import com.kgraph.graph.suport.mapper.ExtractKnowledgeSubTaskMapper;
 import com.kgraph.graph.suport.service.IExtractKnowledgeSubTaskService;
 import com.kgraph.graph.suport.service.ITripletInfoService;
+import com.kgraph.system.service.ISysDictDataService;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.client.RestTemplate;
@@ -25,13 +29,12 @@ import java.util.List;
 
 /**
  * 知识抽取子任务Service业务层处理
- * 
+ *
  * @author Allen
  * @date 2023-03-20
  */
 @Service
-public class ExtractKnowledgeSubTaskServiceImpl implements IExtractKnowledgeSubTaskService 
-{
+public class ExtractKnowledgeSubTaskServiceImpl implements IExtractKnowledgeSubTaskService {
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
@@ -43,77 +46,75 @@ public class ExtractKnowledgeSubTaskServiceImpl implements IExtractKnowledgeSubT
 
     @Autowired
     private IKgService kgService;
+
+    @Autowired
+    private ISysDictDataService sysDictDataService;
+
     /**
      * 查询知识抽取子任务
-     * 
+     *
      * @param id 知识抽取子任务主键
      * @return 知识抽取子任务
      */
     @Override
-    public ExtractKnowledgeSubTask selectExtractKnowledgeSubTaskById(Long id)
-    {
+    public ExtractKnowledgeSubTask selectExtractKnowledgeSubTaskById(Long id) {
         return extractKnowledgeSubTaskMapper.selectExtractKnowledgeSubTaskById(id);
     }
 
     /**
      * 查询知识抽取子任务列表
-     * 
+     *
      * @param extractKnowledgeSubTask 知识抽取子任务
      * @return 知识抽取子任务
      */
     @Override
-    public List<ExtractKnowledgeSubTask> selectExtractKnowledgeSubTaskList(ExtractKnowledgeSubTask extractKnowledgeSubTask)
-    {
+    public List<ExtractKnowledgeSubTask> selectExtractKnowledgeSubTaskList(ExtractKnowledgeSubTask extractKnowledgeSubTask) {
         return extractKnowledgeSubTaskMapper.selectExtractKnowledgeSubTaskList(extractKnowledgeSubTask);
     }
 
     /**
      * 新增知识抽取子任务
-     * 
+     *
      * @param extractKnowledgeSubTask 知识抽取子任务
      * @return 结果
      */
     @Override
-    public int insertExtractKnowledgeSubTask(ExtractKnowledgeSubTask extractKnowledgeSubTask)
-    {
+    public int insertExtractKnowledgeSubTask(ExtractKnowledgeSubTask extractKnowledgeSubTask) {
         extractKnowledgeSubTask.setCreateTime(DateUtils.getNowDate());
         return extractKnowledgeSubTaskMapper.insertExtractKnowledgeSubTask(extractKnowledgeSubTask);
     }
 
     /**
      * 修改知识抽取子任务
-     * 
+     *
      * @param extractKnowledgeSubTask 知识抽取子任务
      * @return 结果
      */
     @Override
-    public int updateExtractKnowledgeSubTask(ExtractKnowledgeSubTask extractKnowledgeSubTask)
-    {
+    public int updateExtractKnowledgeSubTask(ExtractKnowledgeSubTask extractKnowledgeSubTask) {
         extractKnowledgeSubTask.setUpdateTime(DateUtils.getNowDate());
         return extractKnowledgeSubTaskMapper.updateExtractKnowledgeSubTask(extractKnowledgeSubTask);
     }
 
     /**
      * 批量删除知识抽取子任务
-     * 
+     *
      * @param ids 需要删除的知识抽取子任务主键
      * @return 结果
      */
     @Override
-    public int deleteExtractKnowledgeSubTaskByIds(Long[] ids)
-    {
+    public int deleteExtractKnowledgeSubTaskByIds(Long[] ids) {
         return extractKnowledgeSubTaskMapper.deleteExtractKnowledgeSubTaskByIds(ids);
     }
 
     /**
      * 删除知识抽取子任务信息
-     * 
+     *
      * @param id 知识抽取子任务主键
      * @return 结果
      */
     @Override
-    public int deleteExtractKnowledgeSubTaskById(Long id)
-    {
+    public int deleteExtractKnowledgeSubTaskById(Long id) {
         return extractKnowledgeSubTaskMapper.deleteExtractKnowledgeSubTaskById(id);
     }
 
@@ -125,7 +126,7 @@ public class ExtractKnowledgeSubTaskServiceImpl implements IExtractKnowledgeSubT
         String createBy = extractKnowledgeTask.getCreateBy();
         List<ExtractKnowledgeSubTask> extractKnowledgeSubTaskList = new ArrayList<>(selectSubTasks.length);
         // 根据子任务创建任务
-        for (String subTask: selectSubTasks) {
+        for (String subTask : selectSubTasks) {
             ExtractKnowledgeSubTask extractKnowledgeSubTask = new ExtractKnowledgeSubTask();
             extractKnowledgeSubTask.setTaskId(taskId);
             extractKnowledgeSubTask.setType(subTask);
@@ -135,26 +136,32 @@ public class ExtractKnowledgeSubTaskServiceImpl implements IExtractKnowledgeSubT
             extractKnowledgeSubTaskMapper.insertExtractKnowledgeSubTask(extractKnowledgeSubTask);
             extractKnowledgeSubTaskList.add(extractKnowledgeSubTask);
         }
-        // TODO Allen 暂时关闭推送数据
-//        processSubTask(extractKnowledgeSubTaskList);
+
+        processSubTask(extractKnowledgeSubTaskList);
     }
 
     private void processSubTask(List<ExtractKnowledgeSubTask> extractKnowledgeSubTaskList) {
         RestTemplate restTemplate = new RestTemplate();
-//        String url="http://192.168.13.151:9999/extractKnowledge";
-        String url="http://localhost:9999/extractKnowledge";
-        try{
+        String url = "http://localhost:9999/extractKnowledge";
+        SysDictData remoteData = sysDictDataService.getDictDataByTypeAndValue("kg_algorithm", "url");
+        if (remoteData != null && StringUtils.isNotBlank(remoteData.getRemark())) {
+            url = remoteData.getRemark();
+        }
+        try {
+            String finalUrl = url;
             extractKnowledgeSubTaskList.forEach(extractKnowledgeSubTask -> {
                 DocInfo docInfo = extractKnowledgeSubTaskMapper.getDocInfoBySubtask(extractKnowledgeSubTask.getId());
-                BaseResponse response = restTemplate.postForObject(url, docInfo, BaseResponse.class);
-                if(response == null){
-                    logger.error("response is null, url:{}, docInfo:{}",url, docInfo);
-                } else if(response.getCode() != 200){
-                    logger.error("request is error! errorMsg: {}, url:{}, docInfo:{}",response.getMsg(), url, docInfo);
+                docInfo.setDocAddress("http://localhost:11082/upload/uploadManage/download?filePath=" + docInfo.getDocAddress());
+                BaseResponse response = restTemplate.postForObject(finalUrl, docInfo, BaseResponse.class);
+                if (response == null) {
+                    logger.error("response is null, url:{}, docInfo:{}", finalUrl, docInfo);
+                } else if (response.getCode() != 200) {
+                    logger.error("request is error! errorMsg: {}, url:{}, docInfo:{}", response.getMsg(), finalUrl, docInfo);
                 }
+                logger.info("算法推送成功,url:{}, docInfo:{}", finalUrl, docInfo);
             });
-        }catch (Exception e){
-            logger.error("算法请求报错",e);
+        } catch (Exception e) {
+            logger.error("算法请求报错", e);
         }
     }
 
@@ -172,13 +179,14 @@ public class ExtractKnowledgeSubTaskServiceImpl implements IExtractKnowledgeSubT
 
     @Override
     @Transactional
+    @Async
     public void approveSubTask(Long id, String status) {
-        extractKnowledgeSubTaskMapper.updateSubTaskStatusById(id, status,null, null);
+        extractKnowledgeSubTaskMapper.updateSubTaskStatusById(id, status, null, null);
         // TODO 以下逻辑可优化成异步执行
-        if(ExtractKnowledgeSubTask.REVIEWED.equals(status)){
+        if (ExtractKnowledgeSubTask.REVIEWED.equals(status)) {
             List<KgDTO> kgDTOList = tripletInfoService.getKgDTO(id);
             kgService.create(kgDTOList);
-            extractKnowledgeSubTaskMapper.updateSubTaskStatusById(id, ExtractKnowledgeSubTask.DOWN,null, null);
+            extractKnowledgeSubTaskMapper.updateSubTaskStatusById(id, ExtractKnowledgeSubTask.DOWN, null, null);
         }
         extractKnowledgeSubTaskMapper.updateTaskStatusBySubTaskId(id);
     }
@@ -196,16 +204,16 @@ public class ExtractKnowledgeSubTaskServiceImpl implements IExtractKnowledgeSubT
         // 更新状态
         List<TripletInfo> tripletInfoList = new ArrayList<>(kgDocDTO.getKnowledgeList().size());
         Long subTaskId = kgDocDTO.getDocInfo().getSubTaskId();
-        for (KgDTO kgDTO: kgDocDTO.getKnowledgeList()){
+        for (KgDTO kgDTO : kgDocDTO.getKnowledgeList()) {
             TripletInfo tripletInfo = TripletInfo.buildByKgDocDTO(kgDTO, subTaskId);
             tripletInfoList.add(tripletInfo);
         }
         tripletInfoService.createList(tripletInfoList);
         // 更新task状态
-        updateSubTaskStatusById(subTaskId,ExtractKnowledgeSubTask.TO_BE_REVIEWED, kgDocDTO.getMsg());
+        updateSubTaskStatusById(subTaskId, ExtractKnowledgeSubTask.TO_BE_REVIEWED, kgDocDTO.getMsg());
     }
 
-    public void updateSubTaskStatusById(Long subTaskId, String status, String msg){
+    public void updateSubTaskStatusById(Long subTaskId, String status, String msg) {
         extractKnowledgeSubTaskMapper.updateSubTaskStatusById(subTaskId, status, msg, new Date());
         extractKnowledgeSubTaskMapper.updateTaskStatusBySubTaskId(subTaskId);
     }

+ 1 - 1
kgraph-graph/src/main/resources/mapper/upload/UploadManageMapper.xml

@@ -101,6 +101,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM
             t_upload_manage
         <if test="name != null">WHERE `name` like concat('%', #{name}, '%')</if>
-        ORDER BY update_time DESC
+        ORDER BY create_time DESC
     </select>
 </mapper>

+ 3 - 1
sql/system.sql

@@ -1318,4 +1318,6 @@ values('事故信息删除', @parentId, '4',  '#', '', 1, 0, 'F', '0', '0', 'upl
 insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
 values('事故信息导出', @parentId, '5',  '#', '', 1, 0, 'F', '0', '0', 'uploadDetail:accident:export',       '#', 'admin', sysdate(), '', null, '');
 
--- 添加数据字典  kg_upload_type  kg_upload_template file_upload_status kg_extract_status extract_sub_task_list extract_sub_task_status
+-- 添加数据字典  kg_upload_type  kg_upload_template file_upload_status kg_extract_status extract_sub_task_list extract_sub_task_status graph_search_length
+
+-- 目录 /graphdata/search