9 Commits 87f6ab7e01 ... bf1e66ef24

Author SHA1 Message Date
  twzydn20000928 bf1e66ef24 构建故障流程 2 years ago
  twzydn20000928 011f786d55 Merge remote-tracking branch 'origin/master' 2 years ago
  twzydn20000928 e3cd6b42cc 构建故障流程 2 years ago
  allen 1fc0047780 [dev] save entity by class 2 years ago
  allen 663d07f4ae Merge branch 'dev_xlk' 2 years ago
  allen 56e03f03ae add sql 2 years ago
  allen 9a76e3c6a2 dev subtask & question 2 years ago
  allen b201b55da1 fix approve subtask 2 years ago
  allen 6b575f1825 fix approve subtask 2 years ago
23 changed files with 975 additions and 95 deletions
  1. 12 3
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/controller/KgController.java
  2. 8 4
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/domain/Neo4jEntity.java
  3. 3 0
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/mapper/RelationRepository.java
  4. 4 2
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/IKgService.java
  5. 56 2
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/impl/KgServiceImpl.java
  6. 45 13
      kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/ExtractResultController.java
  7. 100 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/QuestionRecordController.java
  8. 9 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/TBuildFlowController.java
  9. 69 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/domain/QuestionRecord.java
  10. 10 51
      kgraph-graph/src/main/java/com/kgraph/graph/suport/domain/TBuildFlow.java
  11. 16 1
      kgraph-graph/src/main/java/com/kgraph/graph/suport/dto/BuildEntityRelationDTO.java
  12. 63 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/mapper/QuestionRecordMapper.java
  13. 4 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/mapper/TBuildFlowMapper.java
  14. 63 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/service/IQuestionRecordService.java
  15. 4 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/service/ITBuildFlowService.java
  16. 8 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/BuildEntityRelationServiceImpl.java
  17. 57 16
      kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/ExtractKnowledgeSubTaskServiceImpl.java
  18. 101 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/QuestionRecordServiceImpl.java
  19. 26 1
      kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/TBuildFlowServiceImpl.java
  20. 92 0
      kgraph-graph/src/main/resources/mapper/suport/QuestionRecordMapper.xml
  21. 22 2
      kgraph-graph/src/main/resources/mapper/suport/TBuildFlowMapper.xml
  22. 125 0
      sql/update20230523.sql
  23. 78 0
      sql/update20230524.sql

+ 12 - 3
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/controller/KgController.java

@@ -7,6 +7,8 @@ import com.kgraph.graph.neo4j.VO.GraphVO;
 import com.kgraph.graph.neo4j.domain.Neo4jRelation;
 import com.kgraph.graph.neo4j.service.IKgService;
 import com.kgraph.graph.neo4j.uitils.Neo4j2VOUtils;
