fix(测试计划): 更改测试计划批量开关定时任务的接口
This commit is contained in:
parent
696bd0d88a
commit
851d60c8c6
|
@ -20,9 +20,6 @@ public class TestPlanBatchEditRequest extends TestPlanBatchProcessRequest {
|
||||||
@Schema(description = "标签")
|
@Schema(description = "标签")
|
||||||
private List<String> tags;
|
private List<String> tags;
|
||||||
|
|
||||||
@Schema(description = "定时任务是否开启")
|
@Schema(description = "本次编辑的字段", allowableValues = {"TAGS"})
|
||||||
private boolean scheduleOpen;
|
|
||||||
|
|
||||||
@Schema(description = "本次编辑的字段", allowableValues = {"TAGS", "SCHEDULE"})
|
|
||||||
private String editColumn;
|
private String editColumn;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package io.metersphere.plan.dto.request;
|
package io.metersphere.plan.dto.request;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ -15,7 +14,6 @@ public class TestPlanScheduleBatchConfigRequest extends TestPlanBatchProcessRequ
|
||||||
private boolean enable;
|
private boolean enable;
|
||||||
|
|
||||||
@Schema(description = "Cron表达式")
|
@Schema(description = "Cron表达式")
|
||||||
@NotBlank
|
|
||||||
@Size(max = 255, message = "{length.too.large}")
|
@Size(max = 255, message = "{length.too.large}")
|
||||||
private String cron;
|
private String cron;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import io.metersphere.system.dto.request.schedule.BaseScheduleConfigRequest;
|
||||||
import io.metersphere.system.schedule.ScheduleService;
|
import io.metersphere.system.schedule.ScheduleService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.collections4.MapUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -37,9 +38,14 @@ public class TestPlanScheduleService {
|
||||||
List<String> ids = request.getSelectIds();
|
List<String> ids = request.getSelectIds();
|
||||||
if (CollectionUtils.isNotEmpty(ids)) {
|
if (CollectionUtils.isNotEmpty(ids)) {
|
||||||
TestPlanExample example = new TestPlanExample();
|
TestPlanExample example = new TestPlanExample();
|
||||||
example.createCriteria().andIdIn(ids).andGroupIdIsNotNull();
|
example.createCriteria().andIdIn(ids);
|
||||||
List<TestPlan> testPlanList = testPlanMapper.selectByExample(example);
|
List<TestPlan> testPlanList = testPlanMapper.selectByExample(example);
|
||||||
for (TestPlan testPlan : testPlanList) {
|
for (TestPlan testPlan : testPlanList) {
|
||||||
|
if (MapUtils.isEmpty(request.getRunConfig()) && StringUtils.isBlank(request.getCron())) {
|
||||||
|
// 这里仅仅是开启/关闭定时任务
|
||||||
|
scheduleService.updateIfExist(testPlan.getId(), request.isEnable(), TestPlanScheduleJob.getJobKey(testPlan.getId()),
|
||||||
|
TestPlanScheduleJob.getTriggerKey(testPlan.getId()), TestPlanScheduleJob.class, operator);
|
||||||
|
} else {
|
||||||
ScheduleConfig scheduleConfig = ScheduleConfig.builder()
|
ScheduleConfig scheduleConfig = ScheduleConfig.builder()
|
||||||
.resourceId(testPlan.getId())
|
.resourceId(testPlan.getId())
|
||||||
.key(testPlan.getId())
|
.key(testPlan.getId())
|
||||||
|
@ -71,6 +77,7 @@ public class TestPlanScheduleService {
|
||||||
TestPlanScheduleJob.class,
|
TestPlanScheduleJob.class,
|
||||||
operator);
|
operator);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
testPlanLogService.batchScheduleLog(request.getProjectId(), testPlanList, operator);
|
testPlanLogService.batchScheduleLog(request.getProjectId(), testPlanList, operator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -745,23 +745,12 @@ public class TestPlanService extends TestPlanBaseUtilsService {
|
||||||
// 目前计划的批量操作不支持全选所有页
|
// 目前计划的批量操作不支持全选所有页
|
||||||
List<String> ids = request.getSelectIds();
|
List<String> ids = request.getSelectIds();
|
||||||
if (CollectionUtils.isNotEmpty(ids)) {
|
if (CollectionUtils.isNotEmpty(ids)) {
|
||||||
if (StringUtils.equalsIgnoreCase(request.getEditColumn(), "SCHEDULE")) {
|
|
||||||
TestPlanExample example = new TestPlanExample();
|
|
||||||
example.createCriteria().andIdIn(ids).andStatusNotEqualTo(TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED);
|
|
||||||
List<TestPlan> testPlanList = testPlanMapper.selectByExample(example);
|
|
||||||
//批量编辑定时任务
|
|
||||||
for (TestPlan testPlan : testPlanList) {
|
|
||||||
scheduleService.updateIfExist(testPlan.getId(), request.isScheduleOpen(), TestPlanScheduleJob.getJobKey(testPlan.getId()),
|
|
||||||
TestPlanScheduleJob.getTriggerKey(testPlan.getId()), TestPlanScheduleJob.class, userId);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//默认编辑tags
|
//默认编辑tags
|
||||||
User user = userMapper.selectByPrimaryKey(userId);
|
User user = userMapper.selectByPrimaryKey(userId);
|
||||||
handleTags(request, userId, ids);
|
handleTags(request, userId, ids);
|
||||||
testPlanSendNoticeService.batchSendNotice(request.getProjectId(), ids, user, NoticeConstants.Event.UPDATE);
|
testPlanSendNoticeService.batchSendNotice(request.getProjectId(), ids, user, NoticeConstants.Event.UPDATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理标签
|
* 处理标签
|
||||||
|
|
|
@ -1547,6 +1547,17 @@ public class TestPlanTests extends BaseTest {
|
||||||
testPlanTestService.checkSchedule(groupTestPlanId15, batchRequest.isEnable());
|
testPlanTestService.checkSchedule(groupTestPlanId15, batchRequest.isEnable());
|
||||||
batchRequest.setEnable(true);
|
batchRequest.setEnable(true);
|
||||||
this.requestPostWithOk(URL_POST_TEST_PLAN_BATCH_SCHEDULE, batchRequest);
|
this.requestPostWithOk(URL_POST_TEST_PLAN_BATCH_SCHEDULE, batchRequest);
|
||||||
|
|
||||||
|
//测试只是关闭
|
||||||
|
batchRequest = new TestPlanScheduleBatchConfigRequest();
|
||||||
|
batchRequest.setProjectId(project.getId());
|
||||||
|
batchRequest.setEnable(false);
|
||||||
|
batchRequest.setSelectIds(new ArrayList<>(List.of(groupTestPlanId7, groupTestPlanId15)));
|
||||||
|
this.requestPostWithOk(URL_POST_TEST_PLAN_BATCH_SCHEDULE, batchRequest);
|
||||||
|
//测试只是开启
|
||||||
|
batchRequest.setEnable(true);
|
||||||
|
this.requestPostWithOk(URL_POST_TEST_PLAN_BATCH_SCHEDULE, batchRequest);
|
||||||
|
|
||||||
testPlanTestService.checkSchedule(groupTestPlanId7, batchRequest.isEnable());
|
testPlanTestService.checkSchedule(groupTestPlanId7, batchRequest.isEnable());
|
||||||
testPlanTestService.checkSchedule(groupTestPlanId15, batchRequest.isEnable());
|
testPlanTestService.checkSchedule(groupTestPlanId15, batchRequest.isEnable());
|
||||||
//增加日志检查
|
//增加日志检查
|
||||||
|
|
Loading…
Reference in New Issue