fix:参数库审批功能调整
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.sdm.common.entity.resp.system;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -33,6 +34,7 @@ public class CIDUserResp implements Serializable{
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "密码(存储加密后的密码,如MD5、BCrypt加密结果,可选)")
|
||||
@JsonIgnore
|
||||
private String password;
|
||||
|
||||
@Schema(description = "盐值(用于密码加密的随机字符串,与password配套使用,可选)")
|
||||
|
||||
@@ -99,6 +99,16 @@ public class DataFileController implements IDataFeignClient {
|
||||
return IDataFileService.approveDataFile(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数库和类的删除审批不涉及文件,走这个审批回调
|
||||
*/
|
||||
@PostMapping("/approveParamLibrary")
|
||||
@Operation(summary = "参数库审批状态修改", description = "参数库审批状态修改")
|
||||
public SdmResponse approveParamLibrary(@RequestBody @Validated LaunchApproveReq req) {
|
||||
return IDataFileService.approveParamLibrary(req);
|
||||
}
|
||||
|
||||
|
||||
//判断是否为空文件夹
|
||||
@GetMapping("/isDirEmpty")
|
||||
@Operation(summary = "判断是否为空文件夹", description = "根据请求参数判断指定文件夹是否为空")
|
||||
|
||||
@@ -23,5 +23,13 @@ public class ApprovalParamContentsModel {
|
||||
* 上传的参数库json文件数据
|
||||
*/
|
||||
private SimulationParameterLibraryCategoryObjectResp paramData;
|
||||
/**
|
||||
* 参数库删除类型 库/类/对象
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 参数库删除 库/类/对象id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
}
|
||||
|
||||
@@ -23,4 +23,7 @@ public class SimulationParamLibraryReq {
|
||||
@Schema(description = "参数库文件审批模板名称")
|
||||
private String templateName;
|
||||
|
||||
@Schema(description = "是否需要审批")
|
||||
private boolean isApprove = true;
|
||||
|
||||
}
|
||||
|
||||
@@ -407,6 +407,8 @@ public interface IDataFileService {
|
||||
*/
|
||||
default SdmResponse approveDataFile(LaunchApproveReq req){return null;};
|
||||
|
||||
default SdmResponse approveParamLibrary(LaunchApproveReq req){return null;};
|
||||
|
||||
|
||||
SdmResponse<FileMetadataInfoResp> queryFileMetadataInfo(String uuid, String uuidOwnType, Long dirId);
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.sdm.common.utils.excel.ExcelUtil;
|
||||
import com.sdm.data.aop.PermissionCheckAspect;
|
||||
import com.sdm.data.bo.ExportOperate;
|
||||
import com.sdm.data.model.bo.ApprovalFileDataContentsModel;
|
||||
import com.sdm.data.model.bo.ApprovalParamContentsModel;
|
||||
import com.sdm.data.model.dto.ExportKnowledgeDto;
|
||||
import com.sdm.data.model.dto.FileDictTagsAggDTO;
|
||||
import com.sdm.data.model.entity.*;
|
||||
@@ -66,6 +67,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -151,7 +153,9 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
|
||||
@Autowired
|
||||
ISimulationParameterLibraryCategoryObjectService paramObjectService;
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
ISimulationParameterLibraryService simulationParameterLibraryService;
|
||||
|
||||
@Autowired
|
||||
private ApproveStrategyFactory approveStrategyFactory;
|
||||
@@ -1717,6 +1721,45 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse approveParamLibrary(LaunchApproveReq req) {
|
||||
log.info("参数库审批结果req:{}",req);
|
||||
// 审批状态
|
||||
int approveStatus = req.approveStatus;
|
||||
|
||||
// 前置校验
|
||||
validateApproveRequest(req);
|
||||
|
||||
// 解析审批内容
|
||||
String approveContents = req.approveContents;
|
||||
ApprovalParamContentsModel approvalModel = null;
|
||||
try {
|
||||
approvalModel = JSONObject.parseObject(approveContents, ApprovalParamContentsModel.class);
|
||||
} catch (Exception e) {
|
||||
String errorMsg = "参数库审批回调修改失败,审批内容格式非法";
|
||||
log.error("{},param:{}", errorMsg, JSONObject.toJSONString(req), e);
|
||||
throw new RuntimeException(errorMsg);
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
}
|
||||
return SdmResponse.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse<FileMetadataInfoResp> queryFileMetadataInfo(String uuid, String uuidOwnType, Long dirId) {
|
||||
LambdaQueryWrapper<FileMetadataInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
@@ -9,10 +9,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.sdm.data.model.req.SimulationParameterItem;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.entity.enums.ApprovalFileDataStatusEnum;
|
||||
import com.sdm.common.entity.enums.ApproveFileDataTypeEnum;
|
||||
import com.sdm.common.entity.enums.ApproveTypeEnum;
|
||||
import com.sdm.common.entity.enums.SimulationParameterDataTypeEnum;
|
||||
import com.sdm.common.entity.enums.*;
|
||||
import com.sdm.common.entity.req.system.LaunchApproveReq;
|
||||
import com.sdm.common.feign.impl.system.ApproveFeignClientImpl;
|
||||
import com.sdm.common.service.UserNameCacheService;
|
||||
@@ -291,15 +288,26 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
Set<Long> userIdsSet = new HashSet<>(userIds);
|
||||
Map<Long, String> longStringMap = userNameCacheService.batchGetUserNames(userIdsSet);
|
||||
|
||||
simulationParameterLibraryCategoryObjects.forEach(simulationParameterLibraryCategoryObject -> {
|
||||
Map<Long, Integer> fileApproveTypeMap = new HashMap<>();
|
||||
List<Long> fileIds = simulationParameterLibraryCategoryObjects.stream().map(SimulationParameterLibraryCategoryObject::getFileId).filter(ObjectUtils::isNotEmpty).toList();
|
||||
List<FileMetadataInfo> fileMetadataInfoList = fileMetadataInfoService.listByIds(fileIds);
|
||||
if (!CollectionUtils.isEmpty(fileMetadataInfoList)) {
|
||||
fileApproveTypeMap = fileMetadataInfoList.stream().collect(Collectors.toMap(
|
||||
FileMetadataInfo::getId,
|
||||
FileMetadataInfo::getApproveType
|
||||
));
|
||||
}
|
||||
|
||||
for (SimulationParameterLibraryCategoryObject simulationParameterLibraryCategoryObject : simulationParameterLibraryCategoryObjects) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("id", simulationParameterLibraryCategoryObject.getId());
|
||||
jsonObject.put("type", SimulationParameterDataTypeEnum.OBJECT.getValue());
|
||||
jsonObject.put("name", simulationParameterLibraryCategoryObject.getParameterLibraryCategoryObjectName());
|
||||
jsonObject.put("createName",longStringMap.get(simulationParameterLibraryCategoryObject.getCreatorId()));
|
||||
jsonObject.put("createTime", simulationParameterLibraryCategoryObject.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
jsonObject.put("approveType", fileApproveTypeMap.get(simulationParameterLibraryCategoryObject.getFileId()));
|
||||
jsonObjects.add(jsonObject);
|
||||
});
|
||||
}
|
||||
return SdmResponse.success(jsonObjects);
|
||||
}
|
||||
return SdmResponse.success(jsonObjects);
|
||||
@@ -337,6 +345,8 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
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);
|
||||
if (StringUtils.isEmpty(cidFlowId)) {
|
||||
@@ -350,17 +360,65 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
// simulationParameterLibraryCategoryObjectService.removeById(id);
|
||||
|
||||
} else if (req.getType() == SimulationParameterDataTypeEnum.CATEGORY.getValue()) {
|
||||
simulationParameterLibraryCategoryService.removeById(req.getId());
|
||||
simulationParameterLibraryCategoryObjectService.lambdaUpdate().eq(SimulationParameterLibraryCategoryObject::getParameterLibraryCategoryId, req.getId()).remove();
|
||||
List<SimulationParameterLibraryCategoryObject> objectList = simulationParameterLibraryCategoryObjectService.lambdaQuery().eq(SimulationParameterLibraryCategoryObject::getParameterLibraryCategoryId, req.getId()).list();
|
||||
SdmResponse checkResult = checkApprove(objectList);
|
||||
if (!checkResult.isSuccess()) {
|
||||
return checkResult;
|
||||
}
|
||||
if (req.isApprove()) {
|
||||
SdmResponse response = deleteApprove(req);
|
||||
if (!response.isSuccess()) {
|
||||
return response;
|
||||
}
|
||||
} else {
|
||||
simulationParameterLibraryCategoryService.removeById(req.getId());
|
||||
simulationParameterLibraryCategoryObjectService.lambdaUpdate().eq(SimulationParameterLibraryCategoryObject::getParameterLibraryCategoryId, req.getId()).remove();
|
||||
}
|
||||
} else if (req.getType() == SimulationParameterDataTypeEnum.LIBRARY.getValue()) {
|
||||
this.removeById(req.getId());
|
||||
simulationParameterLibraryCategoryService.lambdaUpdate().eq(SimulationParameterLibraryCategory::getParameterLibraryId, req.getId()).remove();
|
||||
simulationParameterLibraryCategoryObjectService.lambdaUpdate().eq(SimulationParameterLibraryCategoryObject::getParameterLibraryId, req.getId()).remove();
|
||||
List<SimulationParameterLibraryCategoryObject> objectList = simulationParameterLibraryCategoryObjectService.lambdaQuery().eq(SimulationParameterLibraryCategoryObject::getParameterLibraryId, req.getId()).list();
|
||||
SdmResponse checkResult = checkApprove(objectList);
|
||||
if (!checkResult.isSuccess()) {
|
||||
return checkResult;
|
||||
}
|
||||
if (req.isApprove()) {
|
||||
SdmResponse response = deleteApprove(req);
|
||||
if (!response.isSuccess()) {
|
||||
return response;
|
||||
}
|
||||
} else {
|
||||
this.removeById(req.getId());
|
||||
simulationParameterLibraryCategoryService.lambdaUpdate().eq(SimulationParameterLibraryCategory::getParameterLibraryId, req.getId()).remove();
|
||||
simulationParameterLibraryCategoryObjectService.lambdaUpdate().eq(SimulationParameterLibraryCategoryObject::getParameterLibraryId, req.getId()).remove();
|
||||
}
|
||||
}
|
||||
|
||||
return SdmResponse.success("删除成功");
|
||||
}
|
||||
|
||||
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()))) {
|
||||
return SdmResponse.failed("有正在审批中的参数对象,无法删除");
|
||||
}
|
||||
}
|
||||
return SdmResponse.success();
|
||||
}
|
||||
|
||||
private SdmResponse deleteApprove(SimulationParamLibraryReq req) {
|
||||
ApprovalParamContentsModel contentsModel = new ApprovalParamContentsModel();
|
||||
contentsModel.setApproveAction(3);
|
||||
contentsModel.setContents("参数库文件删除");
|
||||
contentsModel.setType(req.getType());
|
||||
contentsModel.setId(req.getId());
|
||||
// 发起审批
|
||||
String cidFlowId = launchParamApprove(req.getTemplateId(),req.getTemplateName(), JSONObject.toJSONString(contentsModel),3);
|
||||
if (StringUtils.isEmpty(cidFlowId)) {
|
||||
return SdmResponse.failed("发起评审失败");
|
||||
}
|
||||
return SdmResponse.success(cidFlowId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse editSimulationParameter(SimulationParamLibraryReq req) {
|
||||
// 根据参数类型和参数id删除参数
|
||||
|
||||
@@ -58,6 +58,7 @@ public class DeleteApproveStrategy implements ApproveStrategy {
|
||||
*/
|
||||
private boolean handleFileDeletion(ApproveContext context, FileMetadataInfo metadata, int type) {
|
||||
IFileMetadataInfoService service = context.getFileMetadataInfoService();
|
||||
ISimulationParameterLibraryCategoryObjectService paramObjectService = context.getParamObjectService();
|
||||
|
||||
try {
|
||||
// 1. 移入回收站 (MinIO Rename + DB Path Update + DB DeleteStatus Update)
|
||||
@@ -70,6 +71,11 @@ 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) {
|
||||
|
||||
Reference in New Issue
Block a user