allen il y a 2 ans
Parent
commit
25db84df5c
29 fichiers modifiés avec 1005 ajouts et 21 suppressions
  1. 1 0
      kgraph-admin/src/main/java/com/kgraph/KgraphApplication.java
  2. 6 2
      kgraph-admin/src/main/java/com/kgraph/web/controller/common/CommonController.java
  3. 1 1
      kgraph-common/src/main/java/com/kgraph/common/config/KgraphConfig.java
  4. 31 0
      kgraph-common/src/main/java/com/kgraph/common/core/domain/BaseResponse.java
  5. 11 0
      kgraph-common/src/main/java/com/kgraph/common/utils/file/FileUtils.java
  6. 2 0
      kgraph-framework/src/main/java/com/kgraph/framework/config/SecurityConfig.java
  7. 7 0
      kgraph-graph/src/main/java/com/kgraph/graph/knowledge/controller/mock/MockController.java
  8. 67 0
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/DTO/DocInfo.java
  9. 13 0
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/DTO/KgDocDTO.java
  10. 3 0
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/controller/KgController.java
  11. 2 0
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/seavice/IKgService.java
  12. 2 0
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/seavice/impl/KgServiceImpl.java
  13. 27 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/ExtractKnowledgeSubTaskController.java
  14. 105 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/TripletInfoController.java
  15. 37 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/UploadManageController.java
  16. 2 1
      kgraph-graph/src/main/java/com/kgraph/graph/suport/domain/ExtractKnowledgeSubTask.java
  17. 13 2
      kgraph-graph/src/main/java/com/kgraph/graph/suport/domain/ExtractKnowledgeSubTaskDetail.java
  18. 107 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/domain/TripletInfo.java
  19. 10 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/mapper/ExtractKnowledgeSubTaskMapper.java
  20. 1 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/mapper/ExtractKnowledgeTaskMapper.java
  21. 65 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/mapper/TripletInfoMapper.java
  22. 8 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/service/IExtractKnowledgeSubTaskService.java
  23. 67 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/service/ITripletInfoService.java
  24. 101 6
      kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/ExtractKnowledgeSubTaskServiceImpl.java
  25. 107 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/TripletInfoServiceImpl.java
  26. 56 0
      kgraph-graph/src/main/resources/mapper/extract/ExtractKnowledgeSubTaskMapper.xml
  27. 4 4
      kgraph-graph/src/main/resources/mapper/extract/ExtractKnowledgeTaskMapper.xml
  28. 90 0
      kgraph-graph/src/main/resources/mapper/extract/TripletInfoMapper.xml
  29. 59 5
      sql/system.sql

+ 1 - 0
kgraph-admin/src/main/java/com/kgraph/KgraphApplication.java

@@ -3,6 +3,7 @@ package com.kgraph;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
 
 /**
  * 启动程序

+ 6 - 2
kgraph-admin/src/main/java/com/kgraph/web/controller/common/CommonController.java

@@ -52,8 +52,12 @@ public class CommonController
             {
                 throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
             }
-            String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
-            String filePath = KgraphConfig.getDownloadPath() + fileName;
+            String realFileName = FileUtils.getFileNameByPath(fileName);
+
+            if(fileName.startsWith("/profile/upload")){
+                fileName = fileName.substring(15);
+            }
+            String filePath = KgraphConfig.getUploadPath() + fileName;
 
             response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
             FileUtils.setAttachmentResponseHeader(response, realFileName);

+ 1 - 1
kgraph-common/src/main/java/com/kgraph/common/config/KgraphConfig.java

@@ -121,7 +121,7 @@ public class KgraphConfig
      */
     public static String getDownloadPath()
     {
-        return getProfile() + "/download/";
+        return getProfile() + "/download";
     }
 
     /**

+ 31 - 0
kgraph-common/src/main/java/com/kgraph/common/core/domain/BaseResponse.java

@@ -0,0 +1,31 @@
+package com.kgraph.common.core.domain;
+
+import java.io.Serializable;
+
+/**
+ * 响应基础类
+ * 
+ * @author Allen
+ */
+public class BaseResponse implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+    private Integer code;
+    private String msg;
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+}

+ 11 - 0
kgraph-common/src/main/java/com/kgraph/common/utils/file/FileUtils.java

@@ -291,4 +291,15 @@ public class FileUtils
         return baseName;
     }
 
+    public static String getRealFileNameByPath(String filePath) {
+        String[] filePaths = filePath.split("/");
+        String fileName = filePaths[filePaths.length-1];
+        String suffix = fileName.substring(fileName.indexOf("."));
+        return fileName.substring(0, fileName.indexOf("_")) + suffix;
+    }
+
+    public static String getFileNameByPath(String filePath) {
+        String[] filePaths = filePath.split("/");
+        return filePaths[filePaths.length-1];
+    }
 }

+ 2 - 0
kgraph-framework/src/main/java/com/kgraph/framework/config/SecurityConfig.java

@@ -118,6 +118,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 // TODO 以后需要删除 知识图谱部分可以访问
                 .antMatchers("/**/*.ttf","/**/*.woff").permitAll()
                 .antMatchers("/entcls/tree","/knowledge/class/entcls/tree").permitAll()
