feat(任务中心): 用例执行任务列表数据统计接口
This commit is contained in:
parent
9513b52de1
commit
5639549797
|
@ -41,8 +41,8 @@ public class ExecTask implements Serializable {
|
||||||
@Size(min = 1, max = 50, message = "{exec_task.task_type.length_range}", groups = {Created.class, Updated.class})
|
@Size(min = 1, max = 50, message = "{exec_task.task_type.length_range}", groups = {Created.class, Updated.class})
|
||||||
private String taskType;
|
private String taskType;
|
||||||
|
|
||||||
@Schema(description = "测试计划id")
|
@Schema(description = "测试计划id/测试计划组id")
|
||||||
private String testPlanId;
|
private String resourceId;
|
||||||
|
|
||||||
@Schema(description = "执行模式", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "执行模式", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotBlank(message = "{exec_task.trigger_mode.not_blank}", groups = {Created.class})
|
@NotBlank(message = "{exec_task.trigger_mode.not_blank}", groups = {Created.class})
|
||||||
|
@ -81,7 +81,7 @@ public class ExecTask implements Serializable {
|
||||||
caseCount("case_count", "caseCount", "BIGINT", false),
|
caseCount("case_count", "caseCount", "BIGINT", false),
|
||||||
result("result", "result", "VARCHAR", true),
|
result("result", "result", "VARCHAR", true),
|
||||||
taskType("task_type", "taskType", "VARCHAR", false),
|
taskType("task_type", "taskType", "VARCHAR", false),
|
||||||
testPlanId("test_plan_id", "testPlanId", "VARCHAR", false),
|
resourceId("resource_id", "resourceId", "VARCHAR", false),
|
||||||
triggerMode("trigger_mode", "triggerMode", "VARCHAR", false),
|
triggerMode("trigger_mode", "triggerMode", "VARCHAR", false),
|
||||||
projectId("project_id", "projectId", "VARCHAR", false),
|
projectId("project_id", "projectId", "VARCHAR", false),
|
||||||
organizationId("organization_id", "organizationId", "VARCHAR", false),
|
organizationId("organization_id", "organizationId", "VARCHAR", false),
|
||||||
|
|
|
@ -574,73 +574,73 @@ public class ExecTaskExample {
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andTestPlanIdIsNull() {
|
public Criteria andResourceIdIsNull() {
|
||||||
addCriterion("test_plan_id is null");
|
addCriterion("resource_id is null");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andTestPlanIdIsNotNull() {
|
public Criteria andResourceIdIsNotNull() {
|
||||||
addCriterion("test_plan_id is not null");
|
addCriterion("resource_id is not null");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andTestPlanIdEqualTo(String value) {
|
public Criteria andResourceIdEqualTo(String value) {
|
||||||
addCriterion("test_plan_id =", value, "testPlanId");
|
addCriterion("resource_id =", value, "resourceId");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andTestPlanIdNotEqualTo(String value) {
|
public Criteria andResourceIdNotEqualTo(String value) {
|
||||||
addCriterion("test_plan_id <>", value, "testPlanId");
|
addCriterion("resource_id <>", value, "resourceId");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andTestPlanIdGreaterThan(String value) {
|
public Criteria andResourceIdGreaterThan(String value) {
|
||||||
addCriterion("test_plan_id >", value, "testPlanId");
|
addCriterion("resource_id >", value, "resourceId");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andTestPlanIdGreaterThanOrEqualTo(String value) {
|
public Criteria andResourceIdGreaterThanOrEqualTo(String value) {
|
||||||
addCriterion("test_plan_id >=", value, "testPlanId");
|
addCriterion("resource_id >=", value, "resourceId");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andTestPlanIdLessThan(String value) {
|
public Criteria andResourceIdLessThan(String value) {
|
||||||
addCriterion("test_plan_id <", value, "testPlanId");
|
addCriterion("resource_id <", value, "resourceId");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andTestPlanIdLessThanOrEqualTo(String value) {
|
public Criteria andResourceIdLessThanOrEqualTo(String value) {
|
||||||
addCriterion("test_plan_id <=", value, "testPlanId");
|
addCriterion("resource_id <=", value, "resourceId");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andTestPlanIdLike(String value) {
|
public Criteria andResourceIdLike(String value) {
|
||||||
addCriterion("test_plan_id like", value, "testPlanId");
|
addCriterion("resource_id like", value, "resourceId");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andTestPlanIdNotLike(String value) {
|
public Criteria andResourceIdNotLike(String value) {
|
||||||
addCriterion("test_plan_id not like", value, "testPlanId");
|
addCriterion("resource_id not like", value, "resourceId");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andTestPlanIdIn(List<String> values) {
|
public Criteria andResourceIdIn(List<String> values) {
|
||||||
addCriterion("test_plan_id in", values, "testPlanId");
|
addCriterion("resource_id in", values, "resourceId");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andTestPlanIdNotIn(List<String> values) {
|
public Criteria andResourceIdNotIn(List<String> values) {
|
||||||
addCriterion("test_plan_id not in", values, "testPlanId");
|
addCriterion("resource_id not in", values, "resourceId");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andTestPlanIdBetween(String value1, String value2) {
|
public Criteria andResourceIdBetween(String value1, String value2) {
|
||||||
addCriterion("test_plan_id between", value1, value2, "testPlanId");
|
addCriterion("resource_id between", value1, value2, "resourceId");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Criteria andTestPlanIdNotBetween(String value1, String value2) {
|
public Criteria andResourceIdNotBetween(String value1, String value2) {
|
||||||
addCriterion("test_plan_id not between", value1, value2, "testPlanId");
|
addCriterion("resource_id not between", value1, value2, "resourceId");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<result column="case_count" jdbcType="BIGINT" property="caseCount" />
|
<result column="case_count" jdbcType="BIGINT" property="caseCount" />
|
||||||
<result column="result" jdbcType="VARCHAR" property="result" />
|
<result column="result" jdbcType="VARCHAR" property="result" />
|
||||||
<result column="task_type" jdbcType="VARCHAR" property="taskType" />
|
<result column="task_type" jdbcType="VARCHAR" property="taskType" />
|
||||||
<result column="test_plan_id" jdbcType="VARCHAR" property="testPlanId" />
|
<result column="resource_id" jdbcType="VARCHAR" property="resourceId" />
|
||||||
<result column="trigger_mode" jdbcType="VARCHAR" property="triggerMode" />
|
<result column="trigger_mode" jdbcType="VARCHAR" property="triggerMode" />
|
||||||
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
|
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
|
||||||
<result column="organization_id" jdbcType="VARCHAR" property="organizationId" />
|
<result column="organization_id" jdbcType="VARCHAR" property="organizationId" />
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, num, task_name, `status`, case_count, `result`, task_type, test_plan_id, trigger_mode,
|
id, num, task_name, `status`, case_count, `result`, task_type, resource_id, trigger_mode,
|
||||||
project_id, organization_id, create_time, create_user, start_time, end_time
|
project_id, organization_id, create_time, create_user, start_time, end_time
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectByExample" parameterType="io.metersphere.system.domain.ExecTaskExample" resultMap="BaseResultMap">
|
<select id="selectByExample" parameterType="io.metersphere.system.domain.ExecTaskExample" resultMap="BaseResultMap">
|
||||||
|
@ -113,13 +113,13 @@
|
||||||
<insert id="insert" parameterType="io.metersphere.system.domain.ExecTask">
|
<insert id="insert" parameterType="io.metersphere.system.domain.ExecTask">
|
||||||
insert into exec_task (id, num, task_name,
|
insert into exec_task (id, num, task_name,
|
||||||
`status`, case_count, `result`,
|
`status`, case_count, `result`,
|
||||||
task_type, test_plan_id, trigger_mode,
|
task_type, resource_id, trigger_mode,
|
||||||
project_id, organization_id, create_time,
|
project_id, organization_id, create_time,
|
||||||
create_user, start_time, end_time
|
create_user, start_time, end_time
|
||||||
)
|
)
|
||||||
values (#{id,jdbcType=VARCHAR}, #{num,jdbcType=BIGINT}, #{taskName,jdbcType=VARCHAR},
|
values (#{id,jdbcType=VARCHAR}, #{num,jdbcType=BIGINT}, #{taskName,jdbcType=VARCHAR},
|
||||||
#{status,jdbcType=VARCHAR}, #{caseCount,jdbcType=BIGINT}, #{result,jdbcType=VARCHAR},
|
#{status,jdbcType=VARCHAR}, #{caseCount,jdbcType=BIGINT}, #{result,jdbcType=VARCHAR},
|
||||||
#{taskType,jdbcType=VARCHAR}, #{testPlanId,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR},
|
#{taskType,jdbcType=VARCHAR}, #{resourceId,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR},
|
||||||
#{projectId,jdbcType=VARCHAR}, #{organizationId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
|
#{projectId,jdbcType=VARCHAR}, #{organizationId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT},
|
||||||
#{createUser,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT}
|
#{createUser,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT}
|
||||||
)
|
)
|
||||||
|
@ -148,8 +148,8 @@
|
||||||
<if test="taskType != null">
|
<if test="taskType != null">
|
||||||
task_type,
|
task_type,
|
||||||
</if>
|
</if>
|
||||||
<if test="testPlanId != null">
|
<if test="resourceId != null">
|
||||||
test_plan_id,
|
resource_id,
|
||||||
</if>
|
</if>
|
||||||
<if test="triggerMode != null">
|
<if test="triggerMode != null">
|
||||||
trigger_mode,
|
trigger_mode,
|
||||||
|
@ -195,8 +195,8 @@
|
||||||
<if test="taskType != null">
|
<if test="taskType != null">
|
||||||
#{taskType,jdbcType=VARCHAR},
|
#{taskType,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="testPlanId != null">
|
<if test="resourceId != null">
|
||||||
#{testPlanId,jdbcType=VARCHAR},
|
#{resourceId,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="triggerMode != null">
|
<if test="triggerMode != null">
|
||||||
#{triggerMode,jdbcType=VARCHAR},
|
#{triggerMode,jdbcType=VARCHAR},
|
||||||
|
@ -251,8 +251,8 @@
|
||||||
<if test="record.taskType != null">
|
<if test="record.taskType != null">
|
||||||
task_type = #{record.taskType,jdbcType=VARCHAR},
|
task_type = #{record.taskType,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="record.testPlanId != null">
|
<if test="record.resourceId != null">
|
||||||
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
|
resource_id = #{record.resourceId,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="record.triggerMode != null">
|
<if test="record.triggerMode != null">
|
||||||
trigger_mode = #{record.triggerMode,jdbcType=VARCHAR},
|
trigger_mode = #{record.triggerMode,jdbcType=VARCHAR},
|
||||||
|
@ -289,7 +289,7 @@
|
||||||
case_count = #{record.caseCount,jdbcType=BIGINT},
|
case_count = #{record.caseCount,jdbcType=BIGINT},
|
||||||
`result` = #{record.result,jdbcType=VARCHAR},
|
`result` = #{record.result,jdbcType=VARCHAR},
|
||||||
task_type = #{record.taskType,jdbcType=VARCHAR},
|
task_type = #{record.taskType,jdbcType=VARCHAR},
|
||||||
test_plan_id = #{record.testPlanId,jdbcType=VARCHAR},
|
resource_id = #{record.resourceId,jdbcType=VARCHAR},
|
||||||
trigger_mode = #{record.triggerMode,jdbcType=VARCHAR},
|
trigger_mode = #{record.triggerMode,jdbcType=VARCHAR},
|
||||||
project_id = #{record.projectId,jdbcType=VARCHAR},
|
project_id = #{record.projectId,jdbcType=VARCHAR},
|
||||||
organization_id = #{record.organizationId,jdbcType=VARCHAR},
|
organization_id = #{record.organizationId,jdbcType=VARCHAR},
|
||||||
|
@ -322,8 +322,8 @@
|
||||||
<if test="taskType != null">
|
<if test="taskType != null">
|
||||||
task_type = #{taskType,jdbcType=VARCHAR},
|
task_type = #{taskType,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="testPlanId != null">
|
<if test="resourceId != null">
|
||||||
test_plan_id = #{testPlanId,jdbcType=VARCHAR},
|
resource_id = #{resourceId,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
<if test="triggerMode != null">
|
<if test="triggerMode != null">
|
||||||
trigger_mode = #{triggerMode,jdbcType=VARCHAR},
|
trigger_mode = #{triggerMode,jdbcType=VARCHAR},
|
||||||
|
@ -357,7 +357,7 @@
|
||||||
case_count = #{caseCount,jdbcType=BIGINT},
|
case_count = #{caseCount,jdbcType=BIGINT},
|
||||||
`result` = #{result,jdbcType=VARCHAR},
|
`result` = #{result,jdbcType=VARCHAR},
|
||||||
task_type = #{taskType,jdbcType=VARCHAR},
|
task_type = #{taskType,jdbcType=VARCHAR},
|
||||||
test_plan_id = #{testPlanId,jdbcType=VARCHAR},
|
resource_id = #{resourceId,jdbcType=VARCHAR},
|
||||||
trigger_mode = #{triggerMode,jdbcType=VARCHAR},
|
trigger_mode = #{triggerMode,jdbcType=VARCHAR},
|
||||||
project_id = #{projectId,jdbcType=VARCHAR},
|
project_id = #{projectId,jdbcType=VARCHAR},
|
||||||
organization_id = #{organizationId,jdbcType=VARCHAR},
|
organization_id = #{organizationId,jdbcType=VARCHAR},
|
||||||
|
@ -369,13 +369,13 @@
|
||||||
</update>
|
</update>
|
||||||
<insert id="batchInsert" parameterType="map">
|
<insert id="batchInsert" parameterType="map">
|
||||||
insert into exec_task
|
insert into exec_task
|
||||||
(id, num, task_name, `status`, case_count, `result`, task_type, test_plan_id, trigger_mode,
|
(id, num, task_name, `status`, case_count, `result`, task_type, resource_id, trigger_mode,
|
||||||
project_id, organization_id, create_time, create_user, start_time, end_time)
|
project_id, organization_id, create_time, create_user, start_time, end_time)
|
||||||
values
|
values
|
||||||
<foreach collection="list" item="item" separator=",">
|
<foreach collection="list" item="item" separator=",">
|
||||||
(#{item.id,jdbcType=VARCHAR}, #{item.num,jdbcType=BIGINT}, #{item.taskName,jdbcType=VARCHAR},
|
(#{item.id,jdbcType=VARCHAR}, #{item.num,jdbcType=BIGINT}, #{item.taskName,jdbcType=VARCHAR},
|
||||||
#{item.status,jdbcType=VARCHAR}, #{item.caseCount,jdbcType=BIGINT}, #{item.result,jdbcType=VARCHAR},
|
#{item.status,jdbcType=VARCHAR}, #{item.caseCount,jdbcType=BIGINT}, #{item.result,jdbcType=VARCHAR},
|
||||||
#{item.taskType,jdbcType=VARCHAR}, #{item.testPlanId,jdbcType=VARCHAR}, #{item.triggerMode,jdbcType=VARCHAR},
|
#{item.taskType,jdbcType=VARCHAR}, #{item.resourceId,jdbcType=VARCHAR}, #{item.triggerMode,jdbcType=VARCHAR},
|
||||||
#{item.projectId,jdbcType=VARCHAR}, #{item.organizationId,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT},
|
#{item.projectId,jdbcType=VARCHAR}, #{item.organizationId,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT},
|
||||||
#{item.createUser,jdbcType=VARCHAR}, #{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT}
|
#{item.createUser,jdbcType=VARCHAR}, #{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT}
|
||||||
)
|
)
|
||||||
|
@ -412,8 +412,8 @@
|
||||||
<if test="'task_type'.toString() == column.value">
|
<if test="'task_type'.toString() == column.value">
|
||||||
#{item.taskType,jdbcType=VARCHAR}
|
#{item.taskType,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
<if test="'test_plan_id'.toString() == column.value">
|
<if test="'resource_id'.toString() == column.value">
|
||||||
#{item.testPlanId,jdbcType=VARCHAR}
|
#{item.resourceId,jdbcType=VARCHAR}
|
||||||
</if>
|
</if>
|
||||||
<if test="'trigger_mode'.toString() == column.value">
|
<if test="'trigger_mode'.toString() == column.value">
|
||||||
#{item.triggerMode,jdbcType=VARCHAR}
|
#{item.triggerMode,jdbcType=VARCHAR}
|
||||||
|
|
|
@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS exec_task(
|
||||||
`case_count` BIGINT NOT NULL COMMENT '用例数量' ,
|
`case_count` BIGINT NOT NULL COMMENT '用例数量' ,
|
||||||
`result` VARCHAR(64) COMMENT '执行结果' ,
|
`result` VARCHAR(64) COMMENT '执行结果' ,
|
||||||
`task_type` VARCHAR(50) NOT NULL COMMENT '任务类型' ,
|
`task_type` VARCHAR(50) NOT NULL COMMENT '任务类型' ,
|
||||||
`test_plan_id` VARCHAR(50) COMMENT '测试计划id' ,
|
`resource_id` VARCHAR(50) COMMENT '测试计划id/测试计划组id' ,
|
||||||
`trigger_mode` VARCHAR(20) NOT NULL COMMENT '执行模式' ,
|
`trigger_mode` VARCHAR(20) NOT NULL COMMENT '执行模式' ,
|
||||||
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID' ,
|
`project_id` VARCHAR(50) NOT NULL COMMENT '项目ID' ,
|
||||||
`organization_id` VARCHAR(50) NOT NULL COMMENT '组织ID' ,
|
`organization_id` VARCHAR(50) NOT NULL COMMENT '组织ID' ,
|
||||||
|
|
|
@ -6,9 +6,12 @@ import io.metersphere.system.dto.taskhub.TaskHubDTO;
|
||||||
import io.metersphere.system.dto.taskhub.TaskHubItemDTO;
|
import io.metersphere.system.dto.taskhub.TaskHubItemDTO;
|
||||||
import io.metersphere.system.dto.taskhub.TaskHubScheduleDTO;
|
import io.metersphere.system.dto.taskhub.TaskHubScheduleDTO;
|
||||||
import io.metersphere.system.dto.taskhub.request.TaskHubItemRequest;
|
import io.metersphere.system.dto.taskhub.request.TaskHubItemRequest;
|
||||||
|
import io.metersphere.system.dto.taskhub.response.TaskStatisticsResponse;
|
||||||
import io.metersphere.system.service.BaseTaskHubService;
|
import io.metersphere.system.service.BaseTaskHubService;
|
||||||
import io.metersphere.system.utils.Pager;
|
import io.metersphere.system.utils.Pager;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
@ -50,4 +53,12 @@ public class SystemTaskHubController {
|
||||||
return baseTaskHubService.getCaseTaskItemList(request, null, null);
|
return baseTaskHubService.getCaseTaskItemList(request, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/exec-task/statistics")
|
||||||
|
@Operation(summary = "系统-任务中心-获取任务统计{通过率}接口")
|
||||||
|
@RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_READ)
|
||||||
|
@Parameter(name = "ids", description = "任务ID集合", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||||
|
public List<TaskStatisticsResponse> selectTestPlanMetricById(@RequestBody List<String> ids) {
|
||||||
|
return baseTaskHubService.calculateRate(ids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
package io.metersphere.system.dto.taskhub.response;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import io.metersphere.system.serializer.CustomRateSerializer;
|
||||||
|
import io.metersphere.system.utils.RateCalculateUtils;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wx
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class TaskStatisticsResponse implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "任务id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Schema(description = "任务完成率{已执行用例/全部用例}")
|
||||||
|
@JsonSerialize(using = CustomRateSerializer.class)
|
||||||
|
private Double executeRate;
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(description = "成功用例数量")
|
||||||
|
private long successCount = 0;
|
||||||
|
@Schema(description = "失败用例数量")
|
||||||
|
private long errorCount = 0;
|
||||||
|
@Schema(description = "误报用例数量")
|
||||||
|
private long fakeErrorCount = 0;
|
||||||
|
@Schema(description = "未执行用例数量")
|
||||||
|
private long pendingCount = 0;
|
||||||
|
|
||||||
|
@Schema(description = "用例总数")
|
||||||
|
private long caseTotal = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public void calculateExecuteRate() {
|
||||||
|
this.executeRate = RateCalculateUtils.divWithPrecision(this.caseTotal - this.pendingCount, this.caseTotal, 2);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package io.metersphere.system.mapper;
|
package io.metersphere.system.mapper;
|
||||||
|
|
||||||
|
import io.metersphere.system.domain.ExecTaskItem;
|
||||||
import io.metersphere.system.dto.sdk.BasePageRequest;
|
import io.metersphere.system.dto.sdk.BasePageRequest;
|
||||||
import io.metersphere.system.dto.taskhub.TaskHubDTO;
|
import io.metersphere.system.dto.taskhub.TaskHubDTO;
|
||||||
import io.metersphere.system.dto.taskhub.TaskHubItemDTO;
|
import io.metersphere.system.dto.taskhub.TaskHubItemDTO;
|
||||||
|
@ -13,4 +14,6 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface ExtExecTaskItemMapper {
|
public interface ExtExecTaskItemMapper {
|
||||||
List<TaskHubItemDTO> selectList(@Param("request") TaskHubItemRequest request, @Param("orgId") String orgId, @Param("projectId") String projectId);
|
List<TaskHubItemDTO> selectList(@Param("request") TaskHubItemRequest request, @Param("orgId") String orgId, @Param("projectId") String projectId);
|
||||||
|
|
||||||
|
List<ExecTaskItem> selectItemByTaskIds(@Param("taskIds") List<String> taskIds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,4 +21,13 @@
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectItemByTaskIds" resultType="io.metersphere.system.domain.ExecTaskItem">
|
||||||
|
select id, task_id, `status`, result
|
||||||
|
from exec_task_item
|
||||||
|
where task_id in
|
||||||
|
<foreach collection="taskIds" item="taskId" open="(" separator="," close=")">
|
||||||
|
#{taskId}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -1,4 +1,4 @@
|
||||||
package io.metersphere.plan.serializer;
|
package io.metersphere.system.serializer;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
import com.fasterxml.jackson.databind.JsonSerializer;
|
|
@ -2,6 +2,9 @@ package io.metersphere.system.service;
|
||||||
|
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.page.PageMethod;
|
import com.github.pagehelper.page.PageMethod;
|
||||||
|
import io.metersphere.plan.mapper.TestPlanMapper;
|
||||||
|
import io.metersphere.sdk.constants.ExecStatus;
|
||||||
|
import io.metersphere.sdk.constants.ResultStatus;
|
||||||
import io.metersphere.sdk.util.SubListUtils;
|
import io.metersphere.sdk.util.SubListUtils;
|
||||||
import io.metersphere.system.domain.ExecTask;
|
import io.metersphere.system.domain.ExecTask;
|
||||||
import io.metersphere.system.domain.ExecTaskItem;
|
import io.metersphere.system.domain.ExecTaskItem;
|
||||||
|
@ -11,6 +14,7 @@ import io.metersphere.system.dto.taskhub.TaskHubDTO;
|
||||||
import io.metersphere.system.dto.taskhub.TaskHubItemDTO;
|
import io.metersphere.system.dto.taskhub.TaskHubItemDTO;
|
||||||
import io.metersphere.system.dto.taskhub.TaskHubScheduleDTO;
|
import io.metersphere.system.dto.taskhub.TaskHubScheduleDTO;
|
||||||
import io.metersphere.system.dto.taskhub.request.TaskHubItemRequest;
|
import io.metersphere.system.dto.taskhub.request.TaskHubItemRequest;
|
||||||
|
import io.metersphere.system.dto.taskhub.response.TaskStatisticsResponse;
|
||||||
import io.metersphere.system.mapper.*;
|
import io.metersphere.system.mapper.*;
|
||||||
import io.metersphere.system.utils.PageUtils;
|
import io.metersphere.system.utils.PageUtils;
|
||||||
import io.metersphere.system.utils.Pager;
|
import io.metersphere.system.utils.Pager;
|
||||||
|
@ -50,6 +54,8 @@ public class BaseTaskHubService {
|
||||||
private SqlSessionFactory sqlSessionFactory;
|
private SqlSessionFactory sqlSessionFactory;
|
||||||
@Resource
|
@Resource
|
||||||
private ExtExecTaskItemMapper extExecTaskItemMapper;
|
private ExtExecTaskItemMapper extExecTaskItemMapper;
|
||||||
|
@Resource
|
||||||
|
private TestPlanMapper testPlanMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统-获取执行任务列表
|
* 系统-获取执行任务列表
|
||||||
|
@ -174,4 +180,38 @@ public class BaseTaskHubService {
|
||||||
private List<TaskHubItemDTO> getCaseTaskItemPage(TaskHubItemRequest request, String orgId, String projectId) {
|
private List<TaskHubItemDTO> getCaseTaskItemPage(TaskHubItemRequest request, String orgId, String projectId) {
|
||||||
return extExecTaskItemMapper.selectList(request, orgId, projectId);
|
return extExecTaskItemMapper.selectList(request, orgId, projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算任务通过率和执行进度
|
||||||
|
*
|
||||||
|
* @param taskIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<TaskStatisticsResponse> calculateRate(List<String> taskIds) {
|
||||||
|
List<TaskStatisticsResponse> responseList = new ArrayList<>();
|
||||||
|
List<ExecTaskItem> taskItemList = extExecTaskItemMapper.selectItemByTaskIds(taskIds);
|
||||||
|
Map<String, List<ExecTaskItem>> taskItems = taskItemList.stream().collect(Collectors.groupingBy(ExecTaskItem::getTaskId));
|
||||||
|
taskItems.forEach((taskId, items) -> {
|
||||||
|
//成功数量
|
||||||
|
long successCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ResultStatus.SUCCESS.name(), item.getStatus())).count();
|
||||||
|
//失败数量
|
||||||
|
long errorCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ResultStatus.ERROR.name(), item.getStatus())).count();
|
||||||
|
//误报数量
|
||||||
|
long fakeErrorCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ResultStatus.FAKE_ERROR.name(), item.getStatus())).count();
|
||||||
|
//未执行数量
|
||||||
|
long pendingCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ExecStatus.PENDING.name(), item.getStatus())).count();
|
||||||
|
|
||||||
|
TaskStatisticsResponse response = new TaskStatisticsResponse();
|
||||||
|
response.setId(taskId);
|
||||||
|
response.setCaseTotal(items.size());
|
||||||
|
response.setSuccessCount(successCount);
|
||||||
|
response.setErrorCount(errorCount);
|
||||||
|
response.setFakeErrorCount(fakeErrorCount);
|
||||||
|
response.setPendingCount(pendingCount);
|
||||||
|
response.calculateExecuteRate();
|
||||||
|
responseList.add(response);
|
||||||
|
});
|
||||||
|
return responseList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package io.metersphere.plan.utils;
|
package io.metersphere.system.utils;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
||||||
public static final String SYSTEM_TASK_PAGE = "/system/task-center/exec-task/page";
|
public static final String SYSTEM_TASK_PAGE = "/system/task-center/exec-task/page";
|
||||||
public static final String SYSTEM_SCHEDULE_TASK_PAGE = "/system/task-center/schedule/page";
|
public static final String SYSTEM_SCHEDULE_TASK_PAGE = "/system/task-center/schedule/page";
|
||||||
public static final String SYSTEM_TASK_ITEM_PAGE = "/system/task-center/exec-task/item/page";
|
public static final String SYSTEM_TASK_ITEM_PAGE = "/system/task-center/exec-task/item/page";
|
||||||
|
public static final String SYSTEM_STATISTICS = "/system/task-center/exec-task/statistics";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@Order(1)
|
||||||
|
@ -90,6 +91,21 @@ public class BaseTaskHubControllerTests extends BaseTest {
|
||||||
Assertions.assertNotNull(resultHolder);
|
Assertions.assertNotNull(resultHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统用例任务完成率统计
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
@Order(3)
|
||||||
|
public void getStatistics() throws Exception {
|
||||||
|
List<String> ids = List.of("1","2");
|
||||||
|
MvcResult mvcResult = this.requestPostWithOkAndReturn(SYSTEM_STATISTICS, ids);
|
||||||
|
// 获取返回值
|
||||||
|
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
|
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||||
|
// 返回请求正常
|
||||||
|
Assertions.assertNotNull(resultHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组织任务中心测试用例
|
* 组织任务中心测试用例
|
||||||
|
|
|
@ -2,7 +2,7 @@ package io.metersphere.plan.dto.response;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import io.metersphere.plan.dto.CaseCount;
|
import io.metersphere.plan.dto.CaseCount;
|
||||||
import io.metersphere.plan.serializer.CustomRateSerializer;
|
import io.metersphere.system.serializer.CustomRateSerializer;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package io.metersphere.plan.dto.response;
|
package io.metersphere.plan.dto.response;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import io.metersphere.plan.serializer.CustomRateSerializer;
|
import io.metersphere.system.serializer.CustomRateSerializer;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package io.metersphere.plan.dto.response;
|
package io.metersphere.plan.dto.response;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import io.metersphere.plan.serializer.CustomRateSerializer;
|
|
||||||
import io.metersphere.plan.utils.RateCalculateUtils;
|
|
||||||
import io.metersphere.sdk.constants.TestPlanConstants;
|
import io.metersphere.sdk.constants.TestPlanConstants;
|
||||||
import io.metersphere.system.dto.request.schedule.BaseScheduleConfigRequest;
|
import io.metersphere.system.dto.request.schedule.BaseScheduleConfigRequest;
|
||||||
|
import io.metersphere.system.serializer.CustomRateSerializer;
|
||||||
|
import io.metersphere.system.utils.RateCalculateUtils;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
|
@ -15,7 +15,6 @@ import io.metersphere.plan.dto.response.TestPlanReportPageResponse;
|
||||||
import io.metersphere.plan.enums.TestPlanReportAttachmentSourceType;
|
import io.metersphere.plan.enums.TestPlanReportAttachmentSourceType;
|
||||||
import io.metersphere.plan.mapper.*;
|
import io.metersphere.plan.mapper.*;
|
||||||
import io.metersphere.plan.utils.CountUtils;
|
import io.metersphere.plan.utils.CountUtils;
|
||||||
import io.metersphere.plan.utils.RateCalculateUtils;
|
|
||||||
import io.metersphere.plugin.platform.dto.SelectOption;
|
import io.metersphere.plugin.platform.dto.SelectOption;
|
||||||
import io.metersphere.sdk.constants.*;
|
import io.metersphere.sdk.constants.*;
|
||||||
import io.metersphere.sdk.exception.MSException;
|
import io.metersphere.sdk.exception.MSException;
|
||||||
|
@ -33,6 +32,7 @@ import io.metersphere.system.service.CommonFileService;
|
||||||
import io.metersphere.system.service.FileService;
|
import io.metersphere.system.service.FileService;
|
||||||
import io.metersphere.system.service.SimpleUserService;
|
import io.metersphere.system.service.SimpleUserService;
|
||||||
import io.metersphere.system.uid.IDGenerator;
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
|
import io.metersphere.system.utils.RateCalculateUtils;
|
||||||
import io.metersphere.system.utils.ServiceUtils;
|
import io.metersphere.system.utils.ServiceUtils;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
Loading…
Reference in New Issue