refactor(任务中心): 任务中心数据记录补充资源id&计划id

This commit is contained in:
WangXu10 2024-11-12 16:25:49 +08:00 committed by Craftsman
parent c8b08735a5
commit ab848b47a7
19 changed files with 164 additions and 55 deletions

View File

@ -78,13 +78,16 @@ public class ExecTaskItem implements Serializable {
@Size(min = 1, max = 50, message = "{exec_task_item.executor.length_range}", groups = {Created.class, Updated.class})
private String executor;
@Schema(description = "测试集ID")
private String collectionId;
@Schema(description = "删除标识", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "{exec_task_item.deleted.not_blank}", groups = {Created.class})
private Boolean deleted;
@Schema(description = "测试集ID")
private String collectionId;
@Schema(description = "用例表id")
private String caseId;
private static final long serialVersionUID = 1L;
public enum Column {
@ -104,8 +107,9 @@ public class ExecTaskItem implements Serializable {
startTime("start_time", "startTime", "BIGINT", false),
endTime("end_time", "endTime", "BIGINT", false),
executor("executor", "executor", "VARCHAR", false),
deleted("deleted", "deleted", "BIT", false),
collectionId("collection_id", "collectionId", "VARCHAR", false),
deleted("deleted", "deleted", "BIT", false);
caseId("case_id", "caseId", "VARCHAR", false);
private static final String BEGINNING_DELIMITER = "`";

View File

@ -1204,6 +1204,66 @@ public class ExecTaskItemExample {
return (Criteria) this;
}
public Criteria andDeletedIsNull() {
addCriterion("deleted is null");
return (Criteria) this;
}
public Criteria andDeletedIsNotNull() {
addCriterion("deleted is not null");
return (Criteria) this;
}
public Criteria andDeletedEqualTo(Boolean value) {
addCriterion("deleted =", value, "deleted");
return (Criteria) this;
}
public Criteria andDeletedNotEqualTo(Boolean value) {
addCriterion("deleted <>", value, "deleted");
return (Criteria) this;
}
public Criteria andDeletedGreaterThan(Boolean value) {
addCriterion("deleted >", value, "deleted");
return (Criteria) this;
}
public Criteria andDeletedGreaterThanOrEqualTo(Boolean value) {
addCriterion("deleted >=", value, "deleted");
return (Criteria) this;
}
public Criteria andDeletedLessThan(Boolean value) {
addCriterion("deleted <", value, "deleted");
return (Criteria) this;
}
public Criteria andDeletedLessThanOrEqualTo(Boolean value) {
addCriterion("deleted <=", value, "deleted");
return (Criteria) this;
}
public Criteria andDeletedIn(List<Boolean> values) {
addCriterion("deleted in", values, "deleted");
return (Criteria) this;
}
public Criteria andDeletedNotIn(List<Boolean> values) {
addCriterion("deleted not in", values, "deleted");
return (Criteria) this;
}
public Criteria andDeletedBetween(Boolean value1, Boolean value2) {
addCriterion("deleted between", value1, value2, "deleted");
return (Criteria) this;
}
public Criteria andDeletedNotBetween(Boolean value1, Boolean value2) {
addCriterion("deleted not between", value1, value2, "deleted");
return (Criteria) this;
}
public Criteria andCollectionIdIsNull() {
addCriterion("collection_id is null");
return (Criteria) this;
@ -1274,63 +1334,73 @@ public class ExecTaskItemExample {
return (Criteria) this;
}
public Criteria andDeletedIsNull() {
addCriterion("deleted is null");
public Criteria andCaseIdIsNull() {
addCriterion("case_id is null");
return (Criteria) this;
}
public Criteria andDeletedIsNotNull() {
addCriterion("deleted is not null");
public Criteria andCaseIdIsNotNull() {
addCriterion("case_id is not null");
return (Criteria) this;
}
public Criteria andDeletedEqualTo(Boolean value) {
addCriterion("deleted =", value, "deleted");
public Criteria andCaseIdEqualTo(String value) {
addCriterion("case_id =", value, "caseId");
return (Criteria) this;
}
public Criteria andDeletedNotEqualTo(Boolean value) {
addCriterion("deleted <>", value, "deleted");
public Criteria andCaseIdNotEqualTo(String value) {
addCriterion("case_id <>", value, "caseId");
return (Criteria) this;
}
public Criteria andDeletedGreaterThan(Boolean value) {
addCriterion("deleted >", value, "deleted");
public Criteria andCaseIdGreaterThan(String value) {
addCriterion("case_id >", value, "caseId");
return (Criteria) this;
}
public Criteria andDeletedGreaterThanOrEqualTo(Boolean value) {
addCriterion("deleted >=", value, "deleted");
public Criteria andCaseIdGreaterThanOrEqualTo(String value) {
addCriterion("case_id >=", value, "caseId");
return (Criteria) this;
}
public Criteria andDeletedLessThan(Boolean value) {
addCriterion("deleted <", value, "deleted");
public Criteria andCaseIdLessThan(String value) {
addCriterion("case_id <", value, "caseId");
return (Criteria) this;
}
public Criteria andDeletedLessThanOrEqualTo(Boolean value) {
addCriterion("deleted <=", value, "deleted");
public Criteria andCaseIdLessThanOrEqualTo(String value) {
addCriterion("case_id <=", value, "caseId");
return (Criteria) this;
}
public Criteria andDeletedIn(List<Boolean> values) {
addCriterion("deleted in", values, "deleted");
public Criteria andCaseIdLike(String value) {
addCriterion("case_id like", value, "caseId");
return (Criteria) this;
}
public Criteria andDeletedNotIn(List<Boolean> values) {
addCriterion("deleted not in", values, "deleted");
public Criteria andCaseIdNotLike(String value) {
addCriterion("case_id not like", value, "caseId");
return (Criteria) this;
}
public Criteria andDeletedBetween(Boolean value1, Boolean value2) {
addCriterion("deleted between", value1, value2, "deleted");
public Criteria andCaseIdIn(List<String> values) {
addCriterion("case_id in", values, "caseId");
return (Criteria) this;
}
public Criteria andDeletedNotBetween(Boolean value1, Boolean value2) {
addCriterion("deleted not between", value1, value2, "deleted");
public Criteria andCaseIdNotIn(List<String> values) {
addCriterion("case_id not in", values, "caseId");
return (Criteria) this;
}
public Criteria andCaseIdBetween(String value1, String value2) {
addCriterion("case_id between", value1, value2, "caseId");
return (Criteria) this;
}
public Criteria andCaseIdNotBetween(String value1, String value2) {
addCriterion("case_id not between", value1, value2, "caseId");
return (Criteria) this;
}
}

View File

@ -18,8 +18,9 @@
<result column="start_time" jdbcType="BIGINT" property="startTime" />
<result column="end_time" jdbcType="BIGINT" property="endTime" />
<result column="executor" jdbcType="VARCHAR" property="executor" />
<result column="collection_id" jdbcType="VARCHAR" property="collectionId" />
<result column="deleted" jdbcType="BIT" property="deleted" />
<result column="collection_id" jdbcType="VARCHAR" property="collectionId" />
<result column="case_id" jdbcType="VARCHAR" property="caseId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -82,7 +83,7 @@
<sql id="Base_Column_List">
id, task_id, resource_id, resource_name, task_origin, `status`, `result`, resource_pool_id,
resource_pool_node, resource_type, project_id, organization_id, thread_id, start_time,
end_time, executor, collection_id, deleted
end_time, executor, deleted, collection_id, case_id
</sql>
<select id="selectByExample" parameterType="io.metersphere.system.domain.ExecTaskItemExample" resultMap="BaseResultMap">
select
@ -120,15 +121,15 @@
`result`, resource_pool_id, resource_pool_node,
resource_type, project_id, organization_id,
thread_id, start_time, end_time,
executor, collection_id, deleted
)
executor, deleted, collection_id,
case_id)
values (#{id,jdbcType=VARCHAR}, #{taskId,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR},
#{resourceName,jdbcType=VARCHAR}, #{taskOrigin,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{result,jdbcType=VARCHAR}, #{resourcePoolId,jdbcType=VARCHAR}, #{resourcePoolNode,jdbcType=VARCHAR},
#{resourceType,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{organizationId,jdbcType=VARCHAR},
#{threadId,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT},
#{executor,jdbcType=VARCHAR}, #{collectionId,jdbcType=VARCHAR}, #{deleted,jdbcType=BIT}
)
#{executor,jdbcType=VARCHAR}, #{deleted,jdbcType=BIT}, #{collectionId,jdbcType=VARCHAR},
#{caseId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.system.domain.ExecTaskItem">
insert into exec_task_item
@ -181,11 +182,14 @@
<if test="executor != null">
executor,
</if>
<if test="deleted != null">
deleted,
</if>
<if test="collectionId != null">
collection_id,
</if>
<if test="deleted != null">
deleted,
<if test="caseId != null">
case_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@ -237,11 +241,14 @@
<if test="executor != null">
#{executor,jdbcType=VARCHAR},
</if>
<if test="deleted != null">
#{deleted,jdbcType=BIT},
</if>
<if test="collectionId != null">
#{collectionId,jdbcType=VARCHAR},
</if>
<if test="deleted != null">
#{deleted,jdbcType=BIT},
<if test="caseId != null">
#{caseId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
@ -302,11 +309,14 @@
<if test="record.executor != null">
executor = #{record.executor,jdbcType=VARCHAR},
</if>
<if test="record.deleted != null">
deleted = #{record.deleted,jdbcType=BIT},
</if>
<if test="record.collectionId != null">
collection_id = #{record.collectionId,jdbcType=VARCHAR},
</if>
<if test="record.deleted != null">
deleted = #{record.deleted,jdbcType=BIT},
<if test="record.caseId != null">
case_id = #{record.caseId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
@ -331,8 +341,9 @@
start_time = #{record.startTime,jdbcType=BIGINT},
end_time = #{record.endTime,jdbcType=BIGINT},
executor = #{record.executor,jdbcType=VARCHAR},
deleted = #{record.deleted,jdbcType=BIT},
collection_id = #{record.collectionId,jdbcType=VARCHAR},
deleted = #{record.deleted,jdbcType=BIT}
case_id = #{record.caseId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -385,11 +396,14 @@
<if test="executor != null">
executor = #{executor,jdbcType=VARCHAR},
</if>
<if test="deleted != null">
deleted = #{deleted,jdbcType=BIT},
</if>
<if test="collectionId != null">
collection_id = #{collectionId,jdbcType=VARCHAR},
</if>
<if test="deleted != null">
deleted = #{deleted,jdbcType=BIT},
<if test="caseId != null">
case_id = #{caseId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
@ -411,15 +425,16 @@
start_time = #{startTime,jdbcType=BIGINT},
end_time = #{endTime,jdbcType=BIGINT},
executor = #{executor,jdbcType=VARCHAR},
deleted = #{deleted,jdbcType=BIT},
collection_id = #{collectionId,jdbcType=VARCHAR},
deleted = #{deleted,jdbcType=BIT}
case_id = #{caseId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<insert id="batchInsert" parameterType="map">
insert into exec_task_item
(id, task_id, resource_id, resource_name, task_origin, `status`, `result`, resource_pool_id,
resource_pool_node, resource_type, project_id, organization_id, thread_id, start_time,
end_time, executor, collection_id, deleted)
end_time, executor, deleted, collection_id, case_id)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.taskId,jdbcType=VARCHAR}, #{item.resourceId,jdbcType=VARCHAR},
@ -427,8 +442,8 @@
#{item.result,jdbcType=VARCHAR}, #{item.resourcePoolId,jdbcType=VARCHAR}, #{item.resourcePoolNode,jdbcType=VARCHAR},
#{item.resourceType,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR}, #{item.organizationId,jdbcType=VARCHAR},
#{item.threadId,jdbcType=VARCHAR}, #{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT},
#{item.executor,jdbcType=VARCHAR}, #{item.collectionId,jdbcType=VARCHAR}, #{item.deleted,jdbcType=BIT}
)
#{item.executor,jdbcType=VARCHAR}, #{item.deleted,jdbcType=BIT}, #{item.collectionId,jdbcType=VARCHAR},
#{item.caseId,jdbcType=VARCHAR})
</foreach>
</insert>
<insert id="batchInsertSelective" parameterType="map">
@ -489,11 +504,14 @@
<if test="'executor'.toString() == column.value">
#{item.executor,jdbcType=VARCHAR}
</if>
<if test="'deleted'.toString() == column.value">
#{item.deleted,jdbcType=BIT}
</if>
<if test="'collection_id'.toString() == column.value">
#{item.collectionId,jdbcType=VARCHAR}
</if>
<if test="'deleted'.toString() == column.value">
#{item.deleted,jdbcType=BIT}
<if test="'case_id'.toString() == column.value">
#{item.caseId,jdbcType=VARCHAR}
</if>
</foreach>
)

View File

@ -74,7 +74,8 @@ CREATE INDEX idx_project_id_delete_create_time_create_user
ALTER TABLE exec_task ADD COLUMN deleted bit(1) NOT NULL DEFAULT b'0' COMMENT '删除标识';
ALTER TABLE exec_task_item ADD COLUMN deleted bit(1) NOT NULL DEFAULT b'0' COMMENT '删除标识';
ALTER TABLE exec_task_item ADD COLUMN case_id VARCHAR(50) COMMENT '用例表id';
CREATE INDEX idx_case_id ON exec_task_item(case_id);
-- 任务项添加测试集字段
ALTER TABLE exec_task_item ADD collection_id varchar(50) NULL COMMENT '测试集ID';

View File

@ -77,6 +77,7 @@ public class ApiScenarioScheduleJob extends BaseScheduleJob {
execTaskItem.setOrganizationId(project.getOrganizationId());
execTaskItem.setResourceType(ApiExecuteResourceType.API_SCENARIO.name());
execTaskItem.setResourceId(apiScenarioDetail.getId());
execTaskItem.setCaseId(apiScenarioDetail.getId());
execTaskItem.setResourceName(apiScenarioDetail.getName());
baseTaskHubService.insertExecTaskAndDetail(execTask, execTaskItem);

View File

@ -139,6 +139,7 @@ public class ApiTestCaseBatchRunService {
execTaskItem.setOrganizationId(project.getOrganizationId());
execTaskItem.setResourceType(ApiExecuteResourceType.API_CASE.name());
execTaskItem.setResourceId(apiTestCase.getId());
execTaskItem.setCaseId(apiTestCase.getId());
execTaskItem.setResourceName(apiTestCase.getName());
execTaskItems.add(execTaskItem);
}

View File

@ -108,6 +108,7 @@ public class ApiTestCaseRunService {
execTaskItem.setOrganizationId(project.getOrganizationId());
execTaskItem.setResourceType(ApiExecuteResourceType.API_CASE.name());
execTaskItem.setResourceId(apiTestCase.getId());
execTaskItem.setCaseId(apiTestCase.getId());
execTaskItem.setResourceName(apiTestCase.getName());
baseTaskHubService.insertExecTaskAndDetail(execTask, execTaskItem);

View File

@ -240,6 +240,7 @@ public class ApiScenarioBatchRunService {
execTaskItem.setOrganizationId(project.getOrganizationId());
execTaskItem.setResourceType(ApiExecuteResourceType.API_SCENARIO.name());
execTaskItem.setResourceId(apiScenario.getId());
execTaskItem.setCaseId(apiScenario.getId());
execTaskItem.setResourceName(apiScenario.getName());
execTaskItems.add(execTaskItem);
}

View File

@ -201,6 +201,7 @@ public class ApiScenarioRunService {
execTaskItem.setOrganizationId(project.getOrganizationId());
execTaskItem.setResourceType(ApiExecuteResourceType.API_SCENARIO.name());
execTaskItem.setResourceId(apiScenario.getId());
execTaskItem.setCaseId(apiScenario.getId());
execTaskItem.setResourceName(apiScenario.getName());
baseTaskHubService.insertExecTaskAndDetail(execTask, execTaskItem);

View File

@ -620,6 +620,7 @@ public class BaseTaskHubControllerTests extends BaseTest {
execTaskItem.setId("1111");
execTaskItem.setTaskId("1");
execTaskItem.setResourceId("1");
execTaskItem.setCaseId("1");
execTaskItem.setStatus("SUCCESS");
execTaskItem.setResourcePoolId("1");
execTaskItem.setResourceType("FUNCTIONAL");

View File

@ -7,4 +7,5 @@ public class TestPlanApiCaseBatchRunDTO {
private String id;
private String name;
private String testPlanCollectionId;
private String caseId;
}

View File

@ -7,4 +7,5 @@ public class TestPlanApiScenarioBatchRunDTO {
private String id;
private String name;
private String testPlanCollectionId;
private String caseId;
}

View File

@ -841,7 +841,7 @@
</select>
<select id="getSelectIdAndCollectionId" resultType="io.metersphere.plan.dto.TestPlanApiCaseBatchRunDTO">
SELECT t.id as id, t.test_plan_collection_id as test_plan_collection_id, atc.name as name
SELECT t.id as id, t.test_plan_collection_id as test_plan_collection_id, atc.name as name, atc.id as caseId
FROM test_plan_api_case t
INNER JOIN api_test_case atc ON t.api_case_id = atc.id
INNER JOIN api_definition a ON atc.api_definition_id = a.id
@ -893,7 +893,7 @@
AND test_plan.status != 'ARCHIVED'
</select>
<select id="getBatchRunInfoByIds" resultType="io.metersphere.plan.dto.TestPlanApiCaseBatchRunDTO">
SELECT t.id as id, t.test_plan_collection_id as test_plan_collection_id, atc.name as name
SELECT t.id as id, t.test_plan_collection_id as test_plan_collection_id, atc.name as name, atc.id as caseId
FROM test_plan_api_case t
INNER JOIN api_test_case atc ON t.api_case_id = atc.id
where

View File

@ -535,7 +535,7 @@
<select id="getSelectIdAndCollectionId" resultType="io.metersphere.plan.dto.TestPlanApiScenarioBatchRunDTO">
SELECT
test_plan_api_scenario.id as id, test_plan_api_scenario.test_plan_collection_id as testPlanCollectionId,
api_scenario.name as name
api_scenario.name as name, api_scenario.id as caseId
FROM
test_plan_api_scenario
INNER JOIN api_scenario on api_scenario.id = test_plan_api_scenario.api_scenario_id
@ -634,7 +634,7 @@
</select>
<select id="getBatchRunInfoByIds" resultType="io.metersphere.plan.dto.TestPlanApiScenarioBatchRunDTO">
SELECT tpas.id, tpas.test_plan_collection_id, t.name as name
SELECT tpas.id, tpas.test_plan_collection_id, t.name as name, t.id as caseId
FROM test_plan_api_scenario tpas
INNER JOIN api_scenario t ON tpas.api_scenario_id = t.id
WHERE

View File

@ -303,6 +303,7 @@ public class TestPlanApiCaseBatchRunService {
execTaskItem.setOrganizationId(project.getOrganizationId());
execTaskItem.setResourceType(ApiExecuteResourceType.TEST_PLAN_API_CASE.name());
execTaskItem.setResourceId(apiTestCase.getId());
execTaskItem.setCaseId(apiTestCase.getCaseId());
execTaskItem.setResourceName(apiTestCase.getName());
execTaskItem.setCollectionId(apiTestCase.getTestPlanCollectionId());
execTaskItems.add(execTaskItem);

View File

@ -767,7 +767,9 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
ExecTaskItem execTaskItem = apiCommonService.newExecTaskItem(execTask.getId(), project.getId(), userId);
execTaskItem.setOrganizationId(project.getOrganizationId());
execTaskItem.setResourceType(ApiExecuteResourceType.TEST_PLAN_API_CASE.name());
execTaskItem.setResourceId(apiTestCase.getId());
execTaskItem.setResourceId(testPlanApiCase.getId());
execTaskItem.setCaseId(apiTestCase.getId());
execTaskItem.setTaskOrigin(testPlanApiCase.getTestPlanId());
execTaskItem.setResourceName(apiTestCase.getName());
baseTaskHubService.insertExecTaskAndDetail(execTask, execTaskItem);

View File

@ -281,6 +281,7 @@ public class TestPlanApiScenarioBatchRunService {
execTaskItem.setOrganizationId(project.getOrganizationId());
execTaskItem.setResourceType(ApiExecuteResourceType.TEST_PLAN_API_SCENARIO.name());
execTaskItem.setResourceId(testPlanApiScenario.getId());
execTaskItem.setCaseId(testPlanApiScenario.getCaseId());
execTaskItem.setResourceName(testPlanApiScenario.getName());
execTaskItem.setCollectionId(testPlanApiScenario.getTestPlanCollectionId());
execTaskItems.add(execTaskItem);

View File

@ -350,6 +350,8 @@ public class TestPlanApiScenarioService extends TestPlanResourceService {
execTaskItem.setOrganizationId(project.getOrganizationId());
execTaskItem.setResourceType(ApiExecuteResourceType.TEST_PLAN_API_SCENARIO.name());
execTaskItem.setResourceId(testPlanApiScenario.getId());
execTaskItem.setCaseId(testPlanApiScenario.getApiScenarioId());
execTaskItem.setTaskOrigin(testPlanApiScenario.getTestPlanId());
execTaskItem.setResourceName(apiScenario.getName());
baseTaskHubService.insertExecTaskAndDetail(execTask, execTaskItem);

View File

@ -660,6 +660,7 @@ public class TestPlanReportService {
execTaskItem.setOrganizationId(project.getOrganizationId());
execTaskItem.setResourceType(ApiExecuteResourceType.PLAN_RUN_API_CASE.name());
execTaskItem.setResourceId(apiTestCase.getId());
execTaskItem.setCaseId(apiTestCase.getApiCaseId());
execTaskItem.setResourceName(apiTestCase.getApiCaseName());
execTaskItem.setTaskOrigin(testPlanId);
execTaskItem.setCollectionId(apiTestCase.getTestPlanCollectionId());
@ -675,6 +676,7 @@ public class TestPlanReportService {
execTaskItem.setOrganizationId(project.getOrganizationId());
execTaskItem.setResourceType(ApiExecuteResourceType.PLAN_RUN_API_SCENARIO.name());
execTaskItem.setResourceId(testPlanReportApiScenario.getId());
execTaskItem.setCaseId(testPlanReportApiScenario.getApiScenarioId());
execTaskItem.setResourceName(testPlanReportApiScenario.getApiScenarioName());
execTaskItem.setCollectionId(testPlanReportApiScenario.getTestPlanCollectionId());
execTaskItem.setTaskOrigin(testPlanId);