Browse Source

kg init

dev-cp
chenpeng 1 year ago
parent
commit
1a81e831e6
10 changed files with 620 additions and 1 deletions
  1. +104
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/kg/KgInfoController.java
  2. +83
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/kg/KgInfo.java
  3. +93
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/kg/KgInfoPageVo.java
  4. +21
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/kg/dto/KgInfoIdDTO.java
  5. +26
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/kg/dto/KgInfoPageDTO.java
  6. +26
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/kg/KgInfoMapper.java
  7. +23
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/KgInfoService.java
  8. +55
    -0
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/KgInfoServiceImpl.java
  9. +187
    -0
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/KgInfoMapper.xml
  10. +2
    -1
      ruoyi-modules/management-platform/src/test/java/com/ruoyi/platform/utils/ExcelReaderTest.java

+ 104
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/kg/KgInfoController.java View File

@@ -0,0 +1,104 @@
package com.ruoyi.platform.controller.kg;

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.platform.domain.kg.KgInfo;
import com.ruoyi.platform.domain.kg.KgInfoPageVo;
import com.ruoyi.platform.domain.kg.dto.KgInfoIdDTO;
import com.ruoyi.platform.service.KgInfoService;
import com.ruoyi.system.api.domain.SysDictData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/kgInfos")
public class KgInfoController extends BaseController {

@Autowired
private KgInfoService kgInfoService;

/**
* 新增图谱
*
* @param kgInfo
* @return
*/
@PostMapping()
public R<String> createKgInfo(@RequestBody KgInfo kgInfo) {
kgInfoService.insertKgInfo(kgInfo);
return R.ok();
}

/**
* 修改图谱
*
* @param kgInfo
* @return
*/
@PutMapping
public R<String> updateKgInfo(@RequestBody KgInfo kgInfo) {
kgInfoService.updateKgInfo(kgInfo);
return R.ok();
}

/**
* 图谱列表
* @return
*/
@GetMapping("/list")
public TableDataInfo getAllKgInfos() {
startPage();
List<KgInfoPageVo> kgInfo = kgInfoService.getAllKgInfos();
return getDataTable(kgInfo);
}

/**
* 图谱详情
* @param kgInfoIdDTO
* @return
*/
@GetMapping
public R<KgInfo> getKgInfo( KgInfoIdDTO kgInfoIdDTO) {
return R.ok(kgInfoService.getKgInfo(kgInfoIdDTO));
}

/**
* 删除图谱
* @param id
* @return
*/
@DeleteMapping("/{id}")
public R<String> deleteKgInfoById(@PathVariable Long id) {
kgInfoService.deleteKgInfoById(id);
return R.ok();
}

/**
* 图谱版本列表
* @param kgInfoIdDTO
* @return
*/
@GetMapping("/version/list")
public TableDataInfo versionList(KgInfoIdDTO kgInfoIdDTO) {
startPage();
List<KgInfo> kgInfo = kgInfoService.versionList(kgInfoIdDTO);
return getDataTable(kgInfo);
}

/**
* 图谱版本导出
* @param response
* @param kgInfoIdDTO
*/
@GetMapping("/version/export")
public void versionExport(HttpServletResponse response,KgInfoIdDTO kgInfoIdDTO) {
KgInfo KgInfo = kgInfoService.getKgInfo(kgInfoIdDTO);
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
util.exportExcel(response, null, "图谱数据");
}
}

+ 83
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/kg/KgInfo.java View File

@@ -0,0 +1,83 @@
package com.ruoyi.platform.domain.kg;

import java.io.Serializable;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

/**
* 知识图谱信息表
* kg_info
*/
@Data
public class KgInfo implements Serializable {
/**
* ID
*/
private Long id;

/**
* 版本
*/
private String version;

/**
* 图谱名称
*/
private String name;

/**
* 本体ID
*/
private Long ontologyId;

/**
* neo4j数据库名称
*/
private String dbName;

/**
* 状态(0正常 1停用)
*/
private String status;

/**
* 创建者
*/
private String createBy;

/**
* 创建时间
*/
private Date createTime;

/**
* 更新者
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String updateBy;

/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;

/**
* 备注
*/
private String remark;

/**
* 规格
*/
private String spec;

/**
* 删除标志(2删除,0未删除)
*/
private String delFlag;

private static final long serialVersionUID = 1L;
}

+ 93
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/kg/KgInfoPageVo.java View File