+                // TODO 给算法提供的文件下载
+                .antMatchers("/upload/uploadManage/download", "/extractKnowledge","/extract/subTask/saveKnowledge").permitAll()
                 // 除上面外的所有请求全部需要鉴权认证
                 .anyRequest().authenticated()
                 .and()

+ 7 - 0
kgraph-graph/src/main/java/com/kgraph/graph/knowledge/controller/mock/MockController.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.kgraph.common.core.controller.BaseController;
 import com.kgraph.graph.knowledge.domain.EntityRelation;
+import com.kgraph.graph.neo4j.DTO.DocInfo;
 import org.springframework.web.bind.annotation.*;
 
 import java.io.File;
@@ -198,4 +199,10 @@ public class MockController extends BaseController {
             return JSONObject.parseObject(s);
         }
     }
+
+    @PostMapping("/extractKnowledge")
+    public void extractKnowledge(@RequestBody DocInfo docInfo)
+    {
+        logger.info(docInfo.toString());
+    }
 }

+ 67 - 0
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/DTO/DocInfo.java

@@ -0,0 +1,67 @@
+package com.kgraph.graph.neo4j.DTO;
+
+import com.kgraph.common.utils.StringUtils;
+import com.kgraph.common.utils.file.FileUtils;
+
+public class DocInfo {
+
+    private Long docId;
+    private Long taskId;
+    private Long subTaskId;
+    private String docName;
+    private String docAddress;
+
+    public Long getDocId() {
+        return docId;
+    }
+
+    public void setDocId(Long docId) {
+        this.docId = docId;
+    }
+
+    public Long getTaskId() {
+        return taskId;
+    }
+
+    public void setTaskId(Long taskId) {
+        this.taskId = taskId;
+    }
+
+    public Long getSubTaskId() {
+        return subTaskId;
+    }
+
+    public void setSubTaskId(Long subTaskId) {
+        this.subTaskId = subTaskId;
+    }
+
+    public String getDocName() {
+        if(StringUtils.isEmpty(docName) && StringUtils.isNotEmpty(docAddress)){
+            return FileUtils.getFileNameByPath(docAddress);
+        }
+        return docName;
+    }
+
+    public void setDocName(String docName) {
+        this.docName = docName;
+    }
+
+    public String getDocAddress() {
+        return docAddress;
+    }
+
+    public void setDocAddress(String docAddress) {
+        this.docAddress = docAddress;
+    }
+
+    @Override
+    public String toString() {
+        return "DocInfo{" +
+                "docId=" + docId +
+                ", taskId=" + taskId +
+                ", subTaskId=" + subTaskId +
+                ", docName='" + docName + '\'' +
+                ", docAddress='" + docAddress + '\'' +
+                '}';
+    }
+}

+ 13 - 0
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/DTO/KgDocDTO.java

@@ -0,0 +1,13 @@
+package com.kgraph.graph.neo4j.DTO;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class KgDocDTO {
+    private DocInfo docInfo;
+    private List<KgDTO> knowledgeList;
+    private Integer code;
+    private String msg;
+}

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

@@ -3,8 +3,10 @@ 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.DTO.KgDocDTO;
 import com.kgraph.graph.neo4j.seavice.IKgService;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -35,4 +37,5 @@ public class KgController extends BaseController {
     public AjaxResult getAllRelationList(){
         return AjaxResult.success(kgService.getAllRelationList());
     }
+
 }

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

@@ -1,6 +1,7 @@
 package com.kgraph.graph.neo4j.seavice;
 
 import com.kgraph.graph.neo4j.DTO.KgDTO;
+import com.kgraph.graph.neo4j.DTO.KgDocDTO;
 
 import java.util.List;
 
@@ -10,4 +11,5 @@ public interface IKgService {
     Iterable getAllEntityList();
 
     Iterable getAllRelationList();
+
 }

+ 2 - 0
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/seavice/impl/KgServiceImpl.java

@@ -1,6 +1,7 @@
 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;
@@ -8,6 +9,7 @@ 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;

+ 27 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/ExtractKnowledgeSubTaskController.java

@@ -2,6 +2,9 @@ package com.kgraph.graph.suport.controller;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
+import com.kgraph.graph.neo4j.DTO.KgDocDTO;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -101,4 +104,28 @@ public class ExtractKnowledgeSubTaskController extends BaseController
     {
         return toAjax(extractKnowledgeSubTaskService.deleteExtractKnowledgeSubTaskByIds(ids));
     }
+
+    @PostMapping("/saveKnowledge")
+    public AjaxResult saveKnowledge(@RequestBody KgDocDTO kgDocDTO){
+        if(kgDocDTO == null){
+            return AjaxResult.error("无效payload");
+        }
+
+        if(kgDocDTO.getDocInfo() == null || kgDocDTO.getDocInfo().getDocId() == null){
+            return AjaxResult.error("文件信息不能为null");
+        }
+
+        if(CollectionUtils.isEmpty(kgDocDTO.getKnowledgeList())){
+            return AjaxResult.error("没有数据");
+        }
+        extractKnowledgeSubTaskService.saveKnowledge(kgDocDTO);
+        return AjaxResult.success();
+    }
+
+    @GetMapping("/approve/{id}/{status}")
+    public AjaxResult approveSubTask(@PathVariable("id") Long id, @PathVariable("status") String status){
+        extractKnowledgeSubTaskService.approveSubTask(id, status);
+        return success();
+    }
+
 }

