data模块 存储租户信息,支持基于租户隔离信息
This commit is contained in:
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
* @since 2025-09-05
|
||||
*/
|
||||
public interface FileMetadataInfoMapper extends BaseMapper<FileMetadataInfo> {
|
||||
List<FileMetadataInfo> listSimulationNodeDir(@Param("dirIds") List<Long> dirIds,@Param("filterEmptyData") boolean filterEmptyData);
|
||||
List<FileMetadataInfo> listSimulationNodeFiles(@Param("parentId") Long parentId,@Param("fileIds") List<Long> fileIds, @Param("filterEmptyData") boolean isFilterEmptyData);
|
||||
List<FileMetadataInfo> listSimulationNodeDir(@Param("dirIds") List<Long> dirIds, @Param("filterEmptyData") boolean filterEmptyData, @Param("tenantId") Long tenantId);
|
||||
List<FileMetadataInfo> listSimulationNodeFiles(@Param("parentId") Long parentId,@Param("fileIds") List<Long> fileIds, @Param("filterEmptyData") boolean isFilterEmptyData,@Param("tenantId") Long tenantId);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.List;
|
||||
* @since 2025-11-04
|
||||
*/
|
||||
public interface FileStorageMapper extends BaseMapper<FileStorage> {
|
||||
List<NodeSizeDTO> selectNodeSizeByNodeType(@Param("directoryIds") List<Long> directoryIds,@Param("intervalMonths") Integer intervalMonths);
|
||||
List<NodeSizeDTO> selectNodeSizeByNodeType(@Param("directoryIds") List<Long> directoryIds, @Param("intervalMonths") Integer intervalMonths, @Param("tenantId") Long tenantId);
|
||||
|
||||
/**
|
||||
* 批量统计项目的存储占用:目标年月之前(历史累计) + 目标年月(当月增量)
|
||||
@@ -26,11 +26,11 @@ public interface FileStorageMapper extends BaseMapper<FileStorage> {
|
||||
* @param targetYm 目标年月(格式:YYYY-MM,如 "2024-10",与表中 createYearMonth 一致)
|
||||
* @return 统计结果列表:每个项目对应2条记录(历史累计 + 当月增量)
|
||||
*/
|
||||
List<NodeSizeDTO> statDirStorageByTargetYm(@Param("dirIds") List<Long> dirIds, @Param("targetYm") String targetYm);
|
||||
List<NodeSizeDTO> statDirStorageByTargetYm(@Param("dirIds") List<Long> dirIds, @Param("targetYm") String targetYm,@Param("tenantId") Long tenantId);
|
||||
|
||||
List<UserTotalFileSizeDTO> getTotalFileSizeByCreator(@Param("userIds") List<Long> userIds,@Param("intervalMonths") Integer intervalMonths);
|
||||
List<UserTotalFileSizeDTO> getTotalFileSizeByCreator(@Param("userIds") List<Long> userIds,@Param("intervalMonths") Integer intervalMonths,@Param("tenantId") Long tenantId);
|
||||
|
||||
List<UserTotalFileSizeDTO> getTotalFileSizeByCreatorAndTargetYm(@Param("userIds") List<Long> userIds,@Param("targetYm") String targetYm);
|
||||
List<UserTotalFileSizeDTO> getTotalFileSizeByCreatorAndTargetYm(@Param("userIds") List<Long> userIds,@Param("targetYm") String targetYm,@Param("tenantId") Long tenantId);
|
||||
|
||||
List<FileStorage> selectBigFiles(@Param("queryBigFileReq") QueryBigFileReq queryBigFileReq, @Param("fileSizeInBytes") Long fileSizeInBytes);
|
||||
List<FileStorage> selectBigFiles(@Param("queryBigFileReq") QueryBigFileReq queryBigFileReq, @Param("fileSizeInBytes") Long fileSizeInBytes,@Param("tenantId") Long tenantId);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,10 @@ public class DimensionTemplate implements Serializable {
|
||||
@TableField("description")
|
||||
private String description;
|
||||
|
||||
@Schema(description= "租户ID")
|
||||
@TableField("tenantId")
|
||||
private Long tenantId;
|
||||
|
||||
@Schema(description = "创建者")
|
||||
@TableField("createdBy")
|
||||
private Long createdBy;
|
||||
|
||||
@@ -45,6 +45,10 @@ public class DimensionTemplateHierarchy implements Serializable {
|
||||
@TableField("sortOrder")
|
||||
private Integer sortOrder;
|
||||
|
||||
@Schema(description= "租户ID")
|
||||
@TableField("tenantId")
|
||||
private Long tenantId;
|
||||
|
||||
@Schema(description = "创建者")
|
||||
@TableField("createdBy")
|
||||
private Long createdBy;
|
||||
|
||||
@@ -96,6 +96,10 @@ public class FileMetadataInfo implements Serializable {
|
||||
@TableField("creatorId")
|
||||
private Long creatorId;
|
||||
|
||||
@Schema(description= "租户ID")
|
||||
@TableField("tenantId")
|
||||
private Long tenantId; //租户ID
|
||||
|
||||
@Schema(description= "创建者名称,列表展示使用")
|
||||
@TableField(value = "creatorName", insertStrategy = FieldStrategy.NEVER,select = false,updateStrategy = FieldStrategy.NEVER)
|
||||
private String creatorName;
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -45,6 +46,10 @@ public class FileStorage implements Serializable {
|
||||
@TableField("userGroupId")
|
||||
private Long userGroupId;
|
||||
|
||||
@Schema(description= "租户ID")
|
||||
@TableField("tenantId")
|
||||
private Long tenantId; //租户ID
|
||||
|
||||
@ApiModelProperty(value = "文件所属用户ID")
|
||||
@TableField("userId")
|
||||
private Long userId;
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -36,6 +38,10 @@ public class FileStorageQuota implements Serializable {
|
||||
@TableField("userId")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value= "租户ID")
|
||||
@TableField("tenantId")
|
||||
private Long tenantId; //租户ID
|
||||
|
||||
@ApiModelProperty(value = "存储阈值(单位:字节)")
|
||||
@TableField("quotaValue")
|
||||
private Long quotaValue;
|
||||
@@ -52,5 +58,12 @@ public class FileStorageQuota implements Serializable {
|
||||
@TableField("status")
|
||||
private String status;
|
||||
|
||||
@TableField("createTime")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@TableField("updateTime")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -45,5 +45,9 @@ public class FileUserPermission implements Serializable {
|
||||
@TableField("userId")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description= "租户ID")
|
||||
@TableField("tenantId")
|
||||
private Long tenantId;
|
||||
|
||||
|
||||
}
|
||||
@@ -45,5 +45,9 @@ public class SimulationParameterLibrary implements Serializable {
|
||||
@TableField("update_time")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@ApiModelProperty(value= "租户ID")
|
||||
@TableField("tenantId")
|
||||
private Long tenantId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -152,4 +152,12 @@ public class TrainingModel implements Serializable {
|
||||
@TableField("updateTime")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@ApiModelProperty(value= "租户ID")
|
||||
@TableField("tenantId")
|
||||
private Long tenantId; //租户ID
|
||||
|
||||
@ApiModelProperty(value = "创建人")
|
||||
@TableField("creator")
|
||||
private Long creator;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,6 @@ public interface IFileMetadataInfoService extends IService<FileMetadataInfo> {
|
||||
* 数据总览 需要过滤空文件夹查询文件夹
|
||||
* @return
|
||||
*/
|
||||
List<FileMetadataInfo> listSimulationNodeDir(List<Long> dirIds,boolean filterEmptyData);
|
||||
List<FileMetadataInfo> listSimulationNodeFiles(Long parentId, List<Long> fileIds, boolean isFilterEmptyData);
|
||||
List<FileMetadataInfo> listSimulationNodeDir(List<Long> dirIds,boolean filterEmptyData,Long tenantId);
|
||||
List<FileMetadataInfo> listSimulationNodeFiles(Long parentId, List<Long> fileIds, boolean isFilterEmptyData,Long tenantId);
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@ import java.util.List;
|
||||
* @since 2025-11-04
|
||||
*/
|
||||
public interface IFileStorageService extends IService<FileStorage> {
|
||||
List<NodeSizeDTO> selectNodeSizeByNodeType(List<Long> directoryIds,Integer intervalMonths);
|
||||
List<NodeSizeDTO> selectNodeSizeByNodeType(List<Long> directoryIds, Integer intervalMonths, Long tenantId);
|
||||
|
||||
List<NodeSizeDTO> statDirStorageByTargetYm(List<Long> dirIds, String targetYm);
|
||||
List<NodeSizeDTO> statDirStorageByTargetYm(List<Long> dirIds, String targetYm, Long tenantId);
|
||||
|
||||
List<UserTotalFileSizeDTO> getTotalFileSizeByCreator(List<Long> userIds,Integer intervalMonths);
|
||||
List<UserTotalFileSizeDTO> getTotalFileSizeByCreator(List<Long> userIds,Integer intervalMonths,Long tenantId);
|
||||
|
||||
List<UserTotalFileSizeDTO> getTotalFileSizeByCreatorAndTargetYm(List<Long> userIds,String targetYm);
|
||||
List<UserTotalFileSizeDTO> getTotalFileSizeByCreatorAndTargetYm(List<Long> userIds,String targetYm,Long tenantId);
|
||||
|
||||
List<FileStorage> selectBigFiles(@Param("queryBigFileReq") QueryBigFileReq queryBigFileReq, @Param("fileSizeInBytes") Long fileSizeInBytes);
|
||||
List<FileStorage> selectBigFiles(@Param("queryBigFileReq") QueryBigFileReq queryBigFileReq, @Param("fileSizeInBytes") Long fileSizeInBytes, Long tenantId);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.sdm.data.service.impl;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.entity.resp.PageDataResp;
|
||||
import com.sdm.common.utils.FileSizeUtils;
|
||||
import com.sdm.common.utils.PageUtils;
|
||||
@@ -48,7 +49,10 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
BeanUtils.copyProperties(getSimulationTaskFileReq, queryBigFileReq);
|
||||
|
||||
|
||||
FileMetadataInfo fileMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getRelatedResourceUuid, getSimulationTaskFileReq.getUuid()).one();
|
||||
FileMetadataInfo fileMetadataInfo = fileMetadataInfoService.lambdaQuery()
|
||||
.eq(FileMetadataInfo::getRelatedResourceUuid, getSimulationTaskFileReq.getUuid())
|
||||
.eq(FileMetadataInfo::getTenantId, ThreadLocalContext.getTenantId())
|
||||
.one();
|
||||
if(ObjectUtils.isNotEmpty(fileMetadataInfo)) {
|
||||
queryBigFileReq.setDirId(fileMetadataInfo.getId());
|
||||
}
|
||||
@@ -63,6 +67,7 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
|
||||
List<FileMetadataInfo> simulationTaskFileMetadataInfos = fileMetadataInfoService
|
||||
.lambdaQuery()
|
||||
.eq(FileMetadataInfo::getTenantId, ThreadLocalContext.getTenantId())
|
||||
.in(FileMetadataInfo::getId, fileIdList)
|
||||
.list();
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
|
||||
|
||||
public SdmResponse getNodeSizeByNodeType(String queryNodeType, String uuid, Integer intervalMonths, String targetYm) {
|
||||
SdmResponse<List<AllNodeByProjectIdAndTypeResp>> response = simuluationNodeFeignClient.getAllNodeByProjectIdAndType(uuid, queryNodeType);
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
if (!response.isSuccess()) {
|
||||
return SdmResponse.failed("获取节点信息失败");
|
||||
}
|
||||
@@ -86,6 +87,7 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
|
||||
// uuidToDirIdMap :获取uuid->fileID映射
|
||||
Map<String, Long> uuidToDirIdMap = fileMetadataInfoService.lambdaQuery().select(FileMetadataInfo::getId, FileMetadataInfo::getRelatedResourceUuid)
|
||||
.in(FileMetadataInfo::getRelatedResourceUuid, uuids)
|
||||
.eq(FileMetadataInfo::getTenantId, tenantId)
|
||||
.list().stream().collect(Collectors.toMap(FileMetadataInfo::getRelatedResourceUuid, FileMetadataInfo::getId));
|
||||
if (CollectionUtils.isEmpty(uuidToDirIdMap)) {
|
||||
return SdmResponse.failed("获取节点信息失败");
|
||||
@@ -98,11 +100,11 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
|
||||
List<NodeSizeDTO> nodeSizeDTOS = null;
|
||||
if (ObjectUtils.isNotEmpty(intervalMonths)) {
|
||||
// 近几个月
|
||||
nodeSizeDTOS = fileStorageService.selectNodeSizeByNodeType(fileMetadIds, intervalMonths);
|
||||
nodeSizeDTOS = fileStorageService.selectNodeSizeByNodeType(fileMetadIds, intervalMonths,tenantId );
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(targetYm)) {
|
||||
//查询增量的
|
||||
nodeSizeDTOS = fileStorageService.statDirStorageByTargetYm(fileMetadIds, targetYm);
|
||||
nodeSizeDTOS = fileStorageService.statDirStorageByTargetYm(fileMetadIds, targetYm,tenantId);
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(nodeSizeDTOS)) {
|
||||
@@ -135,17 +137,18 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
|
||||
|
||||
@Override
|
||||
public SdmResponse getDirectorySizeByUserId(List<Long> userIds, Integer intervalMonths, String targetYm) {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
if (ObjectUtils.isEmpty(userIds)) {
|
||||
return SdmResponse.success();
|
||||
}
|
||||
List<UserTotalFileSizeDTO> totalFileSizeByCreator = null;
|
||||
if (ObjectUtils.isNotEmpty(intervalMonths)) {
|
||||
// 近几个月
|
||||
totalFileSizeByCreator = fileStorageService.getTotalFileSizeByCreator(userIds, intervalMonths);
|
||||
totalFileSizeByCreator = fileStorageService.getTotalFileSizeByCreator(userIds, intervalMonths,tenantId);
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(targetYm)) {
|
||||
//查询增量的
|
||||
totalFileSizeByCreator = fileStorageService.getTotalFileSizeByCreatorAndTargetYm(userIds, targetYm);
|
||||
totalFileSizeByCreator = fileStorageService.getTotalFileSizeByCreatorAndTargetYm(userIds, targetYm,tenantId);
|
||||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(totalFileSizeByCreator)) return SdmResponse.success();
|
||||
@@ -181,9 +184,9 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
|
||||
if (queryBigFileReq.getFileSize() != null && queryBigFileReq.getFileSizeUnit() != null) {
|
||||
fileSizeInBytes = convertToBytes(queryBigFileReq.getFileSize(), queryBigFileReq.getFileSizeUnit());
|
||||
}
|
||||
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
PageHelper.startPage(queryBigFileReq.getCurrent(), queryBigFileReq.getSize());
|
||||
List<FileStorage> list = fileStorageService.selectBigFiles(queryBigFileReq, fileSizeInBytes);
|
||||
List<FileStorage> list = fileStorageService.selectBigFiles(queryBigFileReq, fileSizeInBytes, tenantId);
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -230,16 +233,18 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
|
||||
|
||||
@Override
|
||||
public SdmResponse addUserQuota(AddUserQuotaEntity addUserQuota) {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
if(ObjectUtils.isEmpty(addUserQuota.getUserId()) || ObjectUtils.isEmpty(addUserQuota.getQuotaValue()) || ObjectUtils.isEmpty(addUserQuota.getQuotaUnit())){
|
||||
return SdmResponse.failed("配置参数不能为空");
|
||||
}
|
||||
FileStorageQuota existFileStorageQuota = fileStorageQuotaService.lambdaQuery().eq(FileStorageQuota::getUserId, addUserQuota.getUserId()).one();
|
||||
FileStorageQuota existFileStorageQuota = fileStorageQuotaService.lambdaQuery().eq(FileStorageQuota::getUserId, addUserQuota.getUserId()).eq(FileStorageQuota::getTenantId, tenantId).one();
|
||||
if (existFileStorageQuota != null){
|
||||
return SdmResponse.failed("该用户已存在存储配额");
|
||||
}
|
||||
|
||||
FileStorageQuota fileStorageQuota = new FileStorageQuota();
|
||||
fileStorageQuota.setUserId(addUserQuota.getUserId());
|
||||
fileStorageQuota.setTenantId(tenantId);
|
||||
fileStorageQuota.setQuotaValue(addUserQuota.getQuotaValue());
|
||||
fileStorageQuota.setQuotaUnit(addUserQuota.getQuotaUnit());
|
||||
fileStorageQuotaService.save(fileStorageQuota);
|
||||
@@ -248,6 +253,7 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
|
||||
|
||||
@Override
|
||||
public SdmResponse listUserQuota(ListUserQuotaReq listUserQuotaReq) {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
UserListReq req = new UserListReq();
|
||||
req.setNickname(listUserQuotaReq.getUserName());
|
||||
req.setCurrent(listUserQuotaReq.getCurrent());
|
||||
@@ -262,12 +268,13 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
|
||||
|
||||
// 查询这些 userId 的配额信息,创建 userId -> quota 的映射
|
||||
Map<Long, FileStorageQuota> quotaMap = fileStorageQuotaService.lambdaQuery()
|
||||
.eq(FileStorageQuota::getTenantId, tenantId)
|
||||
.in(ObjectUtils.isNotEmpty(userIds), FileStorageQuota::getUserId, userIds)
|
||||
.list().stream()
|
||||
.collect(Collectors.toMap(FileStorageQuota::getUserId, Function.identity()));
|
||||
|
||||
// fileStorageService 查询用户已使用的存储空间
|
||||
Map<Long,UserTotalFileSizeDTO> usedStorageMap = fileStorageService.getTotalFileSizeByCreator(userIds, null).stream()
|
||||
Map<Long,UserTotalFileSizeDTO> usedStorageMap = fileStorageService.getTotalFileSizeByCreator(userIds, null,tenantId).stream()
|
||||
.collect(Collectors.toMap(UserTotalFileSizeDTO::getUserId, Function.identity()));
|
||||
|
||||
|
||||
@@ -329,6 +336,7 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
|
||||
|
||||
@Override
|
||||
public SdmResponse batchUpdateUserQuota(List<AddUserQuotaEntity> addUserQuota) {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
if (CollectionUtils.isEmpty(addUserQuota)) {
|
||||
return SdmResponse.failed("配置参数不能为空");
|
||||
}
|
||||
@@ -342,6 +350,7 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
|
||||
if (ObjectUtils.isEmpty(existFileStorageQuota)) {
|
||||
FileStorageQuota fileStorageQuota = new FileStorageQuota();
|
||||
fileStorageQuota.setUserId(addUserQuotaEntity.getUserId());
|
||||
fileStorageQuota.setTenantId(tenantId);
|
||||
fileStorageQuota.setQuotaValue(addUserQuotaEntity.getQuotaValue());
|
||||
fileStorageQuota.setQuotaUnit(addUserQuotaEntity.getQuotaUnit());
|
||||
fileStorageQuotaService.save(fileStorageQuota);
|
||||
@@ -350,6 +359,7 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
|
||||
// 更新用户存储配额
|
||||
fileStorageQuotaService.lambdaUpdate()
|
||||
.eq(FileStorageQuota::getUserId, addUserQuotaEntity.getUserId())
|
||||
.eq(FileStorageQuota::getTenantId, tenantId)
|
||||
.set(FileStorageQuota::getQuotaValue, addUserQuotaEntity.getQuotaValue())
|
||||
.set(FileStorageQuota::getQuotaUnit, addUserQuotaEntity.getQuotaUnit())
|
||||
.update();
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.entity.enums.DataTypeEnum;
|
||||
import com.sdm.common.entity.enums.DirTypeEnum;
|
||||
import com.sdm.common.entity.enums.NodeTypeEnum;
|
||||
@@ -70,12 +71,16 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SdmResponse saveDimensionTemplateWithHierarchies(TemplateCreationRequest request) {
|
||||
if (lambdaQuery().eq(DimensionTemplate::getTemplateName, request.getTemplate().getTemplateName()).exists()) {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
Long userId = ThreadLocalContext.getUserId();
|
||||
if (lambdaQuery().eq(DimensionTemplate::getTemplateName, request.getTemplate().getTemplateName()).eq(DimensionTemplate::getTenantId, tenantId).exists()) {
|
||||
return SdmResponse.failed("模版已存在");
|
||||
}
|
||||
// 保存模板信息
|
||||
DimensionTemplate template = new DimensionTemplate();
|
||||
BeanUtils.copyProperties(request.getTemplate(), template);
|
||||
template.setTenantId(tenantId);
|
||||
template.setCreatedBy(userId);
|
||||
this.save(template);
|
||||
|
||||
// 保存层级信息
|
||||
@@ -112,12 +117,16 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
* @param hierarchyReqs 层级请求列表
|
||||
*/
|
||||
private void saveHierarchiesForTemplate(Long templateId, List<DimensionTemplateHierarchyReq> hierarchyReqs) {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
Long userId = ThreadLocalContext.getUserId();
|
||||
List<DimensionTemplateHierarchy> hierarchies = new ArrayList<>();
|
||||
int sortOrder = 0; // 初始化排序序号从0开始
|
||||
if (hierarchyReqs != null) {
|
||||
for (DimensionTemplateHierarchyReq hierarchyReq : hierarchyReqs) {
|
||||
DimensionTemplateHierarchy hierarchy = new DimensionTemplateHierarchy();
|
||||
BeanUtils.copyProperties(hierarchyReq, hierarchy);
|
||||
hierarchy.setTenantId(tenantId);
|
||||
hierarchy.setCreatedBy(userId);
|
||||
hierarchy.setTemplateId(templateId);
|
||||
hierarchy.setSortOrder(sortOrder++); // 设置排序序号并递增
|
||||
hierarchies.add(hierarchy);
|
||||
@@ -148,8 +157,9 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
|
||||
@Override
|
||||
public SdmResponse getAllTemplate() {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
List<DimensionTemplate> dimensionTemplates = this.list();
|
||||
List<DimensionTemplate> dimensionTemplates = this.lambdaQuery().eq(DimensionTemplate::getTenantId, tenantId).list();
|
||||
jsonObject.put("allDimensionTemplates", dimensionTemplates);
|
||||
return SdmResponse.success(jsonObject);
|
||||
}
|
||||
@@ -165,6 +175,7 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
|
||||
@Override
|
||||
public SdmResponse<List<FileMetadataInfo>> getSimulationNodeTree(GetSimulationNodeTreeReq req) {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
// 根据展示维度获取展示节点类型顺序
|
||||
Long dimensionTemplateId = req.getDimensionTemplateId();
|
||||
LambdaQueryWrapper<DimensionTemplateHierarchy> queryWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -191,6 +202,7 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
// 1、先获取普通文件夹
|
||||
List<FileMetadataInfo> dirInfos = fileMetadataInfoService
|
||||
.lambdaQuery()
|
||||
.eq(FileMetadataInfo::getTenantId, tenantId)
|
||||
.eq(FileMetadataInfo::getParentId, fileId)
|
||||
.eq(FileMetadataInfo::getDataType, DataTypeEnum.DIRECTORY.getValue())
|
||||
.isNull(FileMetadataInfo::getRelatedResourceUuid)
|
||||
@@ -241,13 +253,17 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
return SdmResponse.success(resultDir);
|
||||
}
|
||||
|
||||
List<FileMetadataInfo> nodeDirInfos = fileMetadataInfoService.lambdaQuery().in(FileMetadataInfo::getRelatedResourceUuid, uuids).orderByDesc(FileMetadataInfo::getCreateTime).list();
|
||||
List<FileMetadataInfo> nodeDirInfos = fileMetadataInfoService.lambdaQuery()
|
||||
.in(FileMetadataInfo::getRelatedResourceUuid, uuids)
|
||||
.eq(FileMetadataInfo::getTenantId, tenantId)
|
||||
.orderByDesc(FileMetadataInfo::getCreateTime).list();
|
||||
resultDir.addAll(nodeDirInfos);
|
||||
return SdmResponse.success(resultDir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse listSimulationNodeFiles(ListSimulationNodeTreeReq req) {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
// 按照显示维度展示后,会打乱原本的文件夹父子关系,需要重新构建父子关系:
|
||||
// 1、先调用 getSimulationNodeTree 按照维度查询项目子节点node,根据node-uuid获取fileId
|
||||
// 2、再查询原本的普通文件夹信息,需要isProjectDimension=true 只查询普通文件夹,不查询节点文件夹,union all 查询node的fileId 后 分页查询
|
||||
@@ -269,7 +285,7 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
}
|
||||
|
||||
PageHelper.startPage(req.getCurrent(), req.getSize());
|
||||
List<FileMetadataInfo> fileMetadataInfos = fileMetadataInfoService.listSimulationNodeDir(dirInfos, req.isFilterEmptyData());
|
||||
List<FileMetadataInfo> fileMetadataInfos = fileMetadataInfoService.listSimulationNodeDir(dirInfos, req.isFilterEmptyData(), tenantId);
|
||||
|
||||
PageInfo<FileMetadataInfo> page = new PageInfo<>(fileMetadataInfos);
|
||||
return PageUtils.getJsonObjectSdmResponse(fileMetadataInfos, page);
|
||||
@@ -277,7 +293,7 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
|
||||
//fileId 不为空也不为0,是右侧点击进入文件夹下一层级查询
|
||||
parentDirId = req.getFileId();
|
||||
Optional<FileMetadataInfo> parentDirInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getId, parentDirId).oneOpt();
|
||||
Optional<FileMetadataInfo> parentDirInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getId, parentDirId).eq(FileMetadataInfo::getTenantId, tenantId).oneOpt();
|
||||
if (!parentDirInfo.isPresent()) {
|
||||
return SdmResponse.failed("父文件夹不存在");
|
||||
}
|
||||
@@ -293,7 +309,7 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
|
||||
|
||||
PageHelper.startPage(req.getCurrent(), req.getSize());
|
||||
List<FileMetadataInfo> fileMetadataInfos = fileMetadataInfoService.listSimulationNodeFiles(parentDirId, dirInfos,req.isFilterEmptyData());
|
||||
List<FileMetadataInfo> fileMetadataInfos = fileMetadataInfoService.listSimulationNodeFiles(parentDirId, dirInfos,req.isFilterEmptyData(),tenantId);
|
||||
|
||||
PageInfo<FileMetadataInfo> page = new PageInfo<>(fileMetadataInfos);
|
||||
return PageUtils.getJsonObjectSdmResponse(fileMetadataInfos, page);
|
||||
|
||||
@@ -19,12 +19,12 @@ import java.util.List;
|
||||
@Service
|
||||
public class FileMetadataInfoServiceImpl extends ServiceImpl<FileMetadataInfoMapper, FileMetadataInfo> implements IFileMetadataInfoService {
|
||||
@Override
|
||||
public List<FileMetadataInfo> listSimulationNodeDir(List<Long> dirIds,boolean filterEmptyData) {
|
||||
return this.baseMapper.listSimulationNodeDir(dirIds, filterEmptyData);
|
||||
public List<FileMetadataInfo> listSimulationNodeDir(List<Long> dirIds, boolean filterEmptyData, Long tenantId) {
|
||||
return this.baseMapper.listSimulationNodeDir(dirIds, filterEmptyData,tenantId );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileMetadataInfo> listSimulationNodeFiles(Long parentId, List<Long> fileIds, boolean isFilterEmptyData) {
|
||||
return this.baseMapper.listSimulationNodeFiles(parentId,fileIds,isFilterEmptyData);
|
||||
public List<FileMetadataInfo> listSimulationNodeFiles(Long parentId, List<Long> fileIds, boolean isFilterEmptyData,Long tenantId) {
|
||||
return this.baseMapper.listSimulationNodeFiles(parentId, fileIds, isFilterEmptyData,tenantId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.sdm.data.dao.FileStorageMapper;
|
||||
import com.sdm.data.model.req.QueryBigFileReq;
|
||||
import com.sdm.data.service.IFileStorageService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -23,27 +22,27 @@ import java.util.List;
|
||||
@Service
|
||||
public class FileStorageServiceImpl extends ServiceImpl<FileStorageMapper, FileStorage> implements IFileStorageService {
|
||||
@Override
|
||||
public List<NodeSizeDTO> selectNodeSizeByNodeType(List<Long> directoryIds, Integer intervalMonths) {
|
||||
return baseMapper.selectNodeSizeByNodeType(directoryIds, intervalMonths);
|
||||
public List<NodeSizeDTO> selectNodeSizeByNodeType(List<Long> directoryIds, Integer intervalMonths, Long tenantId) {
|
||||
return baseMapper.selectNodeSizeByNodeType(directoryIds, intervalMonths, tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NodeSizeDTO> statDirStorageByTargetYm(List<Long> dirIds, String targetYm) {
|
||||
return baseMapper.statDirStorageByTargetYm(dirIds, targetYm);
|
||||
public List<NodeSizeDTO> statDirStorageByTargetYm(List<Long> dirIds, String targetYm, Long tenantId) {
|
||||
return baseMapper.statDirStorageByTargetYm(dirIds, targetYm, tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserTotalFileSizeDTO> getTotalFileSizeByCreator(List<Long> userIds, Integer intervalMonths) {
|
||||
return baseMapper.getTotalFileSizeByCreator(userIds, intervalMonths);
|
||||
public List<UserTotalFileSizeDTO> getTotalFileSizeByCreator(List<Long> userIds, Integer intervalMonths,Long tenantId) {
|
||||
return baseMapper.getTotalFileSizeByCreator(userIds, intervalMonths,tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserTotalFileSizeDTO> getTotalFileSizeByCreatorAndTargetYm(List<Long> userIds, String targetYm) {
|
||||
return baseMapper.getTotalFileSizeByCreatorAndTargetYm(userIds, targetYm);
|
||||
public List<UserTotalFileSizeDTO> getTotalFileSizeByCreatorAndTargetYm(List<Long> userIds, String targetYm,Long tenantId) {
|
||||
return baseMapper.getTotalFileSizeByCreatorAndTargetYm(userIds, targetYm,tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileStorage> selectBigFiles(QueryBigFileReq queryBigFileReq, Long fileSizeInBytes) {
|
||||
return baseMapper.selectBigFiles(queryBigFileReq, fileSizeInBytes);
|
||||
public List<FileStorage> selectBigFiles(QueryBigFileReq queryBigFileReq, Long fileSizeInBytes, Long tenantId) {
|
||||
return baseMapper.selectBigFiles(queryBigFileReq, fileSizeInBytes, tenantId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,6 +370,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
fileStorage.setFileId(fileInfo.getId());
|
||||
fileStorage.setFileName(fileInfo.getOriginalName());
|
||||
fileStorage.setUserId(ThreadLocalContext.getUserId());
|
||||
fileStorage.setTenantId(ThreadLocalContext.getTenantId());
|
||||
fileStorage.setFileBizType(fileInfo.getFileType());
|
||||
// 文件后缀
|
||||
fileStorage.setFileSuffix(getSuffixWithoutDot(fileInfo.getOriginalName()));
|
||||
@@ -498,6 +499,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
* @return 创建结果
|
||||
*/
|
||||
public SdmResponse<?> createRootDir(CreateDirReq req) {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
if(ObjectUtils.isEmpty(req.getDirType())){
|
||||
log.error("请选择目录类型:1 知识库文件夹,2 项目节点文件夹,3 头像库文件夹,4 仿真参数库文件夹,5 训练模型文件夹");
|
||||
return SdmResponse.failed("请选择目录类型:1 知识库文件夹,2 项目节点文件夹,3 头像库文件夹,4 仿真参数库文件夹,5 训练模型文件夹");
|
||||
@@ -511,7 +513,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
|
||||
// 先检查根目录是否已存在
|
||||
String rootDirMinioObjectKey = getDirMinioObjectKey(dirTypeByValue.getDirName());
|
||||
Optional<FileMetadataInfo> fileMetadataInfoByObjectKey = getFileMetadataInfoByObjectKey(rootDirMinioObjectKey);
|
||||
Optional<FileMetadataInfo> fileMetadataInfoByObjectKey = getFileMetadataInfoByObjectKey(rootDirMinioObjectKey, null);
|
||||
// 检查目录是否已存在
|
||||
if (!fileMetadataInfoByObjectKey.isPresent()) {
|
||||
log.error("知识库、项目根目录不存在,等待initSystemDirectory 初始化完成");
|
||||
@@ -529,7 +531,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
|
||||
try {
|
||||
// 检查目录是否已存在
|
||||
if (getFileMetadataInfoByObjectKey(dirMinioObjectKey).isPresent()) {
|
||||
if (getFileMetadataInfoByObjectKey(dirMinioObjectKey,tenantId).isPresent()) {
|
||||
log.error("目录已存在");
|
||||
return SdmResponse.failed("目录已存在");
|
||||
}
|
||||
@@ -565,6 +567,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
* @return 创建结果
|
||||
*/
|
||||
public SdmResponse<Object> createChildDir(CreateDirReq req) {
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
Long parDirId = null;
|
||||
if (req.getParentUuId() != null) {
|
||||
FileMetadataInfo node = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getRelatedResourceUuid, req.getParentUuId()).one();
|
||||
@@ -587,7 +590,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
String childDirMinioObjectKey = getDirMinioObjectKey(parDirInfo.getObjectKey() + req.getDirName());
|
||||
|
||||
// 检查子目录是否已存在
|
||||
if (getFileMetadataInfoByObjectKey(childDirMinioObjectKey).isPresent()) {
|
||||
if (getFileMetadataInfoByObjectKey(childDirMinioObjectKey, tenantId).isPresent()) {
|
||||
log.error("目录已存在");
|
||||
return SdmResponse.failed("目录已存在");
|
||||
}
|
||||
@@ -646,6 +649,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
dirInfo.setIsRoot(isRoot);
|
||||
dirInfo.setDirType(dirType);
|
||||
dirInfo.setCreatorId(ThreadLocalContext.getUserId());
|
||||
dirInfo.setTenantId(ThreadLocalContext.getTenantId());
|
||||
if (!isRoot && parentId != null) {
|
||||
dirInfo.setParentId(parentId);
|
||||
}
|
||||
@@ -686,6 +690,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
fileInfo.setParentId(parentId);
|
||||
fileInfo.setIsRoot(false);
|
||||
fileInfo.setCreatorId(ThreadLocalContext.getUserId());
|
||||
fileInfo.setTenantId(ThreadLocalContext.getTenantId());
|
||||
fileInfo.setFileSize(fileSize);
|
||||
return fileInfo;
|
||||
}
|
||||
@@ -700,6 +705,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
permission.setTFilemetaId(directoryId);
|
||||
permission.setPermission(FilePermissionEnum.ALL.getValue());
|
||||
permission.setUserId(ThreadLocalContext.getUserId());
|
||||
permission.setTenantId(ThreadLocalContext.getTenantId());
|
||||
fileUserPermissionService.save(permission);
|
||||
}
|
||||
|
||||
@@ -722,6 +728,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
permission.setTFilemetaId(fileId);
|
||||
permission.setPermission(FilePermissionEnum.ALL.getValue());
|
||||
permission.setUserId(ThreadLocalContext.getUserId());
|
||||
permission.setTenantId(ThreadLocalContext.getTenantId());
|
||||
fileUserPermissionService.save(permission);
|
||||
}
|
||||
|
||||
@@ -734,12 +741,12 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
fileUserPermissionService.lambdaUpdate().eq(FileUserPermission::getTFilemetaId, fileId).remove();
|
||||
}
|
||||
|
||||
private Optional<FileMetadataInfo> getFileMetadataInfoByObjectKey(String minioObjectKey) {
|
||||
private Optional<FileMetadataInfo> getFileMetadataInfoByObjectKey(String minioObjectKey, Long tenantId) {
|
||||
if (!StringUtils.hasText(minioObjectKey)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
minioObjectKey = getDirMinioObjectKey(minioObjectKey);
|
||||
return Optional.ofNullable(fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getObjectKey, minioObjectKey).one());
|
||||
return Optional.ofNullable(fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getObjectKey, minioObjectKey).eq(ObjectUtils.isNotEmpty(tenantId), FileMetadataInfo::getTenantId, tenantId).one());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -1106,6 +1113,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
FileUserPermission fileUserPermission = new FileUserPermission();
|
||||
fileUserPermission.setTFilemetaId(fileId);
|
||||
fileUserPermission.setUserId(userId);
|
||||
fileUserPermission.setTenantId(ThreadLocalContext.getTenantId());
|
||||
fileUserPermission.setPermission(permission);
|
||||
fileUserPermissionService.save(fileUserPermission);
|
||||
}
|
||||
@@ -1116,7 +1124,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
@Override
|
||||
public SdmResponse fileExists(String path) {
|
||||
String filePath = getDirMinioObjectKey(path);
|
||||
FileMetadataInfo fileMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getObjectKey, filePath).one();
|
||||
FileMetadataInfo fileMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getObjectKey, filePath).eq(FileMetadataInfo::getTenantId, ThreadLocalContext.getTenantId()).one();
|
||||
if (fileMetadataInfo == null) {
|
||||
return SdmResponse.failed("文件不存在");
|
||||
}
|
||||
@@ -1130,7 +1138,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
String dirMinioObjectKey = getDirMinioObjectKey(dirType.getDirName());
|
||||
try {
|
||||
// 检查目录是否已存在
|
||||
if (getFileMetadataInfoByObjectKey(dirMinioObjectKey).isPresent()) {
|
||||
if (getFileMetadataInfoByObjectKey(dirMinioObjectKey, null).isPresent()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1139,6 +1147,9 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
|
||||
// 创建目录元数据并保存到数据库
|
||||
FileMetadataInfo dirInfo = createDirectoryMetadata(dirMinioObjectKey, dirType.getDirName(), true, null, null, null, dirType.getValue());
|
||||
// 顶层目录的创建者ID和租户ID设置为null,表示这是系统级别的根目录
|
||||
dirInfo.setCreatorId(null);
|
||||
dirInfo.setTenantId(null);
|
||||
fileMetadataInfoService.save(dirInfo);
|
||||
} catch (Exception dbException) {
|
||||
log.error("创建根目录失败", dbException);
|
||||
@@ -1162,7 +1173,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SdmResponse renameDir(String filePath, String newName, Integer type) {
|
||||
String oldPath = getDirMinioObjectKey(filePath);
|
||||
FileMetadataInfo fileMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getObjectKey, oldPath).one();
|
||||
FileMetadataInfo fileMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getObjectKey, oldPath).eq(FileMetadataInfo::getTenantId, ThreadLocalContext.getTenantId()).one();
|
||||
if (fileMetadataInfo == null) {
|
||||
return SdmResponse.failed("文件不存在");
|
||||
}
|
||||
@@ -1333,6 +1344,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
fileStorage.setFileId(fileInfo.getId());
|
||||
fileStorage.setFileName(fileInfo.getOriginalName());
|
||||
fileStorage.setUserId(ThreadLocalContext.getUserId());
|
||||
fileStorage.setTenantId(ThreadLocalContext.getTenantId());
|
||||
fileStorage.setFileBizType(fileInfo.getFileType());
|
||||
// 文件后缀
|
||||
fileStorage.setFileSuffix(getSuffixWithoutDot(fileInfo.getOriginalName()));
|
||||
@@ -1438,7 +1450,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
|
||||
// 先检查根目录是否已存在
|
||||
String rootDirMinioObjectKey = getDirMinioObjectKey(dirTypeByValue.getDirName());
|
||||
Optional<FileMetadataInfo> fileMetadataInfoByObjectKey = getFileMetadataInfoByObjectKey(rootDirMinioObjectKey);
|
||||
Optional<FileMetadataInfo> fileMetadataInfoByObjectKey = getFileMetadataInfoByObjectKey(rootDirMinioObjectKey, null);
|
||||
// 检查目录是否已存在
|
||||
if (!fileMetadataInfoByObjectKey.isPresent()) {
|
||||
return SdmResponse.failed("知识库、项目根目录不存在,等待initSystemDirectory 初始化完成");
|
||||
@@ -1453,7 +1465,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
} else {
|
||||
fileMetadataInfoLambdaQueryChainWrapper.eq(FileMetadataInfo::getParentId, parentDirId);
|
||||
}
|
||||
List<FileMetadataInfo> list = fileMetadataInfoLambdaQueryChainWrapper.eq(FileMetadataInfo::getDataType, DataTypeEnum.DIRECTORY.getValue()).list();
|
||||
List<FileMetadataInfo> list = fileMetadataInfoLambdaQueryChainWrapper.eq(FileMetadataInfo::getTenantId, ThreadLocalContext.getTenantId()).eq(FileMetadataInfo::getDataType, DataTypeEnum.DIRECTORY.getValue()).orderByDesc(FileMetadataInfo::getCreateTime).list();
|
||||
|
||||
List<FileMetadataInfoResp> dtoList = list.stream().map(entity -> {
|
||||
FileMetadataInfoResp dto = new FileMetadataInfoResp();
|
||||
@@ -1598,6 +1610,27 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
}
|
||||
fileMetadataExtensionService.saveBatch(fileMetadataExtensionList);
|
||||
|
||||
// 循环查询当前文件每一级父目录id,并保存为一条file_storage,用户后续文件搜索统计
|
||||
Long parentDirId = dirMetadataInfo.getId();
|
||||
FileStorage fileStorage = new FileStorage();
|
||||
|
||||
fileStorage.setFileId(fileInfo.getId());
|
||||
fileStorage.setFileName(fileInfo.getOriginalName());
|
||||
fileStorage.setUserId(ThreadLocalContext.getUserId());
|
||||
fileStorage.setTenantId(ThreadLocalContext.getTenantId());
|
||||
fileStorage.setFileBizType(fileInfo.getFileType());
|
||||
// 文件后缀
|
||||
fileStorage.setFileSuffix(getSuffixWithoutDot(fileInfo.getOriginalName()));
|
||||
fileStorage.setFileSize(req.getFile().getSize());
|
||||
while (parentDirId != null) {
|
||||
fileStorage.setId(null);
|
||||
fileStorage.setDirId(parentDirId);
|
||||
fileStorageService.save(fileStorage);
|
||||
parentDirId = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getId, parentDirId).oneOpt()
|
||||
.map(FileMetadataInfo::getParentId)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
// 创建默认权限记录
|
||||
createFilePermission(fileInfo.getId());
|
||||
|
||||
@@ -1624,7 +1657,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
public SdmResponse uploadAvatar(MultipartFile avatar) {
|
||||
// 先创建 avatar 目录
|
||||
String dirMinioObjectKey = getDirMinioObjectKey(DirTypeEnum.AVATAR_DIR.getDirName());
|
||||
Optional<FileMetadataInfo> fileMetadataInfoByObjectKey = getFileMetadataInfoByObjectKey(dirMinioObjectKey);
|
||||
Optional<FileMetadataInfo> fileMetadataInfoByObjectKey = getFileMetadataInfoByObjectKey(dirMinioObjectKey,null );
|
||||
// 检查目录是否已存在
|
||||
if (!fileMetadataInfoByObjectKey.isPresent()) {
|
||||
return SdmResponse.failed("avatar 目录不存在,等待initSystemDirectory 初始化完成");
|
||||
@@ -1685,7 +1718,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
public SdmResponse<Long> uploadSimulationParamFile(MultipartFile paramFile) {
|
||||
// 先创建 simulationParameter 目录
|
||||
String dirMinioObjectKey = getDirMinioObjectKey(DirTypeEnum.SIMULATION_PARAMETER_DIR.getDirName());
|
||||
Optional<FileMetadataInfo> fileMetadataInfoByObjectKey = getFileMetadataInfoByObjectKey(dirMinioObjectKey);
|
||||
Optional<FileMetadataInfo> fileMetadataInfoByObjectKey = getFileMetadataInfoByObjectKey(dirMinioObjectKey,null );
|
||||
// 检查目录是否已存在
|
||||
if (!fileMetadataInfoByObjectKey.isPresent()) {
|
||||
return SdmResponse.failed("仿真参数库文件夹 目录不存在,等待initSystemDirectory 初始化完成");
|
||||
@@ -1747,7 +1780,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
public SdmResponse<Long> uploadTrainModelDataFile(MultipartFile trainModelFile) {
|
||||
// 先创建 trainModel 目录
|
||||
String dirMinioObjectKey = getDirMinioObjectKey(DirTypeEnum.TRAIN_MODEL_DIR.getDirName());
|
||||
Optional<FileMetadataInfo> fileMetadataInfoByObjectKey = getFileMetadataInfoByObjectKey(dirMinioObjectKey);
|
||||
Optional<FileMetadataInfo> fileMetadataInfoByObjectKey = getFileMetadataInfoByObjectKey(dirMinioObjectKey, null);
|
||||
// 检查目录是否已存在
|
||||
if (!fileMetadataInfoByObjectKey.isPresent()) {
|
||||
return SdmResponse.failed("trainModel 目录不存在,等待initSystemDirectory 初始化完成");
|
||||
@@ -1792,7 +1825,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
public SdmResponse<Long> uploadScriptFile(MultipartFile scriptFile) {
|
||||
// 先创建 script 目录
|
||||
String dirMinioObjectKey = getDirMinioObjectKey(DirTypeEnum.SCRIPT_DIR.getDirName());
|
||||
Optional<FileMetadataInfo> fileMetadataInfoByObjectKey = getFileMetadataInfoByObjectKey(dirMinioObjectKey);
|
||||
Optional<FileMetadataInfo> fileMetadataInfoByObjectKey = getFileMetadataInfoByObjectKey(dirMinioObjectKey, null);
|
||||
// 检查目录是否已存在
|
||||
if (!fileMetadataInfoByObjectKey.isPresent()) {
|
||||
return SdmResponse.failed("script 目录不存在,等待initSystemDirectory 初始化完成");
|
||||
@@ -1837,7 +1870,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
public SdmResponse updateScriptFile(UpdateScriptReq req) {
|
||||
// 先创建 script 目录
|
||||
String dirMinioObjectKey = getDirMinioObjectKey(DirTypeEnum.SCRIPT_DIR.getDirName());
|
||||
Optional<FileMetadataInfo> scriptDirInfo = getFileMetadataInfoByObjectKey(dirMinioObjectKey);
|
||||
Optional<FileMetadataInfo> scriptDirInfo = getFileMetadataInfoByObjectKey(dirMinioObjectKey,null );
|
||||
// 检查目录是否已存在
|
||||
if (!scriptDirInfo.isPresent()) {
|
||||
return SdmResponse.failed("script 目录不存在,等待initSystemDirectory 初始化完成");
|
||||
@@ -2370,6 +2403,11 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
.in(FileStorage::getFileId, failBusinessIds));
|
||||
// 4. 删除文件元数据表(最后删除主表)
|
||||
fileMetadataInfoService.removeBatchByIds(failBusinessIds);
|
||||
|
||||
// 5. 删除文件工况映射表
|
||||
fileSimulationMappingService.lambdaUpdate()
|
||||
.in(FileSimulationMapping::getFileId, failBusinessIds)
|
||||
.remove();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
CoreLogger.error("handleFailFiles error:{}", e.getMessage());
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.common.ThreadLocalContext;
|
||||
import com.sdm.common.entity.ExportExcelFormat;
|
||||
import com.sdm.common.entity.enums.ApprovalFileDataStatusEnum;
|
||||
import com.sdm.common.entity.req.data.BaseReq;
|
||||
@@ -157,6 +158,8 @@ public class ModelServiceImpl implements IModelService {
|
||||
|
||||
TrainingModel trainingModel = new TrainingModel();
|
||||
BeanUtils.copyProperties(addModelReq, trainingModel);
|
||||
trainingModel.setCreator(ThreadLocalContext.getUserId());
|
||||
trainingModel.setTenantId(ThreadLocalContext.getTenantId());
|
||||
trainingModelService.save(trainingModel);
|
||||
return SdmResponse.success("添加训练模型成功");
|
||||
} catch (RuntimeException e) {
|
||||
@@ -177,7 +180,9 @@ public class ModelServiceImpl implements IModelService {
|
||||
@Override
|
||||
public SdmResponse getModelList(QueryModelReq baseReq) {
|
||||
PageHelper.startPage(baseReq.getCurrent(), baseReq.getSize());
|
||||
List<TrainingModel> models = trainingModelService.lambdaQuery().eq(StringUtils.isNotBlank(baseReq.getAlgorithmUsed()),TrainingModel::getAlgorithmUsed,baseReq.getAlgorithmUsed())
|
||||
List<TrainingModel> models = trainingModelService.lambdaQuery()
|
||||
.eq(TrainingModel::getTenantId, ThreadLocalContext.getTenantId())
|
||||
.eq(StringUtils.isNotBlank(baseReq.getAlgorithmUsed()),TrainingModel::getAlgorithmUsed,baseReq.getAlgorithmUsed())
|
||||
.like(StringUtils.isNotBlank(baseReq.getDescription()),TrainingModel::getDescription,baseReq.getDescription())
|
||||
.like(StringUtils.isNotBlank(baseReq.getModelName()),TrainingModel::getModelName,baseReq.getModelName())
|
||||
.eq(StringUtils.isNotBlank(baseReq.getTrainer()),TrainingModel::getTrainer,baseReq.getTrainer())
|
||||
|
||||
@@ -68,6 +68,7 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
public SdmResponse addLibrary(String parameterLibraryName) {
|
||||
SimulationParameterLibrary simulationParameterLibrary = new SimulationParameterLibrary();
|
||||
simulationParameterLibrary.setParameterLibraryName(parameterLibraryName);
|
||||
simulationParameterLibrary.setTenantId(ThreadLocalContext.getTenantId());
|
||||
this.save(simulationParameterLibrary);
|
||||
return SdmResponse.success("仿真参数库添加成功");
|
||||
}
|
||||
@@ -145,7 +146,7 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
List<JSONObject> jsonObjects = new ArrayList<>();
|
||||
if (id == null) {
|
||||
// 获取所有仿真参数库
|
||||
List<SimulationParameterLibrary> simulationParameterLibraries = this.list();
|
||||
List<SimulationParameterLibrary> simulationParameterLibraries = this.lambdaQuery().eq(SimulationParameterLibrary::getTenantId, ThreadLocalContext.getTenantId()).list();
|
||||
if (CollectionUtils.isEmpty(simulationParameterLibraries)) {
|
||||
return SdmResponse.success(jsonObjects);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
<if test="filterEmptyData != null and filterEmptyData">
|
||||
LEFT JOIN file_storage ON file_metadata_info.id = file_storage.dirId
|
||||
</if>
|
||||
WHERE file_metadata_info.id IN (
|
||||
WHERE
|
||||
file_metadata_info.tenantId = #{tenantId}
|
||||
and
|
||||
file_metadata_info.id IN (
|
||||
<foreach collection="dirIds" item="dirId" separator=",">
|
||||
#{dirId}
|
||||
</foreach>
|
||||
@@ -24,6 +27,7 @@
|
||||
SELECT distinct file_metadata_info.*
|
||||
FROM file_metadata_info
|
||||
WHERE parentId = #{parentId}
|
||||
and tenantId = #{tenantId}
|
||||
AND dataType = 2
|
||||
AND isLatest = true
|
||||
|
||||
@@ -36,7 +40,10 @@
|
||||
<if test="filterEmptyData != null and filterEmptyData">
|
||||
LEFT JOIN file_storage ON file_metadata_info.id = file_storage.dirId
|
||||
</if>
|
||||
WHERE file_metadata_info.id IN (
|
||||
WHERE
|
||||
tenantId = #{tenantId}
|
||||
and
|
||||
file_metadata_info.id IN (
|
||||
<foreach collection="fileIds" item="fileId" separator=",">
|
||||
#{fileId}
|
||||
</foreach>
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
dirId,
|
||||
SUM(fileSize) AS totalSize
|
||||
FROM file_storage
|
||||
WHERE dirId IN
|
||||
WHERE
|
||||
file_storage.tenantId = #{tenantId}
|
||||
and
|
||||
dirId IN
|
||||
<foreach collection="directoryIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
@@ -26,6 +29,8 @@
|
||||
SUM(fileSize) AS totalSize -- 总占用字节数(原始单位)
|
||||
FROM file_storage
|
||||
WHERE
|
||||
file_storage.tenantId = #{tenantId}
|
||||
and
|
||||
dirId IN
|
||||
<foreach collection="dirIds" item="dirId" open="(" separator="," close=")">
|
||||
#{dirId}
|
||||
@@ -42,6 +47,8 @@
|
||||
SUM(fileSize) AS totalSize
|
||||
FROM file_storage
|
||||
WHERE
|
||||
file_storage.tenantId = #{tenantId}
|
||||
and
|
||||
dirId IN
|
||||
<foreach collection="dirIds" item="dirId" open="(" separator="," close=")">
|
||||
#{dirId}
|
||||
@@ -55,7 +62,10 @@
|
||||
userId,
|
||||
SUM(fileSize) AS totalSize
|
||||
FROM file_storage
|
||||
WHERE userId IN
|
||||
WHERE
|
||||
file_storage.tenantId = #{tenantId}
|
||||
and
|
||||
userId IN
|
||||
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
@@ -74,7 +84,10 @@
|
||||
'BEFORE' AS statDimension,
|
||||
SUM(fileSize) AS totalSize
|
||||
FROM file_storage
|
||||
WHERE userId IN
|
||||
WHERE
|
||||
file_storage.tenantId = #{tenantId}
|
||||
and
|
||||
userId IN
|
||||
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
@@ -89,7 +102,10 @@
|
||||
'INCREMENT' AS statDimension,
|
||||
SUM(fileSize) AS totalSize
|
||||
FROM file_storage
|
||||
WHERE userId IN
|
||||
WHERE
|
||||
file_storage.tenantId = #{tenantId}
|
||||
and
|
||||
userId IN
|
||||
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
@@ -106,6 +122,8 @@
|
||||
<where>
|
||||
file_metadata_info.id is not null
|
||||
and file_metadata_info.isLatest = #{queryBigFileReq.isLatest}
|
||||
and file_metadata_info.tenantId = #{tenantId}
|
||||
and file_storage.tenantId = #{tenantId}
|
||||
<if test="queryBigFileReq.approveTypeList != null and queryBigFileReq.approveTypeList.size()>0">
|
||||
AND file_metadata_info.approveType IN
|
||||
<foreach collection="queryBigFileReq.approveTypeList" item="approveType" open="(" separator="," close=")">
|
||||
|
||||
Reference in New Issue
Block a user