Browse Source

Merge branch 'master' into prod

allen 2 years ago
parent
commit
62c4ca4a06
22 changed files with 189 additions and 179 deletions
  1. 2 2
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/DTO/EntityDTO.java
  2. 7 0
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/controller/EntityClassRelationController.java
  3. 6 6
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/controller/Neo4jEntityController.java
  4. 4 3
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/domain/Entity.java
  5. 2 2
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/domain/Neo4jRelation.java
  6. 3 0
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/mapper/EntityClassRelationMapper.java
  7. 7 7
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/mapper/EntityRepository.java
  8. 2 0
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/IEntityClassRelationService.java
  9. 3 0
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/IKgService.java
  10. 5 6
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/INeo4jEntityService.java
  11. 0 2
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/INeo4jRelationService.java
  12. 5 0
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/impl/EntityClassRelationServiceImpl.java
  13. 80 17
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/impl/KgServiceImpl.java
  14. 5 5
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/impl/Neo4JNeo4jEntityServiceImpl.java
  15. 3 3
      kgraph-graph/src/main/java/com/kgraph/graph/neo4j/uitils/Neo4j2VOUtils.java
  16. 23 27
      kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/BuildEntityRelationController.java
  17. 2 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/service/IBuildEntityRelationService.java
  18. 6 0
      kgraph-graph/src/main/java/com/kgraph/graph/suport/service/impl/BuildEntityRelationServiceImpl.java
  19. 3 6
      kgraph-graph/src/main/resources/mapper/neo4j/EntityClassRelationMapper.xml
  20. 3 15
      sql/update20230523.sql
  21. 0 78
      sql/update20230524.sql
  22. 18 0
      sql/update20230529.sql

+ 2 - 2
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/DTO/EntityDTO.java

@@ -1,10 +1,10 @@
 package com.kgraph.graph.neo4j.DTO;
 
-import com.kgraph.graph.neo4j.domain.Neo4jEntity;
+import com.kgraph.graph.neo4j.domain.Entity;
 import lombok.Data;
 
 @Data
-public class EntityDTO extends Neo4jEntity {
+public class EntityDTO extends Entity {
     private int pageNum;
     private int pageSize;
 }

+ 7 - 0
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/controller/EntityClassRelationController.java

@@ -101,4 +101,11 @@ public class EntityClassRelationController extends BaseController
     {
         return toAjax(entityClassRelationService.deleteEntityClassRelationByIds(ids));
     }
+
+    @GetMapping("/getClassRelationOptionByClassId/{startId}/{endId}")
+    public AjaxResult getClassRelationOptionByClassId(@PathVariable("startId") Long startId, @PathVariable("endId") Long endId)
+    {
+        List<EntityClassRelation> list = entityClassRelationService.getClassRelationOptionByClassId(startId, endId);
+        return success(list);
+    }
 }

+ 6 - 6
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/controller/Neo4jEntityController.java

@@ -3,7 +3,7 @@ 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.EntityDTO;
-import com.kgraph.graph.neo4j.domain.Neo4jEntity;
+import com.kgraph.graph.neo4j.domain.Entity;
 import com.kgraph.graph.neo4j.service.INeo4jEntityService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
