fix:数据优化
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.sdm.data.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.resp.PageDataResp;
|
||||
@@ -16,6 +17,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -42,15 +44,22 @@ public class DataStorageAnalysisController {
|
||||
@Operation(summary = "根据nodeId(项目nodeId)获取指定查询类型(queryNodeType)文件空间占用")
|
||||
public SdmResponse getNodeSizeByNodeType(
|
||||
@Parameter(description = "查询节点类型:project,discipline") @RequestParam(value = "queryNodeType", required = false) String queryNodeType,
|
||||
@Parameter(description = "节点id:项目Uuid") @RequestParam(value = "uuid", required = false) String uuid,
|
||||
@Parameter(description = "节点id:项目Uuid列表") @RequestParam(value = "uuids", required = false) List<String> uuids,
|
||||
@Parameter(description = "查询时间间隔(月)") @RequestParam(value = "intervalMonths", required = false) Integer intervalMonths,
|
||||
@Parameter(description = "增量查询指定的月:2025-06") @RequestParam(value = "targetYm", required = false) String targetYm
|
||||
) {
|
||||
try {
|
||||
if (ObjectUtils.isEmpty(queryNodeType) || ObjectUtils.isEmpty(uuid)) {
|
||||
if (ObjectUtils.isEmpty(queryNodeType) || ObjectUtils.isEmpty(uuids)) {
|
||||
return SdmResponse.success();
|
||||
}
|
||||
return dataStorageAnalysis.getNodeSizeByNodeType(queryNodeType, uuid, intervalMonths, targetYm);
|
||||
List<List<JSONObject>> result = new ArrayList<>();
|
||||
for (String uuid : uuids) {
|
||||
SdmResponse<List<JSONObject>> sdmResponse = dataStorageAnalysis.getNodeSizeByNodeType(queryNodeType, uuid, intervalMonths, targetYm);
|
||||
if (sdmResponse.getData() != null) {
|
||||
result.add(sdmResponse.getData());
|
||||
}
|
||||
}
|
||||
return SdmResponse.success(result);
|
||||
} catch (Exception e) {
|
||||
log.error("获取文件空间占用失败", e);
|
||||
return SdmResponse.failed("获取文件空间占用失败");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.sdm.data.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.resp.PageDataResp;
|
||||
import com.sdm.data.model.entity.FileStorage;
|
||||
@@ -20,7 +21,7 @@ public interface DataStorageAnalysis {
|
||||
* @param targetYm 增量查询指定的月:2025-06
|
||||
* @return 文件总大小(字节)
|
||||
*/
|
||||
SdmResponse getNodeSizeByNodeType(String queryNodeType, String uuid, Integer intervalMonths, String targetYm);
|
||||
SdmResponse<List<JSONObject>> getNodeSizeByNodeType(String queryNodeType, String uuid, Integer intervalMonths, String targetYm);
|
||||
|
||||
/**
|
||||
* 根据用户id获取用户的空间占用
|
||||
|
||||
@@ -65,7 +65,7 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
|
||||
@Autowired
|
||||
IFileStorageQuotaService fileStorageQuotaService;
|
||||
|
||||
public SdmResponse getNodeSizeByNodeType(String queryNodeType, String uuid, Integer intervalMonths, String targetYm) {
|
||||
public SdmResponse<List<JSONObject>> getNodeSizeByNodeType(String queryNodeType, String uuid, Integer intervalMonths, String targetYm) {
|
||||
SdmResponse<List<AllNodeByProjectIdAndTypeResp>> response = simuluationNodeFeignClient.getAllNodeByProjectIdAndType(uuid, queryNodeType);
|
||||
Long tenantId = ThreadLocalContext.getTenantId();
|
||||
if (!response.isSuccess()) {
|
||||
@@ -166,7 +166,7 @@ public class DataStorageAnalysisImpl implements DataStorageAnalysis {
|
||||
if (!cidUserRespSdmResponse.isSuccess()) continue;
|
||||
|
||||
JSONObject tmp = new JSONObject();
|
||||
tmp.put("userName", cidUserRespSdmResponse.getData().getUsername() != null ? cidUserRespSdmResponse.getData().getUsername() : cidUserRespSdmResponse.getData().getNickname());
|
||||
tmp.put("userName", cidUserRespSdmResponse.getData().getNickname());
|
||||
tmp.put("totalFileSize", FileSizeUtils.formatFileSizeToGB(new BigDecimal(userTotalFileSizeDTO.getTotalSize())));
|
||||
result.add(tmp);
|
||||
}
|
||||
|
||||
@@ -1043,7 +1043,7 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
UserListReq userListReq = new UserListReq();
|
||||
BeanUtils.copyProperties(req, userListReq);
|
||||
userListReq.setUserId(req.getUserId());
|
||||
userListReq.setUserName(req.getUserName());
|
||||
userListReq.setNickname(req.getUserName());
|
||||
|
||||
SdmResponse<PageDataResp<List<CIDUserResp>>> sdmResponse = sysUserFeignClient.listUser(userListReq);
|
||||
if (!sdmResponse.isSuccess()) {
|
||||
|
||||
Reference in New Issue
Block a user