新增:知识库文件增删改增加cidFlowId
This commit is contained in:
@@ -180,4 +180,8 @@ public class FileMetadataInfo implements Serializable {
|
||||
@TableField(value = "tempMetadata", updateStrategy = FieldStrategy.IGNORED)
|
||||
private String tempMetadata;
|
||||
|
||||
@Schema(description= "cidFlowId:cid审核电子流程id")
|
||||
@TableField(value = "cidFlowId")
|
||||
private String cidFlowId;
|
||||
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.assertj.core.util.DateUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -549,13 +550,14 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
// 发送审批电子流,成功继续西面操作,失败直接返回
|
||||
// String templateId, String templateName,String approveContents,int approveAction:1:新增 2:修改 3:删除
|
||||
String approveContents = getApproveContents(delFileId, "知识库文件删除", NumberConstants.THREE, deleteFileMetadataInfo, null);
|
||||
boolean approveResult = launchFileDataApprove(req.getTemplateId(), req.getTemplateName(), approveContents, NumberConstants.THREE);
|
||||
if(!approveResult) {
|
||||
Pair<Boolean, String> approvePair = launchFileDataApprove(req.getTemplateId(), req.getTemplateName(), approveContents, NumberConstants.THREE);
|
||||
if(!approvePair.getLeft()|| org.apache.commons.lang3.StringUtils.isBlank(approvePair.getRight())) {
|
||||
log.error("delFile approveInit failed, params :{}", JSONObject.toJSONString(req));
|
||||
throw new RuntimeException("文件删除,创建审批流失败");
|
||||
throw new RuntimeException("文件删除,创建审批流失败,cidFlowId:"+approvePair.getRight());
|
||||
}
|
||||
deleteFileMetadataInfo.setApprovalStatus(ApprovalFileDataStatusEnum.PENDING.getKey());
|
||||
deleteFileMetadataInfo.setApproveType(ApproveFileDataTypeEnum.DELETE_REVIEWING.getCode());
|
||||
deleteFileMetadataInfo.setCidFlowId(approvePair.getRight());
|
||||
fileMetadataInfoService.updateById(deleteFileMetadataInfo);
|
||||
return SdmResponse.success("操作成功,删除文件待审批");
|
||||
} catch (Exception e) {
|
||||
@@ -1019,14 +1021,19 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
// 调用审批流,开启审批; 上面先入库拿到主键id,审批流创建失败后再回退数据
|
||||
// String templateId, String templateName,String approveContents,int approveAction:1:新增 2:修改 3:删除
|
||||
String approveContents = getApproveContents(fileInfo.getId(), "知识库文件新增", NumberConstants.ONE, fileInfo, null);
|
||||
boolean approveResult = launchFileDataApprove(req.getTemplateId(), req.getTemplateName(), approveContents, NumberConstants.ONE);
|
||||
if(!approveResult){
|
||||
Pair<Boolean,String> approvePair = launchFileDataApprove(req.getTemplateId(), req.getTemplateName(), approveContents, NumberConstants.ONE);
|
||||
if(!approvePair.getLeft()|| org.apache.commons.lang3.StringUtils.isBlank(approvePair.getRight())) {
|
||||
log.error("uploadFiles create approveInit failed, params :{}", JSONObject.toJSONString(req));
|
||||
// - 回退MinIO中已上传的文件(删除该文件)。catch 里统一操作了
|
||||
//- 新增 file_metadata_info 信息不入表。
|
||||
//- 向前端返回“上传文件失败”。
|
||||
throw new RuntimeException("文件上传,创建审批流失败");
|
||||
throw new RuntimeException("文件上传,创建审批流失败,cidFlowId:"+approvePair.getRight());
|
||||
}
|
||||
// 需要保存文件的历史版本记录,同一文件的所有版本共享一个ID,
|
||||
fileInfo.setFileGroupId(fileInfo.getId());
|
||||
// cid流程id
|
||||
fileInfo.setCidFlowId(approvePair.getRight());
|
||||
fileMetadataInfoService.updateById(fileInfo);
|
||||
|
||||
// 创建文件扩展信息并保存到数据库
|
||||
List<FileMetadataExtension> fileMetadataExtensionList = new ArrayList<>();
|
||||
@@ -1055,7 +1062,6 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
throw new RuntimeException("上传文件失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getSuffixWithoutDot(String fileName) {
|
||||
int lastDotIndex = fileName.lastIndexOf('.');
|
||||
if (lastDotIndex == -1) {
|
||||
@@ -1064,6 +1070,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
return fileName.substring(lastDotIndex + 1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SdmResponse downloadRecord(AddDownloadRecordReq req) {
|
||||
return null;
|
||||
@@ -1156,19 +1163,16 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
// 本次待审核的数据
|
||||
fileMetadataInfo.setTempMetadata(JSONObject.toJSONString(tempFileMetadataInfo));
|
||||
|
||||
fileMetadataInfoService.updateById(fileMetadataInfo);
|
||||
// String templateId, String templateName,String approveContents,int approveAction:1:新增 2:修改 3:删除
|
||||
boolean approveResult = launchFileDataApprove(req.getTemplateId(), req.getTemplateName(), approveContents, NumberConstants.TWO);
|
||||
if(!approveResult){
|
||||
Pair<Boolean, String> approvePair = launchFileDataApprove(req.getTemplateId(), req.getTemplateName(), approveContents, NumberConstants.TWO);
|
||||
if(!approvePair.getLeft()||org.apache.commons.lang3.StringUtils.isBlank(approvePair.getRight())){
|
||||
log.error("updateFile meteData approveInit failed, params :{}", JSONObject.toJSONString(req));
|
||||
// 失败数据回退
|
||||
fileMetadataInfo.setTempMetadata(null);
|
||||
fileMetadataInfo.setApprovalStatus(null);
|
||||
// 回退到已完成
|
||||
fileMetadataInfo.setApproveType(ApproveFileDataTypeEnum.COMPLETED.getCode());
|
||||
fileMetadataInfoService.updateById(fileMetadataInfo);
|
||||
throw new RuntimeException("文件元数据修改失败,创建审批流失败");
|
||||
// 失败数据还未入表
|
||||
throw new RuntimeException("文件元数据修改失败,创建审批流失败,cidFlowId:"+approvePair.getRight());
|
||||
}
|
||||
// 审批中的cidFlowId
|
||||
fileMetadataInfo.setCidFlowId(approvePair.getRight());
|
||||
fileMetadataInfoService.updateById(fileMetadataInfo);
|
||||
} else {
|
||||
// 需要上传minio新文件,更新文件元数据
|
||||
uploadAndUpdateFile(req, oldFileMinioObjectKey, fileMetadataInfo, versionNo, fileGroupId);
|
||||
@@ -1214,14 +1218,17 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
// 获取前后变化的file信息
|
||||
String approveContents = getApproveContents(fileInfo.getId(), "知识库文件修改",
|
||||
NumberConstants.TWO,fileMetadataInfo , fileInfo);
|
||||
boolean approveResult = launchFileDataApprove(req.getTemplateId(), req.getTemplateName(), approveContents, NumberConstants.TWO);
|
||||
if(!approveResult){
|
||||
Pair<Boolean, String> approvePair = launchFileDataApprove(req.getTemplateId(), req.getTemplateName(), approveContents, NumberConstants.TWO);
|
||||
if(!approvePair.getLeft()||org.apache.commons.lang3.StringUtils.isBlank(approvePair.getRight())){
|
||||
log.error("uploadAndUpdateFile updateFile approveInit failed, params :{}", JSONObject.toJSONString(req));
|
||||
// 失败数据回退删除
|
||||
fileMetadataInfoService.removeById(fileInfo.getId());
|
||||
throw new RuntimeException("文件修改失败,创建审批流失败");
|
||||
// 失败数据回退删除--事务回滚
|
||||
throw new RuntimeException("文件修改失败,创建审批流失败,cidFlowId:"+approvePair.getRight());
|
||||
}
|
||||
|
||||
// cid流程id
|
||||
fileInfo.setCidFlowId(approvePair.getRight());
|
||||
fileMetadataInfoService.updateById(fileInfo);
|
||||
|
||||
// 创建文件扩展信息并保存到数据库
|
||||
List<FileMetadataExtension> fileMetadataExtensionList = new ArrayList<>();
|
||||
List<UploadFilesReq.FileMetadataExtensionRequest> fileMetadataExtensionRequestList = req.getFileMetadataExtensionRequest();
|
||||
@@ -1535,9 +1542,10 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
}
|
||||
|
||||
// 发起仿真知识库文件审核 true 成功 false失败
|
||||
private boolean launchFileDataApprove(String templateId, String templateName,String approveContents,int approveAction)
|
||||
private Pair<Boolean,String> launchFileDataApprove(String templateId, String templateName, String approveContents, int approveAction)
|
||||
{
|
||||
boolean result = false;
|
||||
String cidFlowId="";
|
||||
LaunchApproveReq req = new LaunchApproveReq();
|
||||
try {
|
||||
// 评审流程模版ID 前端传过来
|
||||
@@ -1562,19 +1570,23 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
// req.userId = 1979078323595476993l;
|
||||
// 审批创建者
|
||||
req.creator = ThreadLocalContext.getUserId();
|
||||
// req.creator = 1979078323595476993l;
|
||||
SdmResponse response = approveFeignClient.launchApproval(req);
|
||||
if(response.isSuccess()){
|
||||
// 成功
|
||||
result = true;
|
||||
cidFlowId = Optional.ofNullable(response.getData())
|
||||
.map(Object::toString)
|
||||
.orElse("");
|
||||
}
|
||||
return response.isSuccess();
|
||||
} catch (Exception e) {
|
||||
log.error("launchFileDataApprove error :{}",e);
|
||||
log.error("launchFileDataApprove error :{},",e);
|
||||
}finally {
|
||||
if(!result){
|
||||
log.warn("launchFileDataApprove fileData failed:{}",JSONObject.toJSONString(req));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return Pair.of(result,cidFlowId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user