Commit 87d16df2 authored by alex yao's avatar alex yao

feat: 知识库文档保存分片规则

parent 9495df61
......@@ -176,6 +176,7 @@ public class KnowledgeServiceImpl implements KnowledgeService {
}
bizKnowledgeDocumentEntity.setTrainStatus(KnowledgeConstant.TrainStatus.LINE);
bizKnowledgeDocumentEntity.setSegmentationConfig(segmentationConfig);
bizKnowledgeDocumentService.update(kdId, bizKnowledgeDocumentEntity);
TrainKnowledgeMessage message = new TrainKnowledgeMessage();
......@@ -213,6 +214,10 @@ public class KnowledgeServiceImpl implements KnowledgeService {
result = knowledgeQueryItems.stream().map(item -> {
BizKnowledgeDocumentEntity entity = new BizKnowledgeDocumentEntity();
BeanUtil.copyProperties(item, entity);
if (StringUtils.isNotBlank(item.getSegmentationConfig())) {
SegmentationConfigRequest segmentationConfigRequest = JsonUtils.deSerialize(item.getSegmentationConfig(), SegmentationConfigRequest.class);
entity.setSegmentationConfig(segmentationConfigRequest);
}
return entity;
}).collect(Collectors.toList());
}
......
package cn.com.poc.knowledge.convert;
import cn.com.poc.common.utils.JsonUtils;
import cn.com.poc.common.utils.StringUtils;
import cn.com.poc.knowledge.entity.BizKnowledgeDocumentEntity;
import cn.com.poc.knowledge.model.BizKnowledgeDocumentModel;
import cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge.SegmentationConfigRequest;
public class KnowledgeDocumentConvert {
......@@ -16,6 +19,10 @@ public class KnowledgeDocumentConvert {
bizKnowledgeDocumentEntity.setCharCount(model.getCharCount());
bizKnowledgeDocumentEntity.setUploadTime(model.getUploadTime());
bizKnowledgeDocumentEntity.setIsEnable(model.getIsEnable());
if (StringUtils.isNotBlank(model.getSegmentationConfig())) {
SegmentationConfigRequest segmentationConfigRequest = JsonUtils.deSerialize(model.getSegmentationConfig(), SegmentationConfigRequest.class);
bizKnowledgeDocumentEntity.setSegmentationConfig(segmentationConfigRequest);
}
bizKnowledgeDocumentEntity.setKnowledgeId(model.getKnowledgeId());
bizKnowledgeDocumentEntity.setTrainStatus(model.getTrainStatus());
bizKnowledgeDocumentEntity.setIsDeleted(model.getIsDeleted());
......@@ -37,6 +44,7 @@ public class KnowledgeDocumentConvert {
bizKnowledgeDocumentModel.setCharCount(entity.getCharCount());
bizKnowledgeDocumentModel.setUploadTime(entity.getUploadTime());
bizKnowledgeDocumentModel.setIsEnable(entity.getIsEnable());
bizKnowledgeDocumentModel.setSegmentationConfig(JsonUtils.serialize(entity.getSegmentationConfig()));
bizKnowledgeDocumentModel.setKnowledgeId(entity.getKnowledgeId());
bizKnowledgeDocumentModel.setTrainStatus(entity.getTrainStatus());
bizKnowledgeDocumentModel.setIsDeleted(entity.getIsDeleted());
......
package cn.com.poc.knowledge.dto;
import cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge.SegmentationConfigRequest;
/**
* Model class for biz_knowledge_document
* 知识库文件表
......@@ -146,5 +148,16 @@ public class BizKnowledgeDocumentDto {
this.trainStatus = trainStatus;
}
/**
* 分片规则
*/
private SegmentationConfigRequest segmentationConfig;
public SegmentationConfigRequest getSegmentationConfig() {
return segmentationConfig;
}
public void setSegmentationConfig(SegmentationConfigRequest segmentationConfig) {
this.segmentationConfig = segmentationConfig;
}
}
\ No newline at end of file
package cn.com.poc.knowledge.entity;
import cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge.SegmentationConfigRequest;
/**
* Model class for biz_knowledge_document
* 知识库文件表
......@@ -145,8 +147,20 @@ public class BizKnowledgeDocumentEntity{
public void setTrainStatus(String trainStatus){
this.trainStatus = trainStatus;
}
/**
* 分片规则
*/
private SegmentationConfigRequest segmentationConfig;
public SegmentationConfigRequest getSegmentationConfig() {
return segmentationConfig;
}
public void setSegmentationConfig(SegmentationConfigRequest segmentationConfig) {
this.segmentationConfig = segmentationConfig;
}
/** is_deleted
*是否删除 Y 是 N 否
*/
......
package cn.com.poc.knowledge.model;
import cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge.SegmentationConfigRequest;
import cn.com.yict.framemax.data.model.BaseModelClass;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
......@@ -18,264 +19,295 @@ import java.io.Serializable;
public class BizKnowledgeDocumentModel extends BaseModelClass implements Serializable {
private static final long serialVersionUID = 1L;
/** kd_id
*主键
*/
/**
* kd_id
* 主键
*/
private Integer kdId;
@Column(name = "kd_id",length = 10)
@Id @GeneratedValue(strategy = GenerationType.AUTO)
public Integer getKdId(){
@Column(name = "kd_id", length = 10)
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getKdId() {
return this.kdId;
}
public void setKdId(Integer kdId){
public void setKdId(Integer kdId) {
this.kdId = kdId;
super.addValidField("kdId");
}
/** owner
*拥有者:System-系统 、User-用户
*/
/**
* owner
* 拥有者:System-系统 、User-用户
*/
private String owner;
@Column(name = "owner",length = 10)
public String getOwner(){
@Column(name = "owner", length = 10)
public String getOwner() {
return this.owner;
}
public void setOwner(String owner){
public void setOwner(String owner) {
this.owner = owner;
super.addValidField("owner");
}
/** knowledge_type
*知识库类型 QA-问答、Base-基础
*/
/**
* knowledge_type
* 知识库类型 QA-问答、Base-基础
*/
private String knowledgeType;
@Column(name = "knowledge_type",length = 10)
public String getKnowledgeType(){
@Column(name = "knowledge_type", length = 10)
public String getKnowledgeType() {
return this.knowledgeType;
}
public void setKnowledgeType(String knowledgeType){
public void setKnowledgeType(String knowledgeType) {
this.knowledgeType = knowledgeType;
super.addValidField("knowledgeType");
}
/** document_name
*文档名
*/
/**
* document_name
* 文档名
*/
private String documentName;
@Column(name = "document_name",length = 100)
public String getDocumentName(){
@Column(name = "document_name", length = 100)
public String getDocumentName() {
return this.documentName;
}
public void setDocumentName(String documentName){
public void setDocumentName(String documentName) {
this.documentName = documentName;
super.addValidField("documentName");
}
/** document_url
*文件下载地址
*/
/**
* document_url
* 文件下载地址
*/
private String documentUrl;
@Column(name = "document_url",length = 225)
public String getDocumentUrl(){
@Column(name = "document_url", length = 225)
public String getDocumentUrl() {
return this.documentUrl;
}
public void setDocumentUrl(String documentUrl){
public void setDocumentUrl(String documentUrl) {
this.documentUrl = documentUrl;
super.addValidField("documentUrl");
}
/** char_count
*文档字符数
*/
/**
* char_count
* 文档字符数
*/
private Long charCount;
@Column(name = "char_count",length = 19)
public Long getCharCount(){
@Column(name = "char_count", length = 19)
public Long getCharCount() {
return this.charCount;
}
public void setCharCount(Long charCount){
public void setCharCount(Long charCount) {
this.charCount = charCount;
super.addValidField("charCount");
}
/** upload_time
*上传时间
*/
/**
* upload_time
* 上传时间
*/
private java.util.Date uploadTime;
@Column(name = "upload_time",length = 19)
public java.util.Date getUploadTime(){
@Column(name = "upload_time", length = 19)
public java.util.Date getUploadTime() {
return this.uploadTime;
}
public void setUploadTime(java.util.Date uploadTime){
public void setUploadTime(java.util.Date uploadTime) {
this.uploadTime = uploadTime;
super.addValidField("uploadTime");
}
/** is_enable
*是否启用 N-不启用 Y-启用
*/
/**
* 分片规则
*/
private String segmentationConfig;
@Column(name = "segmentation_config",length = 1073741824)
public String getSegmentationConfig() {
return segmentationConfig;
}
public void setSegmentationConfig(String segmentationConfig) {
this.segmentationConfig = segmentationConfig;
super.addValidField("segmentationConfig");
}
/**
* is_enable
* 是否启用 N-不启用 Y-启用
*/
private String isEnable;
@Column(name = "is_enable",length = 1)
public String getIsEnable(){
@Column(name = "is_enable", length = 1)
public String getIsEnable() {
return this.isEnable;
}
public void setIsEnable(String isEnable){
public void setIsEnable(String isEnable) {
this.isEnable = isEnable;
super.addValidField("isEnable");
}
/** knowledge_id
*中台知识库ID
*/
/**
* knowledge_id
* 中台知识库ID
*/
private String knowledgeId;
@Column(name = "knowledge_id",length = 225)
public String getKnowledgeId(){
@Column(name = "knowledge_id", length = 225)
public String getKnowledgeId() {
return this.knowledgeId;
}
public void setKnowledgeId(String knowledgeId){
public void setKnowledgeId(String knowledgeId) {
this.knowledgeId = knowledgeId;
super.addValidField("knowledgeId");
}
/** train_status
*状态:未执行-Unopened、 排队-Line 、训练中-Training、 完成-Complete、失败-Fail
*/
/**
* train_status
* 状态:未执行-Unopened、 排队-Line 、训练中-Training、 完成-Complete、失败-Fail
*/
private String trainStatus;
@Column(name = "train_status",length = 15)
public String getTrainStatus(){
@Column(name = "train_status", length = 15)
public String getTrainStatus() {
return this.trainStatus;
}
public void setTrainStatus(String trainStatus){
public void setTrainStatus(String trainStatus) {
this.trainStatus = trainStatus;
super.addValidField("trainStatus");
}
/** is_deleted
*是否删除 Y 是 N 否
*/
/**
* is_deleted
* 是否删除 Y 是 N 否
*/
private String isDeleted;
@Column(name = "is_deleted",length = 1)
public String getIsDeleted(){
@Column(name = "is_deleted", length = 1)
public String getIsDeleted() {
return this.isDeleted;
}
public void setIsDeleted(String isDeleted){
public void setIsDeleted(String isDeleted) {
this.isDeleted = isDeleted;
super.addValidField("isDeleted");
}
/** CREATOR
*创建人
*/
/**
* CREATOR
* 创建人
*/
private String creator;
@Column(name = "CREATOR",length = 50)
public String getCreator(){
@Column(name = "CREATOR", length = 50)
public String getCreator() {
return this.creator;
}
public void setCreator(String creator){
public void setCreator(String creator) {
this.creator = creator;
super.addValidField("creator");
}
/** CREATED_TIME
*创建时间
*/
/**
* CREATED_TIME
* 创建时间
*/
private java.util.Date createdTime;
@Column(name = "CREATED_TIME",length = 19)
public java.util.Date getCreatedTime(){
@Column(name = "CREATED_TIME", length = 19)
public java.util.Date getCreatedTime() {
return this.createdTime;
}
public void setCreatedTime(java.util.Date createdTime){
public void setCreatedTime(java.util.Date createdTime) {
this.createdTime = createdTime;
super.addValidField("createdTime");
}
/** MODIFIER
*修改人
*/
/**
* MODIFIER
* 修改人
*/
private String modifier;
@Column(name = "MODIFIER",length = 50)
public String getModifier(){
@Column(name = "MODIFIER", length = 50)
public String getModifier() {
return this.modifier;
}
public void setModifier(String modifier){
public void setModifier(String modifier) {
this.modifier = modifier;
super.addValidField("modifier");
}
/** MODIFIED_TIME
*修改时间
*/
/**
* MODIFIED_TIME
* 修改时间
*/
private java.util.Date modifiedTime;
@Column(name = "MODIFIED_TIME",length = 19)
public java.util.Date getModifiedTime(){
@Column(name = "MODIFIED_TIME", length = 19)
public java.util.Date getModifiedTime() {
return this.modifiedTime;
}
public void setModifiedTime(java.util.Date modifiedTime){
public void setModifiedTime(java.util.Date modifiedTime) {
this.modifiedTime = modifiedTime;
super.addValidField("modifiedTime");
}
/** SYS_VERSION
*乐观锁,版本号
*/
/**
* SYS_VERSION
* 乐观锁,版本号
*/
private Integer sysVersion;
@Column(name = "SYS_VERSION",length = 10)
@Version
public Integer getSysVersion(){
@Column(name = "SYS_VERSION", length = 10)
@Version
public Integer getSysVersion() {
return this.sysVersion;
}
public void setSysVersion(Integer sysVersion){
public void setSysVersion(Integer sysVersion) {
this.sysVersion = sysVersion;
super.addValidField("sysVersion");
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ select
bkd.document_name,
bkd.document_url,
bkd.char_count,
bkd.segmentation_config,
bkd.upload_time,
bkd.is_enable,
bkd.knowledge_id,
......
......@@ -10,148 +10,169 @@ import java.io.Serializable;
* Query Item class for KnowledgeQuery
*/
@Entity
public class KnowledgeQueryItem extends BaseItemClass implements Serializable{
public class KnowledgeQueryItem extends BaseItemClass implements Serializable {
private static final long serialVersionUID = 1L;
/** kd_id
*kd_id
*/
/**
* kd_id
* kd_id
*/
private Integer kdId;
@Column(name = "kd_id")
public Integer getKdId(){
public Integer getKdId() {
return this.kdId;
}
public void setKdId(Integer kdId){
public void setKdId(Integer kdId) {
this.kdId = kdId;
}
/** owner
*owner
*/
/**
* owner
* owner
*/
private String owner;
@Column(name = "owner")
public String getOwner(){
public String getOwner() {
return this.owner;
}
public void setOwner(String owner){
public void setOwner(String owner) {
this.owner = owner;
}
/** knowledge_type
*knowledge_type
*/
/**
* knowledge_type
* knowledge_type
*/
private String knowledgeType;
@Column(name = "knowledge_type")
public String getKnowledgeType(){
public String getKnowledgeType() {
return this.knowledgeType;
}
public void setKnowledgeType(String knowledgeType){
public void setKnowledgeType(String knowledgeType) {
this.knowledgeType = knowledgeType;
}
/** document_name
*document_name
*/
/**
* document_name
* document_name
*/
private String documentName;
@Column(name = "document_name")
public String getDocumentName(){
public String getDocumentName() {
return this.documentName;
}
public void setDocumentName(String documentName){
public void setDocumentName(String documentName) {
this.documentName = documentName;
}
/** document_url
*document_url
*/
/**
* document_url
* document_url
*/
private String documentUrl;
@Column(name = "document_url")
public String getDocumentUrl(){
public String getDocumentUrl() {
return this.documentUrl;
}
public void setDocumentUrl(String documentUrl){
public void setDocumentUrl(String documentUrl) {
this.documentUrl = documentUrl;
}
/** char_count
*char_count
*/
/**
* char_count
* char_count
*/
private Long charCount;
@Column(name = "char_count")
public Long getCharCount(){
public Long getCharCount() {
return this.charCount;
}
public void setCharCount(Long charCount){
public void setCharCount(Long charCount) {
this.charCount = charCount;
}
/** upload_time
*upload_time
*/
/**
* upload_time
* upload_time
*/
private java.util.Date uploadTime;
@Column(name = "upload_time")
public java.util.Date getUploadTime(){
public java.util.Date getUploadTime() {
return this.uploadTime;
}
public void setUploadTime(java.util.Date uploadTime){
public void setUploadTime(java.util.Date uploadTime) {
this.uploadTime = uploadTime;
}
/** is_enable
*is_enable
*/
private String segmentationConfig;
@Column(name = "segmentation_config")
public String getSegmentationConfig() {
return segmentationConfig;
}
public void setSegmentationConfig(String segmentationConfig) {
this.segmentationConfig = segmentationConfig;
}
/**
* is_enable
* is_enable
*/
private String isEnable;
@Column(name = "is_enable")
public String getIsEnable(){
public String getIsEnable() {
return this.isEnable;
}
public void setIsEnable(String isEnable){
public void setIsEnable(String isEnable) {
this.isEnable = isEnable;
}
/** knowledge_id
*knowledge_id
*/
/**
* knowledge_id
* knowledge_id
*/
private String knowledgeId;
@Column(name = "knowledge_id")
public String getKnowledgeId(){
public String getKnowledgeId() {
return this.knowledgeId;
}
public void setKnowledgeId(String knowledgeId){
public void setKnowledgeId(String knowledgeId) {
this.knowledgeId = knowledgeId;
}
/** train_status
*train_status
*/
/**
* train_status
* train_status
*/
private String trainStatus;
@Column(name = "train_status")
public String getTrainStatus(){
public String getTrainStatus() {
return this.trainStatus;
}
public void setTrainStatus(String trainStatus){
public void setTrainStatus(String trainStatus) {
this.trainStatus = trainStatus;
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package cn.com.poc.knowledge.service.impl;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.utils.Assert;
import cn.com.poc.common.utils.JsonUtils;
import cn.com.poc.knowledge.convert.KnowledgeDocumentConvert;
import cn.com.poc.knowledge.entity.BizKnowledgeDocumentEntity;
import cn.com.poc.knowledge.model.BizKnowledgeDocumentModel;
......@@ -64,6 +65,10 @@ public class BizKnowledgeDocumentServiceImpl extends BaseServiceImpl
BeanUtil.copyProperties(entity, bizKnowledgeDocumentModel, new CopyOptions() {{
setIgnoreNullValue(true);
}});
if (null != entity.getSegmentationConfig()) {
String config = JsonUtils.serialize(entity.getSegmentationConfig());
bizKnowledgeDocumentModel.setSegmentationConfig(config);
}
BizKnowledgeDocumentModel updateModel = this.repository.save(bizKnowledgeDocumentModel);
return KnowledgeDocumentConvert.modelToEntity(updateModel);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment