byteblogs168 2024-03-01 17:40:47 +08:00
parent 86ae31421e
commit 0b39d54bdc
16 changed files with 38 additions and 60 deletions

View File

@ -52,6 +52,10 @@
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -12,7 +12,7 @@ import javax.validation.constraints.NotNull;
@Data
public class DispatchJobRequest {
@NotNull(message = "namespaceId 不能为空")
@NotBlank(message = "namespaceId 不能为空")
private String namespaceId;
@NotNull(message = "jobId 不能为空")
@ -30,7 +30,7 @@ public class DispatchJobRequest {
@NotBlank(message = "group 不能为空")
private String groupName;
@NotBlank(message = "parallelNum 不能为空")
@NotNull(message = "parallelNum 不能为空")
private Integer parallelNum;
@NotNull(message = "executorType 不能为空")
@ -39,7 +39,7 @@ public class DispatchJobRequest {
@NotBlank(message = "executorInfo 不能为空")
private String executorInfo;
@NotBlank(message = "executorTimeout 不能为空")
@NotNull(message = "executorTimeout 不能为空")
private Integer executorTimeout;
private String argsStr;

View File

@ -122,4 +122,10 @@ public interface SystemConstants {
* 客户端返回的非json对象单值比如 "aa", 123等
*/
String SINGLE_PARAM = "SINGLE_PARAM";
/**
* 工作流触发类型
* 仅表示定时任务类型为工作流
*/
Integer WORKFLOW_TRIGGER_TYPE = 99;
}

View File

@ -1,30 +0,0 @@
package com.aizuda.easy.retry.server.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 1 CRON表达式 2 固定时间 3 工作流
* @author xiaowoniu
* @date 2024-01-03 22:10:01
* @since 2.6.0
*/
@AllArgsConstructor
@Getter
public enum TriggerTypeEnum {
CRON(1, "CRON表达式"),
FIXED_TIME(2, "固定时间"),
WORKFLOW(3, "工作流");
private final Integer type;
private final String desc;
public static TriggerTypeEnum get(Integer type) {
for (TriggerTypeEnum triggerTypeEnum : TriggerTypeEnum.values()) {
if (triggerTypeEnum.type.equals(type)) {
return triggerTypeEnum;
}
}
return null;
}
}

View File

@ -12,7 +12,6 @@ import com.aizuda.easy.retry.server.common.config.SystemProperties;
import com.aizuda.easy.retry.server.common.dto.PartitionTask;
import com.aizuda.easy.retry.server.common.dto.ScanTask;
import com.aizuda.easy.retry.server.common.enums.JobTaskExecutorSceneEnum;
import com.aizuda.easy.retry.server.common.enums.TriggerTypeEnum;
import com.aizuda.easy.retry.server.common.strategy.WaitStrategies;
import com.aizuda.easy.retry.server.common.util.DateUtils;
import com.aizuda.easy.retry.server.common.util.PartitionTaskUtils;
@ -168,7 +167,7 @@ public class ScanJobTaskActor extends AbstractActor {
Job::getId, Job::getNamespaceId)
.eq(Job::getJobStatus, StatusEnum.YES.getStatus())
.eq(Job::getDeleted, StatusEnum.NO.getStatus())
.ne(Job::getTriggerType, TriggerTypeEnum.WORKFLOW.getType())
.ne(Job::getTriggerType, SystemConstants.WORKFLOW_TRIGGER_TYPE)
.in(Job::getBucketIndex, scanTask.getBuckets())
.le(Job::getNextTriggerAt,
DateUtils.toNowMilli() + DateUtils.toEpochMilli(SystemConstants.SCHEDULE_PERIOD))

View File

@ -35,6 +35,7 @@ public class WorkflowBatchController {
}
@PostMapping("/stop/{id}")
@LoginRequired
public Boolean stop(@PathVariable("id") Long id) {
return workflowBatchService.stop(id);
}

View File

@ -31,7 +31,7 @@ public class WorkflowController {
private final WorkflowService workflowService;
@PostMapping
@LoginRequired(role = RoleEnum.ADMIN)
@LoginRequired(role = RoleEnum.USER)
public Boolean saveWorkflow(@RequestBody @Validated WorkflowRequestVO workflowRequestVO) {
return workflowService.saveWorkflow(workflowRequestVO);
}
@ -43,7 +43,7 @@ public class WorkflowController {
}
@PutMapping
@LoginRequired(role = RoleEnum.ADMIN)
@LoginRequired(role = RoleEnum.USER)
public Boolean updateWorkflow(@RequestBody @Validated WorkflowRequestVO workflowRequestVO) {
return workflowService.updateWorkflow(workflowRequestVO);
}
@ -55,7 +55,7 @@ public class WorkflowController {
}
@PutMapping("/update/status/{id}")
@LoginRequired(role = RoleEnum.ADMIN)
@LoginRequired(role = RoleEnum.USER)
public Boolean updateStatus(@PathVariable("id") Long id) {
return workflowService.updateStatus(id);
}
@ -81,7 +81,7 @@ public class WorkflowController {
}
@PostMapping("/check-node-expression")
@LoginRequired(role = RoleEnum.ADMIN)
@LoginRequired(role = RoleEnum.USER)
public Pair<Integer, String> checkNodeExpression(@RequestBody DecisionConfig decisionConfig) {
return workflowService.checkNodeExpression(decisionConfig);
}

View File

@ -43,7 +43,6 @@ public class JobRequestVO {
/**
* 参数类型 text/json
*/
// @NotNull(message = "argsType 不能为空")
private Integer argsType;
/**

View File

@ -3,11 +3,11 @@ package com.aizuda.easy.retry.server.web.service.impl;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.HashUtil;
import cn.hutool.core.util.StrUtil;
import com.aizuda.easy.retry.common.core.constant.SystemConstants;
import com.aizuda.easy.retry.common.core.enums.StatusEnum;
import com.aizuda.easy.retry.server.common.WaitStrategy;
import com.aizuda.easy.retry.server.common.config.SystemProperties;
import com.aizuda.easy.retry.server.common.enums.JobTaskExecutorSceneEnum;
import com.aizuda.easy.retry.server.common.enums.TriggerTypeEnum;
import com.aizuda.easy.retry.server.common.exception.EasyRetryServerException;
import com.aizuda.easy.retry.server.common.strategy.WaitStrategies;
import com.aizuda.easy.retry.server.common.util.CronUtils;
@ -151,7 +151,7 @@ public class JobServiceImpl implements JobService {
updateJob.setNamespaceId(job.getNamespaceId());
// 工作流任务
if (Objects.equals(jobRequestVO.getTriggerType(), TriggerTypeEnum.WORKFLOW.getType())) {
if (Objects.equals(jobRequestVO.getTriggerType(), SystemConstants.WORKFLOW_TRIGGER_TYPE)) {
job.setNextTriggerAt(0L);
// 非常驻任务 > 非常驻任务
} else if (Objects.equals(job.getResident(), StatusEnum.NO.getStatus()) && Objects.equals(
@ -174,7 +174,7 @@ public class JobServiceImpl implements JobService {
}
private static Long calculateNextTriggerAt(final JobRequestVO jobRequestVO, Long time) {
if (Objects.equals(jobRequestVO.getTriggerType(), TriggerTypeEnum.WORKFLOW.getType())) {
if (Objects.equals(jobRequestVO.getTriggerType(), SystemConstants.WORKFLOW_TRIGGER_TYPE)) {
return 0L;
}
@ -189,7 +189,7 @@ public class JobServiceImpl implements JobService {
public Job updateJobResident(JobRequestVO jobRequestVO) {
Job job = JobConverter.INSTANCE.toJob(jobRequestVO);
job.setResident(StatusEnum.NO.getStatus());
if (Objects.equals(jobRequestVO.getTriggerType(), TriggerTypeEnum.WORKFLOW.getType())) {
if (Objects.equals(jobRequestVO.getTriggerType(), SystemConstants.WORKFLOW_TRIGGER_TYPE)) {
return job;
}

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Easy Retry</title>
<script type="module" crossorigin src="./assets/fjGXFx1T.js"></script>
<script type="module" crossorigin src="./assets/te7nzc9K.js"></script>
<link rel="stylesheet" crossorigin href="./assets/RihNDpOw.css">
</head>

View File

@ -24,15 +24,15 @@ const enums = {
}
},
triggerType: {
'1': {
'name': 'CRON表达式',
'color': '#d06892'
},
'2': {
'name': '固定时间',
'color': '#f5a22d'
},
'3': {
'name': 'CRON表达式',
'color': '#d06892'
},
'99': {
'name': '工作流',
'color': '#76f52d'
}

View File

@ -37,7 +37,7 @@
:data="loadData"
:alert="options.alert"
:rowSelection="options.rowSelection"
:scroll="{ x: 1800 }"
:scroll="{ x: 2000 }"
>
<span slot="groupName" slot-scope="text, record">
<a href="#" @click="handlerOpenDrawer(record)">{{ text }}</a>

View File

@ -129,13 +129,12 @@
>
<a href="javascript:;" v-if="record.workflowStatus === 0">删除</a>
</a-popconfirm>
<a-divider type="vertical" v-if="record.workflowStatus === 0"/>
<a-divider type="vertical" v-if="record.workflowStatus === 0 && $auth('job.del')"/>
<a-popconfirm
title="是否复制此工作流?"
ok-text="复制"
cancel-text="取消"
@confirm="handleCopy(record)"
v-if="$auth('job.del')"
>
<a href="javascript:;">复制</a>
</a-popconfirm>

View File

@ -113,7 +113,7 @@
]" />
<a-input
v-if="triggerTypeValue === '1'"
v-if="triggerTypeValue === '3'"
@click="handlerCron"
placeholder="请输入间隔时长"
v-decorator="[
@ -122,7 +122,7 @@
]" />
<a-input
v-if="triggerTypeValue === '3'"
v-if="triggerTypeValue === '99'"
disabled
placeholder=""
v-decorator="[
@ -406,7 +406,7 @@ export default {
},
handlerCron () {
const triggerType = this.form.getFieldValue('triggerType')
if (triggerType === '1') {
if (triggerType === '3') {
let triggerInterval = this.form.getFieldValue('triggerInterval')
if (triggerInterval === null || triggerInterval === '') {
triggerInterval = '* * * * * ?'
@ -477,7 +477,7 @@ export default {
values['argsStr'] = JSON.stringify(this.argsStrValue)
}
if (this.triggerTypeValue === '3') {
if (this.triggerTypeValue === '99') {
values['triggerInterval'] = '0'
}
@ -515,7 +515,7 @@ export default {
this.triggerTypeValue = formData.triggerType
this.taskTypeValue = formData.taskType
if (this.triggerTypeValue === '3') {
if (this.triggerTypeValue === '99') {
formData.triggerInterval = null
}

View File

@ -21,7 +21,7 @@
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<revision>2.6.0</revision>
<revision>2.6.1-SNAPSHOT</revision>
<dingding-talk.version>1.0.0</dingding-talk.version>
<netty-all.version>4.1.94.Final</netty-all.version>
<hutool-all.version>5.8.19</hutool-all.version>