+import com.kgraph.graph.suport.domain.QuestionRecord;
+import com.kgraph.graph.suport.service.IQuestionRecordService;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -21,6 +23,8 @@ public class KgController extends BaseController {
 
     @Autowired
     IKgService kgService;
+    @Autowired
+    IQuestionRecordService questionRecordService;
 
     @PostMapping("/create")
     public AjaxResult create(@RequestBody List<KgDTO> kgDTOList) {
@@ -78,9 +82,9 @@ public class KgController extends BaseController {
     }
 
     @GetMapping("/getRelationByLikeName")
-    public AjaxResult getRelationByLikeName(String name) {
+    public AjaxResult getRelationByLikeName(String name, Integer type) {
         // TODO length 的最大最小值,从数据字典获取
-        GraphVO graphVO = Neo4j2VOUtils.relation2GraphVO(kgService.getRelationByLikeName(name));
+        GraphVO graphVO = Neo4j2VOUtils.relation2GraphVO(kgService.getRelationByLikeName(name, type));
         return AjaxResult.success(graphVO);
     }
 
@@ -92,6 +96,11 @@ public class KgController extends BaseController {
 
     @GetMapping("/question")
     public AjaxResult question(@RequestParam("text") String question) {
-        return AjaxResult.success("success", kgService.question(question));
+        String result = kgService.question(question);
+        QuestionRecord questionRecord = new QuestionRecord();
+        questionRecord.setQuestion(question);
+        questionRecord.setResult(result);
+        questionRecordService.insertQuestionRecord(questionRecord);
+        return AjaxResult.success("success", result);
     }
 }

+ 8 - 4
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/domain/Neo4jEntity.java

@@ -1,10 +1,10 @@
 package com.kgraph.graph.neo4j.domain;
 
 import lombok.Data;
-import org.neo4j.ogm.annotation.GeneratedValue;
-import org.neo4j.ogm.annotation.Id;
-import org.neo4j.ogm.annotation.NodeEntity;
-import org.neo4j.ogm.annotation.Property;
+import org.neo4j.ogm.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
 
 @NodeEntity("Entity")
 @Data
@@ -12,8 +12,12 @@ public class Neo4jEntity {
     @Id
     @GeneratedValue
     private Long id;
+    @Property("code")
+    private String code;
     @Property("name")
     private String name;
+    @Labels()
+    private List<String> labels = new ArrayList<>();
     @Property("content")
     private String content;
     @Property("attachmentUrl")

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

@@ -41,4 +41,7 @@ public interface RelationRepository extends Neo4jRepository<Neo4jRelation, Long>
 
     @Query("match data=(e1:Entity)-[r:Relation]-(e2:Entity) where e1.name =~ $name and e2.name =~ $name return data")
     List<Neo4jRelation> getRelationByLikeName(@Param("name") String name);
+
+    @Query("match data=(e1:Entity)-[r:Relation]-(e2:Entity) where e1.name =~ $name return data")
+    List<Neo4jRelation> getRelationByLikeName2(@Param("name") String name);
 }

+ 4 - 2
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/IKgService.java

@@ -1,8 +1,8 @@
 package com.kgraph.graph.neo4j.service;
 
 import com.kgraph.graph.neo4j.DTO.KgDTO;
-import com.kgraph.graph.neo4j.DTO.KgDocDTO;
 import com.kgraph.graph.neo4j.domain.Neo4jRelation;
+import com.kgraph.graph.suport.dto.BuildEntityRelationDTO;
 
 import java.util.List;
 
@@ -21,5 +21,7 @@ public interface IKgService {
 
     String analysis(String question);
 
-    List<Neo4jRelation> getRelationByLikeName(String name);
+    List<Neo4jRelation> getRelationByLikeName(String name, Integer type);
+
+    void buildEntityByClass(List<BuildEntityRelationDTO> bu1ildEntityRelationDTOList);
 }

+ 56 - 2
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/impl/KgServiceImpl.java

@@ -8,6 +8,7 @@ import com.kgraph.graph.neo4j.domain.Neo4jRelation;
 import com.kgraph.graph.neo4j.mapper.EntityRepository;
 import com.kgraph.graph.neo4j.mapper.RelationRepository;
 import com.kgraph.graph.neo4j.service.IKgService;
+import com.kgraph.graph.suport.dto.BuildEntityRelationDTO;
 import com.kgraph.system.service.ISysDictDataService;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -71,6 +72,11 @@ public class KgServiceImpl implements IKgService {
         return false;
     }
 
+    private boolean relationExist(Neo4jEntity subEntity, Neo4jEntity objEntity, String relationName) {
+        Neo4jRelation relationDb = relationRepository.findRelation(subEntity.getId(), objEntity.getId(), relationName);
+        return relationDb != null;
+    }
+
     @Override
     public Iterable getAllEntityList() {
         return entityRepository.findAll();
@@ -200,8 +206,56 @@ public class KgServiceImpl implements IKgService {
     }
 
     @Override
-    public List<Neo4jRelation> getRelationByLikeName(String name) {
-        return relationRepository.getRelationByLikeName(".*" + name + ".*");
+    public List<Neo4jRelation> getRelationByLikeName(String name, Integer type) {
+        if (0 == type) {
+            return relationRepository.getRelationByLikeName2(".*" + name + ".*");
+        } else {
+            return relationRepository.getRelationByLikeName(".*" + name + ".*");
+        }
+    }
+
+    @Override
+    public void buildEntityByClass(List<BuildEntityRelationDTO> bu1ildEntityRelationDTOList) {
+        bu1ildEntityRelationDTOList.forEach(buildEntityRelationDTO -> {
+            String subEntityName = buildEntityRelationDTO.getSubEntity();
+            Neo4jEntity subEntity = entityRepository.findByName(subEntityName);
+            String subClassName = buildEntityRelationDTO.getSubName();
+            // 如果实体不存在,新建实体
+            if (subEntity == null) {
+                subEntity = new Neo4jEntity();
+                subEntity.setName(subEntityName);
+                subEntity.getLabels().add(subClassName);
+                entityRepository.save(subEntity);
+                // 如果实体存在,实体类没有则添加实体类
+            } else if (!subEntity.getLabels().contains(subClassName)) {
+                subEntity.getLabels().add(subClassName);
+                entityRepository.save(subEntity);
+            }
+
+            String objEntityName = buildEntityRelationDTO.getObjEntity();
+            Neo4jEntity objEntity = entityRepository.findByName(objEntityName);
+            String objClassName = buildEntityRelationDTO.getObjName();
+            // 如果实体不存在,新建实体
+            if (objEntity == null) {
+                objEntity = new Neo4jEntity();
+                objEntity.setName(objEntityName);
+                objEntity.getLabels().add(objClassName);
+                entityRepository.save(objEntity);
+                // 如果实体存在,实体类没有则添加实体类
+            } else if (!objEntity.getLabels().contains(objClassName)) {
+                objEntity.getLabels().add(objClassName);
+                entityRepository.save(objEntity);
+            }
+
+            String relationName = buildEntityRelationDTO.getName();
+            if(!relationExist(subEntity,objEntity, relationName)){
+                Neo4jRelation relation = new Neo4jRelation();
+                relation.setName(relationName);
+                relation.setStartNode(subEntity);
+                relation.setEndNode(objEntity);
+                relationRepository.save(relation);
+            }
+        });
     }
 
 }

+ 45 - 13
kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/ExtractResultController.java

@@ -5,6 +5,7 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.ArrayList;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
@@ -23,14 +24,14 @@ import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-import com.kgraph.common.annotation.Log;;
-import com.kgraph.common.core.controller.BaseController;;
-import com.kgraph.common.core.domain.AjaxResult;;
-import com.kgraph.common.enums.BusinessType;;
+import com.kgraph.common.annotation.Log;
+import com.kgraph.common.core.controller.BaseController;
+import com.kgraph.common.core.domain.AjaxResult;
+import com.kgraph.common.enums.BusinessType;
 import com.kgraph.graph.suport.domain.ExtractResult;
 import com.kgraph.graph.suport.service.IExtractResultService;
-import com.kgraph.common.utils.poi.ExcelUtil;;
-import com.kgraph.common.core.page.TableDataInfo;;
+import com.kgraph.common.utils.poi.ExcelUtil;
+import com.kgraph.common.core.page.TableDataInfo;
 
 /**
  * 抽取结果信息Controller
@@ -131,13 +132,7 @@ public class ExtractResultController extends BaseController
         if (!FileUtils.checkAllowDownload(filePath)) {
             throw new RuntimeException(StringUtils.format("文件名称({})非法,不允许下载。 ", filePath));
         }
-        String realFileName = FileUtils.getFileNameByPath(filePath);
-
-//        String parentPath = dictDataService.getValueByTypeAndValue("kg_algorithm", "resultPath");
         String filePathFinal = filePath;
-//        if (StringUtils.isNotEmpty(parentPath)) {
-//            filePathFinal = parentPath + filePathFinal;
-//        }
         Path path = Paths.get(filePathFinal);
         String data = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
         return AjaxResult.success("success", data);
@@ -170,8 +165,45 @@ public class ExtractResultController extends BaseController
         if(StringUtils.isNotEmpty(resultPath)){
             String data = (String) getResult(resultPath).get(AjaxResult.DATA_TAG);
             JSONObject jsonObject = JSONObject.parseObject(data);
-            return success(jsonObject);
+            return success(refactorData(jsonObject));
         }
         return error("没有生成抽取结果");
     }
+    private JSONObject refactorData(JSONObject jsonObject) {
+        JSONArray dataList = new JSONArray();
+        JSONArray sentenceList = jsonObject.getJSONArray("sentenceList");
+        JSONArray knowledgeList = jsonObject.getJSONArray("knowledgeList");
+        int step = 5;
+        int sentSize = sentenceList.size();
+        int pageSize = (sentSize - 1) / step;
+        for (int i = 0; i <= pageSize; i++) {
+            JSONObject newData = new JSONObject();
+            JSONArray subSentenceList = new JSONArray();
+            JSONArray subKnowledgeList = new JSONArray();
+            List sentenceIdList = new ArrayList<>(8);;
+            for (int index = 0; index < step; index++) {
+                if(i * step + index >= sentSize){
+                    break;
+                }
+                JSONObject sentence = sentenceList.getJSONObject(i * step + index);
+                subSentenceList.add(sentence);
+                sentenceIdList.add(sentence.get("id"));
+            }
+            int size = knowledgeList.size();
+            for(int index = 0; index < size; index++){
+                JSONObject knowledge = knowledgeList.getJSONObject(index);
+                if(sentenceIdList.contains(knowledge.get("sentenceId"))){
+                    subKnowledgeList.add(knowledge);
+                }
+            }
+            newData.put("sentenceList",subSentenceList);
+            newData.put("knowledgeList",subKnowledgeList);
+            dataList.add(newData);
+        }
+        JSONObject returnValue = new JSONObject();
+        returnValue.put("dataList",dataList);
+        returnValue.put("total",pageSize+1);
+        returnValue.put("step",step);
+        return returnValue;
+    }
 }

+ 100 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/QuestionRecordController.java

@@ -0,0 +1,100 @@
+package com.kgraph.graph.suport.controller;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.kgraph.common.annotation.Log;;
+import com.kgraph.common.core.controller.BaseController;;
+import com.kgraph.common.core.domain.AjaxResult;;
+import com.kgraph.common.enums.BusinessType;;
+import com.kgraph.graph.suport.domain.QuestionRecord;
+import com.kgraph.graph.suport.service.IQuestionRecordService;
+import com.kgraph.common.utils.poi.ExcelUtil;;
+import com.kgraph.common.core.page.TableDataInfo;;
+
+/**
+ * 问答查询记录Controller
+ * 
+ * @author Allen
+ * @date 2023-05-24
+ */
+@RestController
+@RequestMapping("/suport/question")
+public class QuestionRecordController extends BaseController
+{
+    @Autowired
+    private IQuestionRecordService questionRecordService;
+
+    /**
+     * 查询问答查询记录列表
+     */
+    @GetMapping("/list")
+    public TableDataInfo list(QuestionRecord questionRecord)
+    {
+        startPage();
+        List<QuestionRecord> list = questionRecordService.selectQuestionRecordList(questionRecord);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出问答查询记录列表
+     */
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, QuestionRecord questionRecord)
+    {
+        List<QuestionRecord> list = questionRecordService.selectQuestionRecordList(questionRecord);
+        ExcelUtil<QuestionRecord> util = new ExcelUtil<QuestionRecord>(QuestionRecord.class);
+        util.exportExcel(response, list, "问答查询记录数据");
+    }
+
+    /**
+     * 获取问答查询记录详细信息
+     */
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(questionRecordService.selectQuestionRecordById(id));
+    }
+
+    /**
+     * 新增问答查询记录
+     */
+    @PostMapping
+    public AjaxResult add(@RequestBody QuestionRecord questionRecord)
+    {
+        return toAjax(questionRecordService.insertQuestionRecord(questionRecord));
+    }
+
+    /**
+     * 修改问答查询记录
+     */
+    @PutMapping
+    public AjaxResult edit(@RequestBody QuestionRecord questionRecord)
+    {
+        return toAjax(questionRecordService.updateQuestionRecord(questionRecord));
+    }
+
+    /**
+     * 删除问答查询记录
+     */
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(questionRecordService.deleteQuestionRecordByIds(ids));
+    }
+
+    @GetMapping("/getTop10")
+    public AjaxResult getTop10(){
+
+        return success(questionRecordService.getTop10());
+    }
+}

+ 9 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/TBuildFlowController.java

@@ -101,4 +101,13 @@ public class TBuildFlowController extends BaseController
     {
         return toAjax(tBuildFlowService.deleteTBuildFlowByIds(ids));
     }
+
+    /**
+     * 查看构建结果
+     */
+    @GetMapping("/getFlow/{subTaskId}")
+    public AjaxResult getFlow(@PathVariable("subTaskId") Long subtaskId)
+    {
+        return success(tBuildFlowService.getFlow(subtaskId));
+    }
 }

+ 69 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/domain/QuestionRecord.java

@@ -0,0 +1,69 @@
+package com.kgraph.graph.suport.domain;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.kgraph.common.annotation.Excel;
+import com.kgraph.common.core.domain.BaseEntity;;
+
+/**
+ * 问答查询记录对象 t_question_record
+ * 
+ * @author Allen
+ * @date 2023-05-24
+ */
+public class QuestionRecord extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 序号 */
+    private Long id;
+
+    /** 问题 */
+    @Excel(name = "问题")
+    private String question;
+
+    /** 结果 */
+    @Excel(name = "结果")
+    private String result;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setQuestion(String question) 
+    {
+        this.question = question;
+    }
+
+    public String getQuestion() 
+    {
+        return question;
+    }
+    public void setResult(String result) 
+    {
+        this.result = result;
+    }
+
+    public String getResult() 
+    {
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("question", getQuestion())
+            .append("result", getResult())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .toString();
+    }
+}