+ 105 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/TripletInfoController.java

@@ -0,0 +1,105 @@
+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.TripletInfo;
+import com.kgraph.graph.suport.service.ITripletInfoService;
+import com.kgraph.common.utils.poi.ExcelUtil;;
+import com.kgraph.common.core.page.TableDataInfo;;
+
+/**
+ * 三元组信息Controller
+ * 
+ * @author Allen
+ * @date 2023-03-23
+ */
+@RestController
+@RequestMapping("/extract/info")
+public class TripletInfoController extends BaseController
+{
+    @Autowired
+    private ITripletInfoService tripletInfoService;
+
+    /**
+     * 查询三元组信息列表
+     */
+    @PreAuthorize("@ss.hasPermi('extract:info:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TripletInfo tripletInfo)
+    {
+        startPage();
+        List<TripletInfo> list = tripletInfoService.selectTripletInfoList(tripletInfo);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出三元组信息列表
+     */
+    @PreAuthorize("@ss.hasPermi('extract:info:export')")
+    @Log(title = "三元组信息", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, TripletInfo tripletInfo)
+    {
+        List<TripletInfo> list = tripletInfoService.selectTripletInfoList(tripletInfo);
+        ExcelUtil<TripletInfo> util = new ExcelUtil<TripletInfo>(TripletInfo.class);
+        util.exportExcel(response, list, "三元组信息数据");
+    }
+
+    /**
+     * 获取三元组信息详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('extract:info:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(tripletInfoService.selectTripletInfoById(id));
+    }
+
+    /**
+     * 新增三元组信息
+     */
+    @PreAuthorize("@ss.hasPermi('extract:info:add')")
+    @Log(title = "三元组信息", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TripletInfo tripletInfo)
+    {
+        return toAjax(tripletInfoService.insertTripletInfo(tripletInfo));
+    }
+
+    /**
+     * 修改三元组信息
+     */
+    @PreAuthorize("@ss.hasPermi('extract:info:edit')")
+    @Log(title = "三元组信息", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TripletInfo tripletInfo)
+    {
+        return toAjax(tripletInfoService.updateTripletInfo(tripletInfo));
+    }
+
+    /**
+     * 删除三元组信息
+     */
+    @PreAuthorize("@ss.hasPermi('extract:info:remove')")
+    @Log(title = "三元组信息", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(tripletInfoService.deleteTripletInfoByIds(ids));
+    }
+
+}

+ 37 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/UploadManageController.java

@@ -1,7 +1,13 @@
 package com.kgraph.graph.suport.controller;
 
 import java.util.List;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+
+import com.kgraph.common.config.KgraphConfig;
+import com.kgraph.common.utils.StringUtils;
+import com.kgraph.common.utils.file.FileUtils;
+import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -104,4 +110,35 @@ public class UploadManageController extends BaseController
     public AjaxResult getOptionByName(@RequestParam(name = "name", required = false) String name) {
         return success(uploadManageService.getOptionByName(name));
     }
+
+    /**
+     * 通用下载请求
+     *
+     * @param filePath 文件路径
+     */
+    @GetMapping("/download")
+    public void fileDownload(String filePath, HttpServletResponse response, HttpServletRequest request)
+    {
+        try
+        {
+            if (!FileUtils.checkAllowDownload(filePath))
+            {
+                throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", filePath));
+            }
+            String realFileName = FileUtils.getFileNameByPath(filePath);
+
+            if(filePath.startsWith("/profile/upload")){
+                filePath = filePath.substring(15);
+            }
+            String filePathFinal = KgraphConfig.getUploadPath() + filePath;
+
+            response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
+            FileUtils.setAttachmentResponseHeader(response, realFileName);
+            FileUtils.writeBytes(filePathFinal, response.getOutputStream());
+        }
+        catch (Exception e)
+        {
+            logger.error("下载文件失败", e);
+        }
+    }
 }

+ 2 - 1
kgraph-graph/src/main/java/com/kgraph/graph/suport/domain/ExtractKnowledgeSubTask.java

@@ -22,6 +22,7 @@ public class ExtractKnowledgeSubTask extends BaseEntity
     public static final String REVIEWED = "2";
     public static final String DOWN = "3";
     public static final String FAILED = "4";
+    public static final String REJECTED = "5";
 
     /** 编号 */
     private Long id;
@@ -42,7 +43,7 @@ public class ExtractKnowledgeSubTask extends BaseEntity
     private String log;
 
     /** 完成时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Excel(name = "完成时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date completedDate;
 

+ 13 - 2
kgraph-graph/src/main/java/com/kgraph/graph/suport/domain/ExtractKnowledgeSubTaskDetail.java

@@ -1,9 +1,12 @@
 package com.kgraph.graph.suport.domain;
 
+import com.kgraph.common.annotation.Excel;
+import com.kgraph.common.core.domain.BaseEntity;
+import com.kgraph.graph.neo4j.DTO.KgDTO;
 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_extract_knowledge_sub_task_detail
@@ -94,4 +97,12 @@ public class ExtractKnowledgeSubTaskDetail extends BaseEntity
             .append("updateTime", getUpdateTime())
             .toString();
     }
+
+    public static ExtractKnowledgeSubTaskDetail buildByKgDocDTO(KgDTO kgDTO){
+        ExtractKnowledgeSubTaskDetail detail = new ExtractKnowledgeSubTaskDetail();
+        detail.setStart(kgDTO.getStart());
+        detail.setEnd(kgDTO.getEnd());
+        detail.setRelation(kgDTO.getRelation());
+        return detail;
+    }
 }

+ 107 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/domain/TripletInfo.java

@@ -0,0 +1,107 @@
+package com.kgraph.graph.suport.domain;
+
+import com.kgraph.graph.neo4j.DTO.KgDTO;
+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_triplet_info
+ * 
+ * @author Allen
+ * @date 2023-03-23
+ */
+public class TripletInfo extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 编号 */
+    private Long id;
+
+    /** 子任务id */
+    @Excel(name = "子任务id")
+    private Long subTaskId;
+
+    /** 起点实体 */
+    @Excel(name = "起点实体")
+    private String start;
+
+    /** 终点实体 */
+    @Excel(name = "终点实体")
+    private String end;
+
+    /** 关系 */
+    @Excel(name = "关系")
+    private String relation;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+    public void setSubTaskId(Long subTaskId) 
+    {
+        this.subTaskId = subTaskId;
+    }
+
+    public Long getSubTaskId() 
+    {
+        return subTaskId;
+    }
+    public void setStart(String start) 
+    {
+        this.start = start;
+    }
+
+    public String getStart() 
+    {
+        return start;
+    }
+    public void setEnd(String end) 
+    {
+        this.end = end;
+    }
+
+    public String getEnd() 
+    {
+        return end;
+    }
+    public void setRelation(String relation) 
+    {
+        this.relation = relation;
+    }
+
+    public String getRelation() 
+    {
+        return relation;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("subTaskId", getSubTaskId())
+            .append("start", getStart())
+            .append("end", getEnd())
+            .append("relation", getRelation())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .toString();
+    }
+
+    public static TripletInfo buildByKgDocDTO(KgDTO kgDTO, Long subTaskId){
+        TripletInfo tripletInfo = new TripletInfo();
+        tripletInfo.setSubTaskId(subTaskId);
+        tripletInfo.setStart(kgDTO.getStart());
+        tripletInfo.setEnd(kgDTO.getEnd());
+        tripletInfo.setRelation(kgDTO.getRelation());
+        return tripletInfo;
+    }
+}

