Merge branch 'main' of http://192.168.65.198:3000/toolchaintechnologycenter/spdm-backend
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
package com.sdm.common.entity.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息通知模板枚举
|
||||||
|
*/
|
||||||
|
public enum MessageTemplateEnum {
|
||||||
|
|
||||||
|
TASK_ISSUE("任务通知", "收到一条下发的新任务:%s,请前去[任务管理-我执行的]进行处理"),
|
||||||
|
HPC_START("作业通知", "作业已发起"),
|
||||||
|
HPC_END("作业通知", "作业已结束")
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String title;
|
||||||
|
private final String content;
|
||||||
|
|
||||||
|
MessageTemplateEnum(String title, String content) {
|
||||||
|
this.title = title;
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取模板内容(含参数替换)
|
||||||
|
*/
|
||||||
|
public String getContent(String taskName) {
|
||||||
|
return String.format(content, taskName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.sdm.common.entity.req.capability;
|
package com.sdm.common.entity.req.capability;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.sdm.common.entity.flowable.dto.NodeDetailInfo;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -59,4 +60,7 @@ public class FlowNodeDto {
|
|||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
private List<FlowNodeDto> flowNodeDtoList;
|
private List<FlowNodeDto> flowNodeDtoList;
|
||||||
|
|
||||||
|
@Schema(description = "节点详细信息 来自flowable")
|
||||||
|
private NodeDetailInfo nodeDetailInfo;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.sdm.common.entity.req.data;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SimulationPoolInfo {
|
||||||
|
/**
|
||||||
|
* 所属工况库id
|
||||||
|
*/
|
||||||
|
@Schema(description = "所属工况库id")
|
||||||
|
private Integer simulationPoolId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工况库版本
|
||||||
|
*/
|
||||||
|
@Schema(description = "工况库版本")
|
||||||
|
private String simulationPoolVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联工况
|
||||||
|
*/
|
||||||
|
@Schema(description = "关联工况")
|
||||||
|
private List<String> simulationPoolTaskIds;
|
||||||
|
}
|
||||||
@@ -73,26 +73,8 @@ public class UploadFilesReq {
|
|||||||
@Schema(description = "关联项目id")
|
@Schema(description = "关联项目id")
|
||||||
private String projectId;
|
private String projectId;
|
||||||
|
|
||||||
/**
|
@Schema(description = "关联工况库信息")
|
||||||
* 所属工况库id
|
private List<SimulationPoolInfo> simulationPoolInfoList;
|
||||||
*/
|
|
||||||
@Schema(description = "所属工况库id")
|
|
||||||
private Integer simulationPoolId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 工况库版本
|
|
||||||
*/
|
|
||||||
@Schema(description = "工况库版本")
|
|
||||||
private String simulationPoolVersion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联工况
|
|
||||||
*/
|
|
||||||
@Schema(description = "关联工况")
|
|
||||||
private List<String> simulationPoolTaskIds;
|
|
||||||
|
|
||||||
@Schema(description = "删除文件和工况库关联")
|
|
||||||
private List<Long> deleteFileSimulationMappingIds;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关联分析项目id
|
* 关联分析项目id
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.sdm.common.entity.req.system;
|
|||||||
|
|
||||||
import com.sdm.common.entity.BaseReq;
|
import com.sdm.common.entity.BaseReq;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Schema(description = "用户列表查询请求参数")
|
@Schema(description = "用户列表查询请求参数")
|
||||||
@@ -14,9 +13,12 @@ public class UserListReq extends BaseReq {
|
|||||||
@Schema(description = "用户ID")
|
@Schema(description = "用户ID")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
@Schema(description = "用户名")
|
@Schema(description = "CID userName是手机号")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(description = "昵称")
|
||||||
|
private String nickname;
|
||||||
|
|
||||||
@Schema(description = "手机号")
|
@Schema(description = "手机号")
|
||||||
private String phone;
|
private String phone;
|
||||||
}
|
}
|
||||||
@@ -20,9 +20,12 @@ public class UserQueryReq {
|
|||||||
@NotNull(message = "用户ID不能为空")
|
@NotNull(message = "用户ID不能为空")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
@Schema(description = "用户名")
|
@Schema(description = "CID userName是手机号")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
|
@Schema(description = "昵称")
|
||||||
|
private String nickName;
|
||||||
|
|
||||||
@Schema(description = "用户IDS")
|
@Schema(description = "用户IDS")
|
||||||
private List<Long> userIds;
|
private List<Long> userIds;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.sdm.common.feign.impl.system;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.sdm.common.common.SdmResponse;
|
||||||
|
import com.sdm.common.entity.req.system.SendMsgReq;
|
||||||
|
import com.sdm.common.feign.inter.system.IMessageFeignClient;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class MessageFeignClientImpl implements IMessageFeignClient {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMessageFeignClient messageFeignClient;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SdmResponse sendMessage(SendMsgReq req) {
|
||||||
|
SdmResponse response=null ;
|
||||||
|
try {
|
||||||
|
response = messageFeignClient.sendMessage(req);
|
||||||
|
if(response==null || !response.isSuccess()){
|
||||||
|
log.error("sendMessage failed response:{}", JSONObject.toJSONString(Optional.ofNullable(response)));
|
||||||
|
return SdmResponse.failed("发送消息通知失败");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("sendMessage error response:{}", JSONObject.toJSONString(Optional.ofNullable(response)));
|
||||||
|
return SdmResponse.failed("发送消息通知异常");
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -65,5 +65,71 @@ public class FileSizeUtils {
|
|||||||
DecimalFormat df = new DecimalFormat("0.00000000");
|
DecimalFormat df = new DecimalFormat("0.00000000");
|
||||||
return df.format(gbValue);
|
return df.format(gbValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将指定单位的文件大小转换为字节大小
|
||||||
|
*
|
||||||
|
* @param size 文件大小
|
||||||
|
* @param unit 文件大小单位 (B, KB, MB, GB, TB)
|
||||||
|
* @return 字节大小
|
||||||
|
*/
|
||||||
|
public static Long convertToBytes(Long size, String unit) {
|
||||||
|
if (size == null || unit == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (unit.toUpperCase()) {
|
||||||
|
case "B":
|
||||||
|
return size;
|
||||||
|
case "KB":
|
||||||
|
return size * 1024L;
|
||||||
|
case "MB":
|
||||||
|
return size * 1024L * 1024L;
|
||||||
|
case "GB":
|
||||||
|
return size * 1024L * 1024L * 1024L;
|
||||||
|
case "TB":
|
||||||
|
return size * 1024L * 1024L * 1024L * 1024L;
|
||||||
|
default:
|
||||||
|
return size; // 默认认为是字节
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将字节大小转换为指定单位的文件大小
|
||||||
|
*
|
||||||
|
* @param bytes 字节大小
|
||||||
|
* @param unit 文件大小单位 (B, KB, MB, GB, TB)
|
||||||
|
* @return 文件大小
|
||||||
|
*/
|
||||||
|
public static BigDecimal convertToUnit(Long bytes, String unit) {
|
||||||
|
if (bytes == null || unit == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal byteValue = new BigDecimal(bytes);
|
||||||
|
BigDecimal result;
|
||||||
|
|
||||||
|
switch (unit.toUpperCase()) {
|
||||||
|
case "B":
|
||||||
|
result = byteValue;
|
||||||
|
break;
|
||||||
|
case "KB":
|
||||||
|
result = byteValue.divide(new BigDecimal(1024L), 8, RoundingMode.HALF_UP);
|
||||||
|
break;
|
||||||
|
case "MB":
|
||||||
|
result = byteValue.divide(new BigDecimal(1024L * 1024L), 8, RoundingMode.HALF_UP);
|
||||||
|
break;
|
||||||
|
case "GB":
|
||||||
|
result = byteValue.divide(new BigDecimal(1024L * 1024L * 1024L), 8, RoundingMode.HALF_UP);
|
||||||
|
break;
|
||||||
|
case "TB":
|
||||||
|
result = byteValue.divide(new BigDecimal(1024L * 1024L * 1024L * 1024L), 8, RoundingMode.HALF_UP);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result = byteValue; // 默认认为是字节
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class DataStorageAnalysisController {
|
|||||||
// 查询用户配额
|
// 查询用户配额
|
||||||
@PostMapping("/listUserQuota")
|
@PostMapping("/listUserQuota")
|
||||||
@Operation(summary = "查询用户配额")
|
@Operation(summary = "查询用户配额")
|
||||||
public SdmResponse listUserQuota(ListUserQuotaReq listUserQuotaReq){
|
public SdmResponse listUserQuota(@RequestBody ListUserQuotaReq listUserQuotaReq){
|
||||||
return dataStorageAnalysis.listUserQuota(listUserQuotaReq);
|
return dataStorageAnalysis.listUserQuota(listUserQuotaReq);
|
||||||
}
|
}
|
||||||
//批量修改用户配额
|
//批量修改用户配额
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.sdm.data.model.enums;
|
||||||
|
|
||||||
|
public enum FileStorageQuotaStatusEnum {
|
||||||
|
// 配额状态(枚举:NORMAL-正常/WARNING-临界/EXCEED-超限)
|
||||||
|
NORMAL("正常"),
|
||||||
|
WARNING("临界"),
|
||||||
|
EXCEED("超限");
|
||||||
|
private String description;
|
||||||
|
FileStorageQuotaStatusEnum(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.sdm.data.model.resp;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FileStorageQuotaResp {
|
||||||
|
@Schema(description = "用户id")
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
@Schema(description = "用户昵称")
|
||||||
|
private String nickName;
|
||||||
|
|
||||||
|
@Schema(description = "用户工号")
|
||||||
|
private String jobNumber;
|
||||||
|
|
||||||
|
@Schema(description = "用户部门")
|
||||||
|
private String department;
|
||||||
|
|
||||||
|
@Schema(description = "存储阈值(显示单位:TB/GB/MB/KB)")
|
||||||
|
private String quotaValueString;
|
||||||
|
|
||||||
|
@Schema(description = "已使用存储(单位:TB/GB/MB/KB)")
|
||||||
|
private String usedValueString;
|
||||||
|
|
||||||
|
@Schema(description = "配额状态(枚举:NORMAL-正常/WARNING-临界/EXCEED-超限)")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,14 +19,15 @@ import com.sdm.data.model.dto.UserTotalFileSizeDTO;
|
|||||||
import com.sdm.data.model.entity.FileMetadataInfo;
|
import com.sdm.data.model.entity.FileMetadataInfo;
|
||||||
import com.sdm.data.model.entity.FileStorage;
|
import com.sdm.data.model.entity.FileStorage;
|
||||||
import com.sdm.data.model.entity.FileStorageQuota;
|
import com.sdm.data.model.entity.FileStorageQuota;
|
||||||
|
import com.sdm.data.model.enums.FileStorageQuotaStatusEnum;
|
||||||
import com.sdm.data.model.req.AddUserQuotaEntity;
|
import com.sdm.data.model.req.AddUserQuotaEntity;
|
||||||
import com.sdm.common.entity.req.data.DelFileReq;
|
import com.sdm.common.entity.req.data.DelFileReq;
|
||||||
import com.sdm.data.model.req.ListUserQuotaReq;
|
import com.sdm.data.model.req.ListUserQuotaReq;
|
||||||
import com.sdm.data.model.req.QueryBigFileReq;
|
import com.sdm.data.model.req.QueryBigFileReq;
|
||||||
|
import com.sdm.data.model.resp.FileStorageQuotaResp;
|
||||||
import com.sdm.data.service.*;
|
import com.sdm.data.service.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -34,10 +35,10 @@ import org.springframework.util.CollectionUtils;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -229,48 +230,131 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SdmResponse addUserQuota(AddUserQuotaEntity addUserQuota) {
|
public SdmResponse addUserQuota(AddUserQuotaEntity addUserQuota) {
|
||||||
Long quotaValue = convertToBytes(addUserQuota.getQuotaValue(), addUserQuota.getQuotaUnit());
|
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();
|
||||||
|
if (existFileStorageQuota != null){
|
||||||
|
return SdmResponse.failed("该用户已存在存储配额");
|
||||||
|
}
|
||||||
|
|
||||||
FileStorageQuota fileStorageQuota = new FileStorageQuota();
|
FileStorageQuota fileStorageQuota = new FileStorageQuota();
|
||||||
fileStorageQuota.setUserId(addUserQuota.getUserId());
|
fileStorageQuota.setUserId(addUserQuota.getUserId());
|
||||||
fileStorageQuota.setQuotaValue(quotaValue);
|
fileStorageQuota.setQuotaValue(addUserQuota.getQuotaValue());
|
||||||
fileStorageQuota.setQuotaUnit(addUserQuota.getQuotaUnit());
|
fileStorageQuota.setQuotaUnit(addUserQuota.getQuotaUnit());
|
||||||
fileStorageQuota.setStatus("NORMAL");
|
|
||||||
fileStorageQuotaService.save(fileStorageQuota);
|
fileStorageQuotaService.save(fileStorageQuota);
|
||||||
return null;
|
return SdmResponse.success("新增用户存储配额成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SdmResponse listUserQuota(ListUserQuotaReq listUserQuotaReq) {
|
public SdmResponse listUserQuota(ListUserQuotaReq listUserQuotaReq) {
|
||||||
UserListReq req = new UserListReq();
|
UserListReq req = new UserListReq();
|
||||||
req.setUserName(listUserQuotaReq.getUserName());
|
req.setNickname(listUserQuotaReq.getUserName());
|
||||||
|
req.setCurrent(listUserQuotaReq.getCurrent());
|
||||||
|
req.setSize(listUserQuotaReq.getSize());
|
||||||
SdmResponse<PageDataResp<List<CIDUserResp>>> pageDataRespSdmResponse = sysUserFeignClient.listUser(req);
|
SdmResponse<PageDataResp<List<CIDUserResp>>> pageDataRespSdmResponse = sysUserFeignClient.listUser(req);
|
||||||
if (!pageDataRespSdmResponse.isSuccess()) {
|
if (!pageDataRespSdmResponse.isSuccess()) {
|
||||||
return SdmResponse.success();
|
return SdmResponse.success();
|
||||||
}
|
}
|
||||||
List<Long> userIds = pageDataRespSdmResponse.getData().getData().stream().map(CIDUserResp::getUserId).toList();
|
List<Long> userIds = pageDataRespSdmResponse.getData().getData().stream().map(CIDUserResp::getUserId).toList();
|
||||||
PageHelper.startPage(listUserQuotaReq.getCurrent(), listUserQuotaReq.getSize());
|
|
||||||
List<FileStorageQuota> list = fileStorageQuotaService.lambdaQuery().in(ObjectUtils.isNotEmpty(userIds), FileStorageQuota::getUserId, userIds).list();
|
Map<Long, CIDUserResp> userIdToNicknameMap = pageDataRespSdmResponse.getData().getData().stream().collect(Collectors.toMap(CIDUserResp::getUserId,Function.identity()));
|
||||||
PageInfo<FileStorageQuota> page = new PageInfo<>(list);
|
|
||||||
return PageUtils.getJsonObjectSdmResponse(list, page);
|
// 查询这些 userId 的配额信息,创建 userId -> quota 的映射
|
||||||
|
Map<Long, FileStorageQuota> quotaMap = fileStorageQuotaService.lambdaQuery()
|
||||||
|
.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()
|
||||||
|
.collect(Collectors.toMap(UserTotalFileSizeDTO::getUserId, Function.identity()));
|
||||||
|
|
||||||
|
|
||||||
|
// 构造最终结果,对于没有配额信息的用户添加默认值,并根据已使用存储量设置状态
|
||||||
|
List<FileStorageQuota> fullList = userIds.stream().map(userId -> {
|
||||||
|
FileStorageQuota quota = quotaMap.getOrDefault(userId, createDefaultFileStorageQuota(userId));
|
||||||
|
// 设置已使用值
|
||||||
|
UserTotalFileSizeDTO usedStorage = usedStorageMap.get(userId);
|
||||||
|
if (usedStorage != null) {
|
||||||
|
quota.setUsedValue(usedStorage.getTotalSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据配额和已使用量设置状态
|
||||||
|
if (quota.getQuotaValue() != null && quota.getUsedValue() != null) {
|
||||||
|
// 将配额值转换为与已使用值相同的单位(字节)进行比较
|
||||||
|
long quotaInBytes = convertToBytes(quota.getQuotaValue(), quota.getQuotaUnit());
|
||||||
|
if (quotaInBytes <= quota.getUsedValue()) {
|
||||||
|
quota.setStatus("EXCEED");
|
||||||
|
} else if (quotaInBytes * 0.8 <= quota.getUsedValue()) {
|
||||||
|
quota.setStatus("WARNING");
|
||||||
|
} else {
|
||||||
|
quota.setStatus("NORMAL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return quota;
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
List<FileStorageQuotaResp> result = new ArrayList<>();
|
||||||
|
for (FileStorageQuota quota : fullList) {
|
||||||
|
FileStorageQuotaResp resp = new FileStorageQuotaResp();
|
||||||
|
resp.setUserId(quota.getUserId().toString());
|
||||||
|
CIDUserResp cidUserResp = userIdToNicknameMap.get(quota.getUserId());
|
||||||
|
resp.setNickName(cidUserResp.getNickname());
|
||||||
|
resp.setQuotaValueString(quota.getQuotaValue() + " " + quota.getQuotaUnit());
|
||||||
|
BigDecimal usedValue = FileSizeUtils.convertToUnit(quota.getUsedValue(), quota.getQuotaUnit());
|
||||||
|
resp.setUsedValueString(usedValue.toPlainString() + " " + quota.getQuotaUnit());
|
||||||
|
// 设置状态为中文
|
||||||
|
resp.setStatus(FileStorageQuotaStatusEnum.valueOf(quota.getStatus()).getDescription());
|
||||||
|
result.add(resp);
|
||||||
|
}
|
||||||
|
// 使用 PageDataResp 中的数据构造 PageInfo
|
||||||
|
PageInfo<FileStorageQuota> page = new PageInfo<>();
|
||||||
|
page.setTotal(pageDataRespSdmResponse.getData().getTotal()); // 设置总记录数
|
||||||
|
page.setPageNum(pageDataRespSdmResponse.getData().getCurrentPage()); // 设置当前页码
|
||||||
|
page.setPageSize(pageDataRespSdmResponse.getData().getPageSize()); // 设置每页记录数
|
||||||
|
return PageUtils.getJsonObjectSdmResponse(result, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 辅助方法:创建默认的 FileStorageQuota 实例
|
||||||
|
private FileStorageQuota createDefaultFileStorageQuota(Long userId) {
|
||||||
|
FileStorageQuota defaultQuota = new FileStorageQuota();
|
||||||
|
defaultQuota.setUserId(userId);
|
||||||
|
defaultQuota.setQuotaValue(2L); // 默认存储阈值
|
||||||
|
defaultQuota.setQuotaUnit("GB"); // 默认单位
|
||||||
|
defaultQuota.setUsedValue(0L); // 默认已使用值
|
||||||
|
defaultQuota.setStatus("NORMAL"); // 默认状态
|
||||||
|
return defaultQuota;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SdmResponse batchUpdateUserQuota(List<AddUserQuotaEntity> addUserQuota) {
|
public SdmResponse batchUpdateUserQuota(List<AddUserQuotaEntity> addUserQuota) {
|
||||||
if (CollectionUtils.isEmpty(addUserQuota)) {
|
if (CollectionUtils.isEmpty(addUserQuota)) {
|
||||||
return SdmResponse.success();
|
return SdmResponse.failed("配置参数不能为空");
|
||||||
}
|
}
|
||||||
List<FileStorageQuota> fileStorageQuotas = new ArrayList<>();
|
|
||||||
for (AddUserQuotaEntity addUserQuotaEntity : addUserQuota) {
|
for (AddUserQuotaEntity addUserQuotaEntity : addUserQuota) {
|
||||||
Long quotaValue = convertToBytes(addUserQuotaEntity.getQuotaValue(), addUserQuotaEntity.getQuotaUnit());
|
if(ObjectUtils.isEmpty(addUserQuotaEntity.getUserId()) || ObjectUtils.isEmpty(addUserQuotaEntity.getQuotaValue()) || ObjectUtils.isEmpty(addUserQuotaEntity.getQuotaUnit())){
|
||||||
FileStorageQuota fileStorageQuota = new FileStorageQuota();
|
return SdmResponse.failed("配置参数不能为空");
|
||||||
fileStorageQuota.setUserId(addUserQuotaEntity.getUserId());
|
}
|
||||||
fileStorageQuota.setQuotaValue(quotaValue);
|
|
||||||
fileStorageQuota.setQuotaUnit(addUserQuotaEntity.getQuotaUnit());
|
|
||||||
fileStorageQuotas.add(fileStorageQuota);
|
|
||||||
}
|
|
||||||
|
|
||||||
fileStorageQuotaService.saveBatch(fileStorageQuotas);
|
// 判断用户是否存在存储配额,如果不存在则新增
|
||||||
return SdmResponse.success();
|
FileStorageQuota existFileStorageQuota = fileStorageQuotaService.lambdaQuery().eq(FileStorageQuota::getUserId, addUserQuotaEntity.getUserId()).one();
|
||||||
|
if (ObjectUtils.isEmpty(existFileStorageQuota)) {
|
||||||
|
FileStorageQuota fileStorageQuota = new FileStorageQuota();
|
||||||
|
fileStorageQuota.setUserId(addUserQuotaEntity.getUserId());
|
||||||
|
fileStorageQuota.setQuotaValue(addUserQuotaEntity.getQuotaValue());
|
||||||
|
fileStorageQuota.setQuotaUnit(addUserQuotaEntity.getQuotaUnit());
|
||||||
|
fileStorageQuotaService.save(fileStorageQuota);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新用户存储配额
|
||||||
|
fileStorageQuotaService.lambdaUpdate()
|
||||||
|
.eq(FileStorageQuota::getUserId, addUserQuotaEntity.getUserId())
|
||||||
|
.set(FileStorageQuota::getQuotaValue, addUserQuotaEntity.getQuotaValue())
|
||||||
|
.set(FileStorageQuota::getQuotaUnit, addUserQuotaEntity.getQuotaUnit())
|
||||||
|
.update();
|
||||||
|
}
|
||||||
|
return SdmResponse.success("更新成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -401,8 +401,10 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
|||||||
fileMetadataExtensionService.saveBatch(fileMetadataExtensionList);
|
fileMetadataExtensionService.saveBatch(fileMetadataExtensionList);
|
||||||
|
|
||||||
//绑定文件和工况库的关系
|
//绑定文件和工况库的关系
|
||||||
if(ObjectUtils.isNotEmpty(req.getSimulationPoolId()) && Objects.nonNull(req.getSimulationPoolVersion()) && CollectionUtils.isNotEmpty(req.getSimulationPoolTaskIds())){
|
if(CollectionUtils.isNotEmpty(req.getSimulationPoolInfoList())){
|
||||||
fileSimulationMappingService.saveFileSimulationMapping(fileInfo.getId(),req.getSimulationPoolId(),req.getSimulationPoolVersion(),req.getSimulationPoolTaskIds());
|
for (SimulationPoolInfo simulationPoolInfo : req.getSimulationPoolInfoList()) {
|
||||||
|
fileSimulationMappingService.saveFileSimulationMapping(fileInfo.getId(),simulationPoolInfo.getSimulationPoolId(),simulationPoolInfo.getSimulationPoolVersion(),simulationPoolInfo.getSimulationPoolTaskIds());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建默认权限记录
|
// 创建默认权限记录
|
||||||
@@ -1353,11 +1355,12 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
|||||||
fileMetadataExtensionService.saveBatch(fileMetadataExtensionList);
|
fileMetadataExtensionService.saveBatch(fileMetadataExtensionList);
|
||||||
|
|
||||||
//绑定文件和工况库的关系
|
//绑定文件和工况库的关系
|
||||||
if(ObjectUtils.isNotEmpty(req.getSimulationPoolId()) && Objects.nonNull(req.getSimulationPoolVersion()) && CollectionUtils.isNotEmpty(req.getSimulationPoolTaskIds())){
|
if(CollectionUtils.isNotEmpty(req.getSimulationPoolInfoList())){
|
||||||
fileSimulationMappingService.saveFileSimulationMapping(fileInfo.getId(),req.getSimulationPoolId(),req.getSimulationPoolVersion(),req.getSimulationPoolTaskIds());
|
for (SimulationPoolInfo simulationPoolInfo : req.getSimulationPoolInfoList()) {
|
||||||
|
fileSimulationMappingService.saveFileSimulationMapping(fileInfo.getId(),simulationPoolInfo.getSimulationPoolId(),simulationPoolInfo.getSimulationPoolVersion(),simulationPoolInfo.getSimulationPoolTaskIds());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 创建默认权限记录
|
// 创建默认权限记录
|
||||||
createFilePermission(fileInfo.getId());
|
createFilePermission(fileInfo.getId());
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,16 @@ import com.sdm.common.common.SdmResponse;
|
|||||||
import com.sdm.common.common.ThreadLocalContext;
|
import com.sdm.common.common.ThreadLocalContext;
|
||||||
import com.sdm.common.entity.ExportExcelFormat;
|
import com.sdm.common.entity.ExportExcelFormat;
|
||||||
import com.sdm.common.entity.enums.DirTypeEnum;
|
import com.sdm.common.entity.enums.DirTypeEnum;
|
||||||
|
import com.sdm.common.entity.enums.MessageTemplateEnum;
|
||||||
import com.sdm.common.entity.req.data.CreateDirReq;
|
import com.sdm.common.entity.req.data.CreateDirReq;
|
||||||
import com.sdm.common.entity.req.data.UploadFilesReq;
|
import com.sdm.common.entity.req.data.UploadFilesReq;
|
||||||
|
import com.sdm.common.entity.req.system.SendMsgReq;
|
||||||
import com.sdm.common.entity.req.system.UserQueryReq;
|
import com.sdm.common.entity.req.system.UserQueryReq;
|
||||||
import com.sdm.common.entity.req.task.DemandExportExcelFormat;
|
import com.sdm.common.entity.req.task.DemandExportExcelFormat;
|
||||||
import com.sdm.common.entity.req.task.DemandExportExcelParam;
|
import com.sdm.common.entity.req.task.DemandExportExcelParam;
|
||||||
import com.sdm.common.entity.resp.system.CIDUserResp;
|
import com.sdm.common.entity.resp.system.CIDUserResp;
|
||||||
import com.sdm.common.feign.impl.data.DataClientFeignClientImpl;
|
import com.sdm.common.feign.impl.data.DataClientFeignClientImpl;
|
||||||
|
import com.sdm.common.feign.impl.system.MessageFeignClientImpl;
|
||||||
import com.sdm.common.feign.impl.system.SysUserFeignClientImpl;
|
import com.sdm.common.feign.impl.system.SysUserFeignClientImpl;
|
||||||
import com.sdm.common.feign.inter.data.IDataFeignClient;
|
import com.sdm.common.feign.inter.data.IDataFeignClient;
|
||||||
import com.sdm.common.service.BaseService;
|
import com.sdm.common.service.BaseService;
|
||||||
@@ -75,7 +78,10 @@ public class DemandServiceImpl extends BaseService implements IDemandService {
|
|||||||
private SysUserFeignClientImpl sysUserFeignClient;
|
private SysUserFeignClientImpl sysUserFeignClient;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IDataFeignClient dataFeignClient;
|
private DataClientFeignClientImpl dataFeignClient;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MessageFeignClientImpl messageFeignClient;
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -580,6 +586,8 @@ public class DemandServiceImpl extends BaseService implements IDemandService {
|
|||||||
));
|
));
|
||||||
for (TaskNode taskNode : taskNodeList) {
|
for (TaskNode taskNode : taskNodeList) {
|
||||||
createDir(taskNode.getUuid(), parentUuid, taskNode.getNodeName());
|
createDir(taskNode.getUuid(), parentUuid, taskNode.getNodeName());
|
||||||
|
// 发送消息通知
|
||||||
|
sendMessage(MessageTemplateEnum.TASK_ISSUE, taskNode.getNodeName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(projectNodeExtraList)) {
|
if (CollectionUtils.isNotEmpty(projectNodeExtraList)) {
|
||||||
@@ -639,6 +647,15 @@ public class DemandServiceImpl extends BaseService implements IDemandService {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sendMessage(MessageTemplateEnum templateEnum, String taskName) {
|
||||||
|
SendMsgReq req = new SendMsgReq();
|
||||||
|
req.setTitle(templateEnum.getTitle());
|
||||||
|
req.setContent(templateEnum.getContent(taskName));
|
||||||
|
req.setTenantId(ThreadLocalContext.getTenantId().toString());
|
||||||
|
req.setUserId(ThreadLocalContext.getUserId().toString());
|
||||||
|
messageFeignClient.sendMessage(req);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SdmResponse uploadDemandFiles(UploadFilesReq req) {
|
public SdmResponse uploadDemandFiles(UploadFilesReq req) {
|
||||||
return dataFeignClient.uploadFiles(req);
|
return dataFeignClient.uploadFiles(req);
|
||||||
|
|||||||
@@ -1245,6 +1245,7 @@ public class SimulationRunServiceImpl extends ServiceImpl<SimulationRunMapper, S
|
|||||||
flowNodeDto.setNodeStatus(i.getStatus());
|
flowNodeDto.setNodeStatus(i.getStatus());
|
||||||
flowNodeDto.setUserParams(i.getUserParam());
|
flowNodeDto.setUserParams(i.getUserParam());
|
||||||
flowNodeDto.setProcessInstanceId(simulationRun.getFlowInstanceId());
|
flowNodeDto.setProcessInstanceId(simulationRun.getFlowInstanceId());
|
||||||
|
flowNodeDto.setNodeDetailInfo(i);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user