+ 10 - 51
kgraph-graph/src/main/java/com/kgraph/graph/suport/domain/TBuildFlow.java

@@ -1,5 +1,6 @@
 package com.kgraph.graph.suport.domain;
 
+import lombok.Data;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.kgraph.common.annotation.Excel;
@@ -11,6 +12,7 @@ import com.kgraph.common.core.domain.BaseEntity;;
  * @author kgraph
  * @date 2023-05-28
  */
+@Data
 public class TBuildFlow extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
@@ -18,6 +20,14 @@ public class TBuildFlow extends BaseEntity
     /** 序号 */
     private Long id;
 
+    /** 子任务id */
+    @Excel(name = "子任务id")
+    private Long subTaskId;
+
+    /** 故障编码 */
+    @Excel(name = "故障名称")
+    private String errorAppearance;
+
     /** 故障编码 */
     @Excel(name = "故障编码")
     private String errorCode;
@@ -29,55 +39,4 @@ public class TBuildFlow extends BaseEntity
     /** 流程树json */
     @Excel(name = "流程树json")
     private String flowTreeJson;
-
-    public void setId(Long id) 
-    {
-        this.id = id;
-    }
-
-    public Long getId() 
-    {
-        return id;
-    }
-    public void setErrorCode(String errorCode) 
-    {
-        this.errorCode = errorCode;
-    }
-
-    public String getErrorCode() 
-    {
-        return errorCode;
-    }
-    public void setFlowEncode(String flowEncode) 
-    {
-        this.flowEncode = flowEncode;
-    }
-
-    public String getFlowEncode() 
-    {
-        return flowEncode;
-    }
-    public void setFlowTreeJson(String flowTreeJson) 
-    {
-        this.flowTreeJson = flowTreeJson;
-    }
-
-    public String getFlowTreeJson() 
-    {
-        return flowTreeJson;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("id", getId())
-            .append("errorCode", getErrorCode())
-            .append("flowEncode", getFlowEncode())
-            .append("flowTreeJson", getFlowTreeJson())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .toString();
-    }
 }

+ 16 - 1
kgraph-graph/src/main/java/com/kgraph/graph/suport/dto/BuildEntityRelationDTO.java