+ 10 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/mapper/ExtractKnowledgeSubTaskMapper.java

@@ -1,7 +1,11 @@
 package com.kgraph.graph.suport.mapper;
 
+import java.util.Date;
 import java.util.List;
+
+import com.kgraph.graph.neo4j.DTO.DocInfo;
 import com.kgraph.graph.suport.domain.ExtractKnowledgeSubTask;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 知识抽取子任务Mapper接口
@@ -58,4 +62,10 @@ public interface ExtractKnowledgeSubTaskMapper
      * @return 结果
      */
     public int deleteExtractKnowledgeSubTaskByIds(Long[] ids);
+
+    public DocInfo getDocInfoBySubtask(Long subTaskId);
+
+    public int updateSubTaskStatusById(@Param("subTaskId") Long subTaskId, @Param("status") String status, @Param("msg") String msg, @Param("completedDate") Date completedDate);
+
+    public int updateTaskStatusBySubTaskId(@Param("subTaskId") Long subTaskId);
 }

+ 1 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/mapper/ExtractKnowledgeTaskMapper.java

@@ -58,4 +58,5 @@ public interface ExtractKnowledgeTaskMapper
      * @return 结果
      */
     public int deleteExtractKnowledgeTaskByIds(Long[] ids);
+
 }

+ 65 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/mapper/TripletInfoMapper.java

@@ -0,0 +1,65 @@
+package com.kgraph.graph.suport.mapper;
+
+import java.util.List;
+
+import com.kgraph.graph.neo4j.DTO.KgDTO;
+import com.kgraph.graph.suport.domain.TripletInfo;
+
+/**
+ * 三元组信息Mapper接口
+ * 
+ * @author Allen
+ * @date 2023-03-23
+ */
+public interface TripletInfoMapper 
+{
+    /**
+     * 查询三元组信息
+     * 
+     * @param id 三元组信息主键
+     * @return 三元组信息
+     */
+    public TripletInfo selectTripletInfoById(Long id);
+
+    /**
+     * 查询三元组信息列表
+     * 
+     * @param tripletInfo 三元组信息
+     * @return 三元组信息集合
+     */
+    public List<TripletInfo> selectTripletInfoList(TripletInfo tripletInfo);
+
+    /**
+     * 新增三元组信息
+     * 
+     * @param tripletInfo 三元组信息
+     * @return 结果
+     */
+    public int insertTripletInfo(TripletInfo tripletInfo);
+
+    /**
+     * 修改三元组信息
+     * 
+     * @param tripletInfo 三元组信息
+     * @return 结果
+     */
+    public int updateTripletInfo(TripletInfo tripletInfo);
+
+    /**
+     * 删除三元组信息
+     * 
+     * @param id 三元组信息主键
+     * @return 结果
+     */
+    public int deleteTripletInfoById(Long id);
+
+    /**
+     * 批量删除三元组信息
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTripletInfoByIds(Long[] ids);
+
+    List<KgDTO> getKgDTO(Long subTaskId);
+}

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

@@ -1,6 +1,8 @@
 package com.kgraph.graph.suport.service;
 
 import java.util.List;
+
+import com.kgraph.graph.neo4j.DTO.KgDocDTO;
 import com.kgraph.graph.suport.domain.ExtractKnowledgeSubTask;
 import com.kgraph.graph.suport.domain.ExtractKnowledgeTask;
 
@@ -65,4 +67,10 @@ public interface IExtractKnowledgeSubTaskService
      * @param extractKnowledgeTask
      */
     void createSubTaskByTask(ExtractKnowledgeTask extractKnowledgeTask);
+
+    void saveKnowledge(KgDocDTO kgDocDTO);
+
+    void approveSubTask(Long id, String status);
+
+    void updateTaskStatusBySubTaskId(Long subTaskId);
 }

