Merge branch 'main' of http://192.168.65.198:3000/toolchaintechnologycenter/spdm-backend
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
package com.sdm.data.config;
|
||||
|
||||
import com.sdm.data.service.IDataFileService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class DataServiceConfig {
|
||||
@Value("${fileSystem.chose}")
|
||||
private String chosenType;
|
||||
|
||||
@Autowired
|
||||
private List<IDataFileService> IDataFileServices;
|
||||
|
||||
@Bean
|
||||
public IDataFileService dataFileService() {
|
||||
return IDataFileServices.stream()
|
||||
.filter(service -> service.getType().equals(chosenType))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new IllegalStateException(
|
||||
"No DataService found for type: " + chosenType
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -19,13 +19,12 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@@ -33,8 +32,8 @@ import java.util.List;
|
||||
@Tag(name = "数据文件管理", description = "文件和目录管理相关接口")
|
||||
public class DataFileController implements IDataFeignClient {
|
||||
|
||||
@Resource
|
||||
@Qualifier("dataFileService")
|
||||
|
||||
@Autowired
|
||||
private IDataFileService IDataFileService;
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,6 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
public class GetSimulationTaskFileReq extends BaseReq {
|
||||
@Schema(description = "文件所属项目节点uuid")
|
||||
@JsonProperty(value = "project")
|
||||
private String uuid;
|
||||
|
||||
@Schema(description = "文件类型", implementation = FileBizTypeEnum.class)
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.sdm.common.utils.SpringUtils;
|
||||
import com.sdm.data.dao.SystemMapper;
|
||||
import com.sdm.data.service.IDataFileService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@@ -22,8 +22,7 @@ public class InitSystemDirectory {
|
||||
@Resource
|
||||
private SpringUtils springUtils;
|
||||
|
||||
@Resource
|
||||
@Qualifier("dataFileService")
|
||||
@Autowired
|
||||
private IDataFileService IDataFileService;
|
||||
|
||||
@Resource
|
||||
|
||||
@@ -21,11 +21,6 @@ import java.util.List;
|
||||
|
||||
@Service
|
||||
public interface IDataFileService {
|
||||
/**
|
||||
* 获取数据服务类型
|
||||
* @return 服务类型字符串
|
||||
*/
|
||||
String getType();
|
||||
|
||||
/**
|
||||
* 创建目录
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.sdm.data.service.IFileMetadataInfoService;
|
||||
import com.sdm.data.service.IMinioService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -44,14 +45,15 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
|
||||
@Override
|
||||
public SdmResponse getSimulationTaskFile(GetSimulationTaskFileReq getSimulationTaskFileReq) {
|
||||
FileMetadataInfo fileMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getRelatedResourceUuid, getSimulationTaskFileReq.getUuid()).one();
|
||||
if(fileMetadataInfo == null) {
|
||||
return SdmResponse.success();
|
||||
}
|
||||
|
||||
QueryBigFileReq queryBigFileReq = new QueryBigFileReq();
|
||||
BeanUtils.copyProperties(getSimulationTaskFileReq, queryBigFileReq);
|
||||
queryBigFileReq.setDirId(fileMetadataInfo.getId());
|
||||
|
||||
|
||||
FileMetadataInfo fileMetadataInfo = fileMetadataInfoService.lambdaQuery().eq(FileMetadataInfo::getRelatedResourceUuid, getSimulationTaskFileReq.getUuid()).one();
|
||||
if(ObjectUtils.isNotEmpty(fileMetadataInfo)) {
|
||||
queryBigFileReq.setDirId(fileMetadataInfo.getId());
|
||||
}
|
||||
|
||||
SdmResponse<PageDataResp<List<FileStorage>>> searchResult = dataStorageAnalysis.listBigFile(queryBigFileReq);
|
||||
PageDataResp<List<FileStorage>> pageDataResp = searchResult.getData();
|
||||
List<FileStorage> data = pageDataResp.getData();
|
||||
@@ -60,12 +62,9 @@ public class DataAnalysisServiceImpl implements IDataAnalysisService {
|
||||
}
|
||||
List<Long> fileIdList = data.stream().map(FileStorage::getFileId).toList();
|
||||
|
||||
|
||||
|
||||
List<FileMetadataInfo> simulationTaskFileMetadataInfos = fileMetadataInfoService
|
||||
.lambdaQuery()
|
||||
.in(FileMetadataInfo::getId, fileIdList)
|
||||
.eq(FileMetadataInfo::getIsLatest, FileIsLastEnum.YES.getValue())
|
||||
.list();
|
||||
|
||||
PageInfo<FileMetadataInfo> pageInfo = new PageInfo<>(simulationTaskFileMetadataInfos);
|
||||
|
||||
@@ -60,8 +60,7 @@ public class DimensionTemplateServiceImpl extends ServiceImpl<DimensionTemplateM
|
||||
@Autowired
|
||||
SimulationNodeFeignClientImpl simuluationNodeFeignClient;
|
||||
|
||||
@Resource
|
||||
@Qualifier("dataFileService")
|
||||
@Autowired
|
||||
private IDataFileService dataFileService;
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -74,6 +75,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "fileSystem.chose", havingValue = "minio")
|
||||
public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
// 初始化用户业务库目录
|
||||
private static final List<DirTypeEnum> INIT_SPMD_DIR = List.of(
|
||||
@@ -88,9 +90,6 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
NumberConstants.FOUR
|
||||
);
|
||||
|
||||
@Value("${fileSystem.minio}")
|
||||
private String type;
|
||||
|
||||
@Value("${fileSystem.chunkBucket:spdm}")
|
||||
private String chunkBucket;
|
||||
|
||||
@@ -134,10 +133,10 @@ public class MinioFileIDataFileServiceImpl implements IDataFileService {
|
||||
@Qualifier(value = "nonSensitiveTaskPool")
|
||||
private Executor nonSensitiveTaskPool;
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
// @Override
|
||||
// public String getType() {
|
||||
// return type;
|
||||
// }
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
@@ -2,12 +2,13 @@ package com.sdm.data.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.common.entity.enums.SimulationParameterDataTypeEnum;
|
||||
import com.sdm.data.model.entity.SimulationParameterLibrary;
|
||||
import com.sdm.data.dao.SimulationParameterLibraryMapper;
|
||||
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.SimulationParameterLibraryCategoryObjectReq;
|
||||
@@ -16,14 +17,11 @@ import com.sdm.data.service.IDataFileService;
|
||||
import com.sdm.data.service.ISimulationParameterLibraryCategoryObjectService;
|
||||
import com.sdm.data.service.ISimulationParameterLibraryCategoryService;
|
||||
import com.sdm.data.service.ISimulationParameterLibraryService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
@@ -38,8 +36,8 @@ import java.util.*;
|
||||
*/
|
||||
@Service
|
||||
public class SimulationParameterLibraryServiceImpl extends ServiceImpl<SimulationParameterLibraryMapper, SimulationParameterLibrary> implements ISimulationParameterLibraryService {
|
||||
@Resource
|
||||
@Qualifier("dataFileService")
|
||||
|
||||
@Autowired
|
||||
private IDataFileService dataFileService;
|
||||
|
||||
@Autowired
|
||||
@@ -183,7 +181,6 @@ public class SimulationParameterLibraryServiceImpl extends ServiceImpl<Simulatio
|
||||
simulationParameterLibraryCategoryObjectResp.setParameterJsonValue(parameterJsonValueFromJsonNode);
|
||||
} catch (IOException e) {
|
||||
log.error("解析JSON文件时发生错误", e);
|
||||
return SdmResponse.failed("解析JSON文件时发生错误");
|
||||
}
|
||||
return SdmResponse
|
||||
.success(simulationParameterLibraryCategoryObjectResp);
|
||||
|
||||
@@ -29,6 +29,7 @@ import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -43,9 +44,8 @@ import java.util.stream.Collectors;
|
||||
// 基于本地文件系统的数据服务
|
||||
@Slf4j
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "fileSystem.chose", havingValue = "system")
|
||||
public class SystemFileIDataFileServiceImpl implements IDataFileService {
|
||||
@Value("${fileSystem.system}")
|
||||
private String type;
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
@@ -68,10 +68,10 @@ public class SystemFileIDataFileServiceImpl implements IDataFileService {
|
||||
@Resource
|
||||
private CommonService commonService;
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
// @Override
|
||||
// public String getType() {
|
||||
// return type;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public SdmResponse createDir(CreateDirReq req) {
|
||||
|
||||
33
pbs/src/main/java/com/sdm/pbs/model/bo/HpcJobStatusInfo.java
Normal file
33
pbs/src/main/java/com/sdm/pbs/model/bo/HpcJobStatusInfo.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.sdm.pbs.model.bo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
public class HpcJobStatusInfo {
|
||||
|
||||
@Schema(description = "作业ID")
|
||||
public String jobId;
|
||||
|
||||
@Schema(description = "作业名称")
|
||||
public String jobName;
|
||||
|
||||
@Schema(description = "作业状态 1:pending 2:submitting 3:running 4:succeed 5:failed")
|
||||
public int jobStatus;
|
||||
|
||||
@Schema(description = "作业所占核数")
|
||||
public int coreNum;
|
||||
|
||||
@Schema(description = "作业占用内存大小")
|
||||
public int memory;
|
||||
|
||||
@Schema(description = "作业开始时间")
|
||||
public String startTime;
|
||||
|
||||
@Schema(description = "作业结束时间")
|
||||
public String endTime;
|
||||
|
||||
@Schema(description = "作业提交时间")
|
||||
public String submitTime;
|
||||
|
||||
@Schema(description = "作业计算软件")
|
||||
public String software;
|
||||
}
|
||||
25
pbs/src/main/java/com/sdm/pbs/model/bo/HpcNodeInfo.java
Normal file
25
pbs/src/main/java/com/sdm/pbs/model/bo/HpcNodeInfo.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.sdm.pbs.model.bo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HpcNodeInfo {
|
||||
|
||||
@Schema(description = "计算节点名称")
|
||||
public String nodeName;
|
||||
|
||||
@Schema(description = "计算节点状态 0:down 1:running 2:suspend")
|
||||
public int nodeStatus;
|
||||
|
||||
@Schema(description = "节点总核数")
|
||||
public int totalCores;
|
||||
|
||||
@Schema(description = "可用核数")
|
||||
public int freeCores;
|
||||
|
||||
@Schema(description = "已用核数")
|
||||
public int usedCores;
|
||||
|
||||
}
|
||||
21
pbs/src/main/java/com/sdm/pbs/model/bo/HpcResouceInfo.java
Normal file
21
pbs/src/main/java/com/sdm/pbs/model/bo/HpcResouceInfo.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.sdm.pbs.model.bo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HpcResouceInfo {
|
||||
|
||||
@Schema(description = "资源总核数")
|
||||
public int totalCores;
|
||||
|
||||
@Schema(description = "已用核数")
|
||||
public int usedCores;
|
||||
|
||||
@Schema(description = "空闲核数")
|
||||
public int freeCores;
|
||||
|
||||
@Schema(description = "节点核数信息")
|
||||
private List<HpcNodeInfo> nodeList = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.sdm.pbs.model.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SubmitHpcTaskReq {
|
||||
|
||||
@Schema(description = "计算任务名称")
|
||||
public String jobName;
|
||||
|
||||
@Schema(description = "计算所需要核数")
|
||||
public int coreNum;
|
||||
|
||||
@Schema(description = "计算软件")
|
||||
public String software;
|
||||
|
||||
@Schema(description = "计算任务类型")
|
||||
public String jobType;
|
||||
|
||||
@Schema(description = "计算任务是否独立存在 0:非独立任务 1:独立任务")
|
||||
public int independence;
|
||||
|
||||
@Schema(description = "求解文件")
|
||||
public List<String> inputFiles = new ArrayList<>();
|
||||
|
||||
@Schema(description = "计算主文件")
|
||||
public String masterFile;
|
||||
|
||||
@Schema(description = "计算任务所属任务ID")
|
||||
public String taskId;
|
||||
|
||||
@Schema(description = "计算任务所属任务名称")
|
||||
public String taskName;
|
||||
|
||||
@Schema(description = "计算任务所属算力ID")
|
||||
public String runId;
|
||||
|
||||
@Schema(description = "计算任务所属算力名称")
|
||||
public String runName;
|
||||
}
|
||||
55
pbs/src/main/java/com/sdm/pbs/service/IPbsService.java
Normal file
55
pbs/src/main/java/com/sdm/pbs/service/IPbsService.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package com.sdm.pbs.service;
|
||||
|
||||
import com.sdm.common.common.SdmResponse;
|
||||
import com.sdm.pbs.model.bo.FileBaseInfo;
|
||||
import com.sdm.pbs.model.bo.HpcJobStatusInfo;
|
||||
import com.sdm.pbs.model.bo.HpcResouceInfo;
|
||||
import com.sdm.pbs.model.req.SubmitHpcTaskReq;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IPbsService {
|
||||
|
||||
/**
|
||||
* 查询HPC资源信息
|
||||
* @return
|
||||
*/
|
||||
SdmResponse<HpcResouceInfo> queryHpcResource();
|
||||
|
||||
/**
|
||||
* 提交HPC作业
|
||||
* @param req
|
||||
* @return 返回jobId
|
||||
*/
|
||||
SdmResponse<String> submitHpcJob(SubmitHpcTaskReq req);
|
||||
|
||||
/**
|
||||
* 停止HPC作业
|
||||
* @param jobId
|
||||
* @return
|
||||
*/
|
||||
SdmResponse<Boolean> stopHpcJob(String jobId);
|
||||
|
||||
|
||||
/**
|
||||
* 作业状态查询
|
||||
* @param jobId
|
||||
* @return
|
||||
*/
|
||||
SdmResponse<HpcJobStatusInfo> getJobStatus(String jobId);
|
||||
|
||||
/**
|
||||
* 获取计算文件结果目录文件信息
|
||||
* @param jobId
|
||||
* @return
|
||||
*/
|
||||
SdmResponse<List<FileBaseInfo>> getJobResultFiles(String jobId);
|
||||
|
||||
/**
|
||||
* 下载计算结果文件
|
||||
* @param jobId
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
SdmResponse downloadFile(String jobId, String fileName);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class SimulationPerformanceServiceImpl extends ServiceImpl<SimulationPerf
|
||||
public SdmResponse batchAddTaskPerformance(BatchAddTaskPerformanceReq batchAddTaskPerformanceReq) {
|
||||
// 查询任务信息
|
||||
SimulationTask simulationTask = simulationTaskService.lambdaQuery()
|
||||
.eq(SimulationTask::getId, batchAddTaskPerformanceReq.getTaskId())
|
||||
.eq(SimulationTask::getUuid, batchAddTaskPerformanceReq.getTaskId())
|
||||
.one();
|
||||
|
||||
if (simulationTask == null) {
|
||||
|
||||
Reference in New Issue
Block a user