@@ -9,9 +9,24 @@ public class BuildEntityRelationDTO {
     private Long startId;
     private Long endId;
     private Long subTaskId;
+    /**
+     * 关系类name
+      */
     String name;
+    /**
+     * 主体类name
+      */
     String subName;
+    /**
+     * 客体类name
+      */
     String objName;
-    String SubEntity;
+    /**
+     * 主体
+     */
+    String subEntity;
+    /**
+     * 客体
+     */
     String objEntity;
 }

+ 63 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/mapper/QuestionRecordMapper.java

@@ -0,0 +1,63 @@
+package com.kgraph.graph.suport.mapper;
+
+import java.util.List;
+import com.kgraph.graph.suport.domain.QuestionRecord;
+
+/**
+ * 问答查询记录Mapper接口
+ * 
+ * @author Allen
+ * @date 2023-05-24
+ */
+public interface QuestionRecordMapper 
+{
+    /**
+     * 查询问答查询记录
+     * 
+     * @param id 问答查询记录主键
+     * @return 问答查询记录
+     */
+    public QuestionRecord selectQuestionRecordById(Long id);
+
+    /**
+     * 查询问答查询记录列表
+     * 
+     * @param questionRecord 问答查询记录
+     * @return 问答查询记录集合
+     */
+    public List<QuestionRecord> selectQuestionRecordList(QuestionRecord questionRecord);
+
+    /**
+     * 新增问答查询记录
+     * 
+     * @param questionRecord 问答查询记录
+     * @return 结果
+     */
+    public int insertQuestionRecord(QuestionRecord questionRecord);
+
+    /**
+     * 修改问答查询记录
+     * 
+     * @param questionRecord 问答查询记录
+     * @return 结果
+     */
+    public int updateQuestionRecord(QuestionRecord questionRecord);
+
+    /**
+     * 删除问答查询记录
+     * 
+     * @param id 问答查询记录主键
+     * @return 结果
+     */
+    public int deleteQuestionRecordById(Long id);
+
+    /**
+     * 批量删除问答查询记录
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteQuestionRecordByIds(Long[] ids);
+
+    List<QuestionRecord> getTop10();
+}

+ 4 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/mapper/TBuildFlowMapper.java

@@ -1,6 +1,8 @@
 package com.kgraph.graph.suport.mapper;
 
 import java.util.List;
+import java.util.Map;
+
 import com.kgraph.graph.suport.domain.TBuildFlow;
 
 /**
@@ -58,4 +60,6 @@ public interface TBuildFlowMapper
      * @return 结果
      */
     public int deleteTBuildFlowByIds(Long[] ids);
+
+    public Map getFlow(Long subtaskId);
 }

+ 63 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/service/IQuestionRecordService.java

@@ -0,0 +1,63 @@
+package com.kgraph.graph.suport.service;
+
+import java.util.List;
+import com.kgraph.graph.suport.domain.QuestionRecord;
+
+/**
+ * 问答查询记录Service接口
+ * 
+ * @author Allen
+ * @date 2023-05-24
+ */
+public interface IQuestionRecordService 
+{
+    /**
+     * 查询问答查询记录
+     * 
+     * @param id 问答查询记录主键
+     * @return 问答查询记录
+     */
+    public QuestionRecord selectQuestionRecordById(Long id);
+
+    /**
+     * 查询问答查询记录列表
+     * 
+     * @param questionRecord 问答查询记录
+     * @return 问答查询记录集合
+     */
+    public List<QuestionRecord> selectQuestionRecordList(QuestionRecord questionRecord);
+
+    /**
+     * 新增问答查询记录
+     * 
+     * @param questionRecord 问答查询记录
+     * @return 结果
+     */
+    public int insertQuestionRecord(QuestionRecord questionRecord);
+
+    /**
+     * 修改问答查询记录
+     * 
+     * @param questionRecord 问答查询记录
+     * @return 结果
+     */
+    public int updateQuestionRecord(QuestionRecord questionRecord);
+
+    /**
+     * 批量删除问答查询记录
+     * 
+     * @param ids 需要删除的问答查询记录主键集合
+     * @return 结果
+     */
+    public int deleteQuestionRecordByIds(Long[] ids);
+
+    /**
+     * 删除问答查询记录信息
+     * 
+     * @param id 问答查询记录主键
+     * @return 结果
+     */
+    public int deleteQuestionRecordById(Long id);
+
+    List<QuestionRecord> getTop10();
+}

+ 4 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/service/ITBuildFlowService.java

@@ -1,6 +1,8 @@
 package com.kgraph.graph.suport.service;
 
 import java.util.List;
+import java.util.Map;
+
 import com.kgraph.graph.suport.domain.TBuildFlow;
 
 /**
@@ -58,4 +60,6 @@ public interface ITBuildFlowService
      * @return 结果
      */
     public int deleteTBuildFlowById(Long id);
+
+    Map getFlow(Long subtaskId);
 }

+ 8 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/BuildEntityRelationServiceImpl.java

@@ -5,6 +5,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.kgraph.common.utils.DateUtils;;
+import com.kgraph.graph.neo4j.service.IKgService;
 import com.kgraph.graph.suport.dto.BuildEntityRelationDTO;
 import com.kgraph.graph.suport.mapper.ExtractKnowledgeSubTaskMapper;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,6 +29,9 @@ public class BuildEntityRelationServiceImpl implements IBuildEntityRelationServi
     @Autowired
     private ExtractKnowledgeSubTaskMapper extractKnowledgeSubTaskMapper;
 