@@ -0,0 +1,93 @@
package com.ruoyi.platform.domain.kg;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
* 知识图谱信息表
* kg_info
*/
@Data
public class KgInfoPageVo implements Serializable {
/**
* ID
*/
private Long id;

/**
* 版本
*/
private String version;

/**
* 图谱名称
*/
private String name;

/**
* 本体ID
*/
private Long ontologyId;

/**
* neo4j数据库名称
*/
private String dbName;

/**
* 状态(0正常 1停用)
*/
private String status;

/**
* 创建者
*/
private String createBy;

/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;

/**
* 更新者
*/
private String updateBy;

/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;

/**
* 备注
*/
private String remark;

/**
* 规格
*/
private String spec;

/**
* 删除标志(2删除,0未删除)
*/
private String delFlag;

/**
* 关系数
*/
private Integer relationCount;

/**
* 实体数
*/
private Integer entityCount;

private static final long serialVersionUID = 1L;
}

+ 21
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/kg/dto/KgInfoIdDTO.java View File

@@ -0,0 +1,21 @@
package com.ruoyi.platform.domain.kg.dto;

import lombok.Data;

import javax.validation.constraints.NotNull;

@Data
public class KgInfoIdDTO {

/**
* ID
*/
@NotNull
private Long id;

/**
* 版本
*/
@NotNull
private String version;
}

+ 26
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/kg/dto/KgInfoPageDTO.java View File

@@ -0,0 +1,26 @@
package com.ruoyi.platform.domain.kg.dto;

import lombok.Data;

@Data
public class KgInfoPageDTO {

/**
* ID
*/
private Long id;

/**
* 搜索关键词
*/
private String searchKey;

/**
* 状态
*/
private String status;

private Integer current;

private Integer pageSize;
}

+ 26
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/kg/KgInfoMapper.java View File

@@ -0,0 +1,26 @@
package com.ruoyi.platform.mapper.kg;
import com.ruoyi.platform.domain.kg.KgInfo;
import com.ruoyi.platform.domain.kg.KgInfoPageVo;
import com.ruoyi.platform.domain.kg.dto.KgInfoIdDTO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface KgInfoMapper {
int deleteByPrimaryKey(Long id);

int insert(KgInfo record);

int insertSelective(KgInfo record);

List<KgInfo> selectByPrimaryKey(KgInfoIdDTO kgInfoIdDTO);

List<KgInfoPageVo> selectALl();

KgInfo queryInfoByPrimaryKey(KgInfoIdDTO kgInfoIdDTO);

int updateByPrimaryKeySelective(KgInfo record);

int updateByPrimaryKey(KgInfo record);
}

+ 23
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/KgInfoService.java View File

@@ -0,0 +1,23 @@
package com.ruoyi.platform.service;

import com.ruoyi.platform.domain.kg.KgInfo;
import com.ruoyi.platform.domain.kg.KgInfoPageVo;
import com.ruoyi.platform.domain.kg.dto.KgInfoIdDTO;

import java.util.List;


public interface KgInfoService {

void insertKgInfo(KgInfo KgInfo);

void updateKgInfo(KgInfo KgInfo);

List<KgInfoPageVo> getAllKgInfos();

KgInfo getKgInfo(KgInfoIdDTO kgInfoIdDTO);

void deleteKgInfoById(Long id);

List<KgInfo> versionList(KgInfoIdDTO kgInfoIdDTO);
}

+ 55
- 0
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/KgInfoServiceImpl.java View File

@@ -0,0 +1,55 @@
package com.ruoyi.platform.service.impl;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.ruoyi.platform.domain.kg.KgInfo;
import com.ruoyi.platform.domain.kg.KgInfoPageVo;
import com.ruoyi.platform.domain.kg.dto.KgInfoIdDTO;
import com.ruoyi.platform.mapper.kg.KgInfoMapper;
import com.ruoyi.platform.service.KgInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class KgInfoServiceImpl implements KgInfoService {

@Autowired
private KgInfoMapper kgInfoMapper;

@Override
public void insertKgInfo(KgInfo KgInfo) {
KgInfo.setVersion("1");
DateTime date = DateUtil.date();
KgInfo.setCreateTime(date);
KgInfo.setUpdateTime(date);
kgInfoMapper.insertSelective(KgInfo);
}

@Override
public void updateKgInfo(KgInfo KgInfo) {
kgInfoMapper.updateByPrimaryKeySelective(KgInfo) ;
}

@Override
public List<KgInfoPageVo> getAllKgInfos() {
List<KgInfoPageVo> kgInfos = kgInfoMapper.selectALl();
return kgInfos;
}

@Override
public KgInfo getKgInfo(KgInfoIdDTO kgInfoIdDTO) {
return kgInfoMapper.queryInfoByPrimaryKey(kgInfoIdDTO);
}

@Override
public void deleteKgInfoById(Long id) {
kgInfoMapper.deleteByPrimaryKey(id);
}

@Override
public List<KgInfo> versionList(KgInfoIdDTO kgInfoIdDTO) {
return kgInfoMapper.selectByPrimaryKey(kgInfoIdDTO);
}

}

