fix:参数库审批功能调整
This commit is contained in:
@@ -139,6 +139,21 @@ public class DataClientFeignClientImpl implements IDataFeignClient {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse approveParamLibrary(LaunchApproveReq req) {
|
||||
SdmResponse response;
|
||||
try {
|
||||
response = dataClient.approveParamLibrary(req);
|
||||
if (!response.isSuccess()) {
|
||||
return SdmResponse.failed("仿真参数库文件审批状态修改失败");
|
||||
}
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
log.error("仿真参数库文件审批状态修改异常", e);
|
||||
return SdmResponse.failed("仿真参数库文件审批状态修改异常");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse uploadFiles(UploadFilesReq req) {
|
||||
SdmResponse response;
|
||||
|
||||
@@ -59,6 +59,9 @@ public interface IDataFeignClient {
|
||||
@PostMapping("/data/approveDataFile")
|
||||
SdmResponse approveDataFile(@RequestBody LaunchApproveReq req);
|
||||
|
||||
@PostMapping("/data/approveParamLibrary")
|
||||
SdmResponse approveParamLibrary(@RequestBody LaunchApproveReq req);
|
||||
|
||||
@PostMapping(value = "/data/uploadFiles",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
SdmResponse uploadFiles(UploadFilesReq req);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.sdm.data.model.bo;
|
||||
|
||||
import com.sdm.data.model.entity.FileMetadataInfo;
|
||||
import com.sdm.data.model.req.UpdateSimulationParameterReq;
|
||||
import com.sdm.data.model.resp.SimulationParameterLibraryCategoryObjectResp;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -31,5 +32,9 @@ public class ApprovalParamContentsModel {
|
||||
* 参数库删除 库/类/对象id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 参数库编辑 请求入参
|
||||
*/
|
||||
private UpdateSimulationParameterReq updateParameterReq;
|
||||
|
||||
}
|
||||
|
||||
@@ -12,4 +12,13 @@ public class UpdateSimulationParameterReq {
|
||||
|
||||
@Schema(description = "要更新的完整参数列表")
|
||||
private List<SimulationParameterItem> parameterList;
|
||||
|
||||
@Schema(description = "参数库文件审批模板id")
|
||||
private String templateId;
|
||||
|
||||
@Schema(description = "参数库文件审批模板名称")
|
||||
private String templateName;
|
||||
|
||||
@Schema(description = "是否需要评审")
|
||||
private boolean isApprove = true;
|
||||
}
|
||||
@@ -1726,6 +1726,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
log.info("参数库审批结果req:{}",req);
|
||||
// 审批状态
|
||||
int approveStatus = req.approveStatus;
|
||||
int approveAction = req.approveAction;
|
||||
|
||||
// 前置校验
|
||||
validateApproveRequest(req);
|
||||
@@ -1744,18 +1745,38 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
Integer type = approvalModel.getType();
|
||||
Long id = approvalModel.getId();
|
||||
|
||||
// 审批通过
|
||||
if (NumberConstants.TWO == approveStatus) {
|
||||
SimulationParamLibraryReq libraryReq = new SimulationParamLibraryReq();
|
||||
libraryReq.setType(type);
|
||||
libraryReq.setId(id);
|
||||
libraryReq.setApprove(false);
|
||||
simulationParameterLibraryService.deleteSimulationParameter(libraryReq);
|
||||
}
|
||||
|
||||
// 审批不通过 不处理
|
||||
if (NumberConstants.THREE == approveStatus) {
|
||||
|
||||
if (ApproveFileDataTypeEnum.UPLOAD_REVIEWING.getCode() == approveAction) {
|
||||
FileMetadataInfo fileMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getId, approvalModel.getIds().get(0)).one();
|
||||
// 审批通过
|
||||
if (NumberConstants.TWO == approveStatus) {
|
||||
fileMetadataInfo.setApprovalStatus(ApprovalFileDataStatusEnum.APPROVED.getKey());
|
||||
fileMetadataInfo.setApproveType(ApproveFileDataTypeEnum.COMPLETED.getCode());
|
||||
fileMetadataInfoService.updateById(fileMetadataInfo);
|
||||
}
|
||||
// 审批不通过
|
||||
if (NumberConstants.THREE == approveStatus) {
|
||||
SimulationParamLibraryReq libraryReq = new SimulationParamLibraryReq();
|
||||
libraryReq.setType(type);
|
||||
libraryReq.setId(id);
|
||||
libraryReq.setApprove(false);
|
||||
simulationParameterLibraryService.deleteSimulationParameter(libraryReq);
|
||||
}
|
||||
} else if (ApproveFileDataTypeEnum.MODIFY_REVIEWING.getCode() == approveAction) {
|
||||
// 审批通过 执行编辑 审批不通过 不处理
|
||||
if (NumberConstants.TWO == approveStatus) {
|
||||
UpdateSimulationParameterReq updateParameterReq = approvalModel.getUpdateParameterReq();
|
||||
updateParameterReq.setApprove(false);
|
||||
simulationParameterLibraryService.updateSimulationParameterValues(updateParameterReq);
|
||||
}
|
||||
} else if (ApproveFileDataTypeEnum.DELETE_REVIEWING.getCode() == approveAction) {
|
||||
// 审批通过 执行删除 审批不通过 不处理
|
||||
if (NumberConstants.TWO == approveStatus) {
|
||||
SimulationParamLibraryReq libraryReq = new SimulationParamLibraryReq();
|
||||
libraryReq.setType(type);
|
||||
libraryReq.setId(id);
|
||||
libraryReq.setApprove(false);
|
||||
simulationParameterLibraryService.deleteSimulationParameter(libraryReq);
|
||||
}
|
||||
}
|
||||
return SdmResponse.success();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.sdm.data.model.enums.ApproveFileActionENUM;
|
||||
import com.sdm.data.model.req.SimulationParameterItem;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
@@ -177,12 +178,14 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
SimulationParameterLibraryCategoryObjectResp objectResp = getSimulationParameterLibraryCategoryObjectInner(simulationParameterLibraryCategoryObject.getId());
|
||||
ApprovalParamContentsModel contentsModel = new ApprovalParamContentsModel();
|
||||
contentsModel.setIds(Arrays.asList(fileId));
|
||||
contentsModel.setApproveAction(1);
|
||||
contentsModel.setApproveAction(ApproveFileActionENUM.ADD.getCode());
|
||||
contentsModel.setContents("参数库文件新增");
|
||||
contentsModel.setFileInfo(fileMetadataInfo);
|
||||
contentsModel.setParamData(objectResp);
|
||||
contentsModel.setId(simulationParameterLibraryCategoryObject.getId());
|
||||
contentsModel.setType(SimulationParameterDataTypeEnum.OBJECT.getValue());
|
||||
// 发起审批
|
||||
String cidFlowId = launchParamApprove(req.getTemplateId(),req.getTemplateName(), JSONObject.toJSONString(contentsModel),1);
|
||||
String cidFlowId = launchParamApprove(req.getTemplateId(),req.getTemplateName(), JSONObject.toJSONString(contentsModel),ApproveFileActionENUM.ADD.getCode());
|
||||
if (StringUtils.isEmpty(cidFlowId)) {
|
||||
return SdmResponse.failed("发起评审失败");
|
||||
}
|
||||
@@ -341,14 +344,14 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
SimulationParameterLibraryCategoryObjectResp objectResp = getSimulationParameterLibraryCategoryObjectInner(req.getId());
|
||||
ApprovalParamContentsModel contentsModel = new ApprovalParamContentsModel();
|
||||
contentsModel.setIds(Arrays.asList(deleteFileMetadataInfo.getId()));
|
||||
contentsModel.setApproveAction(3);
|
||||
contentsModel.setApproveAction(ApproveFileActionENUM.DELETE.getCode());
|
||||
contentsModel.setContents("参数库文件删除");
|
||||
contentsModel.setFileInfo(deleteFileMetadataInfo);
|
||||
contentsModel.setParamData(objectResp);
|
||||
contentsModel.setType(req.getType());
|
||||
contentsModel.setId(req.getId());
|
||||
// 发起审批
|
||||
String cidFlowId = launchParamApprove(req.getTemplateId(),req.getTemplateName(), JSONObject.toJSONString(contentsModel),3);
|
||||
String cidFlowId = launchParamApprove(req.getTemplateId(),req.getTemplateName(), JSONObject.toJSONString(contentsModel),ApproveFileActionENUM.DELETE.getCode());
|
||||
if (StringUtils.isEmpty(cidFlowId)) {
|
||||
return SdmResponse.failed("发起评审失败");
|
||||
}
|
||||
@@ -367,9 +370,7 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
}
|
||||
if (req.isApprove()) {
|
||||
SdmResponse response = deleteApprove(req);
|
||||
if (!response.isSuccess()) {
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
} else {
|
||||
simulationParameterLibraryCategoryService.removeById(req.getId());
|
||||
simulationParameterLibraryCategoryObjectService.lambdaUpdate().eq(SimulationParameterLibraryCategoryObject::getParameterLibraryCategoryId, req.getId()).remove();
|
||||
@@ -382,9 +383,7 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
}
|
||||
if (req.isApprove()) {
|
||||
SdmResponse response = deleteApprove(req);
|
||||
if (!response.isSuccess()) {
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
} else {
|
||||
this.removeById(req.getId());
|
||||
simulationParameterLibraryCategoryService.lambdaUpdate().eq(SimulationParameterLibraryCategory::getParameterLibraryId, req.getId()).remove();
|
||||
@@ -398,7 +397,7 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
private SdmResponse checkApprove(List<SimulationParameterLibraryCategoryObject> objectList) {
|
||||
if (!CollectionUtils.isEmpty(objectList)) {
|
||||
List<Long> fileIds = objectList.stream().map(SimulationParameterLibraryCategoryObject::getFileId).filter(ObjectUtils::isNotEmpty).toList();
|
||||
if (fileMetadataInfoService.listByIds(fileIds).stream().anyMatch(i -> ApproveStatusEnum.APPROVING.getCode().equals(i.getApproveType()))) {
|
||||
if (fileMetadataInfoService.listByIds(fileIds).stream().anyMatch(i -> ApprovalFileDataStatusEnum.PENDING.getKey().equals(i.getApprovalStatus()))) {
|
||||
return SdmResponse.failed("有正在审批中的参数对象,无法删除");
|
||||
}
|
||||
}
|
||||
@@ -407,12 +406,12 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
|
||||
private SdmResponse deleteApprove(SimulationParamLibraryReq req) {
|
||||
ApprovalParamContentsModel contentsModel = new ApprovalParamContentsModel();
|
||||
contentsModel.setApproveAction(3);
|
||||
contentsModel.setApproveAction(ApproveFileActionENUM.DELETE.getCode());
|
||||
contentsModel.setContents("参数库文件删除");
|
||||
contentsModel.setType(req.getType());
|
||||
contentsModel.setId(req.getId());
|
||||
// 发起审批
|
||||
String cidFlowId = launchParamApprove(req.getTemplateId(),req.getTemplateName(), JSONObject.toJSONString(contentsModel),3);
|
||||
String cidFlowId = launchParamApprove(req.getTemplateId(),req.getTemplateName(), JSONObject.toJSONString(contentsModel),ApproveFileActionENUM.DELETE.getCode());
|
||||
if (StringUtils.isEmpty(cidFlowId)) {
|
||||
return SdmResponse.failed("发起评审失败");
|
||||
}
|
||||
@@ -558,6 +557,10 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
}
|
||||
});
|
||||
|
||||
if (req.isApprove()) {
|
||||
return modifyApprove(fileMetadataInfo, req);
|
||||
}
|
||||
|
||||
// 将参数列表直接转换为JSON
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String updatedJson = objectMapper.writeValueAsString(req.getParameterList());
|
||||
@@ -584,4 +587,29 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
return SdmResponse.failed("参数更新失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private SdmResponse modifyApprove(FileMetadataInfo fileMetadataInfo, UpdateSimulationParameterReq req) {
|
||||
SimulationParameterLibraryCategoryObject object = simulationParameterLibraryCategoryObjectService.lambdaQuery().eq(SimulationParameterLibraryCategoryObject::getFileId, fileMetadataInfo.getId()).one();
|
||||
// 参数库上传json文件内容
|
||||
SimulationParameterLibraryCategoryObjectResp objectResp = getSimulationParameterLibraryCategoryObjectInner(object.getId());
|
||||
objectResp.setParameterJsonValue(req.getParameterList());
|
||||
ApprovalParamContentsModel contentsModel = new ApprovalParamContentsModel();
|
||||
contentsModel.setIds(Arrays.asList(fileMetadataInfo.getId()));
|
||||
contentsModel.setApproveAction(ApproveFileActionENUM.MODIFY.getCode());
|
||||
contentsModel.setContents("参数库文件修改");
|
||||
contentsModel.setFileInfo(fileMetadataInfo);
|
||||
contentsModel.setParamData(objectResp);
|
||||
contentsModel.setType(SimulationParameterDataTypeEnum.OBJECT.getValue());
|
||||
|
||||
// 发起审批
|
||||
String cidFlowId = launchParamApprove(req.getTemplateId(),req.getTemplateName(), JSONObject.toJSONString(contentsModel),ApproveFileActionENUM.MODIFY.getCode());
|
||||
if (StringUtils.isEmpty(cidFlowId)) {
|
||||
return SdmResponse.failed("发起评审失败");
|
||||
}
|
||||
fileMetadataInfo.setCidFlowId(cidFlowId);
|
||||
fileMetadataInfo.setApprovalStatus(ApprovalFileDataStatusEnum.PENDING.getKey());
|
||||
fileMetadataInfo.setApproveType(ApproveFileDataTypeEnum.MODIFY_REVIEWING.getCode());
|
||||
fileMetadataInfoService.updateById(fileMetadataInfo);
|
||||
return SdmResponse.success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,11 +71,6 @@ public class DeleteApproveStrategy implements ApproveStrategy {
|
||||
metadata.setUpdateTime(LocalDateTime.now());
|
||||
service.updateById(metadata);
|
||||
|
||||
// 如果是参数库审批 删除参数库对象
|
||||
if (ApproveTypeEnum.PARAM_APPROVE.getCode() == type) {
|
||||
paramObjectService.remove(new LambdaQueryWrapper<SimulationParameterLibraryCategoryObject>().eq(SimulationParameterLibraryCategoryObject::getFileId, metadata.getId()));
|
||||
}
|
||||
|
||||
log.info("审批通过,文件已移入回收站: id={}, objectKey={}", metadata.getId(), metadata.getObjectKey());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.sdm.data.service.impl.dataFileHandle;
|
||||
|
||||
public interface ParamApproveStrategy {
|
||||
/**
|
||||
* 处理参数库审批逻辑
|
||||
* approveStatus 审批状态(2-通过,3-不通过)
|
||||
* @return 处理结果
|
||||
*/
|
||||
boolean handle(ApproveContext context);
|
||||
}
|
||||
@@ -58,10 +58,6 @@ public class UploadApproveStrategy implements ApproveStrategy {
|
||||
// 删除文件标签关系
|
||||
fileTagRelService.remove(new LambdaQueryWrapper<FileTagRel>().in(FileTagRel::getFileId, removeIds));
|
||||
|
||||
// 如果是参数库审批 删除参数库对象 记录操作日志
|
||||
if (ApproveTypeEnum.PARAM_APPROVE.getCode() == context.getApproveType()) {
|
||||
paramObjectService.remove(new LambdaQueryWrapper<SimulationParameterLibraryCategoryObject>().in(SimulationParameterLibraryCategoryObject::getFileId, removeIds));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class SimulationParamStrategy extends ApproveAbstractNoticeStrategy {
|
||||
|
||||
@Override
|
||||
public SdmResponse noticeResult(LaunchApproveReq req) {
|
||||
return dataFeignClient.approveDataFile(req);
|
||||
return dataFeignClient.approveParamLibrary(req);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user