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 否
*/
......
......@@ -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