+    @Autowired
+    IKgService kgService;
+
     /**
      * 查询实体构建
      * 
@@ -132,6 +136,10 @@ public class BuildEntityRelationServiceImpl implements IBuildEntityRelationServi
         }
         // 更新子任务状态
         extractKnowledgeSubTaskMapper.updateSubTaskStatusById(id, "3", null, new Date());
+        // 更新任务状态
+        extractKnowledgeSubTaskMapper.updateTaskStatusBySubTaskId(id);
+
+        kgService.buildEntityByClass(bu1ildEntityRelationDTOList);
         return res;
     }
 }

+ 57 - 16
kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/ExtractKnowledgeSubTaskServiceImpl.java

@@ -145,10 +145,35 @@ public class ExtractKnowledgeSubTaskServiceImpl implements IExtractKnowledgeSubT
             extractKnowledgeSubTaskList.add(extractKnowledgeSubTask);
         }
 
-        processSubTask(extractKnowledgeSubTaskList);
+        processSubTasks(extractKnowledgeSubTaskList);
     }
 
-    private void processSubTask(List<ExtractKnowledgeSubTask> extractKnowledgeSubTaskList) {
+    private void processSubTasks(List<ExtractKnowledgeSubTask> extractKnowledgeSubTaskList) {
+        extractKnowledgeSubTaskList.forEach(extractKnowledgeSubTask -> {
+            switch (extractKnowledgeSubTask.getType()){
+                case "1":
+                    processExtractSubTask(extractKnowledgeSubTask);
+                    break;
+                case "2":
+                    buildEntityByClassSubTask(extractKnowledgeSubTask);
+                    break;
+                case "3":
+                    buildFlowSubTask(extractKnowledgeSubTask);
+                    break;
+                default:
+            }
+        });
+    }
+
+    private void buildFlowSubTask(ExtractKnowledgeSubTask extractKnowledgeSubTask) {
+        // do noting
+    }
+
+    private void buildEntityByClassSubTask(ExtractKnowledgeSubTask extractKnowledgeSubTask) {
+        // do noting
+    }
+
+    private void processExtractSubTask(ExtractKnowledgeSubTask extractKnowledgeSubTask) {
         HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
         httpRequestFactory.setConnectionRequestTimeout(3000);
         httpRequestFactory.setConnectTimeout(3000);
@@ -161,18 +186,16 @@ public class ExtractKnowledgeSubTaskServiceImpl implements IExtractKnowledgeSubT
         }
         try {
             String finalUrl = url;
-            extractKnowledgeSubTaskList.forEach(extractKnowledgeSubTask -> {
-                DocInfo docInfo = extractKnowledgeSubTaskMapper.getDocInfoBySubtask(extractKnowledgeSubTask.getId());
-                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);
-                } else {
-                    logger.info("算法推送成功,url:{}, docInfo:{}", finalUrl, docInfo);
-                }
-            });
+            DocInfo docInfo = extractKnowledgeSubTaskMapper.getDocInfoBySubtask(extractKnowledgeSubTask.getId());
+            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);
+            } else {
+                logger.info("算法推送成功,url:{}, docInfo:{}", finalUrl, docInfo);
+            }
         } catch (Exception e) {
             logger.error("算法请求报错", e);
             throw new RuntimeException("系统错误(10001),联系管理员");
@@ -204,10 +227,10 @@ public class ExtractKnowledgeSubTaskServiceImpl implements IExtractKnowledgeSubT
 
             // save resultJson
 //            String resultPath = sysDictDataService.getValueByTypeAndValue("kg_algorithm", "resultPath");
-            String result = extractResult.getResultData();
+            String result = refactorResult(extractResult.getResultData());
 
             try {
-                FileUtils.writeJsonToFile(result,extractResult.getResult());
+                FileUtils.writeJsonToFile(result, extractResult.getResult());
             } catch (Exception e) {
                 logger.error("抽取结果保存失败");
             }
@@ -230,6 +253,24 @@ public class ExtractKnowledgeSubTaskServiceImpl implements IExtractKnowledgeSubT
 
     }
 
+    private String refactorResult(String resultData) {
+        JSONArray jsonArray = JSONArray.parseArray(resultData);
+        JSONObject jsonObject = new JSONObject();
+        JSONArray sentenceList = new JSONArray();
+        JSONArray knowledgeList = new JSONArray();
+        int size = jsonArray.size();
+        if(size>0){
+            for(int i=0; i < size; i++){
+                JSONObject item = jsonArray.getJSONObject(i);
+                sentenceList.addAll(item.getJSONArray("sentenceList"));
+                knowledgeList.addAll(item.getJSONArray("knowledgeList"));
+            }
+        }
+        jsonObject.put("sentenceList",sentenceList);
+        jsonObject.put("knowledgeList",knowledgeList);
+        return jsonObject.toString();
+    }
+
     @Override
     public void updateTaskStatusBySubTaskId(Long subTaskId) {
         extractKnowledgeSubTaskMapper.updateTaskStatusBySubTaskId(subTaskId);

+ 101 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/QuestionRecordServiceImpl.java

@@ -0,0 +1,101 @@
+package com.kgraph.graph.suport.service.impl;
+
+import java.util.List;
+import com.kgraph.common.utils.DateUtils;;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.kgraph.graph.suport.mapper.QuestionRecordMapper;
+import com.kgraph.graph.suport.domain.QuestionRecord;
+import com.kgraph.graph.suport.service.IQuestionRecordService;
+
+/**
+ * 问答查询记录Service业务层处理
+ * 
+ * @author Allen
+ * @date 2023-05-24
+ */
+@Service
+public class QuestionRecordServiceImpl implements IQuestionRecordService 
+{
+    @Autowired
+    private QuestionRecordMapper questionRecordMapper;
+
+    /**
+     * 查询问答查询记录
+     * 
+     * @param id 问答查询记录主键
+     * @return 问答查询记录
+     */
+    @Override
+    public QuestionRecord selectQuestionRecordById(Long id)
+    {
+        return questionRecordMapper.selectQuestionRecordById(id);
+    }
+
+    /**
+     * 查询问答查询记录列表
+     * 
+     * @param questionRecord 问答查询记录
+     * @return 问答查询记录
+     */
+    @Override
+    public List<QuestionRecord> selectQuestionRecordList(QuestionRecord questionRecord)
+    {
+        return questionRecordMapper.selectQuestionRecordList(questionRecord);
+    }
+
+    /**
+     * 新增问答查询记录
+     * 
+     * @param questionRecord 问答查询记录
+     * @return 结果
+     */
+    @Override
+    public int insertQuestionRecord(QuestionRecord questionRecord)
+    {
+        questionRecord.setCreateTime(DateUtils.getNowDate());
+        return questionRecordMapper.insertQuestionRecord(questionRecord);
+    }
+
+    /**
+     * 修改问答查询记录
+     * 
+     * @param questionRecord 问答查询记录
+     * @return 结果
+     */
+    @Override
+    public int updateQuestionRecord(QuestionRecord questionRecord)
+    {
+        questionRecord.setUpdateTime(DateUtils.getNowDate());
+        return questionRecordMapper.updateQuestionRecord(questionRecord);
+    }
+
+    /**
+     * 批量删除问答查询记录
+     * 
+     * @param ids 需要删除的问答查询记录主键
+     * @return 结果
+     */
+    @Override
+    public int deleteQuestionRecordByIds(Long[] ids)
+    {
+        return questionRecordMapper.deleteQuestionRecordByIds(ids);
+    }
+
+    /**
+     * 删除问答查询记录信息
+     * 
+     * @param id 问答查询记录主键
+     * @return 结果
+     */
+    @Override
+    public int deleteQuestionRecordById(Long id)
+    {
+        return questionRecordMapper.deleteQuestionRecordById(id);
+    }
+
+    @Override
+    public List<QuestionRecord> getTop10() {
+        return questionRecordMapper.getTop10();
+    }
+}