+ 187
- 0
ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/KgInfoMapper.xml View File

@@ -0,0 +1,187 @@
<?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.ruoyi.platform.mapper.kg.KgInfoMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.platform.domain.kg.KgInfo">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="version" jdbcType="VARCHAR" property="version" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="ontology_id" jdbcType="BIGINT" property="ontologyId" />
<result column="db_name" jdbcType="VARCHAR" property="dbName" />
<result column="status" jdbcType="CHAR" property="status" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="spec" jdbcType="VARCHAR" property="spec" />
<result column="del_flag" jdbcType="CHAR" property="delFlag" />
</resultMap>

<sql id="Base_Column_List">
id, version, `name`, ontology_id, db_name, `status`, create_by, create_time, update_by,
update_time, remark, spec,del_flag
</sql>

<select id="selectByPrimaryKey" parameterType="com.ruoyi.platform.domain.kg.dto.KgInfoIdDTO" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from kg_info
where id = #{id,jdbcType=BIGINT}
</select>

<select id="selectALl" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from kg_info
</select>

<select id="queryInfoByPrimaryKey" parameterType="com.ruoyi.platform.domain.kg.dto.KgInfoIdDTO" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from kg_info
where id = #{id,jdbcType=BIGINT} and version=#{version,jdbcType=VARCHAR}
</select>

<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from kg_info
where id = #{id,jdbcType=BIGINT}
</delete>

<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.platform.domain.kg.KgInfo" useGeneratedKeys="true">
insert into kg_info (version, `name`, ontology_id,
db_name, `status`, create_by,
create_time, update_by, update_time,
remark, del_flag)
values (#{version,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{ontologyId,jdbcType=BIGINT},
#{dbName,jdbcType=VARCHAR}, #{status,jdbcType=CHAR}, #{createBy,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{remark,jdbcType=VARCHAR}, #{delFlag,jdbcType=CHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.platform.domain.kg.KgInfo" useGeneratedKeys="true">
insert into kg_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="version != null">
version,
</if>
<if test="name != null">
`name`,
</if>
<if test="ontologyId != null">
ontology_id,
</if>
<if test="dbName != null">
db_name,
</if>
<if test="status != null">
`status`,
</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>
<if test="remark != null">
remark,
</if>
<if test="delFlag != null">
del_flag,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="version != null">
#{version,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="ontologyId != null">
#{ontologyId,jdbcType=BIGINT},
</if>
<if test="dbName != null">
#{dbName,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=CHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="delFlag != null">
#{delFlag,jdbcType=CHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.platform.domain.kg.KgInfo">
update kg_info
<set>
<if test="version != null">
version = #{version,jdbcType=VARCHAR},
</if>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="ontologyId != null">
ontology_id = #{ontologyId,jdbcType=BIGINT},
</if>
<if test="dbName != null">
db_name = #{dbName,jdbcType=VARCHAR},
</if>
<if test="status != null">
`status` = #{status,jdbcType=CHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="delFlag != null">
del_flag = #{delFlag,jdbcType=CHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.ruoyi.platform.domain.kg.KgInfo">
update kg_info
set version = #{version,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
ontology_id = #{ontologyId,jdbcType=BIGINT},
db_name = #{dbName,jdbcType=VARCHAR},
`status` = #{status,jdbcType=CHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP},
remark = #{remark,jdbcType=VARCHAR},
del_flag = #{delFlag,jdbcType=CHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

+ 2
- 1
ruoyi-modules/management-platform/src/test/java/com/ruoyi/platform/utils/ExcelReaderTest.java View File

@@ -1,6 +1,7 @@
package com.ruoyi.platform.utils;

import com.ruoyi.platform.domain.kg.*;
import com.ruoyi.platform.domain.material.*;
import com.ruoyi.platform.repository.MatKGRepository;
import com.ruoyi.platform.service.impl.MatKGServiceImpl;
import com.ruoyi.platform.vo.MatKGVo;
@@ -21,7 +22,7 @@ public class ExcelReaderTest {
private MatKGRepository repository;
@Test
void read() {
String excelFilePath = "C:\\haha\\matKG\\ENTDOI.csv";
String excelFilePath = "C:\\Users\\Public\\Nwt\\cache\\recv\\LHZ\\ENTDOI.csv";

ExecutorService executorService = Executors.newFixedThreadPool(10);
// 创建ExcelReader实例


Loading…
Cancel
Save