@@ -17,7 +17,7 @@ public class Neo4jEntityController extends BaseController {
     INeo4jEntityService service;
 
     @GetMapping("/findAll")
-    public Iterable<Neo4jEntity> findAll() {
+    public Iterable<Entity> findAll() {
         return service.findAll();
     }
 
@@ -27,12 +27,12 @@ public class Neo4jEntityController extends BaseController {
     }
 
     @PostMapping()
-    public AjaxResult save(@RequestBody Neo4jEntity entity) {
+    public AjaxResult save(@RequestBody Entity entity) {
         service.save(entity);
         return success();
     }
     @PutMapping()
-    public AjaxResult update(@RequestBody Neo4jEntity entity) {
+    public AjaxResult update(@RequestBody Entity entity) {
         service.save(entity);
         return success();
     }
@@ -44,8 +44,8 @@ public class Neo4jEntityController extends BaseController {
     }
 
     @GetMapping("/list")
-    public Page<Neo4jEntity> getPageList(EntityDTO dto){
-        Page<Neo4jEntity> pageList = service.getPageList(dto);
+    public Page<Entity> getPageList(EntityDTO dto){
+        Page<Entity> pageList = service.getPageList(dto);
         return pageList;
     }
 }

+ 4 - 3
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/domain/Neo4jEntity.java → kgraph-graph/src/main/java/com/kgraph/graph/neo4j/domain/Entity.java

@@ -6,9 +6,10 @@ import org.neo4j.ogm.annotation.*;
 import java.util.ArrayList;
 import java.util.List;
 
-@NodeEntity("Entity")
+@NodeEntity
 @Data
-public class Neo4jEntity {
+public class Entity {
+
     @Id
     @GeneratedValue
     private Long id;
@@ -16,7 +17,7 @@ public class Neo4jEntity {
     private String code;
     @Property("name")
     private String name;
-    @Labels()
+    @Labels
     private List<String> labels = new ArrayList<>();
     @Property("content")
     private String content;

+ 2 - 2
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/domain/Neo4jRelation.java

@@ -17,8 +17,8 @@ public class Neo4jRelation {
     private String content;
 
     @StartNode
-    private Neo4jEntity startNode;
+    private Entity startNode;
 
     @EndNode
-    private Neo4jEntity endNode;
+    private Entity endNode;
 }

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

@@ -2,6 +2,7 @@ package com.kgraph.graph.neo4j.mapper;
 
 import java.util.List;
 import com.kgraph.graph.neo4j.domain.EntityClassRelation;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 实体类关系Mapper接口
@@ -58,4 +59,6 @@ public interface EntityClassRelationMapper
      * @return 结果
      */
     public int deleteEntityClassRelationByIds(Long[] ids);
+
+    List<EntityClassRelation> getClassRelationOptionByClassId(@Param("startId") Long startId, @Param("endId") Long endId);
 }

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

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

+ 2 - 0
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/IEntityClassRelationService.java

@@ -58,4 +58,6 @@ public interface IEntityClassRelationService
      * @return 结果
      */
     public int deleteEntityClassRelationById(Long id);
+
+    List<EntityClassRelation> getClassRelationOptionByClassId(Long startId, Long endId);
 }

+ 3 - 0
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/IKgService.java

@@ -2,6 +2,7 @@ package com.kgraph.graph.neo4j.service;
 
 import com.kgraph.graph.neo4j.DTO.KgDTO;
 import com.kgraph.graph.neo4j.domain.Neo4jRelation;
+import com.kgraph.graph.suport.domain.BuildEntityRelation;
 import com.kgraph.graph.suport.dto.BuildEntityRelationDTO;
 
 import java.util.List;
@@ -24,4 +25,6 @@ public interface IKgService {
     List<Neo4jRelation> getRelationByLikeName(String name, Integer type);
 
     void buildEntityByClass(List<BuildEntityRelationDTO> bu1ildEntityRelationDTOList);
+
+    void addEntityRelation(BuildEntityRelation buildEntityRelation);
 }

+ 5 - 6
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/INeo4jEntityService.java

@@ -1,14 +1,13 @@
 package com.kgraph.graph.neo4j.service;
 
 import com.kgraph.graph.neo4j.DTO.EntityDTO;
-import com.kgraph.graph.neo4j.domain.Neo4jEntity;
+import com.kgraph.graph.neo4j.domain.Entity;
 import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
 
 public interface INeo4jEntityService {
-    Iterable<Neo4jEntity> findAll();
-    Neo4jEntity findById(Long id);
-    Neo4jEntity save(Neo4jEntity entity);
+    Iterable<Entity> findAll();
+    Entity findById(Long id);
+    Entity save(Entity entity);
     void delete(Long[] ids);
-    Page<Neo4jEntity> getPageList(EntityDTO dto);
+    Page<Entity> getPageList(EntityDTO dto);
 }

+ 0 - 2
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/INeo4jRelationService.java

@@ -1,10 +1,8 @@
 package com.kgraph.graph.neo4j.service;
 
 import com.kgraph.graph.neo4j.DTO.RelationDTO;
-import com.kgraph.graph.neo4j.domain.Neo4jEntity;
 import com.kgraph.graph.neo4j.domain.Neo4jRelation;
 import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
 
 public interface INeo4jRelationService {
     Iterable<Neo4jRelation> findAll();

+ 5 - 0
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/impl/EntityClassRelationServiceImpl.java

@@ -93,4 +93,9 @@ public class EntityClassRelationServiceImpl implements IEntityClassRelationServi
     {
         return entityClassRelationMapper.deleteEntityClassRelationById(id);
     }
+
+    @Override
+    public List<EntityClassRelation> getClassRelationOptionByClassId(Long startId, Long endId) {
+        return entityClassRelationMapper.getClassRelationOptionByClassId(startId, endId);
+    }
 }

+ 80 - 17
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/impl/KgServiceImpl.java

@@ -3,11 +3,16 @@ package com.kgraph.graph.neo4j.service.impl;
 import com.kgraph.common.core.domain.BaseResponse;
 import com.kgraph.common.core.domain.entity.SysDictData;
 import com.kgraph.graph.neo4j.DTO.KgDTO;
-import com.kgraph.graph.neo4j.domain.Neo4jEntity;
+import com.kgraph.graph.neo4j.domain.EntityClass;
+import com.kgraph.graph.neo4j.domain.EntityClassRelation;
+import com.kgraph.graph.neo4j.domain.Entity;
 import com.kgraph.graph.neo4j.domain.Neo4jRelation;
+import com.kgraph.graph.neo4j.mapper.EntityClassMapper;
+import com.kgraph.graph.neo4j.mapper.EntityClassRelationMapper;
 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.domain.BuildEntityRelation;
 import com.kgraph.graph.suport.dto.BuildEntityRelationDTO;
 import com.kgraph.system.service.ISysDictDataService;
 import org.apache.commons.lang3.StringUtils;
@@ -35,20 +40,26 @@ public class KgServiceImpl implements IKgService {
     @Autowired
     private RelationRepository relationRepository;
 
+    @Autowired
+    private EntityClassRelationMapper entityClassRelationMapper;
+
+    @Autowired
+    private EntityClassMapper entityClassMapper;
+
     @Override
     public void create(List<KgDTO> kgDTOList) {
         // build entity
-        List<Neo4jEntity> entityList = buildEntity(kgDTOList);
+        List<Entity> entityList = buildEntity(kgDTOList);
 
-        Map<String, Neo4jEntity> entityMap = entityList.stream().collect(Collectors.toMap(Neo4jEntity::getName, Neo4jEntity -> Neo4jEntity));
+        Map<String, Entity> entityMap = entityList.stream().collect(Collectors.toMap(Entity::getName, Neo4jEntity -> Neo4jEntity));
 
-        for (Neo4jEntity entity : entityMap.values()) {
-            Neo4jEntity newEntity = entityRepository.findByName(entity.getName());
+        for (Entity entity : entityMap.values()) {
+            Entity newEntity = entityRepository.findByName(entity.getName());
             if (newEntity != null) {
                 // 如果已经在db中则替换
                 entityMap.put(entity.getName(), newEntity);
             } else {
-                Neo4jEntity save = entityRepository.save(entity);
+                Entity save = entityRepository.save(entity);
                 entityMap.put(entity.getName(), save);
             }
         }
@@ -72,7 +83,7 @@ public class KgServiceImpl implements IKgService {
         return false;
     }
 
-    private boolean relationExist(Neo4jEntity subEntity, Neo4jEntity objEntity, String relationName) {
+    private boolean relationExist(Entity subEntity, Entity objEntity, String relationName) {
         Neo4jRelation relationDb = relationRepository.findRelation(subEntity.getId(), objEntity.getId(), relationName);
         return relationDb != null;
     }
@@ -87,22 +98,22 @@ public class KgServiceImpl implements IKgService {
         return relationRepository.findAll();
     }
 
-    private List<Neo4jEntity> buildEntity(List<KgDTO> kgDTOList) {
+    private List<Entity> buildEntity(List<KgDTO> kgDTOList) {
         Set<String> entitySet = new HashSet<>(kgDTOList.size() * 2);
         for (KgDTO kgDTO : kgDTOList) {
             entitySet.add(kgDTO.getStart());
             entitySet.add(kgDTO.getEnd());
         }
-        List<Neo4jEntity> entityList = new ArrayList<>(entitySet.size());
+        List<Entity> entityList = new ArrayList<>(entitySet.size());
         for (String entityStr : entitySet) {
-            Neo4jEntity neo4jEntity = new Neo4jEntity();
-            neo4jEntity.setName(entityStr);
-            entityList.add(neo4jEntity);
+            Entity entity = new Entity();
+            entity.setName(entityStr);
+            entityList.add(entity);
         }
         return entityList;
     }
 
-    private List<Neo4jRelation> buildRelation(List<KgDTO> kgDTOList, Map<String, Neo4jEntity> entityMap) {
+    private List<Neo4jRelation> buildRelation(List<KgDTO> kgDTOList, Map<String, Entity> entityMap) {
         List<Neo4jRelation> relationList = new ArrayList<>(kgDTOList.size());
         for (KgDTO kgDTO : kgDTOList) {
             Neo4jRelation neo4jRelation = new Neo4jRelation();
@@ -218,11 +229,11 @@ public class KgServiceImpl implements IKgService {
     public void buildEntityByClass(List<BuildEntityRelationDTO> bu1ildEntityRelationDTOList) {
         bu1ildEntityRelationDTOList.forEach(buildEntityRelationDTO -> {
             String subEntityName = buildEntityRelationDTO.getSubEntity();
-            Neo4jEntity subEntity = entityRepository.findByName(subEntityName);
+            Entity subEntity = entityRepository.findByName(subEntityName);
             String subClassName = buildEntityRelationDTO.getSubName();
             // 如果实体不存在,新建实体
             if (subEntity == null) {
-                subEntity = new Neo4jEntity();
+                subEntity = new Entity();
                 subEntity.setName(subEntityName);
                 subEntity.getLabels().add(subClassName);
                 entityRepository.save(subEntity);
@@ -233,11 +244,11 @@ public class KgServiceImpl implements IKgService {
             }
 
             String objEntityName = buildEntityRelationDTO.getObjEntity();
-            Neo4jEntity objEntity = entityRepository.findByName(objEntityName);
+            Entity objEntity = entityRepository.findByName(objEntityName);
             String objClassName = buildEntityRelationDTO.getObjName();
             // 如果实体不存在,新建实体
             if (objEntity == null) {
-                objEntity = new Neo4jEntity();
+                objEntity = new Entity();
                 objEntity.setName(objEntityName);
                 objEntity.getLabels().add(objClassName);
                 entityRepository.save(objEntity);
@@ -258,4 +269,56 @@ public class KgServiceImpl implements IKgService {
         });
     }
 
+    @Override
+    public void addEntityRelation(BuildEntityRelation buildEntityRelation) {
+        EntityClass subEntityClass = entityClassMapper.selectEntityClassById(buildEntityRelation.getSubEntityClassId());
+        EntityClass objEntityClass = entityClassMapper.selectEntityClassById(buildEntityRelation.getObjEntityClassId());
+        EntityClassRelation entityClassRelation = entityClassRelationMapper.selectEntityClassRelationById(buildEntityRelation.getEntityClassRelId());
+
+        if(subEntityClass == null || objEntityClass == null || entityClassRelation == null){
+            throw new RuntimeException("实体类或实体关系未找到");
+        }
+
+        String subEntityName = buildEntityRelation.getSubEntity();
+        String subClassName = subEntityClass.getName();
+        Entity subEntity = entityRepository.findByName(subEntityName);
+
+        // 如果实体不存在,新建实体
+        if (subEntity == null) {
+            subEntity = new Entity();
+            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 = buildEntityRelation.getObjEntity();
+        String objClassName = objEntityClass.getName();
+        Entity objEntity = entityRepository.findByName(objEntityName);
+
+        // 如果实体不存在,新建实体
+        if (objEntity == null) {
+            objEntity = new Entity();
+            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 = entityClassRelation.getName();
+        if(!relationExist(subEntity,objEntity, relationName)){
+            Neo4jRelation relation = new Neo4jRelation();
+            relation.setName(relationName);
+            relation.setStartNode(subEntity);
+            relation.setEndNode(objEntity);
+            relationRepository.save(relation);
+        }
+    }
+
 }

+ 5 - 5
kgraph-graph/src/main/java/com/kgraph/graph/neo4j/service/impl/Neo4JNeo4jEntityServiceImpl.java

@@ -2,7 +2,7 @@ package com.kgraph.graph.neo4j.service.impl;
 
 import com.kgraph.common.utils.StringUtils;
 import com.kgraph.graph.neo4j.DTO.EntityDTO;
-import com.kgraph.graph.neo4j.domain.Neo4jEntity;
+import com.kgraph.graph.neo4j.domain.Entity;
 import com.kgraph.graph.neo4j.mapper.EntityRepository;
 import com.kgraph.graph.neo4j.service.INeo4jEntityService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,17 +17,17 @@ public class Neo4JNeo4jEntityServiceImpl implements INeo4jEntityService {
     EntityRepository repository;
 
     @Override
-    public Iterable<Neo4jEntity> findAll() {
+    public Iterable<Entity> findAll() {
         return repository.findAll();
     }
 
     @Override
-    public Neo4jEntity findById(Long id) {
+    public Entity findById(Long id) {
         return repository.findById(id).orElse(null);
     }
 
     @Override
-    public Neo4jEntity save(Neo4jEntity entity) {
+    public Entity save(Entity entity) {
         return repository.save(entity);
     }
 
@@ -40,7 +40,7 @@ public class Neo4JNeo4jEntityServiceImpl implements INeo4jEntityService {
     }
 
     @Override
-    public Page<Neo4jEntity> getPageList(EntityDTO dto) {
+    public Page<Entity> getPageList(EntityDTO dto) {
         if (StringUtils.isNotEmpty(dto.getName())) {
             return repository.getPageListByName(dto, PageRequest.of(dto.getPageNum() - 1, dto.getPageSize()));
         } else {

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

@@ -3,7 +3,7 @@ package com.kgraph.graph.neo4j.uitils;
 import com.kgraph.graph.neo4j.VO.EntityVO;
 import com.kgraph.graph.neo4j.VO.GraphVO;
 import com.kgraph.graph.neo4j.VO.RelationVO;
-import com.kgraph.graph.neo4j.domain.Neo4jEntity;
+import com.kgraph.graph.neo4j.domain.Entity;
 import com.kgraph.graph.neo4j.domain.Neo4jRelation;
 import org.apache.commons.collections4.CollectionUtils;
 
@@ -22,7 +22,7 @@ public class Neo4j2VOUtils {
             return graphVO;
         }
         // process data
-        Set<Neo4jEntity> entitySet = new HashSet<>(relationList.size() * 2);
+        Set<Entity> entitySet = new HashSet<>(relationList.size() * 2);
         relationList.forEach(neo4jRelation -> {
             entitySet.add(neo4jRelation.getStartNode());
             entitySet.add(neo4jRelation.getEndNode());
@@ -47,7 +47,7 @@ public class Neo4j2VOUtils {
         return new RelationVO(neo4jRelation.getId(), neo4jRelation.getName(), neo4jRelation.getContent(), neo4jRelation.getStartNode().getId(), neo4jRelation.getEndNode().getId(), neo4jRelation.getStartNode().getName(), neo4jRelation.getEndNode().getName());
     }
 
-    public static EntityVO entity2VO(Neo4jEntity entity) {
+    public static EntityVO entity2VO(Entity entity) {
         return new EntityVO(entity.getId(), entity.getName(), entity.getContent(), entity.getAttachmentUrl());
     }
 

+ 23 - 27
kgraph-graph/src/main/java/com/kgraph/graph/suport/controller/BuildEntityRelationController.java

@@ -1,34 +1,21 @@
 package com.kgraph.graph.suport.controller;
 
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-
-import com.kgraph.common.utils.StringUtils;
-import com.kgraph.common.utils.file.FileUtils;
-import com.kgraph.graph.suport.dto.BuildEntityRelationDTO;
-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.common.annotation.Log;
+import com.kgraph.common.core.controller.BaseController;
+import com.kgraph.common.core.domain.AjaxResult;
+import com.kgraph.common.core.page.TableDataInfo;
+import com.kgraph.common.enums.BusinessType;
+import com.kgraph.common.utils.poi.ExcelUtil;
 import com.kgraph.graph.suport.domain.BuildEntityRelation;
+import com.kgraph.graph.suport.dto.BuildEntityRelationDTO;
 import com.kgraph.graph.suport.service.IBuildEntityRelationService;
-import com.kgraph.common.utils.poi.ExcelUtil;;
-import com.kgraph.common.core.page.TableDataInfo;;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
 
 /**
  * 实体构建Controller
@@ -124,4 +111,13 @@ public class BuildEntityRelationController extends BaseController
     {
         return success(buildEntityRelationService.bu1ildEntityRelation(bu1ildEntityRelationDTOList));
     }
+
+    @PreAuthorize("@ss.hasPermi('suport:relation:add')")
+    @Log(title = "实体关系构建", businessType = BusinessType.INSERT)
+    @PostMapping("/addEntityRelation")
+    public AjaxResult addEntityRelation(@RequestBody BuildEntityRelation buildEntityRelation)
+    {
+        buildEntityRelationService.addEntityRelation(buildEntityRelation);
+        return success();
+    }
 }

+ 2 - 0
kgraph-graph/src/main/java/com/kgraph/graph/suport/service/IBuildEntityRelationService.java

@@ -65,4 +65,6 @@ public interface IBuildEntityRelationService
     List<Map> getClassRelationList(Long subtaskId);
 
     int bu1ildEntityRelation(List<BuildEntityRelationDTO> bu1ildEntityRelationDTOList);
+
+    void addEntityRelation(BuildEntityRelation buildEntityRelation);
 }

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

@@ -142,4 +142,10 @@ public class BuildEntityRelationServiceImpl implements IBuildEntityRelationServi
         kgService.buildEntityByClass(bu1ildEntityRelationDTOList);
         return res;
     }
+
+    @Override
+    public void addEntityRelation(BuildEntityRelation buildEntityRelation) {
+        this.insertBuildEntityRelation(buildEntityRelation);
+        kgService.addEntityRelation(buildEntityRelation);
+    }
 }

+ 3 - 6
kgraph-graph/src/main/resources/mapper/neo4j/EntityClassRelationMapper.xml

@@ -101,10 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         delete from entity_class_relation where id = #{id}
     </delete>
 
-    <delete id="deleteEntityClassRelationByIds" parameterType="String">
-        delete from entity_class_relation where id in 
-        <foreach item="id" collection="array" open="(" separator="," close=")">
-            #{id}
-        </foreach>
-    </delete>
+    <select id="getClassRelationOptionByClassId" parameterType="Long" resultType="Map">
+        SELECT id,name from entity_class_relation WHERE start_id = #{startId} AND end_id = #{endId}
+    </select>
 </mapper>

+ 3 - 15
sql/update20230523.sql

@@ -155,20 +155,8 @@ 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', '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, '');
+-- 子任务数据字典
+INSERT INTO `kgraph`.`sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (143, 2, '故障构建', '2', 'extract_sub_task_list', NULL, 'default', 'N', '0', 'admin', '2023-05-23 08:06:49', 'admin', '2023-05-26 02:56:34', NULL);
+INSERT INTO `kgraph`.`sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (144, 3, '排故流程构建', '3', 'extract_sub_task_list', NULL, 'default', 'N', '0', 'admin', '2023-05-23 08:07:16', '', NULL, NULL);
 
 commit;

+ 0 - 78
sql/update20230524.sql

@@ -1,78 +0,0 @@
-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 = '问答查询记录';

+ 18 - 0
sql/update20230529.sql

@@ -0,0 +1,18 @@
+use kgraph;
+---- 按钮 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;