+ 26 - 1
kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/TBuildFlowServiceImpl.java

@@ -1,12 +1,17 @@
 package com.kgraph.graph.suport.service.impl;
 
+import java.util.Date;
 import java.util.List;
-import com.kgraph.common.utils.DateUtils;;
+import java.util.Map;
+
+import com.kgraph.common.utils.DateUtils;
+import com.kgraph.graph.suport.mapper.BuildEntityRelationMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.kgraph.graph.suport.mapper.TBuildFlowMapper;
 import com.kgraph.graph.suport.domain.TBuildFlow;
 import com.kgraph.graph.suport.service.ITBuildFlowService;
+import com.kgraph.graph.suport.mapper.ExtractKnowledgeSubTaskMapper;
 
 /**
  * 构建流程Service业务层处理
@@ -20,6 +25,9 @@ public class TBuildFlowServiceImpl implements ITBuildFlowService
     @Autowired
     private TBuildFlowMapper tBuildFlowMapper;
 
+    @Autowired
+    private ExtractKnowledgeSubTaskMapper extractKnowledgeSubTaskMapper;
+
     /**
      * 查询构建流程
      * 
@@ -54,6 +62,12 @@ public class TBuildFlowServiceImpl implements ITBuildFlowService
     public int insertTBuildFlow(TBuildFlow tBuildFlow)
     {
         tBuildFlow.setCreateTime(DateUtils.getNowDate());
+        if(tBuildFlow.getSubTaskId() != null) {
+            // 更新子任务状态
+            extractKnowledgeSubTaskMapper.updateSubTaskStatusById(tBuildFlow.getSubTaskId(), "3", null, new Date());
+            // 更新任务状态
+            extractKnowledgeSubTaskMapper.updateTaskStatusBySubTaskId(tBuildFlow.getSubTaskId());
+        }
         return tBuildFlowMapper.insertTBuildFlow(tBuildFlow);
     }
 
@@ -67,6 +81,12 @@ public class TBuildFlowServiceImpl implements ITBuildFlowService
     public int updateTBuildFlow(TBuildFlow tBuildFlow)
     {
         tBuildFlow.setUpdateTime(DateUtils.getNowDate());
+        if(tBuildFlow.getSubTaskId() != null) {
+            // 更新子任务状态
+            extractKnowledgeSubTaskMapper.updateSubTaskStatusById(tBuildFlow.getSubTaskId(), "3", null, new Date());
+            // 更新任务状态
+            extractKnowledgeSubTaskMapper.updateTaskStatusBySubTaskId(tBuildFlow.getSubTaskId());
+        }
         return tBuildFlowMapper.updateTBuildFlow(tBuildFlow);
     }
 
@@ -93,4 +113,9 @@ public class TBuildFlowServiceImpl implements ITBuildFlowService
     {
         return tBuildFlowMapper.deleteTBuildFlowById(id);
     }
+
+    @Override
+    public Map getFlow(Long subtaskId) {
+        return tBuildFlowMapper.getFlow(subtaskId);
+    }
 }

+ 92 - 0
kgraph-graph/src/main/resources/mapper/suport/QuestionRecordMapper.xml

@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.kgraph.graph.suport.mapper.QuestionRecordMapper">
+    
+    <resultMap type="QuestionRecord" id="QuestionRecordResult">
+        <result property="id"    column="id"    />
+        <result property="question"    column="question"    />
+        <result property="result"    column="result"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+    </resultMap>
+
+    <sql id="selectQuestionRecordVo">
+        select id, question, result, create_by, create_time, update_by, update_time from t_question_record
+    </sql>
+
+    <select id="selectQuestionRecordList" parameterType="QuestionRecord" resultMap="QuestionRecordResult">
+        <include refid="selectQuestionRecordVo"/>
+        <where>  
+            <if test="question != null  and question != ''"> and question = #{question}</if>
+            <if test="result != null  and result != ''"> and result = #{result}</if>
+        </where>
+    </select>
+    
+    <select id="selectQuestionRecordById" parameterType="Long" resultMap="QuestionRecordResult">
+        <include refid="selectQuestionRecordVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="insertQuestionRecord" parameterType="QuestionRecord" useGeneratedKeys="true" keyProperty="id">
+        insert into t_question_record
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="question != null">question,</if>
+            <if test="result != null">result,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="question != null">#{question},</if>
+            <if test="result != null">#{result},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+         </trim>
+    </insert>
+
+    <update id="updateQuestionRecord" parameterType="QuestionRecord">
+        update t_question_record
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="question != null">question = #{question},</if>
+            <if test="result != null">result = #{result},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteQuestionRecordById" parameterType="Long">
+        delete from t_question_record where id = #{id}
+    </delete>
+
+    <delete id="deleteQuestionRecordByIds" parameterType="String">
+        delete from t_question_record where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+
+    <select id="getTop10" resultType="Map">
+        SELECT
+            qr.question,
+            count(*) AS cnt
+        FROM
+            t_question_record qr
+--        WHERE
+--            qr.create_time >= NOW() - INTERVAL 24 HOUR
+        GROUP BY
+            qr.question
+        ORDER BY
+            cnt DESC
+        LIMIT 10;
+    </select>
+</mapper>

+ 22 - 2
kgraph-graph/src/main/resources/mapper/suport/TBuildFlowMapper.xml

@@ -6,6 +6,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     
     <resultMap type="TBuildFlow" id="TBuildFlowResult">
         <result property="id"    column="id"    />
+        <result property="subTaskId"    column="sub_task_id"    />
+        <result property="errorAppearance"    column="error_appearance"    />
         <result property="errorCode"    column="error_code"    />
         <result property="flowEncode"    column="flow_encode"    />
         <result property="flowTreeJson"    column="flow_tree_json"    />
@@ -16,13 +18,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectTBuildFlowVo">
-        select id, error_code, flow_encode, flow_tree_json, create_by, create_time, update_by, update_time from t_build_flow
+        select id, sub_task_id, error_appearance, error_code, flow_encode, flow_tree_json, create_by, create_time, update_by, update_time from t_build_flow
     </sql>
 
     <select id="selectTBuildFlowList" parameterType="TBuildFlow" resultMap="TBuildFlowResult">
         <include refid="selectTBuildFlowVo"/>
         <where>  
-            <if test="errorCode != null  and errorCode != ''"> and error_code = #{errorCode}</if>
+            <if test="errorAppearance != null  and errorAppearance != ''"> and error_appearance = #{errorAppearance}</if>
             <if test="flowEncode != null  and flowEncode != ''"> and flow_encode = #{flowEncode}</if>
             <if test="flowTreeJson != null  and flowTreeJson != ''"> and flow_tree_json = #{flowTreeJson}</if>
         </where>
@@ -36,6 +38,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <insert id="insertTBuildFlow" parameterType="TBuildFlow" useGeneratedKeys="true" keyProperty="id">
         insert into t_build_flow
         <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="subTaskId != null">sub_task_id,</if>
+            <if test="errorAppearance != null">error_appearance,</if>
             <if test="errorCode != null">error_code,</if>
             <if test="flowEncode != null">flow_encode,</if>
             <if test="flowTreeJson != null">flow_tree_json,</if>
@@ -45,6 +49,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">update_time,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="subTaskId != null">#{subTaskId},</if>
+            <if test="errorAppearance != null">#{errorAppearance},</if>
             <if test="errorCode != null">#{errorCode},</if>
             <if test="flowEncode != null">#{flowEncode},</if>
             <if test="flowTreeJson != null">#{flowTreeJson},</if>
@@ -58,6 +64,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="updateTBuildFlow" parameterType="TBuildFlow">
         update t_build_flow
         <trim prefix="SET" suffixOverrides=",">
+            <if test="subTaskId != null">sub_task_id = #{subTaskId},</if>
+            <if test="errorAppearance != null">error_appearance = #{errorAppearance},</if>
             <if test="errorCode != null">error_code = #{errorCode},</if>
             <if test="flowEncode != null">flow_encode = #{flowEncode},</if>
             <if test="flowTreeJson != null">flow_tree_json = #{flowTreeJson},</if>
@@ -79,4 +87,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+
+    <select id="getFlow" resultType="Map">
+        select
+            id,
+            sub_task_id subTaskId,
+            error_appearance errorAppearance,
+            error_code errorCode,
+            flow_encode flowEncode,
+            flow_tree_json flowTreeJson
+        from
+            t_build_flow tbf where tbf.sub_task_id = #{subTaskId}
+    </select>
 </mapper>

+ 125 - 0
sql/update20230523.sql

@@ -1,5 +1,84 @@
 use kgraph;
 
+DROP TABLE
+IF
+	EXISTS entity_class;
+CREATE TABLE entity_class (
+	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '实体类ID',
+	`name` VARCHAR ( 255 ) NULL COMMENT '实体类名称',
+	`desc` VARCHAR ( 1023 ) NULL COMMENT '实体类描述',
+	back_ground_color VARCHAR ( 15 ) NULL COMMENT '实体类背景颜色',
+	create_by VARCHAR ( 64 ) NULL COMMENT '创建者',
+	create_time datetime NULL COMMENT '创建时间',
+	update_by VARCHAR ( 64 ) NULL COMMENT '更新者',
+	update_time datetime NULL COMMENT '更新时间',
+PRIMARY KEY ( id )
+) ENGINE = INNODB auto_increment = 1 COMMENT = '实体类';
+
+DROP TABLE
+IF
+	EXISTS entity_class_relation;
+CREATE TABLE entity_class_relation (
+	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '实体类关系ID',
+	`name` VARCHAR ( 255 ) NULL COMMENT '实体类关系名称',
+	`desc` VARCHAR ( 1023 ) NULL COMMENT '实体类关系描述',
+	back_ground_color VARCHAR ( 15 ) NULL COMMENT '实体类关系背景颜色',
+	start_id BIGINT ( 20 ) COMMENT '起点实体类id',
+	end_id BIGINT ( 20 ) COMMENT '起点实体类id',
+	create_by VARCHAR ( 64 ) NULL COMMENT '创建者',
+	create_time datetime NULL COMMENT '创建时间',
+	update_by VARCHAR ( 64 ) NULL COMMENT '更新者',
+	update_time datetime NULL COMMENT '更新时间',
+PRIMARY KEY ( id )
+) ENGINE = INNODB auto_increment = 1 COMMENT = '实体类关系';
+
+DROP TABLE
+IF
+	EXISTS t_build_entity_relation;
+CREATE TABLE t_build_entity_relation (
+	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '序号',
+	sub_task_id BIGINT ( 20 ) COMMENT '子任务id',
+	sub_entity_class_id BIGINT ( 20 ) COMMENT '主体实体类id',
+	obj_entity_class_id BIGINT ( 20 ) COMMENT '客体实体类id',
+	entity_class_rel_id BIGINT ( 20 ) COMMENT '实体类关系id',
+	sub_entity VARCHAR ( 511 ) COMMENT '主体',
+	obj_entity VARCHAR ( 511 ) COMMENT '客体',
+	create_by VARCHAR ( 64 ) DEFAULT '' COMMENT '创建者',
+	create_time datetime COMMENT '创建时间',
+	update_by VARCHAR ( 64 ) DEFAULT '' COMMENT '更新者',
+	update_time datetime COMMENT '更新时间',
+PRIMARY KEY ( id )
+) ENGINE = INNODB auto_increment = 1 COMMENT = '实体构建表';
+
+DROP TABLE
+IF
+	EXISTS t_build_flow;
+CREATE TABLE t_build_flow (
+	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '序号',
+	error_code VARCHAR ( 64 ) DEFAULT '' COMMENT '故障编码',
+	flow_encode VARCHAR ( 1023 ) DEFAULT '' COMMENT '流程数据',
+	flow_tree_json TINYTEXT COMMENT '流程树json',
+	create_by VARCHAR ( 64 ) DEFAULT '' COMMENT '创建者',
+	create_time datetime COMMENT '创建时间',
+	update_by VARCHAR ( 64 ) DEFAULT '' COMMENT '更新者',
+	update_time datetime COMMENT '更新时间',
+PRIMARY KEY ( id )
+) ENGINE = INNODB COMMENT = '构建流程';
+
+DROP TABLE
+IF
+	EXISTS t_question_record;
+CREATE TABLE t_question_record (
+	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '序号',
+	question VARCHAR ( 255 ) DEFAULT '' COMMENT '问题',
+	result VARCHAR ( 511 ) DEFAULT '' COMMENT '结果',
+	create_by VARCHAR ( 64 ) DEFAULT '' COMMENT '创建者',
+	create_time datetime COMMENT '创建时间',
+	update_by VARCHAR ( 64 ) DEFAULT '' COMMENT '更新者',
+	update_time datetime COMMENT '更新时间',
+PRIMARY KEY ( id )
+) ENGINE = INNODB COMMENT = '问答查询记录';
+
 -- 菜单 SQL
 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('实体类', '2066', '1', 'class', 'neo4j/class/index', 1, 0, 'C', '0', '0', 'neo4j:class:list', '#', 'admin', sysdate(), '', null, '实体类菜单');
@@ -46,4 +125,50 @@ values('实体类关系删除', @parentId, '4',  '#', '', 1, 0, 'F', '0', '0', '
 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', 'neo4j:class_relation:export',       '#', 'admin', sysdate(), '', null, '');
 
+-- 菜单 SQL
+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('构建流程', '2066', '1', 'flow', 'suport/flow/index', 1, 0, 'C', '0', '0', 'suport:flow:list', '#', 'admin', sysdate(), '', null, '构建流程菜单');
+
+-- 按钮父菜单ID
+SELECT @parentId := LAST_INSERT_ID();
+
+-- 菜单 SQL
+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('检查点管理', '2066', '1', 'piont', 'suport/piont/index', 1, 0, 'C', '0', '0', 'suport:piont:list', '#', 'admin', sysdate(), '', null, '检查点管理菜单');
+
+-- 按钮父菜单ID
+SELECT @parentId := LAST_INSERT_ID();
+
+-- 按钮 SQL
+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, '1',  '#', '', 1, 0, 'F', '0', '0', 'suport:piont:query',        '#', 'admin', sysdate(), '', null, '');
+
+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, '2',  '#', '', 1, 0, 'F', '0', '0', 'suport:piont:add',          '#', 'admin', sysdate(), '', null, '');
+
+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, '3',  '#', '', 1, 0, 'F', '0', '0', 'suport:piont:edit',         '#', 'admin', sysdate(), '', null, '');
+
+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, '4',  '#', '', 1, 0, 'F', '0', '0', 'suport:piont:remove',       '#', 'admin', sysdate(), '', null, '');
+
+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', 'suport:piont:export',       '#', 'admin', sysdate(), '', null, '');
+
+---- 按钮 SQL
+--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, '1',  '#', '', 1, 0, 'F', '0', '0', 'suport:flow:query',        '#', 'admin', sysdate(), '', null, '');
+--
+--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, '2',  '#', '', 1, 0, 'F', '0', '0', 'suport:flow:add',          '#', 'admin', sysdate(), '', null, '');
+--
+--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, '3',  '#', '', 1, 0, 'F', '0', '0', 'suport:flow:edit',         '#', 'admin', sysdate(), '', null, '');
+--
+--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, '4',  '#', '', 1, 0, 'F', '0', '0', 'suport:flow:remove',       '#', 'admin', sysdate(), '', null, '');
+--
+--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', 'suport:flow:export',       '#', 'admin', sysdate(), '', null, '');
+
 commit;

+ 78 - 0
sql/update20230524.sql

@@ -0,0 +1,78 @@
+DROP TABLE
+IF
+	EXISTS entity_class;
+CREATE TABLE entity_class (
+	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '实体类ID',
+	`name` VARCHAR ( 255 ) NULL COMMENT '实体类名称',
+	`desc` VARCHAR ( 1023 ) NULL COMMENT '实体类描述',
+	back_ground_color VARCHAR ( 15 ) NULL COMMENT '实体类背景颜色',
+	create_by VARCHAR ( 64 ) NULL COMMENT '创建者',
+	create_time datetime NULL COMMENT '创建时间',
+	update_by VARCHAR ( 64 ) NULL COMMENT '更新者',
+	update_time datetime NULL COMMENT '更新时间',
+PRIMARY KEY ( id )
+) ENGINE = INNODB auto_increment = 1 COMMENT = '实体类';
+
+DROP TABLE
+IF
+	EXISTS entity_class_relation;
+CREATE TABLE entity_class_relation (
+	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '实体类关系ID',
+	`name` VARCHAR ( 255 ) NULL COMMENT '实体类关系名称',
+	`desc` VARCHAR ( 1023 ) NULL COMMENT '实体类关系描述',
+	back_ground_color VARCHAR ( 15 ) NULL COMMENT '实体类关系背景颜色',
+	start_id BIGINT ( 20 ) COMMENT '起点实体类id',
+	end_id BIGINT ( 20 ) COMMENT '起点实体类id',
+	create_by VARCHAR ( 64 ) NULL COMMENT '创建者',
+	create_time datetime NULL COMMENT '创建时间',
+	update_by VARCHAR ( 64 ) NULL COMMENT '更新者',
+	update_time datetime NULL COMMENT '更新时间',
+PRIMARY KEY ( id )
+) ENGINE = INNODB auto_increment = 1 COMMENT = '实体类关系';
+
+DROP TABLE
+IF
+	EXISTS t_build_entity_relation;
+CREATE TABLE t_build_entity_relation (
+	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '序号',
+	sub_task_id BIGINT ( 20 ) COMMENT '子任务id',
+	sub_entity_class_id BIGINT ( 20 ) COMMENT '主体实体类id',
+	obj_entity_class_id BIGINT ( 20 ) COMMENT '客体实体类id',
+	entity_class_rel_id BIGINT ( 20 ) COMMENT '实体类关系id',
+	sub_entity VARCHAR ( 511 ) COMMENT '主体',
+	obj_entity VARCHAR ( 511 ) COMMENT '客体',
+	create_by VARCHAR ( 64 ) DEFAULT '' COMMENT '创建者',
+	create_time datetime COMMENT '创建时间',
+	update_by VARCHAR ( 64 ) DEFAULT '' COMMENT '更新者',
+	update_time datetime COMMENT '更新时间',
+PRIMARY KEY ( id )
+) ENGINE = INNODB auto_increment = 1 COMMENT = '实体构建表';
+
+DROP TABLE
+IF
+	EXISTS t_build_flow;
+CREATE TABLE t_build_flow (
+	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '序号',
+	error_code VARCHAR ( 64 ) DEFAULT '' COMMENT '故障编码',
+	flow_encode VARCHAR ( 1023 ) DEFAULT '' COMMENT '流程数据',
+	flow_tree_json TINYTEXT COMMENT '流程树json',
+	create_by VARCHAR ( 64 ) DEFAULT '' COMMENT '创建者',
+	create_time datetime COMMENT '创建时间',
+	update_by VARCHAR ( 64 ) DEFAULT '' COMMENT '更新者',
+	update_time datetime COMMENT '更新时间',
+PRIMARY KEY ( id )
+) ENGINE = INNODB COMMENT = '构建流程';
+
+DROP TABLE
+IF
+	EXISTS t_question_record;
+CREATE TABLE t_question_record (
+	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '序号',
+	question VARCHAR ( 255 ) DEFAULT '' COMMENT '问题',
+	result VARCHAR ( 511 ) DEFAULT '' COMMENT '结果',
+	create_by VARCHAR ( 64 ) DEFAULT '' COMMENT '创建者',
+	create_time datetime COMMENT '创建时间',
+	update_by VARCHAR ( 64 ) DEFAULT '' COMMENT '更新者',
+	update_time datetime COMMENT '更新时间',
+PRIMARY KEY ( id )
+) ENGINE = INNODB COMMENT = '问答查询记录';