Explorar el Código

add all entity graph

allen hace 2 años
padre
commit
a3ba0e2d1a

+ 5 - 0
kgraph-graph/src/main/java/com/kgraph/graph/knowledge/controller/MapController.java

@@ -28,6 +28,11 @@ public class MapController extends BaseController {
         return success(mapService.getMap(graphRequest.getEntId()));
     }
 
+    @GetMapping("/show/allGraph")
+    public AjaxResult showAllGraph(){
+        return success(mapService.getAllMap());
+    }
+
     @GetMapping("/statistic/entclslist")
     public AjaxResult entclslist(){
         return success(entityClassService.selectEntityClassList(new EntityClass()));

+ 2 - 0
kgraph-graph/src/main/java/com/kgraph/graph/knowledge/mapper/EntityMapper.java

@@ -75,4 +75,6 @@ public interface EntityMapper
                               @Param(value = "entId") String entId);
 
     List<Entity> searchByName(String name);
+
+    List<Entity> getAllEntityByEntityIds();
 }

+ 3 - 0
kgraph-graph/src/main/java/com/kgraph/graph/knowledge/mapper/EntityRelationMapper.java

@@ -81,4 +81,7 @@ public interface EntityRelationMapper
     List<EntityRelationVO> getRelationVOByEntityId(@Param(value = "direction") String direction,
                                                    @Param(value = "relClsId") String relClsId,
                                                    @Param(value = "entId") String entId);
+
+    List<EntityRelation> getAllRelationByEntityId();
+
 }

+ 2 - 0
kgraph-graph/src/main/java/com/kgraph/graph/knowledge/service/IEntityRelationService.java

@@ -80,4 +80,6 @@ public interface IEntityRelationService
     public List<EntityRelationVO> getRelationVOByEntityId(String direction, String relClsId, String entId);
 
     int relAddBatch(List<EntityRelation> entityRelationList);
+
+    List<EntityRelation> getAllRelationByEntityId();
 }

+ 2 - 0
kgraph-graph/src/main/java/com/kgraph/graph/knowledge/service/IEntityService.java

@@ -73,4 +73,6 @@ public interface IEntityService
     List<Entity> getEntclsEnt(String direction, String relClsId, String entId);
 
     List<Entity> searchByName(String name);
+
+    List<Entity> getAllEntityByEntityIds();
 }

+ 2 - 0
kgraph-graph/src/main/java/com/kgraph/graph/knowledge/service/IMapService.java

@@ -15,4 +15,6 @@ public interface IMapService {
      * @return 实体图谱
      */
     Map<String, Object> getMap(String entityId);
+
+    Map<String, Object> getAllMap();
 }

+ 5 - 0
kgraph-graph/src/main/java/com/kgraph/graph/knowledge/service/impl/EntityRelationServiceImpl.java

@@ -134,4 +134,9 @@ public class EntityRelationServiceImpl implements IEntityRelationService
             return 0;
         }
     }
+
+    @Override
+    public List<EntityRelation> getAllRelationByEntityId() {
+        return entityRelationMapper.getAllRelationByEntityId();
+    }
 }

+ 5 - 0
kgraph-graph/src/main/java/com/kgraph/graph/knowledge/service/impl/EntityServiceImpl.java

@@ -134,4 +134,9 @@ public class EntityServiceImpl implements IEntityService
     public List<Entity> searchByName(String name) {
         return entityMapper.searchByName(name);
     }
+
+    @Override
+    public List<Entity> getAllEntityByEntityIds() {
+        return entityMapper.getAllEntityByEntityIds();
+    }
 }

+ 22 - 0
kgraph-graph/src/main/java/com/kgraph/graph/knowledge/service/impl/MapServiceImpl.java

@@ -43,6 +43,7 @@ public class MapServiceImpl implements IMapService {
     @Override
     public Map<String, Object> getMap(String entityId) {
         Map<String, Object> returnValue = new HashMap<>(8);
+
         returnValue.put("entID",entityId);
         HashSet<String> ids = new HashSet<>();
         ids.add(entityId);
@@ -84,6 +85,27 @@ public class MapServiceImpl implements IMapService {
         return returnValue;
     }
 
+    @Override
+    public Map<String, Object> getAllMap() {
+        Map<String, Object> returnValue = new HashMap<>(8);
+        returnValue.put("entID", null);
+        returnValue.put("entName", null);
+        // 2. 根据实体id获取《实体关系》
+        List<EntityRelation> entityRelationList = entityRelationService.getAllRelationByEntityId();
+        returnValue.put("relListVO", entityRelationList);
+
+        // 3. 根据实体关系得实体id 获取所有《实体》
+        List<Entity> entityList = entityService.getAllEntityByEntityIds();
+        returnValue.put("entListVO", entityList);
+//        // 4.2 根据实体类id 获取《实体类关系》
+//        entityClassRelationList = entityClassRelationService.getClazzRelByClassId(classId);
+//        returnValue.put("relClsListVO", entityClassRelationList);
+//        // 5. 根据实体类关系得实体类id 获取所有《实体类》
+//        List<EntityClass> entityClassList = getEntClsListVO(returnValue, classId, entityClassRelationList);
+//        returnValue.put("entClsListVO", entityClassList);
+        return returnValue;
+    }
+
     private List<EntityClass> getEntClsListVO(Map<String, Object> returnValue, String classId, List<EntityClassRelation> entityClassRelationList) {
         Set<String> entityClassIdSet;
         if (CollectionUtils.isNotEmpty(entityClassRelationList)) {

+ 6 - 0
kgraph-graph/src/main/resources/mapper/knowledge/EntityMapper.xml

@@ -101,6 +101,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </select>
 
+    <select id="getAllEntityByEntityIds" resultMap="EntityResult">
+        <include refid="selectEntityVo"/>
+    </select>
+
+
+
     <select id="getEntclsEnt" parameterType="String" resultMap="EntityResult">
         <if test="direction == 'START'">
             SELECT

+ 19 - 0
kgraph-graph/src/main/resources/mapper/knowledge/EntityRelationMapper.xml

@@ -108,6 +108,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND (start_ent_id = #{id} or end_ent_id = #{id})
     </select>
 
+    <select id="getAllRelationByEntityId" resultMap="EntityRelationResult">
+        SELECT
+            er.rel_id,
+            er.rel_cls_id,
+            ecr.rel_cls_name,
+            er.start_ent_id,
+            er.end_ent_id,
+            er.is_model,
+            er.create_by,
+            er.create_time,
+            er.update_by,
+            er.update_time
+        FROM
+            entity_relation er,
+            entity_class_relation ecr
+        WHERE
+            er.rel_cls_id = ecr.rel_cls_id
+    </select>
+
     <select id="getRelationVOByEntityId" parameterType="String" resultType="com.kgraph.graph.knowledge.domain.EntityRelationVO">
         <if test="direction != 'START'">
             SELECT