修改:hpc任务自定义排序
This commit is contained in:
@@ -143,7 +143,7 @@ public class SimulationJob implements Serializable {
|
||||
@TableField("uuid")
|
||||
private String uuid;
|
||||
|
||||
@Schema(description = "任务结果回传状态,generating,uploading,finished")
|
||||
@Schema(description = "任务结果回传状态,generating,uploading,finished,failed")
|
||||
@TableField("fileStatus")
|
||||
private String fileStatus;
|
||||
|
||||
@@ -174,6 +174,7 @@ public class SimulationJob implements Serializable {
|
||||
private Long dirId;
|
||||
|
||||
@Schema(description = "任务耗时,前端展示字段")
|
||||
@TableField(value = "costTime",exist = false)
|
||||
private String costTime;
|
||||
|
||||
}
|
||||
@@ -67,6 +67,9 @@ public class PbsServiceDecorator implements IPbsServiceDecorator {
|
||||
@Autowired
|
||||
private IFlowableFeignClient flowableFeignClient;
|
||||
|
||||
@Value("#{'${hpc.jobs.ascOrders:Queued,Running,Failed,Canceled,Finished }'.split(',')}")
|
||||
private List<String> ascOrders;
|
||||
|
||||
// 正则匹配%后的单词(\w+ 匹配字母、数字、下划线)
|
||||
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("%(\\w+)");
|
||||
|
||||
@@ -570,6 +573,12 @@ public class PbsServiceDecorator implements IPbsServiceDecorator {
|
||||
if (req.getRunId() != null && !req.getRunId().trim().isEmpty()) {
|
||||
// like,实现 包含关键词 的模糊查询(%关键词%)
|
||||
queryChain.like(SimulationJob::getRunId, req.getRunId().trim());
|
||||
}
|
||||
// 排序
|
||||
if (CollectionUtils.isNotEmpty(ascOrders)) {
|
||||
String statusValues = String.join("','", ascOrders);
|
||||
String orderBySql = String.format("ORDER BY FIELD(jobStatus, '%s') ASC, createTime DESC", statusValues);
|
||||
queryChain.getWrapper().last(orderBySql);
|
||||
}
|
||||
List<SimulationJob> results = queryChain.list();
|
||||
// 时间转换
|
||||
|
||||
Reference in New Issue
Block a user