diff --git a/ruoyi-modules/knowledge-graph/pom.xml b/ruoyi-modules/knowledge-graph/pom.xml
new file mode 100644
index 00000000..3645c51d
--- /dev/null
+++ b/ruoyi-modules/knowledge-graph/pom.xml
@@ -0,0 +1,536 @@
+
+
+
+
+ com.ruoyi
+ ruoyi-modules
+ 3.6.3
+
+
+ knowledge-graph
+ 4.0.0
+
+ 知识图谱模块
+
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+
+ com.alibaba
+ druid-spring-boot-starter
+ ${druid.version}
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-sentinel
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+
+ io.springfox
+ springfox-swagger-ui
+ ${swagger.fox.version}
+
+
+
+ com.mysql
+ mysql-connector-j
+
+
+
+
+ com.ruoyi
+ ruoyi-common-datasource
+
+
+
+ com.ruoyi
+ ruoyi-common-datasource
+
+
+
+
+ com.ruoyi
+ ruoyi-common-datascope
+
+
+
+
+ com.ruoyi
+ ruoyi-common-log
+
+
+
+
+ com.ruoyi
+ ruoyi-common-swagger
+
+
+ com.ruoyi
+ ruoyi-common-security
+
+
+ com.ruoyi
+ ruoyi-common-swagger
+
+
+ org.springframework.security
+ spring-security-core
+
+
+ com.ruoyi
+ ruoyi-common-log
+
+
+ com.ruoyi
+ ruoyi-common-core
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+ org.projectlombok
+ lombok
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.5
+
+
+ org.apache.httpcomponents
+ httpmime
+ 4.5
+
+
+
+
+ org.apache.httpcomponents
+ httpcore
+ 4.4.13
+
+
+ io.kubernetes
+ client-java
+ 17.0.0
+
+
+ com.github.docker-java
+ docker-java
+ 3.2.13
+
+
+ commons-beanutils
+ commons-beanutils
+ 1.9.4
+
+
+ com.github.docker-java
+ docker-java-transport-httpclient5
+ 3.2.13
+
+
+ com.baomidou
+ mybatis-plus-annotation
+ 3.3.2
+
+
+ com.baomidou
+ mybatis-plus-core
+ 3.3.2
+
+
+ javax.persistence
+ persistence-api
+ 1.0.2
+
+
+ io.kubernetes
+ client-java-api
+ 16.0.3
+ compile
+
+
+ io.kubernetes
+ client-java-api
+ 12.0.1
+
+
+ com.opencsv
+ opencsv
+ 5.7.1
+
+
+ org.apache.commons
+ commons-csv
+ 1.9.0
+
+
+ io.fabric8
+ kubernetes-client
+ 4.11.1
+
+
+ io.github.classgraph
+ classgraph
+ 4.8.83
+
+
+ io.minio
+ minio
+ 8.2.2
+
+
+ org.mlflow
+ mlflow-client
+ 1.28.0
+
+
+ org.checkerframework
+ checker-qual
+ 3.19.0
+ compile
+
+
+ com.jcraft
+ jsch
+ 0.1.55
+
+
+
+ org.springframework.boot
+ spring-boot-starter-websocket
+
+
+ org.json
+ json
+ 20210307
+
+
+ org.apache.dubbo
+ dubbo
+ 3.0.8
+ compile
+
+
+ commons-lang
+ commons-lang
+ 2.6
+ compile
+
+
+ org.eclipse.jgit
+ org.eclipse.jgit
+ 5.13.0.202109080827-r
+
+
+ redis.clients
+ jedis
+ 3.6.0
+
+
+
+ cn.hutool
+ hutool-all
+ 5.8.5
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-neo4j
+
+
+ org.neo4j.driver
+ neo4j-java-driver
+
+
+ com.alibaba
+ easyexcel
+ 4.0.3
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${project.artifactId}
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ repackage
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/KnowledgeGraphApplication.java b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/KnowledgeGraphApplication.java
new file mode 100644
index 00000000..58aa8aa0
--- /dev/null
+++ b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/KnowledgeGraphApplication.java
@@ -0,0 +1,34 @@
+package com.ruoyi.kg;
+
+import com.ruoyi.common.security.annotation.EnableCustomConfig;
+import com.ruoyi.common.security.annotation.EnableRyFeignClients;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+/**
+ * 项目管理模块
+ *
+ * @author fans
+ */
+@EnableCustomConfig
+@EnableRyFeignClients
+@SpringBootApplication
+@EnableScheduling
+@EnableAsync
+public class KnowledgeGraphApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(KnowledgeGraphApplication.class, args);
+ System.out.println("(♥◠‿◠)ノ゙ 知识图谱启动成功 ლ(´ڡ`ლ)゙ \n" +
+ " .-------. ____ __ \n" +
+ " | _ _ \\ \\ \\ / / \n" +
+ " | ( ' ) | \\ _. / ' \n" +
+ " |(_ o _) / _( )_ .' \n" +
+ " | (_,_).' __ ___(_ o _)' \n" +
+ " | |\\ \\ | || |(_,_)' \n" +
+ " | | \\ `' /| `-' / \n" +
+ " | | \\ / \\ / \n" +
+ " ''-' `'-' `-..-' ");
+ }
+}
\ No newline at end of file
diff --git a/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/config/Neo4jConfig.java b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/config/Neo4jConfig.java
new file mode 100644
index 00000000..a1b7655d
--- /dev/null
+++ b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/config/Neo4jConfig.java
@@ -0,0 +1,27 @@
+package com.ruoyi.kg.config;
+
+import org.neo4j.cypherdsl.core.renderer.Dialect;
+import org.neo4j.driver.Driver;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.neo4j.core.Neo4jClient;
+
+
+@Configuration
+//@EnableNeo4jRepositories("com.ruoyi.platform.service")
+public class Neo4jConfig {
+
+ @Autowired
+ private Driver driver;
+
+ @Bean
+ public Neo4jClient neo4jClient() {
+ return Neo4jClient.create(driver);
+ }
+ @Bean
+ org.neo4j.cypherdsl.core.renderer.Configuration cypherDslConfiguration() {
+ return org.neo4j.cypherdsl.core.renderer.Configuration.newConfig()
+ .withDialect(Dialect.NEO4J_5).build();
+ }
+}
\ No newline at end of file
diff --git a/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/config/WebSocketConfig.java b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/config/WebSocketConfig.java
new file mode 100644
index 00000000..91ca1778
--- /dev/null
+++ b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/config/WebSocketConfig.java
@@ -0,0 +1,17 @@
+package com.ruoyi.kg.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.socket.server.standard.ServerEndpointExporter;
+
+@Configuration
+public class WebSocketConfig {
+ /**
+ * 注入 ServerEndpointExporter,
+ * 这个 bean 会自动注册使用了 @ServerEndpoint 注解声明的 WebSocket endpoint
+ */
+ @Bean
+ public ServerEndpointExporter serverEndpointExporter() {
+ return new ServerEndpointExporter();
+ }
+}
diff --git a/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgEntityController.java b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgEntityController.java
new file mode 100644
index 00000000..07206d36
--- /dev/null
+++ b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgEntityController.java
@@ -0,0 +1,94 @@
+package com.ruoyi.kg.controller;
+
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.kg.domain.KgEntityInfo;
+import com.ruoyi.kg.service.KgEntityInfoService;
+import com.ruoyi.system.api.domain.SysDictData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 知识图谱实体管理
+ */
+@RestController
+@RequestMapping("/kg/entity")
+public class KgEntityController extends BaseController {
+
+ @Autowired
+ private KgEntityInfoService kgEntityInfoService;
+
+ /**
+ * 新增实体
+ *
+ * @param entityInfo
+ * @return
+ */
+ @PostMapping()
+ public R createEntity(@Validated @RequestBody KgEntityInfo entityInfo) {
+ kgEntityInfoService.insertEntity(entityInfo);
+ return R.ok();
+ }
+
+ /**
+ * 修改实体
+ *
+ * @param entityInfo
+ * @return
+ */
+ @PutMapping
+ public R updateEntity(@Validated @RequestBody KgEntityInfo entityInfo) {
+ kgEntityInfoService.updateEntity(entityInfo);
+ return R.ok();
+ }
+
+ /**
+ * 实体列表
+ * @return
+ */
+ @GetMapping("/list")
+ public TableDataInfo getEntities(@RequestBody KgEntityInfo entityInfo) {
+ startPage();
+ List ontologies = kgEntityInfoService.getEntities(entityInfo);
+ return getDataTable(ontologies);
+ }
+
+ /**
+ * 实体详情
+ * @param id
+ * @return
+ */
+ @GetMapping("/{id}")
+ public R getEntity(@PathVariable Long id) {
+ return R.ok(kgEntityInfoService.getEntity(id));
+ }
+
+ /**
+ * 删除实体
+ * @param id
+ * @return
+ */
+ @DeleteMapping("/{id}")
+ public R deleteEntityById(@PathVariable Long id) {
+ kgEntityInfoService.deleteEntityById(id);
+ return R.ok();
+ }
+
+ /**
+ * 实体导出
+ * @param response
+ * @param id
+ */
+ @GetMapping("/export/{id}")
+ public void export(HttpServletResponse response,@PathVariable Long id) {
+ KgEntityInfo Entity = kgEntityInfoService.getEntity(id);
+ ExcelUtil util = new ExcelUtil(SysDictData.class);
+ util.exportExcel(response, null, "实体数据");
+ }
+}
diff --git a/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgEntityPropertiesController.java b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgEntityPropertiesController.java
new file mode 100644
index 00000000..433c7734
--- /dev/null
+++ b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgEntityPropertiesController.java
@@ -0,0 +1,93 @@
+package com.ruoyi.kg.controller;
+
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.kg.domain.KgEntityProperty;
+import com.ruoyi.kg.service.KgEntityPropertiesService;
+import com.ruoyi.system.api.domain.SysDictData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+/**
+ * 知识图谱实体属性管理
+ */
+@RestController
+@RequestMapping("/kg/entityProperties")
+public class KgEntityPropertiesController extends BaseController {
+
+ @Autowired
+ private KgEntityPropertiesService kgEntityPropertiesService;
+
+ /**
+ * 新增实体属性
+ *
+ * @param entityProperties
+ * @return
+ */
+ @PostMapping()
+ public R createEntityProperty(@Validated @RequestBody KgEntityProperty entityProperties) {
+ kgEntityPropertiesService.insertEntityProperties(entityProperties);
+ return R.ok();
+ }
+
+ /**
+ * 修改实体属性
+ *
+ * @param KgEntityProperty
+ * @return
+ */
+ @PutMapping
+ public R updateEntityProperty(@Validated @RequestBody KgEntityProperty KgEntityProperty) {
+ kgEntityPropertiesService.updateEntityProperties(KgEntityProperty);
+ return R.ok();
+ }
+
+ /**
+ * 实体属性列表
+ * @return
+ */
+ @GetMapping("/list")
+ public TableDataInfo getEntityProperties(@RequestBody KgEntityProperty KgEntityProperty) {
+ startPage();
+ List ontologies = kgEntityPropertiesService.getEntityProperties(KgEntityProperty);
+ return getDataTable(ontologies);
+ }
+
+ /**
+ * 实体属性详情
+ * @param id
+ * @return
+ */
+ @GetMapping("/{id}")
+ public R getEntityProperty(@PathVariable Long id) {
+ return R.ok(kgEntityPropertiesService.getEntityProperty(id));
+ }
+
+ /**
+ * 删除实体属性
+ * @param id
+ * @return
+ */
+ @DeleteMapping("/{id}")
+ public R deleteEntityPropertyById(@PathVariable Long id) {
+ kgEntityPropertiesService.deleteEntityPropertyById(id);
+ return R.ok();
+ }
+
+ /**
+ * 实体属性导出
+ * @param response
+ * @param id
+ */
+ @GetMapping("/export/{id}")
+ public void export(HttpServletResponse response,@PathVariable Long id) {
+ KgEntityProperty EntityProperty = kgEntityPropertiesService.getEntityProperty(id);
+ ExcelUtil util = new ExcelUtil(SysDictData.class);
+ util.exportExcel(response, null, "实体属性数据");
+ }
+}
diff --git a/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgEntityRelationsController.java b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgEntityRelationsController.java
new file mode 100644
index 00000000..6720ee66
--- /dev/null
+++ b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgEntityRelationsController.java
@@ -0,0 +1,94 @@
+package com.ruoyi.kg.controller;
+
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.kg.domain.KgEntityRelation;
+import com.ruoyi.kg.service.KgEntityRelationsService;
+import com.ruoyi.system.api.domain.SysDictData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 知识图谱实体关系管理
+ */
+@RestController
+@RequestMapping("/kg/entityRelations")
+public class KgEntityRelationsController extends BaseController {
+
+ @Autowired
+ private KgEntityRelationsService kgEntityRelationsService;
+
+ /**
+ * 新增实体关系
+ *
+ * @param entityRelations
+ * @return
+ */
+ @PostMapping()
+ public R createEntityRelations(@Validated @RequestBody KgEntityRelation entityRelations) {
+ kgEntityRelationsService.insertEntityRelation(entityRelations);
+ return R.ok();
+ }
+
+ /**
+ * 修改实体关系
+ *
+ * @param entityRelations
+ * @return
+ */
+ @PutMapping
+ public R updateEntityRelations(@Validated @RequestBody KgEntityRelation entityRelations) {
+ kgEntityRelationsService.updateEntityRelation(entityRelations);
+ return R.ok();
+ }
+
+ /**
+ * 实体关系列表
+ * @return
+ */
+ @GetMapping("/list")
+ public TableDataInfo getEntityRelations(@RequestBody KgEntityRelation entityRelation) {
+ startPage();
+ List entityRelations = kgEntityRelationsService.getEntityRelations(entityRelation);
+ return getDataTable(entityRelations);
+ }
+
+ /**
+ * 实体关系详情
+ * @param id
+ * @return
+ */
+ @GetMapping("/{id}")
+ public R getEntityRelations(@PathVariable Long id) {
+ return R.ok(kgEntityRelationsService.getEntityRelations(id));
+ }
+
+ /**
+ * 删除实体关系
+ * @param id
+ * @return
+ */
+ @DeleteMapping("/{id}")
+ public R deleteEntityRelationById(@PathVariable Long id) {
+ kgEntityRelationsService.deleteEntityRelationById(id);
+ return R.ok();
+ }
+
+ /**
+ * 实体关系导出
+ * @param response
+ * @param id
+ */
+ @GetMapping("/export/{id}")
+ public void export(HttpServletResponse response,@PathVariable Long id) {
+ KgEntityRelation entityRelations = kgEntityRelationsService.getEntityRelations(id);
+ ExcelUtil util = new ExcelUtil(SysDictData.class);
+ util.exportExcel(response, null, "实体关系数据");
+ }
+}
diff --git a/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgInfoController.java b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgInfoController.java
new file mode 100644
index 00000000..128488a6
--- /dev/null
+++ b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgInfoController.java
@@ -0,0 +1,85 @@
+package com.ruoyi.kg.controller;
+
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.kg.domain.KgInfo;
+import com.ruoyi.kg.domain.KgInfoPageVo;
+import com.ruoyi.kg.domain.dto.KgInfoIdDTO;
+import com.ruoyi.kg.service.KgInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 知识图谱列表管理
+ */
+@RestController
+@RequestMapping("/kg")
+public class KgInfoController extends BaseController {
+
+ @Autowired
+ private KgInfoService kgInfoService;
+
+ /**
+ * 新增图谱
+ *
+ * @param kgInfo
+ * @return
+ */
+ @PostMapping()
+ public R createKgInfo(@Validated @RequestBody KgInfo kgInfo) {
+ kgInfoService.insertKgInfo(kgInfo);
+ return R.ok();
+ }
+
+ /**
+ * 修改图谱
+ *
+ * @param kgInfo
+ * @return
+ */
+ @PutMapping
+ public R updateKgInfo(@Validated @RequestBody KgInfo kgInfo) {
+ kgInfoService.updateKgInfo(kgInfo);
+ return R.ok();
+ }
+
+ /**
+ * 图谱列表
+ *
+ * @return
+ */
+ @GetMapping("/list")
+ public TableDataInfo getAllKgInfos() {
+ startPage();
+ List kgInfo = kgInfoService.getAllKgInfos();
+ return getDataTable(kgInfo);
+ }
+
+ /**
+ * 图谱详情
+ *
+ * @param kgInfoIdDTO
+ * @return
+ */
+ @GetMapping
+ public R getKgInfo(KgInfoIdDTO kgInfoIdDTO) {
+ return R.ok(kgInfoService.getKgInfo(kgInfoIdDTO));
+ }
+
+ /**
+ * 删除图谱
+ *
+ * @param id
+ * @return
+ */
+ @DeleteMapping("/{id}")
+ public R deleteKgInfoById(@PathVariable Long id) {
+ kgInfoService.deleteKgInfoById(id);
+ return R.ok();
+ }
+
+}
diff --git a/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgOntologyInfoController.java b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgOntologyInfoController.java
new file mode 100644
index 00000000..48274a11
--- /dev/null
+++ b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgOntologyInfoController.java
@@ -0,0 +1,145 @@
+package com.ruoyi.kg.controller;
+
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.common.security.utils.SecurityUtils;
+import com.ruoyi.kg.domain.KgOntologyInfo;
+import com.ruoyi.kg.domain.dto.GraphData;
+import com.ruoyi.kg.domain.dto.KgOntologyInfoPageDTO;
+import com.ruoyi.kg.domain.dto.KgOntologyNameAndIdDTO;
+import com.ruoyi.kg.domain.dto.KgOntologyUpdateDTO;
+import com.ruoyi.kg.service.KgOntologyInfoService;
+import com.ruoyi.system.api.domain.SysDictData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 知识图谱主体管理
+ */
+@RestController
+@RequestMapping("/kg/ontology")
+public class KgOntologyInfoController extends BaseController {
+
+ @Autowired
+ private KgOntologyInfoService kgOntologyInfoService;
+
+ /**
+ * 新增主体
+ *
+ * @param ontology
+ * @return
+ */
+ @PostMapping()
+ public R createOntology(@Validated @RequestBody KgOntologyInfo ontology) {
+ kgOntologyInfoService.insertOntology(ontology);
+ return R.ok("新增成功");
+ }
+
+ /**
+ * 修改主体信息
+ *
+ * @param ontology
+ * @return
+ */
+ @PutMapping("/info")
+ public R updateInfo(@Validated @RequestBody KgOntologyUpdateDTO ontology) {
+ kgOntologyInfoService.updateOntology(ontology);
+ return R.ok("修改成功");
+ }
+
+ /**
+ * 主体列表
+ * @return
+ */
+ @PostMapping("/list")
+ public TableDataInfo getOntologies(@RequestBody KgOntologyInfoPageDTO ontology) {
+ startPage();
+ List ontologies = kgOntologyInfoService.getOntologies(ontology);
+ return getDataTable(ontologies);
+ }
+
+ /**
+ * 新增图谱时关联主体内容
+ * @return
+ */
+ @GetMapping("/getBasicInfo")
+ public R> getNameAndIds() {
+ return R.ok(kgOntologyInfoService.getNameAndIds());
+ }
+
+ /**
+ * 主体详情
+ * @param id
+ * @return
+ */
+ @GetMapping("/{id}")
+ public R getOntology(@PathVariable Long id) {
+ return R.ok(kgOntologyInfoService.getOntology(id));
+ }
+
+ /**
+ * 删除主体
+ * @param id
+ * @return
+ */
+ @DeleteMapping("/{id}")
+ public R deleteById(@PathVariable Long id) {
+ kgOntologyInfoService.deleteOntologyById(id);
+ return R.ok("删除成功");
+ }
+
+ /**
+ * 删除主体
+ * @param ids
+ * @return
+ */
+ @DeleteMapping("/batch")
+ public R batchDelete(@RequestParam(value = "ids") List ids) {
+ kgOntologyInfoService.batchDelete(ids);
+ return R.ok("批量删除成功");
+ }
+
+ /**
+ * 保存图谱
+ * @param graphData
+ * @return
+ */
+ @PutMapping("/saveGraph")
+ public R saveGraph(@RequestBody GraphData graphData) {
+ kgOntologyInfoService.saveGraph(graphData);
+ return R.ok("保存成功");
+ }
+
+ /**
+ * 主体导出
+ * @param response
+ * @param id
+ */
+ @GetMapping("/export/{id}")
+ public void export(HttpServletResponse response,@PathVariable Long id) {
+ KgOntologyUpdateDTO ontology = kgOntologyInfoService.getOntology(id);
+ ExcelUtil util = new ExcelUtil(SysDictData.class);
+ util.exportExcel(response, null, "主体数据");
+ }
+
+ /**
+ * 主体导入
+ * @param file
+ * @param updateSupport
+ */
+ @PostMapping("/import")
+ public R importOntology(MultipartFile file, boolean updateSupport) throws Exception {
+ ExcelUtil util = new ExcelUtil<>(KgOntologyInfo.class);
+ List ontologyList = util.importExcel(file.getInputStream());
+ String operName = SecurityUtils.getUsername();
+ return R.ok(kgOntologyInfoService.importOntology(ontologyList, updateSupport, operName));
+
+ }
+}
diff --git a/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgVersionController.java b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgVersionController.java
new file mode 100644
index 00000000..4ded93ff
--- /dev/null
+++ b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/controller/KgVersionController.java
@@ -0,0 +1,134 @@
+package com.ruoyi.kg.controller;
+
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.kg.domain.KnowledgeGraphVersion;
+import com.ruoyi.kg.domain.dto.KgInfoIdDTO;
+import com.ruoyi.kg.domain.dto.KgVersionInsertDTO;
+import com.ruoyi.kg.service.KgVersionService;
+import com.ruoyi.system.api.domain.SysDictData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 知识图谱版本管理
+ */
+@RestController
+@RequestMapping("/kg/version")
+public class KgVersionController extends BaseController {
+
+ @Autowired
+ private KgVersionService kgVersionService;
+
+ /**
+ * 图谱版本列表
+ *
+ * @param kgInfoIdDTO
+ * @return
+ */
+ @GetMapping("/list")
+ public TableDataInfo versionList(KgInfoIdDTO kgInfoIdDTO) {
+ startPage();
+ List kgInfo = kgVersionService.versionList(kgInfoIdDTO);
+ return getDataTable(kgInfo);
+ }
+
+ /**
+ * 图谱版本导出
+ *
+ * @param response
+ * @param kgInfoIdDTO
+ */
+ @GetMapping("/export")
+ public void versionExport(HttpServletResponse response, KgInfoIdDTO kgInfoIdDTO) {
+// KgInfo KgInfo = kgVersionService.getKgInfo(kgInfoIdDTO);
+ ExcelUtil util = new ExcelUtil(SysDictData.class);
+ util.exportExcel(response, null, "图谱数据");
+ }
+
+ /**
+ * 图谱版本导入
+ *
+ * @param file
+ */
+ @PostMapping("/upload")
+ public R uploadCsv(@RequestParam("file") MultipartFile file) {
+ if (file == null || file.isEmpty()) {
+ throw new IllegalArgumentException("文件不能为空");
+ }
+
+ if (!file.getOriginalFilename().endsWith(".csv")) {
+ throw new IllegalArgumentException("仅支持 CSV 文件");
+ }
+
+ try {
+ return R.ok(kgVersionService.uploadCsv(file));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return R.fail();
+ }
+ }
+
+ /**
+ * 图谱版本新增
+ *
+ * @param kgVersionInsertDTO
+ */
+ @PostMapping
+ public R insert(@RequestBody @Validated KgVersionInsertDTO kgVersionInsertDTO) {
+ kgVersionService.insert(kgVersionInsertDTO);
+ return R.ok();
+ }
+
+
+ /**
+ * 图谱版本全量更新
+ *
+ * @param kgInfoIdDTO 版本id
+ */
+ @PostMapping("/fullUpdate")
+ public R fullUpdate(@RequestBody @Validated KgInfoIdDTO kgInfoIdDTO) {
+ kgVersionService.fullUpdate(kgInfoIdDTO.getId());
+ return R.ok("操作成功");
+ }
+
+ /**
+ * 图谱版本增量更新
+ *
+ * @param kgInfoIdDTO
+ */
+ @PostMapping("/incrementalUpdate")
+ public R incrementalUpdate(@RequestBody @Validated KgInfoIdDTO kgInfoIdDTO) {
+ kgVersionService.incrementalUpdate(kgInfoIdDTO.getId());
+ return R.ok("操作成功");
+ }
+
+ /**
+ * 图谱版本回退
+ *
+ * @param kgInfoIdDTO
+ */
+ @PostMapping("/rollback")
+ public R rollback(@RequestBody @Validated KgInfoIdDTO kgInfoIdDTO) {
+ kgVersionService.rollback(kgInfoIdDTO.getId());
+ return R.ok("操作成功");
+ }
+
+ /**
+ * 图谱版本删除
+ *
+ * @param versionId
+ */
+ @DeleteMapping("/{versionId}")
+ public R delete(@PathVariable Long versionId) {
+ kgVersionService.delete(versionId);
+ return R.ok("操作成功");
+ }
+}
diff --git a/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/domain/CsvParser.java b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/domain/CsvParser.java
new file mode 100644
index 00000000..53db4090
--- /dev/null
+++ b/ruoyi-modules/knowledge-graph/src/main/java/com/ruoyi/kg/domain/CsvParser.java
@@ -0,0 +1,37 @@
+package com.ruoyi.kg.domain;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.opencsv.CSVReader;
+import com.opencsv.exceptions.CsvException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public class CsvParser {
+
+ public static List