@@ -6,8 +6,11 @@ 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.common.entity.req.data.* ;
import com.sdm.common.entity.resp.data.FileMetadataInfoResp ;
import com.sdm.data.model.dto.FileMetadataChildrenDTO ;
import com.sdm.data.model.enums.ApproveFileActionENUM ;
import com.sdm.data.model.req.SimulationParameterItem ;
import com.sdm.data.model.req.* ;
import com.sdm.common.common.SdmResponse ;
import com.sdm.common.common.ThreadLocalContext ;
import com.sdm.common.entity.enums.* ;
@@ -21,10 +24,8 @@ import com.sdm.data.model.entity.FileMetadataInfo;
import com.sdm.data.model.entity.SimulationParameterLibrary ;
import com.sdm.data.model.entity.SimulationParameterLibraryCategory ;
import com.sdm.data.model.entity.SimulationParameterLibraryCategoryObject ;
import com.sdm.data.model.req.SimulationParamLibraryReq ;
import com.sdm.data.model.req.SimulationParameterLibraryCategoryObjectReq ;
import com.sdm.data.model.req.UpdateSimulationParameterReq ;
import com.sdm.data.model.resp.SimulationParameterLibraryCategoryObjectResp ;
import com.sdm.data.model.entity.FileUserPermission ;
import com.sdm.data.service.* ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.lang3.ObjectUtils ;
@@ -74,6 +75,9 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
@Autowired
private UserNameCacheService userNameCacheService ;
@Autowired
private IFileUserPermissionService fileUserPermissionService ;
/**
* 新增仿真参数库
*
@@ -96,6 +100,18 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
simulationParameterLibrary . setTenantId ( ThreadLocalContext . getTenantId ( ) ) ;
simulationParameterLibrary . setCreatorId ( ThreadLocalContext . getUserId ( ) ) ;
this . save ( simulationParameterLibrary ) ;
// 同步创建库对应目录, 并在file_metadata_info记录业务映射关系
CreateDirReq createDirReq = new CreateDirReq ( ) ;
createDirReq . setDirName ( parameterLibraryName ) ;
createDirReq . setDirType ( DirTypeEnum . SIMULATION_PARAMETER_DIR . getValue ( ) ) ;
createDirReq . setUuId ( String . valueOf ( simulationParameterLibrary . getId ( ) ) ) ;
createDirReq . setUuIdOwnType ( SimulationParameterOwnType . LIBRARY . getCode ( ) ) ;
SdmResponse createDirResp = dataFileService . createDir ( createDirReq ) ;
if ( ! createDirResp . isSuccess ( ) ) {
throw new RuntimeException ( " 仿真参数库添加成功,但库目录创建失败 " ) ;
}
return SdmResponse . success ( " 仿真参数库添加成功 " ) ;
}
@@ -122,6 +138,19 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
simulationParameterLibraryCategory . setParameterLibraryCategoryName ( parameterLibraryCategoryName ) ;
simulationParameterLibraryCategory . setCreatorId ( ThreadLocalContext . getUserId ( ) ) ;
simulationParameterLibraryCategoryService . save ( simulationParameterLibraryCategory ) ;
// 同步创建分类目录
CreateDirReq createDirReq = new CreateDirReq ( ) ;
createDirReq . setParentUuId ( String . valueOf ( parameterLibraryId ) ) ;
createDirReq . setDirName ( parameterLibraryCategoryName ) ;
createDirReq . setDirType ( DirTypeEnum . SIMULATION_PARAMETER_DIR . getValue ( ) ) ;
createDirReq . setUuId ( String . valueOf ( simulationParameterLibraryCategory . getId ( ) ) ) ;
createDirReq . setUuIdOwnType ( SimulationParameterOwnType . CATEGORY . getCode ( ) ) ;
SdmResponse createDirResp = dataFileService . createDir ( createDirReq ) ;
if ( ! createDirResp . isSuccess ( ) ) {
throw new RuntimeException ( " 仿真参数库分类添加成功,创建分类文件夹失败 " ) ;
}
return SdmResponse . success ( " 仿真参数库分类添加成功 " ) ;
}
@@ -156,14 +185,30 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
SimulationParameterLibraryCategoryObject simulationParameterLibraryCategoryObject = new SimulationParameterLibraryCategoryObject ( ) ;
BeanUtils . copyProperties ( req , simulationParameterLibraryCategoryObject ) ;
simulationParameterLibraryCategoryObject . setCreatorId ( ThreadLocalContext . getUserId ( ) ) ;
simulationParameterLibraryCategoryObjectService . save ( simulationParameterLibraryCategoryObject ) ;
// 同步创建对象目录
CreateDirReq createDirReq = new CreateDirReq ( ) ;
createDirReq . setParentUuId ( String . valueOf ( req . getParameterLibraryCategoryId ( ) ) ) ;
createDirReq . setDirName ( req . getParameterLibraryCategoryObjectName ( ) ) ;
createDirReq . setDirType ( DirTypeEnum . SIMULATION_PARAMETER_DIR . getValue ( ) ) ;
createDirReq . setUuId ( String . valueOf ( simulationParameterLibraryCategoryObject . getId ( ) ) ) ;
createDirReq . setUuIdOwnType ( SimulationParameterOwnType . OBJECT . getCode ( ) ) ;
SdmResponse createDirResp = dataFileService . createDir ( createDirReq ) ;
if ( ! createDirResp . isSuccess ( ) ) {
throw new RuntimeException ( " 仿真参数库分类对象添加成功,创建对象文件夹失败 " ) ;
}
boolean isApprove = true ;
String fileName = req . getParameterLibraryCategoryObjectName ( ) + " .json " ;
simulationParameterLibraryCategoryObject . setFileName ( fileName ) ;
// 兼容未上传文件的情况, 自动创建空JSON文件
if ( inputFile = = null | | inputFile . isEmpty ( ) ) {
isApprove = false ;
String fileName = req . getParameterLibraryCategoryObjectName ( ) ;
String emptyJsonContent = " [] " ;
fileToUpload = new MockMultipartFile ( fileName , fileName + " .json " , " application/json " , emptyJsonContent . getBytes ( StandardCharsets . UTF_8 ) ) ;
simulationParameterLibraryCategoryObject . setFileName ( fileName + " .json " ) ;
fileToUpload = new MockMultipartFile ( fileName , fileName , " application/json " , emptyJsonContent . getBytes ( StandardCharsets . UTF_8 ) ) ;
} else {
// 处理已上传的文件,并添加创建人、创建时间等信息
String originalJson = new String ( inputFile . getBytes ( ) , StandardCharsets . UTF_8 ) ;
@@ -175,15 +220,20 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
} ) ;
}
String content = objectMapper . writerWithDefaultPrettyPrinter ( ) . writeValueAsString ( parameterDataList ) ;
fileToUpload = new MockMultipartFile ( req . getFileName ( ) , inputFile . getOriginalF ilen ame( ) , inputFile . getContentType ( ) , content . getBytes ( StandardCharsets . UTF_8 ) ) ;
fileToUpload = new MockMultipartFile ( fileName , f ileN ame, inputFile . getContentType ( ) , content . getBytes ( StandardCharsets . UTF_8 ) ) ;
}
SdmResponse < Long > integerSdmResponse = dataFileService . uploadSimulationParamFile ( fileToUpload ) ;
Long fileId = integerSdmResponse . getData ( ) ;
UploadFilesReq uploadFilesReq = new UploadFilesReq ( ) ;
uploadFilesReq . setFile ( fileToUpload ) ;
uploadFilesReq . setUuid ( String . valueOf ( simulationParameterLibraryCategoryObject . getId ( ) ) ) ;
uploadFilesReq . setFileName ( fileName ) ;
SdmResponse sdmResponse = dataFileService . uploadFiles ( uploadFilesReq ) ;
if ( ! sdmResponse . isSuccess ( ) ) {
return SdmResponse . failed ( " 仿真参数库文件对象上传失败 " ) ;
}
Long fileId = ( ( JSONObject ) sdmResponse . getData ( ) ) . getLong ( " fileId " ) ;
simulationParameterLibraryCategoryObject . setFileId ( fileId ) ;
simulationParameterLibraryCategoryObject. setCreatorId ( ThreadLocalContext . getUserId ( ) ) ;
simulationParameterLibraryCategoryObjectService . save ( simulationParameterLibraryCategoryObject ) ;
simulationParameterLibraryCategoryObjectService . updateById ( simulationParameterLibraryCategoryObject ) ;
// 上传了文件才需要审批
if ( isApprove ) {
@@ -241,6 +291,25 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
@Override
public SdmResponse getSimulationParameterTree ( Integer type , Long id ) {
// 获取权限
SdmResponse < List < FileMetadataInfoResp > > simulationParameterTree ;
if ( id = = null ) {
simulationParameterTree = dataFileService . listDir ( DirTypeEnum . SIMULATION_PARAMETER_DIR . getValue ( ) , null ) ;
} else {
FileMetadataInfo simulationParameterLibraryFile = fileMetadataInfoService . lambdaQuery ( )
. eq ( FileMetadataInfo : : getTenantId , ThreadLocalContext . getTenantId ( ) )
. eq ( FileMetadataInfo : : getRelatedResourceUuidOwnType , String . valueOf ( type ) )
. eq ( FileMetadataInfo : : getRelatedResourceUuid , id )
. one ( ) ;
simulationParameterTree = dataFileService . listDir ( DirTypeEnum . SIMULATION_PARAMETER_DIR . getValue ( ) , simulationParameterLibraryFile . getId ( ) ) ;
}
Map < String , Integer > uuidToPermissionMap = new HashMap < > ( ) ;
if ( simulationParameterTree . isSuccess ( ) ) {
uuidToPermissionMap = simulationParameterTree . getData ( ) . stream ( ) . collect ( Collectors . toMap ( FileMetadataInfoResp : : getRelatedResourceUuid , FileMetadataInfoResp : : getPermissionValue ) ) ;
}
List < JSONObject > jsonObjects = new ArrayList < > ( ) ;
if ( id = = null ) {
// 获取所有仿真参数库
@@ -253,15 +322,16 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
Set < Long > userIdsSet = new HashSet < > ( userIds ) ;
Map < Long , String > longStringMap = userNameCacheService . batchGetUserNames ( userIdsSet ) ;
s imulationParameterLibraries . forEach ( simulationParameterLibrary - > {
for ( S imulationParameterLibrary simulationParameterLibrary : simulationParameterLibraries ) {
JSONObject jsonObject = new JSONObject ( ) ;
jsonObject . put ( " id " , simulationParameterLibrary . getId ( ) ) ;
jsonObject . put ( " type " , SimulationParameterDataTypeEnum . LIBRARY . getValue ( ) ) ;
jsonObject . put ( " name " , simulationParameterLibrary . getParameterLibraryName ( ) ) ;
jsonObject . put ( " createName " , longStringMap . get ( simulationParameterLibrary . getCreatorId ( ) ) ) ;
jsonObject . put ( " createName " , longStringMap . get ( simulationParameterLibrary . getCreatorId ( ) ) ) ;
jsonObject . put ( " createTime " , simulationParameterLibrary . getCreateTime ( ) . format ( DateTimeFormatter . ofPattern ( " yyyy-MM-dd HH:mm:ss " ) ) ) ;
jsonObject . put ( " permissionValue " , uuidToPermissionMap . getOrDefault ( String . valueOf ( simulationParameterLibrary . getId ( ) ) , 0 ) ) ;
jsonObjects . add ( jsonObject ) ;
} ) ;
}
return SdmResponse . success ( jsonObjects ) ;
}
@@ -283,15 +353,16 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
Map < Long , String > longStringMap = userNameCacheService . batchGetUserNames ( userIdsSet ) ;
s imulationParameterLibraryCategories . forEach ( simulationParameterLibraryCategory - > {
for ( S imulationParameterLibraryCategory simulationParameterLibraryCategory : simulationParameterLibraryCategories ) {
JSONObject jsonObject = new JSONObject ( ) ;
jsonObject . put ( " id " , simulationParameterLibraryCategory . getId ( ) ) ;
jsonObject . put ( " type " , SimulationParameterDataTypeEnum . CATEGORY . getValue ( ) ) ;
jsonObject . put ( " name " , simulationParameterLibraryCategory . getParameterLibraryCategoryName ( ) ) ;
jsonObject . put ( " createName " , longStringMap . get ( simulationParameterLibraryCategory . getCreatorId ( ) ) ) ;
jsonObject . put ( " createName " , longStringMap . get ( simulationParameterLibraryCategory . getCreatorId ( ) ) ) ;
jsonObject . put ( " createTime " , simulationParameterLibraryCategory . getCreateTime ( ) . format ( DateTimeFormatter . ofPattern ( " yyyy-MM-dd HH:mm:ss " ) ) ) ;
jsonObject . put ( " permissionValue " , uuidToPermissionMap . getOrDefault ( String . valueOf ( simulationParameterLibraryCategory . getId ( ) ) , 0 ) ) ;
jsonObjects . add ( jsonObject ) ;
} ) ;
}
return SdmResponse . success ( jsonObjects ) ;
}
}
@@ -327,6 +398,7 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
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 ( ) ) ) ;
jsonObject . put ( " permissionValue " , uuidToPermissionMap . getOrDefault ( String . valueOf ( simulationParameterLibraryCategoryObject . getId ( ) ) , 0 ) ) ;
jsonObjects . add ( jsonObject ) ;
}
return SdmResponse . success ( jsonObjects ) ;
@@ -359,7 +431,12 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
SdmResponse response = deleteApproveWithFile ( req ) ;
return response ;
} else {
SimulationParameterLibraryCategoryObject object = simulationParameterLibraryCategoryObjectService . getById ( req . getId ( ) ) ;
if ( object ! = null ) {
// 始终删除参数对象记录,不依赖 fileId 是否存在
simulationParameterLibraryCategoryObjectService . removeById ( req . getId ( ) ) ;
deleteMappedDir ( SimulationParameterOwnType . OBJECT . getCode ( ) , req . getId ( ) ) ;
}
}
} else if ( req . getType ( ) = = SimulationParameterDataTypeEnum . CATEGORY . getValue ( ) ) {
if ( req . isApprove ( ) ) {
@@ -373,6 +450,7 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
} else {
simulationParameterLibraryCategoryService . removeById ( req . getId ( ) ) ;
simulationParameterLibraryCategoryObjectService . lambdaUpdate ( ) . eq ( SimulationParameterLibraryCategoryObject : : getParameterLibraryCategoryId , req . getId ( ) ) . remove ( ) ;
deleteMappedDir ( SimulationParameterOwnType . CATEGORY . getCode ( ) , req . getId ( ) ) ;
}
} else if ( req . getType ( ) = = SimulationParameterDataTypeEnum . LIBRARY . getValue ( ) ) {
if ( req . isApprove ( ) ) {
@@ -387,6 +465,7 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
this . removeById ( req . getId ( ) ) ;
simulationParameterLibraryCategoryService . lambdaUpdate ( ) . eq ( SimulationParameterLibraryCategory : : getParameterLibraryId , req . getId ( ) ) . remove ( ) ;
simulationParameterLibraryCategoryObjectService . lambdaUpdate ( ) . eq ( SimulationParameterLibraryCategoryObject : : getParameterLibraryId , req . getId ( ) ) . remove ( ) ;
deleteMappedDir ( SimulationParameterOwnType . LIBRARY . getCode ( ) , req . getId ( ) ) ;
}
}
@@ -403,6 +482,15 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
return SdmResponse . success ( ) ;
}
private void deleteMappedDir ( String ownType , Long businessId ) {
DelDirReq delDirReq = new DelDirReq ( ) ;
delDirReq . setDelUuid ( String . valueOf ( businessId ) ) ;
delDirReq . setDelUuIdOwnType ( ownType ) ;
delDirReq . setSkipPermissionCheck ( true ) ;
delDirReq . setImmediateDelete ( true ) ;
dataFileService . delDir ( delDirReq ) ;
}
private SdmResponse deleteApprove ( SimulationParamLibraryReq req , List < SimulationParameterLibraryCategoryObject > objectList ) {
ApprovalParamContentsModel contentsModel = new ApprovalParamContentsModel ( ) ;
contentsModel . setApproveAction ( ApproveFileActionENUM . DELETE . getCode ( ) ) ;
@@ -457,28 +545,62 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
@Override
public SdmResponse editSimulationParameter ( SimulationParamLibraryReq req ) {
// 根据参数类型和参数id删除 参数
// 根据参数类型和参数id编辑 参数
if ( req . getType ( ) = = SimulationParameterDataTypeEnum . OBJECT . getValue ( ) ) {
// 同名校验
SimulationParameterLibraryCategoryObject object = simulationParameterLibraryCategoryObjectService . getById ( req . getId ( ) ) ;
if ( object . getParameterLibraryCategoryObjectName ( ) ! = null & & object . getParameterLibraryCategoryObjectName ( ) . equals ( req . getModifyFileName ( ) ) ) {
return SdmResponse . failed ( " 参数对象名称重复 " ) ;
}
simulationParameterLibraryCategoryObjectService . lambdaUpdate ( )
. set ( SimulationParameterLibraryCategoryObject : : getParameterLibraryCategoryObjectName , req . getModifyFileName ( ) )
. eq ( SimulationParameterLibraryCategoryObject : : getId , req . getId ( ) )
. update ( ) ;
renameMappedDir ( SimulationParameterOwnType . OBJECT . getCode ( ) , req . getId ( ) , req . getModifyFileName ( ) ) ;
} else if ( req . getType ( ) = = SimulationParameterDataTypeEnum . CATEGORY . getValue ( ) ) {
// 同名校验
SimulationParameterLibraryCategory category = simulationParameterLibraryCategoryService . getById ( req . getId ( ) ) ;
if ( category . getParameterLibraryCategoryName ( ) ! = null & & category . getParameterLibraryCategoryName ( ) . equals ( req . getModifyFileName ( ) ) ) {
return SdmResponse . failed ( " 参数类别名称重复 " ) ;
}
simulationParameterLibraryCategoryService . lambdaUpdate ( )
. set ( SimulationParameterLibraryCategory : : getParameterLibraryCategoryName , req . getModifyFileName ( ) )
. eq ( SimulationParameterLibraryCategory : : getId , req . getId ( ) )
. update ( ) ;
renameMappedDir ( SimulationParameterOwnType . CATEGORY . getCode ( ) , req . getId ( ) , req . getModifyFileName ( ) ) ;
} else if ( req . getType ( ) = = SimulationParameterDataTypeEnum . LIBRARY . getValue ( ) ) {
// 同名校验
SimulationParameterLibrary library = this . getById ( req . getId ( ) ) ;
if ( library . getParameterLibraryName ( ) ! = null & & library . getParameterLibraryName ( ) . equals ( req . getModifyFileName ( ) ) ) {
return SdmResponse . failed ( " 参数库名称重复 " ) ;
}
this . lambdaUpdate ( )
. set ( SimulationParameterLibrary : : getParameterLibraryName , req . getModifyFileName ( ) )
. eq ( SimulationParameterLibrary : : getId , req . getId ( ) )
. update ( ) ;
renameMappedDir ( SimulationParameterOwnType . LIBRARY . getCode ( ) , req . getId ( ) , req . getModifyFileName ( ) ) ;
}
return SdmResponse . success ( " 编辑成功 " ) ;
}
private void renameMappedDir ( String ownType , Long businessId , String newName ) {
if ( StringUtils . isBlank ( newName ) ) {
return ;
}
FileMetadataInfo mappedDir = findMappedFileNode ( ownType , businessId ) ;
if ( mappedDir = = null ) {
return ;
}
RenameDirReq renameDirReq = new RenameDirReq ( ) ;
renameDirReq . setDirId ( mappedDir . getId ( ) ) ;
renameDirReq . setNewName ( newName ) ;
renameDirReq . setSkipPermissionCheck ( true ) ;
dataFileService . renameDirNew ( renameDirReq ) ;
}
@Override
public SdmResponse < SimulationParameterLibraryCategoryObjectResp > getSimulationParameterLibraryCategoryObject ( Long ObjectId ) {
SimulationParameterLibraryCategoryObjectResp resp = getSimulationParameterLibraryCategoryObjectInner ( ObjectId ) ;
@@ -638,16 +760,20 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
) ;
// 更新MinIO中的文件内容
SdmResponse uploadResponse = dataFileService . updateSimulationParamFile ( multipartFile ) ;
UpdateFileReq updateFileReq = new UpdateFileReq ( ) ;
updateFileReq . setId ( req . getFileId ( ) ) ;
updateFileReq . setFile ( multipartFile ) ;
updateFileReq . setFileName ( fileMetadataInfo . getOriginalName ( ) ) ;
SdmResponse sdmResponse = dataFileService . updateFile ( updateFileReq ) ;
if ( ! upload Response. isSuccess ( ) ) {
return SdmResponse . failed ( " 参数更新失败 " ) ;
if ( ! sdm Response. isSuccess ( ) ) {
throw new RuntimeException ( " 参数更新失败 " ) ;
}
return SdmResponse . success ( " 参数更新成功 " ) ;
} catch ( Exception e ) {
log . error ( " 更新仿真参数值时发生错误 " , e ) ;
return SdmResponse . failed ( " 参数更新失败: " + e . getMessage ( ) ) ;
throw new RuntimeException ( " 参数更新失败 " ) ;
}
}
@@ -677,4 +803,82 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
fileMetadataInfoService . updateById ( fileMetadataInfo ) ;
return SdmResponse . success ( ) ;
}
@Override
public SdmResponse updateSimulationParameterPermission ( UpdateSimulationParamLibraryPermissionReq req ) {
if ( req = = null | | req . getType ( ) = = null | | req . getId ( ) = = null ) {
return SdmResponse . failed ( " 参数不能为空 " ) ;
}
if ( req . getUserPermissions ( ) = = null | | req . getUserPermissions ( ) . isEmpty ( ) ) {
return SdmResponse . failed ( " 用户权限不能为空 " ) ;
}
Long fileId = getSimulationParameterFileId ( req . getType ( ) , req . getId ( ) ) ;
UpdatePermissionReq updatePermissionReq = new UpdatePermissionReq ( ) ;
updatePermissionReq . setFileId ( fileId ) ;
updatePermissionReq . setUserPermissions ( req . getUserPermissions ( ) ) ;
return dataFileService . updatePermission ( updatePermissionReq ) ;
}
@Override
public SdmResponse querySimulationParameterPermission ( QuerySimulationParamLibraryPermissionReq req ) {
if ( req = = null | | req . getType ( ) = = null | | req . getId ( ) = = null ) {
return SdmResponse . failed ( " 参数不能为空 " ) ;
}
Long fileId = getSimulationParameterFileId ( req . getType ( ) , req . getId ( ) ) ;
QueryPermissionReq queryPermissionReq = new QueryPermissionReq ( ) ;
queryPermissionReq . setFileId ( fileId ) ;
return dataFileService . queryPermission ( queryPermissionReq ) ;
}
/**
* 根据参数库、类、对象 获取关联文件ID
* @param type
* @param id
* @return
*/
private Long getSimulationParameterFileId ( int type , Long id ) {
Long fileId ;
FileMetadataInfo fileNode ;
if ( SimulationParameterDataTypeEnum . LIBRARY . getValue ( ) = = type | | SimulationParameterDataTypeEnum . CATEGORY . getValue ( ) = = type ) {
fileNode = findMappedFileNode ( String . valueOf ( type ) , id ) ;
if ( fileNode = = null ) {
return null ;
}
return fileNode . getId ( ) ;
} else {
SimulationParameterLibraryCategoryObject object = simulationParameterLibraryCategoryObjectService . getById ( id ) ;
if ( object = = null | | object . getFileId ( ) = = null ) {
return null ;
}
return object . getFileId ( ) ;
}
}
private FileMetadataInfo findMappedFileNode ( String ownType , Long relatedResourceId ) {
return fileMetadataInfoService . lambdaQuery ( )
. eq ( FileMetadataInfo : : getRelatedResourceUuidOwnType , ownType )
. eq ( FileMetadataInfo : : getRelatedResourceUuid , String . valueOf ( relatedResourceId ) )
. eq ( FileMetadataInfo : : getTenantId , ThreadLocalContext . getTenantId ( ) )
. one ( ) ;
}
private enum SimulationParameterOwnType {
LIBRARY ( " simulation_parameter_library " ) ,
CATEGORY ( " simulation_parameter_library_category " ) ,
OBJECT ( " simulation_parameter_library_category_object " ) ;
private final String code ;
SimulationParameterOwnType ( String code ) {
this . code = code ;
}
public String getCode ( ) {
return code ;
}
}
}