Merge remote-tracking branch 'origin/main'

This commit is contained in:
2025-11-18 11:42:36 +08:00
5 changed files with 96 additions and 4 deletions

View File

@@ -0,0 +1,8 @@
package com.sdm.common.entity.resp.pbs.hpc;
import lombok.Data;
@Data
public class CloneJobResp {
private String jobId;
}

View File

@@ -0,0 +1,12 @@
package com.sdm.common.entity.resp.pbs.hpc;
import lombok.Data;
@Data
public class JobRequeueResp {
private Boolean requeued;
private String jobId;
}

View File

@@ -522,4 +522,39 @@ public class HpcCommandResulParseUtil {
} }
public static CloneJobResp parseJobCloneResult(String cmdOutput) {
CloneJobResp cloneJobResp = new CloneJobResp();
try {
// 按逗号分割,然后按冒号分割
String[] parts = cmdOutput.split(",");
for (String part : parts) {
if (part.trim().startsWith("ID:")) {
String idStr = part.split(":")[1].trim();
cloneJobResp.setJobId(idStr);
return cloneJobResp;
}
}
} catch (Exception e) {
CoreLogger.error("parseJobCloneResult error:{}",cmdOutput);
}
return cloneJobResp;
}
public static JobRequeueResp parseJobRequeue(String cmdOutput) {
JobRequeueResp jobRequeueResp = new JobRequeueResp();
if (StringUtils.isBlank(cmdOutput)) return jobRequeueResp;
String line = cmdOutput.trim();
// 正常返回格式Requeue job #6
Pattern p = Pattern.compile("Requeue job #?(\\d+)", Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(line);
if (m.find()) {
jobRequeueResp.setRequeued(true);
String requeuedJobId = m.group(1);
jobRequeueResp.setJobId(requeuedJobId);
return jobRequeueResp;
}
jobRequeueResp.setRequeued(false);
return jobRequeueResp;
}
} }

View File