+ 67 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/service/ITripletInfoService.java

@@ -0,0 +1,67 @@
+package com.kgraph.graph.suport.service;
+
+import java.util.List;
+
+import com.kgraph.graph.neo4j.DTO.KgDTO;
+import com.kgraph.graph.suport.domain.TripletInfo;
+
+/**
+ * 三元组信息Service接口
+ * 
+ * @author Allen
+ * @date 2023-03-23
+ */
+public interface ITripletInfoService 
+{
+    /**
+     * 查询三元组信息
+     * 
+     * @param id 三元组信息主键
+     * @return 三元组信息
+     */
+    public TripletInfo selectTripletInfoById(Long id);
+
+    /**
+     * 查询三元组信息列表
+     * 
+     * @param tripletInfo 三元组信息
+     * @return 三元组信息集合
+     */
+    public List<TripletInfo> selectTripletInfoList(TripletInfo tripletInfo);
+
+    /**
+     * 新增三元组信息
+     * 
+     * @param tripletInfo 三元组信息
+     * @return 结果
+     */
+    public int insertTripletInfo(TripletInfo tripletInfo);
+
+    /**
+     * 修改三元组信息
+     * 
+     * @param tripletInfo 三元组信息
+     * @return 结果
+     */
+    public int updateTripletInfo(TripletInfo tripletInfo);
+
+    /**
+     * 批量删除三元组信息
+     * 
+     * @param ids 需要删除的三元组信息主键集合
+     * @return 结果
+     */
+    public int deleteTripletInfoByIds(Long[] ids);
+
+    /**
+     * 删除三元组信息信息
+     * 
+     * @param id 三元组信息主键
+     * @return 结果
+     */
+    public int deleteTripletInfoById(Long id);
+
+    void createList(List<TripletInfo> tripletInfoList);
+
+    List<KgDTO> getKgDTO(Long subTaskId);
+}

+ 101 - 6
kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/ExtractKnowledgeSubTaskServiceImpl.java

@@ -1,13 +1,27 @@
 package com.kgraph.graph.suport.service.impl;
 
-import java.util.List;
-import com.kgraph.common.utils.DateUtils;;
+import com.kgraph.common.core.domain.BaseResponse;
+import com.kgraph.common.utils.DateUtils;
+import com.kgraph.graph.neo4j.DTO.DocInfo;
+import com.kgraph.graph.neo4j.DTO.KgDTO;
+import com.kgraph.graph.neo4j.DTO.KgDocDTO;
+import com.kgraph.graph.neo4j.seavice.IKgService;
+import com.kgraph.graph.suport.domain.ExtractKnowledgeSubTask;
 import com.kgraph.graph.suport.domain.ExtractKnowledgeTask;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
+import com.kgraph.graph.suport.domain.TripletInfo;
 import com.kgraph.graph.suport.mapper.ExtractKnowledgeSubTaskMapper;
-import com.kgraph.graph.suport.domain.ExtractKnowledgeSubTask;
 import com.kgraph.graph.suport.service.IExtractKnowledgeSubTaskService;
