新增:hpc任务列表查询

This commit is contained in:
yangyang01000846
2025-12-01 09:27:42 +08:00
parent 9ac822f916
commit d6113de081
9 changed files with 315 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ import com.sdm.common.common.SdmResponse;
import com.sdm.common.entity.req.pbs.HpcTaskFileReq;
import com.sdm.common.entity.req.pbs.SubmitHpcTaskRemoteReq;
import com.sdm.common.entity.req.pbs.hpc.*;
import com.sdm.common.entity.resp.PageDataResp;
import com.sdm.common.entity.resp.pbs.hpc.*;
import com.sdm.common.entity.resp.pbs.hpc.listjobs.ListJobResp;
import com.sdm.common.entity.resp.pbs.hpc.listtasks.ListTasksResp;
@@ -13,9 +14,12 @@ import com.sdm.common.feign.inter.pbs.ITaskFeignClient;
import com.sdm.common.utils.HpcCommandExcuteUtil;
import com.sdm.pbs.model.bo.HpcJobStatusInfo;
import com.sdm.pbs.model.bo.HpcResouceInfo;
import com.sdm.pbs.model.entity.SimulationJob;
import com.sdm.pbs.model.req.QueryJobReq;
import com.sdm.pbs.model.req.SubmitHpcTaskReq;
import com.sdm.pbs.service.HpcInstructionService;
import com.sdm.pbs.service.IPbsService;
import com.sdm.pbs.service.impl.PbsServiceDecorator;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.lang3.StringUtils;
@@ -43,6 +47,9 @@ public class TaskController implements ITaskFeignClient {
@Qualifier("decoratorPbsService")
private IPbsService pbsService;
@Autowired
private PbsServiceDecorator pbsServiceDecorator;
@Autowired
private HpcCommandExcuteUtil hpcCommandExcuteUtil;
@@ -94,6 +101,12 @@ public class TaskController implements ITaskFeignClient {
return pbsService.downloadFile(jobId,fileName,fileSize);
}
@PostMapping("/queryJobs")
@Operation(summary = "spdm系统查询hpc任务")
SdmResponse<PageDataResp<List<SimulationJob>>> queryJobs(@RequestBody QueryJobReq req) {
return pbsServiceDecorator.queryJobs(req);
}
/*====================================================================*/

View File

@@ -0,0 +1,16 @@
package com.sdm.pbs.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sdm.pbs.model.entity.SimulationJob;
/**
* <p>
* HPC任务入库 Mapper 接口
* </p>
*
* @author author
* @since 2025-11-05
*/
public interface SimulationJobMapper extends BaseMapper<SimulationJob> {
}

View File

@@ -0,0 +1,163 @@
package com.sdm.pbs.model.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
* 仿真计算任务表
* </p>
*
* @author author
* @since 2025-11-30
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("simulation_job")
@Schema(description = "仿真计算任务表")
public class SimulationJob implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "主键ID自增")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@Schema(description = "计算任务名称")
@TableField("jobName")
private String jobName;
@Schema(description = "计算所需要核数")
@TableField("coreNum")
private Integer coreNum;
@Schema(description = "计算软件的名称")
@TableField("software")
private String software;
@Schema(description = "计算任务类型")
@TableField("jobType")
private String jobType;
@Schema(description = "计算任务是否独立存在 0非独立任务 1独立任务")
@TableField("independence")
private Boolean independence;
@Schema(description = "求解文件JSON格式存储文件UUID列表")
@TableField("inputFiles")
private String inputFiles;
@Schema(description = "计算主文件文件UUID")
@TableField("masterFile")
private String masterFile;
@Schema(description = "计算任务所属任务ID")
@TableField("taskId")
private String taskId;
@Schema(description = "计算任务所属任务名称")
@TableField("taskName")
private String taskName;
@Schema(description = "计算任务所属算力ID")
@TableField("runId")
private String runId;
@Schema(description = "计算任务所属算力名称")
@TableField("runName")
private String runName;
@Schema(description = "使用软件的id")
@TableField("softwareId")
private Long softwareId;
@Schema(description = "求解文件对应的文件Id")
@TableField("inputFileId")
private Long inputFileId;
@Schema(description = "计算任务Id,job new 生成")
@TableField("jobId")
private String jobId;
@Schema(description = "计算任务添加时Id,job add 生成")
@TableField("jobDetailId")
private String jobDetailId;
@Schema(description = "任务执行输出的文件在Hpc的绝对路径共享目录+jobName文件回传)+uuid下面可能有多个文件")
@TableField("stdoutHpcFilePath")
private String stdoutHpcFilePath;
@Schema(description = "记录在minio上任务执行输出的文件在Hpc的绝对路径baseDir+jobName文件回传)+uuid文件回传),下面可能有多个文件")
@TableField("stdoutSpdmFilePath")
private String stdoutSpdmFilePath;
@Schema(description = "节点名称")
@TableField("nodeName")
private String nodeName;
@Schema(description = "记录最终执行的执行对应工具命令")
@TableField("executCommand")
private String executCommand;
@Schema(description = "任务开始时间")
@TableField("startTime")
private String startTime;
@Schema(description = "任务结束时间")
@TableField("endTime")
private String endTime;
@Schema(description = "任务状态spdm,+hpc返回的其他状态定时任务维护")
@TableField("jobStatus")
private String jobStatus;
@Schema(description = "求解器名称")
@TableField("solverName")
private String solverName;
@Schema(description = "总内核态时间(单位:毫秒)")
@TableField("totalKernelTime")
private Long totalKernelTime;
@Schema(description = "总用户态时间(单位:毫秒)")
@TableField("totalUserTime")
private Long totalUserTime;
@Schema(description = "作业耗费总秒数(单位:秒)")
@TableField("totalElapsedTime")
private Long totalElapsedTime;
@Schema(description = "配置提交前端生成不带横线的uuid")
@TableField("uuid")
private String uuid;
@Schema(description = "任务结果回传状态generating,uploading,finished")
@TableField("fileStatus")
private String fileStatus;
@Schema(description = "创建者ID")
@TableField("creatorId")
private Long creatorId;
@Schema(description = "创建时间")
@TableField(value = "createTime", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@Schema(description = "更新者ID")
@TableField("updaterId")
private Long updaterId;
@Schema(description = "修改时间")
@TableField(value = "updateTime", fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
}

View File

@@ -0,0 +1,13 @@
package com.sdm.pbs.model.req;
import com.sdm.common.entity.req.data.BaseReq;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class QueryJobReq extends BaseReq {
@Schema(description = "计算任务名称")
private String jobName;
}

View File

@@ -20,8 +20,8 @@ public class SubmitHpcTaskReq {
@Schema(description = "计算任务类型")
public String jobType;
@Schema(description = "计算任务是否独立存在 0:非独立任务 1:独立任务")
public int independence;
@Schema(description = "计算任务是否独立存在 false:非独立任务 true:独立任务")
public boolean independence;
@Schema(description = "求解文件")
public List<String> inputFiles = new ArrayList<>();
@@ -47,4 +47,9 @@ public class SubmitHpcTaskReq {
@Schema(description = "任务所属项目")
public String projectname;
@Schema(description = "软件的id")
public Long softwareId;
}

View File

@@ -5,7 +5,6 @@ import com.sdm.common.entity.resp.pbs.hpc.FileNodeInfo;
import com.sdm.pbs.model.bo.HpcJobStatusInfo;
import com.sdm.pbs.model.bo.HpcResouceInfo;
import com.sdm.pbs.model.req.SubmitHpcTaskReq;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.http.ResponseEntity;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
@@ -56,4 +55,6 @@ public interface IPbsService {
*/
ResponseEntity<StreamingResponseBody> downloadFile(String jobId, String fileName,Long fileSize);
}

View File

@@ -0,0 +1,7 @@
package com.sdm.pbs.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sdm.pbs.model.entity.SimulationJob;
public interface ISimulationJobService extends IService<SimulationJob> {
}

View File

@@ -1,12 +1,21 @@
package com.sdm.pbs.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.entity.resp.PageDataResp;
import com.sdm.common.entity.resp.pbs.hpc.FileNodeInfo;
import com.sdm.common.utils.PageUtils;
import com.sdm.pbs.model.bo.HpcJobStatusInfo;
import com.sdm.pbs.model.bo.HpcResouceInfo;
import com.sdm.pbs.model.entity.SimulationJob;
import com.sdm.pbs.model.req.QueryJobReq;
import com.sdm.pbs.model.req.SubmitHpcTaskReq;
import com.sdm.pbs.service.IPbsService;
import com.sdm.pbs.service.IPbsServiceDecorator;
import com.sdm.pbs.service.ISimulationJobService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -15,6 +24,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
import java.time.LocalDateTime;
import java.util.List;
@Service
@@ -34,6 +44,8 @@ public class PbsServiceDecorator implements IPbsServiceDecorator {
this.pbsService = pbsService;
}
@Autowired
private ISimulationJobService simulationJobService;
@Override
public SdmResponse<HpcResouceInfo> queryHpcResource() {
@@ -42,8 +54,66 @@ public class PbsServiceDecorator implements IPbsServiceDecorator {
@Override
public SdmResponse<String> submitHpcJob(SubmitHpcTaskReq req) {
SdmResponse<String> response = pbsService.submitHpcJob(req);
return response;
// SdmResponse<String> response = pbsService.submitHpcJob(req);
// if(response.isSuccess()&&StringUtils.isNotEmpty(response.getData())) {
String jobId = "8848";
if(StringUtils.isNotEmpty(jobId)) {
// 数据入库
SimulationJob simulationJob = new SimulationJob();
// 基础字段
// simulationJob.setId(1L);
simulationJob.setJobName(req.getJobName());
simulationJob.setCoreNum(req.getCoreNum());
simulationJob.setSoftware(req.getSoftware());
simulationJob.setJobType(req.getJobType());
simulationJob.setIndependence(req.isIndependence());
simulationJob.setInputFiles(JSONObject.toJSONString(req.getInputFiles()));
simulationJob.setMasterFile(req.getMasterFile());
simulationJob.setTaskId(req.getTaskId());
simulationJob.setTaskName(req.getTaskName());
simulationJob.setRunId(req.getRunId());
simulationJob.setRunName(req.getRunName());
// 软件及文件关联
simulationJob.setSoftwareId(req.getSoftwareId());
// 下面的待定 todo
simulationJob.setInputFileId(1l);
simulationJob.setJobId(jobId);
// 没必要要
simulationJob.setJobDetailId("todo");
// 文件路径 todo 共享目录+jobName文件回传)+uuid下面可能有多个文件
simulationJob.setStdoutHpcFilePath("/hpc/shared/job001/uuid-123");
simulationJob.setStdoutSpdmFilePath("/minio/base/job001/uuid-123");
// todo 执行信息 定时任务回传的时候修改
simulationJob.setNodeName("todo");
simulationJob.setExecutCommand("ansys -b -input input.dat -output output.log");
// todo 执行信息 定时任务回传的时候修改
simulationJob.setStartTime("2025-11-30 10:00:00");
simulationJob.setEndTime("2025-11-30 12:30:00");
simulationJob.setJobStatus("Configuring");
// ? todo 没比要
simulationJob.setSolverName("LS-DYNA");
// todo 执行信息 定时任务回传的时候修改
simulationJob.setTotalKernelTime(3600000L);
simulationJob.setTotalUserTime(7200000L);
simulationJob.setTotalElapsedTime(9000L);
// 标识及状态
simulationJob.setUuid("f81d4fae7dec11d0a76500a0c91e6bf6");
simulationJob.setFileStatus("generating");
// 审计字段
simulationJob.setCreatorId(10086L);
simulationJob.setCreateTime(LocalDateTime.now());
simulationJob.setUpdaterId(10086L);
simulationJob.setUpdateTime(LocalDateTime.now());
boolean save = simulationJobService.save(simulationJob);
System.out.println(save);
}
return SdmResponse.success(jobId);
}
@Override
@@ -74,5 +144,16 @@ public class PbsServiceDecorator implements IPbsServiceDecorator {
return pbsService.downloadFile("", fileName,fileSize);
}
public SdmResponse<PageDataResp<List<SimulationJob>>> queryJobs(QueryJobReq req){
PageHelper.startPage(req.getCurrent(), req.getSize());
// 构建查询条件
LambdaQueryChainWrapper<SimulationJob> queryChain = simulationJobService.lambdaQuery();
if (req.getJobName() != null && !req.getJobName().trim().isEmpty()) {
queryChain.eq(SimulationJob::getJobName, req.getJobName().trim());
}
List<SimulationJob> results = queryChain.list();
PageInfo<SimulationJob> page = new PageInfo<>(results);
return PageUtils.getJsonObjectSdmResponse(results, page);
}
}

View File

@@ -0,0 +1,11 @@
package com.sdm.pbs.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sdm.pbs.dao.SimulationJobMapper;
import com.sdm.pbs.model.entity.SimulationJob;
import com.sdm.pbs.service.ISimulationJobService;
import org.springframework.stereotype.Service;
@Service
public class SimulationJobServiceImpl extends ServiceImpl<SimulationJobMapper, SimulationJob> implements ISimulationJobService {
}