修改:hpc任务入表字段优化

This commit is contained in:
yangyang01000846
2025-12-31 09:31:55 +08:00
parent 9fb1fab8b3
commit 3f7ee0eed1
3 changed files with 42 additions and 21 deletions

View File

@@ -2,6 +2,8 @@ package com.sdm.flowable.delegate.handler;
import com.alibaba.fastjson2.JSONObject;
import com.sdm.common.common.SdmResponse;
import com.sdm.common.common.ThreadLocalContext;
import com.sdm.common.config.FlowableConfig;
import com.sdm.common.entity.flowable.executeConfig.HPCExecuteConfig;
import com.sdm.common.entity.req.data.GetFileBaseInfoReq;
import com.sdm.common.entity.req.pbs.SubmitHpcTaskRemoteReq;
@@ -9,7 +11,6 @@ import com.sdm.common.entity.resp.data.FileMetadataInfoResp;
import com.sdm.common.feign.inter.data.IDataFeignClient;
import com.sdm.common.feign.inter.pbs.ITaskFeignClient;
import com.sdm.common.log.CoreLogger;
import com.sdm.common.config.FlowableConfig;
import com.sdm.flowable.entity.ProcessNodeParam;
import com.sdm.flowable.enums.AsyncTaskStatusEnum;
import com.sdm.flowable.service.IAsyncTaskRecordService;
@@ -55,7 +56,8 @@ public class HpcHandler implements ExecutionHandler<Map<String, Object>,HPCExecu
String masterFileRegularStr = config.getMasterFileRegularStr();
String inputFilesRegularStr = config.getInputFilesRegularStr();
CoreLogger.info("beforeNodeId:{},currentNodeId:{},masterFileRegularStr:{},inputFilesRegularStr:{}",beforeNodeId,currentNodeId,masterFileRegularStr,inputFilesRegularStr);
// 初始化用户/租户信息
initUserInfo(execution);
// params 取只是测试使用
String processDefinitionId = (execution==null||StringUtils.isBlank(execution.getProcessDefinitionId()))?
params.get("processDefinitionId").toString():execution.getProcessDefinitionId();
@@ -98,6 +100,17 @@ public class HpcHandler implements ExecutionHandler<Map<String, Object>,HPCExecu
log.info("HPC 任务 {} 已提交", "hpcTaskId");
}
private void initUserInfo(DelegateExecution execution) {
// 获取当前流程实例参数
Long userId = (Long) execution.getVariable("userId");
String userName = (String) execution.getVariable("userName");
Long tenantId = (Long) execution.getVariable("tenantId");
ThreadLocalContext.setUserId(userId);
ThreadLocalContext.setUserName(userName);
ThreadLocalContext.setTenantId(tenantId);
CoreLogger.info("hpcHander initUserInfo userId:{},tenantId:{},userName:{}",userId,tenantId,userName);
}
private void dealHpcFile(SubmitHpcTaskRemoteReq submitHpcTaskRemoteReq, String beforeNodeId, String currentNodeId,
String processDefinitionId, String processInstanceId, String executeMode,Map<String, Object> params) {
String simulationBaseDir = FlowableConfig.FLOWABLE_SIMULATION_BASEDIR;

View File

@@ -151,6 +151,10 @@ public class SimulationJob implements Serializable {
@TableField("creatorId")
private Long creatorId;
@Schema(description = "租户id")
@TableField("tenantId")
private Long tenantId;
@Schema(description = "创建时间")
@TableField(value = "createTime", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

View File

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapp
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.req.flowable.AsyncCallbackRequest;
import com.sdm.common.entity.resp.PageDataResp;
import com.sdm.common.entity.resp.pbs.hpc.FileNodeInfo;
@@ -101,6 +102,7 @@ public class PbsServiceDecorator implements IPbsServiceDecorator {
if(StringUtils.isBlank(command)) {
return SdmResponse.failed("command命令不能为空软件名称:"+req.getSoftware());
}
// 处理 拼接命令 \\CARSAFE\share\solver\RLithium\reta.exe -i %s
String formatCommand = String.format(command, masterFilePath);
req.setCommand(formatCommand);
req.setMasterFilePath(masterFilePath);
@@ -120,7 +122,7 @@ public class PbsServiceDecorator implements IPbsServiceDecorator {
simulationJob.setJobType(req.getJobType());
simulationJob.setIndependence(req.isIndependence());
// simulationJob.setInputFiles(JSONObject.toJSONString(req.getInputFiles()));
// 主文件位置 todo
// 主文件位置
simulationJob.setMasterFile(req.getMasterFilePath());
// 求解文件集合
simulationJob.setInputFiles(JSONObject.toJSONString(req.getInputFilePaths()));
@@ -130,37 +132,39 @@ public class PbsServiceDecorator implements IPbsServiceDecorator {
simulationJob.setRunName(req.getRunName());
// 软件及文件关联
simulationJob.setSoftwareId(req.getSoftwareId());
// 下面的待定 todo
simulationJob.setInputFileId(1l);
// 下面的待定
// simulationJob.setInputFileId(null);
simulationJob.setJobId(jobId);
// 没必要要
simulationJob.setJobDetailId("todo");
// 文件路径 todo 共享目录+jobName文件回传)+uuid下面可能有多个文件
// simulationJob.setJobDetailId("");
// 文件路径 共享目录+jobName文件回传)+uuid下面可能有多个文件
simulationJob.setStdoutHpcFilePath(hpcOutPutDir);
simulationJob.setStdoutSpdmMinoFilePath(req.getStdoutSpdmMinoFilePath());
simulationJob.setStdoutSpdmNasFilePath(req.getStdoutSpdmNasFilePath());
// 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.setNodeName("");
simulationJob.setExecutCommand(command);
// 执行信息 定时任务回传的时候修改
// 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.setSolverName(req.getSoftware());
// 执行信息 定时任务回传的时候修改
simulationJob.setTotalKernelTime(null);
simulationJob.setTotalUserTime(null);
simulationJob.setTotalElapsedTime(null);
// 标识及状态
simulationJob.setUuid("f81d4fae7dec11d0a76500a0c91e6bf6");
// simulationJob.setUuid(null);
simulationJob.setFileStatus("generating");
// 审计字段
simulationJob.setCreatorId(10086L);
Long userId = ThreadLocalContext.getUserId();
Long tenantId = ThreadLocalContext.getTenantId();
CoreLogger.info("submitHpcJob save db userId:{},tenantId:{}",userId,tenantId);
simulationJob.setCreatorId(userId);
simulationJob.setTenantId(tenantId);
simulationJob.setCreateTime(LocalDateTime.now());
simulationJob.setUpdaterId(10086L);
simulationJob.setUpdaterId(userId);
simulationJob.setUpdateTime(LocalDateTime.now());
simulationJobService.save(simulationJob);
}