+import com.kgraph.graph.suport.service.ITripletInfoService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
 
 /**
  * 知识抽取子任务Service业务层处理
@@ -18,9 +32,17 @@ import com.kgraph.graph.suport.service.IExtractKnowledgeSubTaskService;
 @Service
 public class ExtractKnowledgeSubTaskServiceImpl implements IExtractKnowledgeSubTaskService 
 {
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
     @Autowired
     private ExtractKnowledgeSubTaskMapper extractKnowledgeSubTaskMapper;
 
+    @Autowired
+    private ITripletInfoService tripletInfoService;
+
+    @Autowired
+    private IKgService kgService;
     /**
      * 查询知识抽取子任务
      * 
@@ -101,15 +123,88 @@ public class ExtractKnowledgeSubTaskServiceImpl implements IExtractKnowledgeSubT
         String[] selectSubTasks = extractKnowledgeTask.getSelectSubTask().split(",");
         Long taskId = extractKnowledgeTask.getId();
         String createBy = extractKnowledgeTask.getCreateBy();
+        List<ExtractKnowledgeSubTask> extractKnowledgeSubTaskList = new ArrayList<>(selectSubTasks.length);
         // 根据子任务创建任务
         for (String subTask: selectSubTasks) {
             ExtractKnowledgeSubTask extractKnowledgeSubTask = new ExtractKnowledgeSubTask();
-
             extractKnowledgeSubTask.setTaskId(taskId);
             extractKnowledgeSubTask.setType(subTask);
             extractKnowledgeSubTask.setStatus(ExtractKnowledgeSubTask.PROCESSING);
             extractKnowledgeSubTask.setCreateBy(createBy);
+            extractKnowledgeSubTask.setCreateTime(new Date());
             extractKnowledgeSubTaskMapper.insertExtractKnowledgeSubTask(extractKnowledgeSubTask);
+            extractKnowledgeSubTaskList.add(extractKnowledgeSubTask);
+        }
+        // TODO Allen 暂时关闭推送数据
+//        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{
+            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);
+                }
+            });
+        }catch (Exception e){
+            logger.error("算法请求报错",e);
         }
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void saveKnowledge(KgDocDTO kgDocDTO) {
+        switch (kgDocDTO.getCode()) {
+            case 200:
+                processSuccess(kgDocDTO);
+                break;
+            default:
+                processFail(kgDocDTO);
+        }
+    }
+
+    @Override
+    @Transactional
+    public void approveSubTask(Long id, String status) {
+        extractKnowledgeSubTaskMapper.updateSubTaskStatusById(id, status,null, null);
+        if(ExtractKnowledgeSubTask.REVIEWED.equals(status)){
+            List<KgDTO> kgDTOList = tripletInfoService.getKgDTO(id);
+            kgService.create(kgDTOList);
+        }
+        extractKnowledgeSubTaskMapper.updateTaskStatusBySubTaskId(id);
+    }
+
+    @Override
+    public void updateTaskStatusBySubTaskId(Long subTaskId) {
+        extractKnowledgeSubTaskMapper.updateTaskStatusBySubTaskId(subTaskId);
+    }
+
+    private void processFail(KgDocDTO kgDocDTO) {
+        updateSubTaskStatusById(kgDocDTO.getDocInfo().getSubTaskId(), ExtractKnowledgeSubTask.FAILED, kgDocDTO.getMsg());
+    }
+
+    private void processSuccess(KgDocDTO kgDocDTO) {
+        // 更新状态
+        List<TripletInfo> tripletInfoList = new ArrayList<>(kgDocDTO.getKnowledgeList().size());
+        Long subTaskId = kgDocDTO.getDocInfo().getSubTaskId();
+        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());
+    }
+
+    public void updateSubTaskStatusById(Long subTaskId, String status, String msg){
+        extractKnowledgeSubTaskMapper.updateSubTaskStatusById(subTaskId, status, msg, new Date());
+        extractKnowledgeSubTaskMapper.updateTaskStatusBySubTaskId(subTaskId);
+    }
 }

+ 107 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/TripletInfoServiceImpl.java

@@ -0,0 +1,107 @@
+package com.kgraph.graph.suport.service.impl;
+
+import java.util.List;
+import com.kgraph.common.utils.DateUtils;;
+import com.kgraph.graph.neo4j.DTO.KgDTO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.kgraph.graph.suport.mapper.TripletInfoMapper;
+import com.kgraph.graph.suport.domain.TripletInfo;
+import com.kgraph.graph.suport.service.ITripletInfoService;
+
+/**
+ * 三元组信息Service业务层处理
+ * 
+ * @author Allen
+ * @date 2023-03-23
+ */
+@Service
+public class TripletInfoServiceImpl implements ITripletInfoService 
+{
+    @Autowired
+    private TripletInfoMapper tripletInfoMapper;
+
+    /**
+     * 查询三元组信息
+     * 
+     * @param id 三元组信息主键
+     * @return 三元组信息
+     */
+    @Override
+    public TripletInfo selectTripletInfoById(Long id)
+    {
+        return tripletInfoMapper.selectTripletInfoById(id);
+    }
+
+    /**
+     * 查询三元组信息列表
+     * 
+     * @param tripletInfo 三元组信息
+     * @return 三元组信息
+     */
+    @Override
+    public List<TripletInfo> selectTripletInfoList(TripletInfo tripletInfo)
+    {
+        return tripletInfoMapper.selectTripletInfoList(tripletInfo);
+    }
+
+    /**
+     * 新增三元组信息
+     * 
+     * @param tripletInfo 三元组信息
+     * @return 结果
+     */
+    @Override
+    public int insertTripletInfo(TripletInfo tripletInfo)
+    {
+        tripletInfo.setCreateTime(DateUtils.getNowDate());
+        return tripletInfoMapper.insertTripletInfo(tripletInfo);
+    }
+
+    /**
+     * 修改三元组信息
+     * 
+     * @param tripletInfo 三元组信息
+     * @return 结果
+     */
+    @Override
+    public int updateTripletInfo(TripletInfo tripletInfo)
+    {
+        tripletInfo.setUpdateTime(DateUtils.getNowDate());
+        return tripletInfoMapper.updateTripletInfo(tripletInfo);
+    }
+
+    /**
+     * 批量删除三元组信息
+     * 
+     * @param ids 需要删除的三元组信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTripletInfoByIds(Long[] ids)
+    {
+        return tripletInfoMapper.deleteTripletInfoByIds(ids);
+    }
+
+    /**
+     * 删除三元组信息信息
+     * 
+     * @param id 三元组信息主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTripletInfoById(Long id)
+    {
+        return tripletInfoMapper.deleteTripletInfoById(id);
+    }
+
+    @Override
+    public void createList(List<TripletInfo> tripletInfoList) {
+        tripletInfoList.forEach(this::insertTripletInfo);
+    }
+
+    @Override
+    public List<KgDTO> getKgDTO(Long subTaskId) {
+        return tripletInfoMapper.getKgDTO(subTaskId);
+    }
+}

+ 56 - 0
kgraph-graph/src/main/resources/mapper/extract/ExtractKnowledgeSubTaskMapper.xml

@@ -32,6 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="completedDate != null "> and completed_date = #{completedDate}</if>
             <if test="costTime != null "> and cost_time = #{costTime}</if>
         </where>
+        ORDER BY create_time DESC
     </select>
     
     <select id="selectExtractKnowledgeSubTaskById" parameterType="Long" resultMap="ExtractKnowledgeSubTaskResult">
@@ -88,4 +89,59 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+    <select id="getDocInfoBySubtask" parameterType="Long" resultType="com.kgraph.graph.neo4j.DTO.DocInfo">
+        SELECT
+            ekt.upload_id docId,
+            ekst.task_id taskId,
+            ekst.id subTaskId,
+            um.`name` docName,
+            um.file_path docAddress
+        FROM
+            t_extract_knowledge_sub_task ekst,
+            t_extract_knowledge_task ekt,
+            t_upload_manage um
+        WHERE
+            ekst.task_id = ekt.id
+            AND ekt.upload_id = um.id
+            AND ekst.id = #{id}
+    </select>
+    <update id="updateSubTaskStatusById">
+        update t_extract_knowledge_sub_task SET status = #{status}, log = #{msg}
+        <if test="completedDate != null">
+        , completed_date = #{completedDate}, cost_time = TIMESTAMPDIFF(SECOND, create_time, #{completedDate})
+        </if>
+        WHERE id = #{subTaskId}
+    </update>
+    <update id="updateTaskStatusBySubTaskId">
+        UPDATE t_extract_knowledge_task ekt
+            SET STATUS = '1'
+        WHERE
+            1=1
+            AND
+                ekt.id = (SELECT task_id FROM t_extract_knowledge_sub_task ekst WHERE ekst.id = #{subTaskId})
+            AND
+                (SELECT count(*) FROM t_extract_knowledge_sub_task ekst WHERE ekst.id = #{subTaskId})
+                    =
+                (SELECT count(*) FROM t_extract_knowledge_sub_task ekst WHERE ekst.id = #{subTaskId} AND ekst.`status` = '1');
+        UPDATE t_extract_knowledge_task ekt
+            SET STATUS = '2'
+        WHERE
+            1=1
+            AND
+                ekt.id = (SELECT task_id FROM t_extract_knowledge_sub_task ekst WHERE ekst.id = #{subTaskId})
+            AND
+                (SELECT count(*) FROM t_extract_knowledge_sub_task ekst WHERE ekst.id = #{subTaskId})
+                    =
+                (SELECT count(*) FROM t_extract_knowledge_sub_task ekst WHERE ekst.id = #{subTaskId} AND ekst.`status` in ('2','5'));
+        UPDATE t_extract_knowledge_task ekt
+            SET STATUS = '3'
+        WHERE
+            1=1
+            AND
+                ekt.id = (SELECT task_id FROM t_extract_knowledge_sub_task ekst WHERE ekst.id = #{subTaskId})
+            AND
+                (SELECT count(*) FROM t_extract_knowledge_sub_task ekst WHERE ekst.id = #{subTaskId})
+                    =
+                (SELECT count(*) FROM t_extract_knowledge_sub_task ekst WHERE ekst.id = #{subTaskId} AND ekst.`status` in ('3','5'))
+    </update>
 </mapper>

+ 4 - 4
kgraph-graph/src/main/resources/mapper/extract/ExtractKnowledgeTaskMapper.xml

@@ -44,10 +44,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectExtractKnowledgeTaskList" parameterType="ExtractKnowledgeTask" resultMap="ExtractKnowledgeTaskResult">
         <include refid="selectExtractKnowledgeTaskVo2"/>
-        <if test="uploadId != null "> and upload_id = #{uploadId}</if>
-        <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
-        <if test="status != null  and status != ''"> and status = #{status}</if>
-        ORDER BY ekt.update_time DESC
+        <if test="uploadId != null "> and ekt.upload_id = #{uploadId}</if>
+        <if test="name != null  and name != ''"> and ekt.name like concat('%', #{name}, '%')</if>
+        <if test="status != null  and status != ''"> and ekt.status = #{status}</if>
+        ORDER BY ekt.create_time DESC
     </select>
     
     <select id="selectExtractKnowledgeTaskById" parameterType="Long" resultMap="ExtractKnowledgeTaskResult">

+ 90 - 0
kgraph-graph/src/main/resources/mapper/extract/TripletInfoMapper.xml

@@ -0,0 +1,90 @@
+<?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.TripletInfoMapper">
+    
+    <resultMap type="TripletInfo" id="TripletInfoResult">
+        <result property="id"    column="id"    />
+        <result property="subTaskId"    column="sub_task_id"    />
+        <result property="start"    column="start"    />
+        <result property="end"    column="end"    />
+        <result property="relation"    column="relation"    />
+        <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="selectTripletInfoVo">
+        select id, sub_task_id, start, end, relation, create_by, create_time, update_by, update_time from t_triplet_info
+    </sql>
+
+    <select id="selectTripletInfoList" parameterType="TripletInfo" resultMap="TripletInfoResult">
+        <include refid="selectTripletInfoVo"/>
+        <where>  
+            <if test="subTaskId != null "> and sub_task_id = #{subTaskId}</if>
+            <if test="start != null  and start != ''"> and start = #{start}</if>
+            <if test="end != null  and end != ''"> and end = #{end}</if>
+            <if test="relation != null  and relation != ''"> and relation = #{relation}</if>
+        </where>
+    </select>
+    
+    <select id="selectTripletInfoById" parameterType="Long" resultMap="TripletInfoResult">
+        <include refid="selectTripletInfoVo"/>
+        where id = #{id}
+    </select>
+        
+    <insert id="insertTripletInfo" parameterType="TripletInfo" useGeneratedKeys="true" keyProperty="id">
+        insert into t_triplet_info
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="subTaskId != null">sub_task_id,</if>
+            <if test="start != null">start,</if>
+            <if test="end != null">end,</if>
+            <if test="relation != null">relation,</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="subTaskId != null">#{subTaskId},</if>
+            <if test="start != null">#{start},</if>
+            <if test="end != null">#{end},</if>
+            <if test="relation != null">#{relation},</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="updateTripletInfo" parameterType="TripletInfo">
+        update t_triplet_info
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="subTaskId != null">sub_task_id = #{subTaskId},</if>
+            <if test="start != null">start = #{start},</if>
+            <if test="end != null">end = #{end},</if>
+            <if test="relation != null">relation = #{relation},</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="deleteTripletInfoById" parameterType="Long">
+        delete from t_triplet_info where id = #{id}
+    </delete>
+
+    <delete id="deleteTripletInfoByIds" parameterType="String">
+        delete from t_triplet_info where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+    <select id="getKgDTO" resultType="com.kgraph.graph.neo4j.DTO.KgDTO">
+        select start, end, relation from t_triplet_info where sub_task_id = #{subTaskId}
+    </select>
+</mapper>

+ 59 - 5
sql/system.sql

@@ -1078,19 +1078,50 @@ PRIMARY KEY ( id )
 -- 知识抽取子任务明细表
 DROP TABLE
 IF
-	EXISTS t_extract_knowledge_sub_task_detail;
-CREATE TABLE t_extract_knowledge_sub_task_detail (
+	EXISTS t_triplet_info;
+CREATE TABLE t_triplet_info (
 	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '编号',
 	sub_task_id BIGINT ( 20 ) NOT NULL COMMENT '子任务id',
 	`start` VARCHAR ( 511 ) COMMENT '起点实体',
-	relation VARCHAR ( 255 ) COMMENT '关系',
 	`end` VARCHAR ( 511 ) COMMENT '终点实体',
+	relation VARCHAR ( 255 ) 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_value_info;
+CREATE TABLE t_value_info (
+	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '编号',
+	sub_task_id BIGINT ( 20 ) NOT NULL COMMENT '子任务id',
+	`value` 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_similarity_info;
+CREATE TABLE t_similarity_info (
+	id BIGINT ( 20 ) NOT NULL auto_increment COMMENT '编号',
+	value_info_id BIGINT ( 20 ) NOT NULL COMMENT '子任务id',
+	synonym_id BIGINT ( 20 ) COMMENT '同义词id',
+	synonym_name VARCHAR ( 511 ) COMMENT '同义词名称',
+	synonym_info 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 = '知识抽取子任务明细表';
+) ENGINE = INNODB auto_increment = 1 COMMENT = '三元组信息';
 
 
 -- 上传管理 菜单 SQL
@@ -1208,4 +1239,27 @@ values('知识抽取子任务明细删除', @parentId, '4',  '#', '', 1, 0, 'F',
 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', 'extract:subTaskDetail:export',       '#', 'admin', sysdate(), '', null, '');
 
--- 添加数据字典  kg_upload_type  kg_upload_template file_upload_status
+-- 三元组信息 菜单 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('三元组信息', '2176', '1', 'info', 'extract/info/index', 1, 0, 'C', '0', '0', 'extract:info: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', 'extract:info: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', 'extract:info: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', 'extract:info: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', 'extract:info: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', 'extract:info:export',       '#', 'admin', sysdate(), '', null, '');
+
+-- 添加数据字典  kg_upload_type  kg_upload_template file_upload_status kg_extract_status extract_sub_task_list extract_sub_task_status