@@ -9,6 +9,7 @@ import com.sdm.common.utils.HpcCommandExcuteUtil;
import com.sdm.common.utils.HpcCommandResulParseUtil; import com.sdm.common.utils.HpcCommandResulParseUtil;
import com.sdm.pbs.service.TaskService; import com.sdm.pbs.service.TaskService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@@ -17,6 +18,7 @@ import org.springframework.stereotype.Service;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
@Slf4j @Slf4j
@Service @Service
@@ -80,6 +82,10 @@ public class TaskServiceImpl implements TaskService {
NewJobResp newJobResp = HpcCommandResulParseUtil.parseJobNewResult(result); NewJobResp newJobResp = HpcCommandResulParseUtil.parseJobNewResult(result);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("hpcCommand", newJobCommand); map.put("hpcCommand", newJobCommand);
if(Objects.isNull(newJobResp)|| StringUtils.isBlank(newJobResp.getJobId())){
map.put("errMsg", result);
return SdmResponse.failed(map);
}
map.put("result", newJobResp); map.put("result", newJobResp);
return SdmResponse.success(map); return SdmResponse.success(map);
} }
@@ -94,6 +100,10 @@ public class TaskServiceImpl implements TaskService {
AddJobResp addJobResp = HpcCommandResulParseUtil.parseJoAddResult(result); AddJobResp addJobResp = HpcCommandResulParseUtil.parseJoAddResult(result);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("hpcCommand", addJobCommand); map.put("hpcCommand", addJobCommand);
if(Objects.isNull(addJobResp)||StringUtils.isBlank(addJobResp.getTsakId())){
map.put("errMsg", result);
return SdmResponse.failed(map);
}
map.put("result", addJobResp); map.put("result", addJobResp);
return SdmResponse.success(map); return SdmResponse.success(map);
} }
@@ -109,6 +119,10 @@ public class TaskServiceImpl implements TaskService {
submitHpcJobResp.setJobId(req.getId()); submitHpcJobResp.setJobId(req.getId());
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("hpcCommand", submitJobCommand); map.put("hpcCommand", submitJobCommand);
if(Objects.isNull(submitHpcJobResp)||Objects.equals(false,submitHpcJobResp.getSubmit())){
map.put("errMsg", result);
return SdmResponse.failed(map);
}
map.put("result", submitHpcJobResp); map.put("result", submitHpcJobResp);
return SdmResponse.success(map); return SdmResponse.success(map);
} }
@@ -123,6 +137,10 @@ public class TaskServiceImpl implements TaskService {
JobCancelResp jobCancelResp = HpcCommandResulParseUtil.parseJobCancel(result); JobCancelResp jobCancelResp = HpcCommandResulParseUtil.parseJobCancel(result);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("hpcCommand", cancelJobCommand); map.put("hpcCommand", cancelJobCommand);
if(Objects.isNull(jobCancelResp)||Objects.equals(false,jobCancelResp.getCanceled())){
map.put("errMsg", result);
return SdmResponse.failed(map);
}
map.put("result", jobCancelResp); map.put("result", jobCancelResp);
return SdmResponse.success(map); return SdmResponse.success(map);
} }
@@ -134,9 +152,14 @@ public class TaskServiceImpl implements TaskService {
BeanUtils.copyProperties(req, cloneJobParam); BeanUtils.copyProperties(req, cloneJobParam);
String cloneJobCommand = HpcCommandBuilderUtil.buildHpcCommandStr(prefixStr, cloneJobParam, ""); String cloneJobCommand = HpcCommandBuilderUtil.buildHpcCommandStr(prefixStr, cloneJobParam, "");
String result = hpcCommandExcuteUtil.excuteCmd(cloneJobCommand,hpcExcuteWay); String result = hpcCommandExcuteUtil.excuteCmd(cloneJobCommand,hpcExcuteWay);
Map<String, String> map = new HashMap<>(); CloneJobResp cloneJobResp = HpcCommandResulParseUtil.parseJobCloneResult(result);
Map<String, Object> map = new HashMap<>();
map.put("hpcCommand", cloneJobCommand); map.put("hpcCommand", cloneJobCommand);
map.put("result", result); if(Objects.isNull(cloneJobResp)||StringUtils.isBlank(cloneJobResp.getJobId())){
map.put("errMsg", result);
return SdmResponse.failed(map);
}
map.put("result", cloneJobResp);
return SdmResponse.success(map); return SdmResponse.success(map);
} }
@@ -150,6 +173,10 @@ public class TaskServiceImpl implements TaskService {
JobFinishResp jobFinishResp = HpcCommandResulParseUtil.parseJobFinish(result); JobFinishResp jobFinishResp = HpcCommandResulParseUtil.parseJobFinish(result);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("hpcCommand", finishJobCommand); map.put("hpcCommand", finishJobCommand);
if(Objects.isNull(jobFinishResp)||Objects.equals(false,jobFinishResp.getFinished())){
map.put("errMsg", result);
return SdmResponse.failed(map);
}
map.put("result", jobFinishResp); map.put("result", jobFinishResp);
return SdmResponse.success(map); return SdmResponse.success(map);
} }
@@ -192,6 +219,10 @@ public class TaskServiceImpl implements TaskService {
JobModifyResp jobModifyResp = HpcCommandResulParseUtil.parseJobModify(result); JobModifyResp jobModifyResp = HpcCommandResulParseUtil.parseJobModify(result);
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("hpcCommand", modifyJobCommand); map.put("hpcCommand", modifyJobCommand);
if(Objects.isNull(jobModifyResp)||Objects.equals(false,jobModifyResp.getModified())){
map.put("errMsg", result);
return SdmResponse.failed(map);
}
map.put("result", jobModifyResp); map.put("result", jobModifyResp);
return SdmResponse.success(map); return SdmResponse.success(map);
} }
@@ -203,9 +234,14 @@ public class TaskServiceImpl implements TaskService {
BeanUtils.copyProperties(req, jobRequeueParam); BeanUtils.copyProperties(req, jobRequeueParam);
String requeueJobCommand = HpcCommandBuilderUtil.buildHpcCommandStr(prefixStr, jobRequeueParam, ""); String requeueJobCommand = HpcCommandBuilderUtil.buildHpcCommandStr(prefixStr, jobRequeueParam, "");
String result = hpcCommandExcuteUtil.excuteCmd(requeueJobCommand,hpcExcuteWay); String result = hpcCommandExcuteUtil.excuteCmd(requeueJobCommand,hpcExcuteWay);
Map<String, String> map = new HashMap<>(); JobRequeueResp jobRequeueResp = HpcCommandResulParseUtil.parseJobRequeue(result);
Map<String, Object> map = new HashMap<>();
map.put("hpcCommand", requeueJobCommand); map.put("hpcCommand", requeueJobCommand);
map.put("result", result); if(Objects.isNull(jobRequeueResp)||Objects.equals(false,jobRequeueResp.getRequeued())){
map.put("errMsg", result);
return SdmResponse.failed(map);
}
map.put("result", jobRequeueResp);
return SdmResponse.success(map); return SdmResponse.success(map);
} }

View File

@@ -1329,6 +1329,7 @@ public class ProjectServiceImpl extends BaseService implements IProjectService {
currentTopNodeType = taskNode.getNodeType(); currentTopNodeType = taskNode.getNodeType();
traverseTaskNode(taskNode.getPid(), tenantId, VersionEnum.INITIAL.getCode(), taskNode, projectNodeList, projectNodeMemberList, projectNodeExtraList, taskNodeList, taskNodeMemberList, taskNodeExtraList, projectNodePerformanceList, projectNodePerformanceExtraList, tagList,idMap,taskIdMap); traverseTaskNode(taskNode.getPid(), tenantId, VersionEnum.INITIAL.getCode(), taskNode, projectNodeList, projectNodeMemberList, projectNodeExtraList, taskNodeList, taskNodeMemberList, taskNodeExtraList, projectNodePerformanceList, projectNodePerformanceExtraList, tagList,idMap,taskIdMap);
taskIdMap.clear(); taskIdMap.clear();
idMap.clear();
} }
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String createTime = format.format(new Date()); String createTime = format.format(new Date());